-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CU-85ztrjkqe_Make-the-metadata-extractor-lenient #169
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,17 +21,19 @@ | |
import com.prowidesoftware.deprecation.ProwideDeprecated; | ||
import com.prowidesoftware.deprecation.TargetYear; | ||
import com.prowidesoftware.swift.utils.Lib; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.Serializable; | ||
import java.math.BigDecimal; | ||
import java.text.NumberFormat; | ||
import java.util.*; | ||
|
||
import javax.persistence.*; | ||
import javax.xml.bind.annotation.XmlTransient; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* Base entity for MT and MX message persistence. | ||
|
@@ -168,7 +170,7 @@ public AbstractSwiftMessage() {} | |
@Deprecated | ||
@ProwideDeprecated(phase3 = TargetYear.SRU2023) | ||
protected AbstractSwiftMessage(final String content) { | ||
this.message = content; | ||
setMessage(content); | ||
updateFromMessage(); | ||
} | ||
|
||
|
@@ -178,7 +180,7 @@ protected AbstractSwiftMessage(final String content) { | |
@Deprecated | ||
@ProwideDeprecated(phase3 = TargetYear.SRU2023) | ||
protected AbstractSwiftMessage(final String content, final FileFormat fileFormat) { | ||
this.message = content; | ||
setMessage(content); | ||
this.fileFormat = fileFormat; | ||
updateFromMessage(); | ||
} | ||
|
@@ -197,7 +199,7 @@ protected AbstractSwiftMessage(final String content, final FileFormat fileFormat | |
protected AbstractSwiftMessage( | ||
final String content, final FileFormat fileFormat, final MessageMetadataStrategy metadataStrategy) { | ||
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null"); | ||
this.message = StringUtils.trim(content); | ||
setMessage(StringUtils.trim(content)); | ||
this.fileFormat = fileFormat; | ||
updateFromMessage(metadataStrategy); | ||
} | ||
|
@@ -209,7 +211,7 @@ protected AbstractSwiftMessage( | |
@Deprecated | ||
@ProwideDeprecated(phase3 = TargetYear.SRU2023) | ||
protected AbstractSwiftMessage(final InputStream stream) throws IOException { | ||
this.message = Lib.readStream(stream); | ||
setMessage(Lib.readStream(stream)); | ||
updateFromMessage(); | ||
} | ||
|
||
|
@@ -220,7 +222,7 @@ protected AbstractSwiftMessage(final InputStream stream) throws IOException { | |
@Deprecated | ||
@ProwideDeprecated(phase3 = TargetYear.SRU2023) | ||
protected AbstractSwiftMessage(final InputStream stream, final FileFormat fileFormat) throws IOException { | ||
this.message = Lib.readStream(stream); | ||
setMessage(Lib.readStream(stream)); | ||
this.fileFormat = fileFormat; | ||
updateFromMessage(); | ||
} | ||
|
@@ -240,7 +242,7 @@ protected AbstractSwiftMessage( | |
final InputStream stream, final FileFormat fileFormat, final MessageMetadataStrategy metadataStrategy) | ||
throws IOException { | ||
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null"); | ||
this.message = Lib.readStream(stream); | ||
setMessage(Lib.readStream(stream)); | ||
this.fileFormat = fileFormat; | ||
updateFromMessage(metadataStrategy); | ||
} | ||
|
@@ -252,7 +254,7 @@ protected AbstractSwiftMessage( | |
@Deprecated | ||
@ProwideDeprecated(phase3 = TargetYear.SRU2023) | ||
protected AbstractSwiftMessage(final File file) throws IOException { | ||
this.message = Lib.readFile(file); | ||
setMessage(Lib.readFile(file)); | ||
this.filename = file.getAbsolutePath(); | ||
updateFromMessage(); | ||
} | ||
|
@@ -264,7 +266,7 @@ protected AbstractSwiftMessage(final File file) throws IOException { | |
@Deprecated | ||
@ProwideDeprecated(phase3 = TargetYear.SRU2023) | ||
protected AbstractSwiftMessage(final File file, final FileFormat fileFormat) throws IOException { | ||
this.message = Lib.readFile(file); | ||
setMessage(Lib.readFile(file)); | ||
this.filename = file.getAbsolutePath(); | ||
this.fileFormat = fileFormat; | ||
updateFromMessage(); | ||
|
@@ -287,7 +289,7 @@ protected AbstractSwiftMessage( | |
throws IOException { | ||
Objects.requireNonNull(file, "the file parameter cannot be null"); | ||
Objects.requireNonNull(metadataStrategy, "the strategy for metadata extraction cannot be null"); | ||
this.message = Lib.readFile(file); | ||
setMessage(Lib.readFile(file)); | ||
this.filename = file.getAbsolutePath(); | ||
this.fileFormat = fileFormat; | ||
updateFromMessage(metadataStrategy); | ||
|
@@ -347,7 +349,11 @@ public String getMessage() { | |
* @param message raw content of the message | ||
*/ | ||
public void setMessage(String message) { | ||
this.message = message; | ||
this.message = makeXmlLenient(message); | ||
} | ||
|
||
private String makeXmlLenient(String xml) { | ||
return xml.replaceFirst("(?i)<\\?XML", "<?xml"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cuando pongas el hack en el extractor, fíjate que el parametro no sea null There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. El hack de hecho va al proyecto ISO, no habria que tocar nada en Core |
||
} | ||
|
||
/** | ||
|
@@ -1497,4 +1503,5 @@ public String getMessageType() { | |
return getIdentifier(); | ||
} | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El mensaje original no hay que alterarlo. Aca en el entity hay que guardar el payload tal cual como se recibe. Estas clases son JPA entities.
El hack ese hay que hacerlo al momento de usarlo, cuando falla, que es puntualmente en el default metadata extractor.
PD : Ademas, no esta bueno que un setter modifique datos, en general se asume que los accesos (get set) son triviales. Incluso si tuviéramos Lombok en el proyecto, serian métodos generados.