Author: adrianc
Date: Wed May 2 13:11:00 2012
New Revision: 1333028
URL:
http://svn.apache.org/viewvc?rev=1333028&view=revLog:
Added some convenience methods to MethodOperation.java.
Modified:
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java?rev=1333028&r1=1333027&r2=1333028&view=diff==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java Wed May 2 13:11:00 2012
@@ -22,6 +22,9 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.util.List;
+
+import javolution.util.FastList;
import org.ofbiz.minilang.MiniLangException;
import org.ofbiz.minilang.SimpleMethod;
@@ -42,6 +45,25 @@ public abstract class MethodOperation {
this.tagName = element.getTagName().intern();
}
+ public void addErrorMessage(MethodContext methodContext, String message) {
+ String messageListName = methodContext.getMethodType() == MethodContext.EVENT ? this.simpleMethod.getEventErrorMessageListName() : this.simpleMethod.getServiceErrorMessageListName();
+ addMessage(methodContext, messageListName, message);
+ }
+
+ public void addMessage(MethodContext methodContext, String message) {
+ String messageListName = methodContext.getMethodType() == MethodContext.EVENT ? this.simpleMethod.getEventEventMessageListName() : this.simpleMethod.getServiceSuccessMessageListName();
+ addMessage(methodContext, messageListName, message);
+ }
+
+ private void addMessage(MethodContext methodContext, String messageListName, String message) {
+ List<String> messages = methodContext.getEnv(messageListName);
+ if (messages == null) {
+ messages = FastList.newInstance();
+ methodContext.putEnv(messageListName, messages);
+ }
+ messages.add(message);
+ }
+
/** Execute the operation. Returns false if no further operations should be executed.
* @throws MiniLangException */
public abstract boolean exec(MethodContext methodContext) throws MiniLangException;