Skip to content
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

Add realm attr #473

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions jpos/src/main/java/org/jpos/util/FSDMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
* </dd>
* <dt>key</dt>
* <dd>If this optional attribute has a value of "true", then fields from another schema, specified by the value, are appended to this schema.</dd>
* <dt>realm</dt>
* <dd>This is the way to change the value appended to this schema when key="true". For example when the value contain character such as "/"
* it is not possible to create file in the file system. With realm="filename" you can avoid that.
* </dd>
* <dt>separator</dt>
* <dd>An optional attribute containing the separator for the field. This is the preferred method of specifying the separator. See the list of optional</dd>
* </dl>
Expand Down Expand Up @@ -370,6 +374,8 @@ protected void pack (Element schema, StringBuilder sb)
String type = elem.getAttributeValue ("type");
// For backward compatibility, look for a separator at the end of the type attribute, if no separator has been defined.
String separator = elem.getAttributeValue ("separator");
String realm = elem.getAttributeValue ("realm");

if (type != null && separator == null) {
separator = getSeparatorType (type);
}
Expand All @@ -391,6 +397,9 @@ protected void pack (Element schema, StringBuilder sb)
if (key) {
String v = isBinary(type) ? ISOUtil.hexString(value.getBytes(charset)) : value;
keyOff = keyOff + normalizeKeyValue(v, properties);
if(realm != null && realm.length() > 0){
keyOff = realm;
}
defaultKey += elem.getAttributeValue ("default-key");
}
}
Expand Down Expand Up @@ -425,6 +434,7 @@ protected void unpack (InputStreamReader r, Element schema)
int length = Integer.parseInt (elem.getAttributeValue ("length"));
String type = elem.getAttributeValue ("type").toUpperCase();
String separator = elem.getAttributeValue ("separator");
String realm = elem.getAttributeValue ("realm");
if (/* type != null && */ // can't be null or we would have NPE'ed when .toUpperCase()
separator == null) {
separator = getSeparatorType (type);
Expand All @@ -436,6 +446,9 @@ protected void unpack (InputStreamReader r, Element schema)

if (key) {
keyOff = keyOff + normalizeKeyValue(value, properties);
if(realm != null && realm.length() > 0){
keyOff = realm;
}
defaultKey += elem.getAttributeValue ("default-key");
}

Expand Down