From a18b530876a63494355008fcaff185a7869f16a1 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Wed, 17 Aug 2011 15:29:17 +0000 Subject: [PATCH] Tweaked the return object for the ActionFormProcessor, it now encapsulates the 'Action' object and the result stored by the executed action (this can be null). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29840 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../processor/action/ActionFormProcessor.java | 11 ++- .../processor/action/ActionFormResult.java | 79 +++++++++++++++++++ 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 source/java/org/alfresco/repo/forms/processor/action/ActionFormResult.java diff --git a/source/java/org/alfresco/repo/forms/processor/action/ActionFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/action/ActionFormProcessor.java index 2a2da6428f..33d11e0558 100644 --- a/source/java/org/alfresco/repo/forms/processor/action/ActionFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/action/ActionFormProcessor.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.repo.action.executer.ActionExecuter; import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FormData; import org.alfresco.repo.forms.FormException; @@ -56,7 +57,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; * @author Neil Mc Erlean * @since 4.0 */ -public class ActionFormProcessor extends FilteredFormProcessor +public class ActionFormProcessor extends FilteredFormProcessor { public static final String ITEM_KIND = "action"; @@ -140,7 +141,7 @@ public class ActionFormProcessor extends FilteredFormProcessor. + */ +package org.alfresco.repo.forms.processor.action; + +import org.alfresco.service.cmr.action.Action; +import org.alfresco.util.ParameterCheck; + +/** + * Class used purely to represent the result of an action being + * executed via the {@link ActionFormProcessor}. + * + * This class holds the {@link Action} executed and any optional + * results stored by the action. + * + * @author Gavin Cornwell + */ +public class ActionFormResult +{ + private Action action; + private Object result; + + /** + * Default constructor. + * + * @param action The action that was executed, can not be null + * @param result The result from the action, can be null + */ + public ActionFormResult(Action action, Object result) + { + ParameterCheck.mandatory("action", action); + + this.action = action; + this.result = result; + } + + /** + * Returns the action that was executed + * + * @return The executed Action + */ + public Action getAction() + { + return this.action; + } + + /** + * Returns the result from the executed action + * + * @return The result or null if there were no results + */ + public Object getResult() + { + return this.result; + } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(this.action.toString()); + builder.append(" result=").append(this.result); + return builder.toString(); + } +}