svn commit: r1334469 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1334469 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java

adrianc
Author: adrianc
Date: Sat May  5 19:09:26 2012
New Revision: 1334469

URL: http://svn.apache.org/viewvc?rev=1334469&view=rev
Log:
Improved Mini-language <set-service-fields> auto-correction.

Modified:
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java?rev=1334469&r1=1334468&r2=1334469&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java Sat May  5 19:09:26 2012
@@ -47,12 +47,31 @@ public final class SetServiceFields exte
 
     // This method is needed only during the v1 to v2 transition
     private static boolean autoCorrect(Element element) {
+        boolean elementModified = false;
         String errorListAttr = element.getAttribute("error-list-name");
         if (!errorListAttr.isEmpty()) {
             element.removeAttribute("error-list-name");
-            return true;
+            elementModified = true;
+        }
+        // Correct map attribute wrapped in ${}
+        String mapAttr = element.getAttribute("map").trim();
+        if (mapAttr.startsWith("${") && mapAttr.endsWith("}")) {
+            mapAttr = mapAttr.substring(2, mapAttr.length() - 1);
+            if (!mapAttr.contains("${")) {
+                element.setAttribute("map", mapAttr);
+                elementModified = true;
+            }
+        }
+        // Correct to-map attribute wrapped in ${}
+        String toMapAttr = element.getAttribute("to-map").trim();
+        if (toMapAttr.startsWith("${") && toMapAttr.endsWith("}")) {
+            toMapAttr = toMapAttr.substring(2, toMapAttr.length() - 1);
+            if (!toMapAttr.contains("${")) {
+                element.setAttribute("to-map", toMapAttr);
+                elementModified = true;
+            }
         }
-        return false;
+        return elementModified;
     }
 
     private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma;