From 61d301f7cf9d529b3551568e8e350594babcdd24 Mon Sep 17 00:00:00 2001 From: Igor Skljar <39621064+it240884sii@users.noreply.github.com> Date: Fri, 18 Feb 2022 14:44:38 +0200 Subject: [PATCH] Add realm attr 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. --- jpos/src/main/java/org/jpos/util/FSDMsg.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jpos/src/main/java/org/jpos/util/FSDMsg.java b/jpos/src/main/java/org/jpos/util/FSDMsg.java index 8c3b6e093b..99107a529e 100644 --- a/jpos/src/main/java/org/jpos/util/FSDMsg.java +++ b/jpos/src/main/java/org/jpos/util/FSDMsg.java @@ -58,6 +58,10 @@ * *
key
*
If this optional attribute has a value of "true", then fields from another schema, specified by the value, are appended to this schema.
+ *
realm
+ *
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. + *
*
separator
*
An optional attribute containing the separator for the field. This is the preferred method of specifying the separator. See the list of optional
* @@ -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); } @@ -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"); } } @@ -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); @@ -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"); }