mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||||
import org.alfresco.repo.forms.Field;
|
import org.alfresco.repo.forms.Field;
|
||||||
import org.alfresco.repo.forms.FormData;
|
import org.alfresco.repo.forms.FormData;
|
||||||
import org.alfresco.repo.forms.FormException;
|
import org.alfresco.repo.forms.FormException;
|
||||||
@@ -56,7 +57,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|||||||
* @author Neil Mc Erlean
|
* @author Neil Mc Erlean
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class ActionFormProcessor extends FilteredFormProcessor<ActionDefinition, Action>
|
public class ActionFormProcessor extends FilteredFormProcessor<ActionDefinition, ActionFormResult>
|
||||||
{
|
{
|
||||||
public static final String ITEM_KIND = "action";
|
public static final String ITEM_KIND = "action";
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ public class ActionFormProcessor extends FilteredFormProcessor<ActionDefinition,
|
|||||||
* @see org.alfresco.repo.forms.processor.FilteredFormProcessor#internalPersist(java.lang.Object, org.alfresco.repo.forms.FormData)
|
* @see org.alfresco.repo.forms.processor.FilteredFormProcessor#internalPersist(java.lang.Object, org.alfresco.repo.forms.FormData)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Action internalPersist(ActionDefinition item, FormData data)
|
protected ActionFormResult internalPersist(ActionDefinition item, FormData data)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Persisting form for: " + item);
|
logger.debug("Persisting form for: " + item);
|
||||||
@@ -149,9 +150,13 @@ public class ActionFormProcessor extends FilteredFormProcessor<ActionDefinition,
|
|||||||
final NodeRef actionedUponNodeRef = getActionedUponNodeRef(item, data);
|
final NodeRef actionedUponNodeRef = getActionedUponNodeRef(item, data);
|
||||||
final boolean isAsync = isAsynchronousActionRequest(item, data);
|
final boolean isAsync = isAsynchronousActionRequest(item, data);
|
||||||
|
|
||||||
|
// execute the action
|
||||||
actionService.executeAction(actionToExecute, actionedUponNodeRef, true, isAsync);
|
actionService.executeAction(actionToExecute, actionedUponNodeRef, true, isAsync);
|
||||||
|
|
||||||
return actionToExecute;
|
// extract the result
|
||||||
|
Object result = actionToExecute.getParameterValue(ActionExecuter.PARAM_RESULT);
|
||||||
|
|
||||||
|
return new ActionFormResult(actionToExecute, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user