Author: adrianc
Date: Fri May 11 09:50:45 2012 New Revision: 1337092 URL: http://svn.apache.org/viewvc?rev=1337092&view=rev Log: Fixed broken Mini-language <check-errors> element. Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java?rev=1337092&r1=1337091&r2=1337092&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java Fri May 11 09:50:45 2012 @@ -22,7 +22,6 @@ import java.util.List; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.minilang.MiniLangException; -import org.ofbiz.minilang.MiniLangUtil; import org.ofbiz.minilang.MiniLangValidate; import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.method.MethodContext; @@ -34,46 +33,30 @@ import org.w3c.dom.Element; */ public final class CheckErrors extends MethodOperation { - // This method is needed only during the v1 to v2 transition - private static boolean autoCorrect(Element element) { - String errorListAttr = element.getAttribute("error-list-name"); - if (errorListAttr.length() > 0) { - element.removeAttribute("error-list-name"); - return true; - } - return false; - } - private final FlexibleStringExpander errorCodeFse; + private final FlexibleStringExpander errorListNameFse; public CheckErrors(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "error-code"); + MiniLangValidate.attributeNames(simpleMethod, element, "error-code", "error-list-name"); MiniLangValidate.constantPlusExpressionAttributes(simpleMethod, element, "error-code"); MiniLangValidate.noChildElements(simpleMethod, element); } - boolean elementModified = autoCorrect(element); - if (elementModified && MiniLangUtil.autoCorrectOn()) { - MiniLangUtil.flagDocumentAsCorrected(element); - } this.errorCodeFse = FlexibleStringExpander.getInstance(element.getAttribute("error-code")); + this.errorListNameFse = FlexibleStringExpander.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list")); } @Override public boolean exec(MethodContext methodContext) throws MiniLangException { - if (methodContext.getMethodType() == MethodContext.EVENT) { - List<Object> messages = methodContext.getEnv(this.simpleMethod.getEventErrorMessageListName()); - if (messages != null && messages.size() > 0) { + List<Object> messages = methodContext.getEnv(this.errorListNameFse.expandString(methodContext.getEnvMap())); + if (messages != null && messages.size() > 0) { + if (methodContext.getMethodType() == MethodContext.EVENT) { methodContext.putEnv(this.simpleMethod.getEventResponseCodeName(), getErrorCode(methodContext)); - return false; - } - } else { - List<Object> messages = methodContext.getEnv(this.simpleMethod.getServiceErrorMessageListName()); - if (messages != null && messages.size() > 0) { + } else { methodContext.putEnv(this.simpleMethod.getServiceResponseMessageName(), getErrorCode(methodContext)); - return false; } + return false; } return true; } @@ -102,6 +85,9 @@ public final class CheckErrors extends M if (!this.errorCodeFse.isEmpty()) { sb.append("error-code=\"").append(this.errorCodeFse).append("\" "); } + if (!"error_list".equals(this.errorListNameFse.getOriginal())) { + sb.append("error-list-name=\"").append(this.errorListNameFse).append("\" "); + } sb.append("/>"); return sb.toString(); } |
Free forum by Nabble | Edit this page |