Author: adrianc
Date: Wed Apr 25 17:02:26 2012
New Revision: 1330418
URL:
http://svn.apache.org/viewvc?rev=1330418&view=revLog:
Added Mini-language auto-correcting capability.
Modified:
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java?rev=1330418&r1=1330417&r2=1330418&view=diff==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java Wed Apr 25 17:02:26 2012
@@ -91,6 +91,11 @@ public final class MiniLangUtil {
return true;
}
+ public static boolean isDocumentAutoCorrected(Document document) {
+ String autoCorrected = (String) document.getUserData("autoCorrected");
+ return "true".equals(autoCorrected);
+ }
+
public static void removeInvalidAttributes(Element element, String... validAttributeNames) {
Set<String> validNames = new HashSet<String>();
for (String name : validAttributeNames) {
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java?rev=1330418&r1=1330417&r2=1330418&view=diff==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java Wed Apr 25 17:02:26 2012
@@ -306,6 +306,14 @@ public class SimpleMethod {
SimpleMethod simpleMethod = compileSimpleMethod(simpleMethodElement, simpleMethods, xmlURL.toString());
simpleMethods.put(simpleMethod.getMethodName(), simpleMethod);
}
+ if (MiniLangUtil.isDocumentAutoCorrected(document)) {
+ try {
+ UtilXml.writeXmlDocument(xmlURL.getFile(), document);
+ Debug.logInfo("Saved auto-corrected Mini-language file " + xmlURL, module);
+ } catch (Exception e) {
+ Debug.logWarning(e, "Error writing auto-corrected mini-language file " + xmlURL + ": ", module);
+ }
+ }
return simpleMethods;
}