mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,45 +1,45 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
|
||||
/**
|
||||
* Approve Workflow command implementation
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class ApproveWorkflowCommand implements Command
|
||||
{
|
||||
public static final String PROP_TARGET = "target";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_TARGET};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
// get the target Node for the command
|
||||
NodeRef nodeRef = (NodeRef)properties.get(PROP_TARGET);
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute ApproveCommand - mandatory parameter not supplied: " + PROP_TARGET);
|
||||
}
|
||||
|
||||
WorkflowUtil.approve(nodeRef, serviceRegistry.getNodeService(), serviceRegistry.getCopyService());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
|
||||
/**
|
||||
* Approve Workflow command implementation
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class ApproveWorkflowCommand implements Command
|
||||
{
|
||||
public static final String PROP_TARGET = "target";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_TARGET};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
// get the target Node for the command
|
||||
NodeRef nodeRef = (NodeRef)properties.get(PROP_TARGET);
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute ApproveCommand - mandatory parameter not supplied: " + PROP_TARGET);
|
||||
}
|
||||
|
||||
WorkflowUtil.approve(nodeRef, serviceRegistry.getNodeService(), serviceRegistry.getCopyService());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,47 +1,47 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Initial implementation of a Command Processor that is always passed enough URL elements
|
||||
* to construct a single NodeRef argument. The NodeRef is checked against READ permissions
|
||||
* for the current user during the validateArguments() call.
|
||||
* <p>
|
||||
* This class should be enough to form the base of Command Processor objects that only require
|
||||
* a single NodeRef passed on the URL.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public abstract class BaseNodeCommandProcessor implements CommandProcessor
|
||||
{
|
||||
protected NodeRef targetRef;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
if (urlElements.length < 3)
|
||||
{
|
||||
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
|
||||
}
|
||||
|
||||
// get NodeRef to the node with the workflow attached to it
|
||||
StoreRef storeRef = new StoreRef(urlElements[0], urlElements[1]);
|
||||
this.targetRef = new NodeRef(storeRef, urlElements[2]);
|
||||
|
||||
// get the services we need to execute the workflow command
|
||||
PermissionService permissionService = Repository.getServiceRegistry(sc).getPermissionService();
|
||||
|
||||
// check that the user has at least READ access on the node - else redirect to the login page
|
||||
return (permissionService.hasPermission(this.targetRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Initial implementation of a Command Processor that is always passed enough URL elements
|
||||
* to construct a single NodeRef argument. The NodeRef is checked against READ permissions
|
||||
* for the current user during the validateArguments() call.
|
||||
* <p>
|
||||
* This class should be enough to form the base of Command Processor objects that only require
|
||||
* a single NodeRef passed on the URL.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public abstract class BaseNodeCommandProcessor implements CommandProcessor
|
||||
{
|
||||
protected NodeRef targetRef;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
if (urlElements.length < 3)
|
||||
{
|
||||
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
|
||||
}
|
||||
|
||||
// get NodeRef to the node with the workflow attached to it
|
||||
StoreRef storeRef = new StoreRef(urlElements[0], urlElements[1]);
|
||||
this.targetRef = new NodeRef(storeRef, urlElements[2]);
|
||||
|
||||
// get the services we need to execute the workflow command
|
||||
PermissionService permissionService = Repository.getServiceRegistry(sc).getPermissionService();
|
||||
|
||||
// check that the user has at least READ access on the node - else redirect to the login page
|
||||
return (permissionService.hasPermission(this.targetRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public abstract class BaseUIActionCommand implements Command
|
||||
{
|
||||
public static final String PROP_SERVLETCONTEXT = "ServletContext";
|
||||
public static final String PROP_REQUEST = "Request";
|
||||
public static final String PROP_RESPONSE = "Response";
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public abstract class BaseUIActionCommand implements Command
|
||||
{
|
||||
public static final String PROP_SERVLETCONTEXT = "ServletContext";
|
||||
public static final String PROP_REQUEST = "Request";
|
||||
public static final String PROP_RESPONSE = "Response";
|
||||
}
|
||||
|
@@ -1,28 +1,28 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* Simple servlet command pattern interface.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public interface Command
|
||||
{
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param serviceRegistry The ServiceRegistry instance
|
||||
* @param properties Bag of named properties for the command
|
||||
*
|
||||
* @return return value from the command if any
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties);
|
||||
|
||||
/**
|
||||
* @return the names of the properties required for this command
|
||||
*/
|
||||
public String[] getPropertyNames();
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* Simple servlet command pattern interface.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public interface Command
|
||||
{
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param serviceRegistry The ServiceRegistry instance
|
||||
* @param properties Bag of named properties for the command
|
||||
*
|
||||
* @return return value from the command if any
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties);
|
||||
|
||||
/**
|
||||
* @return the names of the properties required for this command
|
||||
*/
|
||||
public String[] getPropertyNames();
|
||||
}
|
||||
|
@@ -1,81 +1,81 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Command Factory helper
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class CommandFactory
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(CommandFactory.class);
|
||||
|
||||
private static CommandFactory instance = new CommandFactory();
|
||||
|
||||
private static Map<String, Class> registry = new HashMap<String, Class>(16, 1.0f);
|
||||
|
||||
/**
|
||||
* Private constructor - protect the singleton instance
|
||||
*/
|
||||
private CommandFactory()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the singleton CommandFactory instance
|
||||
*/
|
||||
public static CommandFactory getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a command name against an implementation
|
||||
*
|
||||
* @param name Unique name of the command
|
||||
* @param clazz Class implementation of the command
|
||||
*/
|
||||
public void registerCommand(String name, Class clazz)
|
||||
{
|
||||
registry.put(name, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a command instance of the specified command name
|
||||
*
|
||||
* @param name Name of the command to create (must be registered)
|
||||
*
|
||||
* @return the Command instance or null if not found
|
||||
*/
|
||||
public Command createCommand(String name)
|
||||
{
|
||||
Command result = null;
|
||||
|
||||
// lookup command by name in the registry
|
||||
Class clazz = registry.get(name);
|
||||
if (clazz != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object obj = clazz.newInstance();
|
||||
if (obj instanceof Command)
|
||||
{
|
||||
result = (Command)obj;
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
// return default if this occurs
|
||||
logger.warn("Unable to create workflow command instance '" + name +
|
||||
"' with classname '" + clazz.getName() + "' due to error: " + err.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Command Factory helper
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class CommandFactory
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(CommandFactory.class);
|
||||
|
||||
private static CommandFactory instance = new CommandFactory();
|
||||
|
||||
private static Map<String, Class> registry = new HashMap<String, Class>(16, 1.0f);
|
||||
|
||||
/**
|
||||
* Private constructor - protect the singleton instance
|
||||
*/
|
||||
private CommandFactory()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the singleton CommandFactory instance
|
||||
*/
|
||||
public static CommandFactory getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a command name against an implementation
|
||||
*
|
||||
* @param name Unique name of the command
|
||||
* @param clazz Class implementation of the command
|
||||
*/
|
||||
public void registerCommand(String name, Class clazz)
|
||||
{
|
||||
registry.put(name, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a command instance of the specified command name
|
||||
*
|
||||
* @param name Name of the command to create (must be registered)
|
||||
*
|
||||
* @return the Command instance or null if not found
|
||||
*/
|
||||
public Command createCommand(String name)
|
||||
{
|
||||
Command result = null;
|
||||
|
||||
// lookup command by name in the registry
|
||||
Class clazz = registry.get(name);
|
||||
if (clazz != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object obj = clazz.newInstance();
|
||||
if (obj instanceof Command)
|
||||
{
|
||||
result = (Command)obj;
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
// return default if this occurs
|
||||
logger.warn("Unable to create workflow command instance '" + name +
|
||||
"' with classname '" + clazz.getName() + "' due to error: " + err.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -1,63 +1,63 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* This interfaces defines the contract and lifecycle of a Servlet Command Processor.
|
||||
* <p>
|
||||
* A command processor is defined as a class capable of executing a set of related Command
|
||||
* objects. It performs the bulk of the work for the command servlet. The processor impl
|
||||
* is responsible for validating that the command can be processed (given the supplied remaining
|
||||
* URL arguments from the servlet) and processing the command. It is also responsible for
|
||||
* supply an output status page on successfuly execution of the command.
|
||||
* <p>
|
||||
* The arguments passed to a Command Processor are the remaining URL elements from the command
|
||||
* servlet URL after removing the web-app name, servlet name and command processor name.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public interface CommandProcessor
|
||||
{
|
||||
/**
|
||||
* Pass and validate URL arguments for the command processor. Validate if the command can be
|
||||
* executed given the arguments supplied. Generally at this post a Command Processor will
|
||||
* convert the supplied arguments to the objects it expects, and also check any permissions
|
||||
* that are required by the current user to execute the command.
|
||||
*
|
||||
* @param sc ServletContext, can be used to retrieve ServiceRegistry instance
|
||||
* from the Repository bean.
|
||||
* @param command Name of the command the arguments are for
|
||||
* @param args Map of URL args passed to the command servlet
|
||||
* @param urlElements String[] of the remaining URL arguments to the command servlet
|
||||
*
|
||||
* @return true if the command can be executed by the current user given the supplied args.
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements);
|
||||
|
||||
/**
|
||||
* Process the supplied command name. It is the responsibility of the Command Processor
|
||||
* to lookup the specified command name using the CommandFactory registry. For that reason
|
||||
* it also has the responsiblity to initially register commands it is responsible for so
|
||||
* they can be constructed later. If the supplied command is unknown to it then an
|
||||
* exception should be thrown to indicate this.
|
||||
*
|
||||
* @param serviceRegistry ServiceRegistry
|
||||
* @param request HttpServletRequest
|
||||
* @param command Name of the command to construct and execute
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command);
|
||||
|
||||
/**
|
||||
* Output a simple status message to the supplied PrintWriter.
|
||||
* It can be assumed that the process() method was successful if this method is called.
|
||||
*
|
||||
* @param out PrintWriter
|
||||
*/
|
||||
public void outputStatus(PrintWriter out);
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* This interfaces defines the contract and lifecycle of a Servlet Command Processor.
|
||||
* <p>
|
||||
* A command processor is defined as a class capable of executing a set of related Command
|
||||
* objects. It performs the bulk of the work for the command servlet. The processor impl
|
||||
* is responsible for validating that the command can be processed (given the supplied remaining
|
||||
* URL arguments from the servlet) and processing the command. It is also responsible for
|
||||
* supply an output status page on successfuly execution of the command.
|
||||
* <p>
|
||||
* The arguments passed to a Command Processor are the remaining URL elements from the command
|
||||
* servlet URL after removing the web-app name, servlet name and command processor name.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public interface CommandProcessor
|
||||
{
|
||||
/**
|
||||
* Pass and validate URL arguments for the command processor. Validate if the command can be
|
||||
* executed given the arguments supplied. Generally at this post a Command Processor will
|
||||
* convert the supplied arguments to the objects it expects, and also check any permissions
|
||||
* that are required by the current user to execute the command.
|
||||
*
|
||||
* @param sc ServletContext, can be used to retrieve ServiceRegistry instance
|
||||
* from the Repository bean.
|
||||
* @param command Name of the command the arguments are for
|
||||
* @param args Map of URL args passed to the command servlet
|
||||
* @param urlElements String[] of the remaining URL arguments to the command servlet
|
||||
*
|
||||
* @return true if the command can be executed by the current user given the supplied args.
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements);
|
||||
|
||||
/**
|
||||
* Process the supplied command name. It is the responsibility of the Command Processor
|
||||
* to lookup the specified command name using the CommandFactory registry. For that reason
|
||||
* it also has the responsiblity to initially register commands it is responsible for so
|
||||
* they can be constructed later. If the supplied command is unknown to it then an
|
||||
* exception should be thrown to indicate this.
|
||||
*
|
||||
* @param serviceRegistry ServiceRegistry
|
||||
* @param request HttpServletRequest
|
||||
* @param command Name of the command to construct and execute
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command);
|
||||
|
||||
/**
|
||||
* Output a simple status message to the supplied PrintWriter.
|
||||
* It can be assumed that the process() method was successful if this method is called.
|
||||
*
|
||||
* @param out PrintWriter
|
||||
*/
|
||||
public void outputStatus(PrintWriter out);
|
||||
}
|
||||
|
@@ -1,72 +1,72 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Command to execute the Edit Content Properties dialog via url.
|
||||
* <p>
|
||||
* Arguments: noderef - of the document to show the edit props dialog for
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class EditContentPropertiesCommand extends BaseUIActionCommand
|
||||
{
|
||||
public static final String PROP_NODEREF = "noderef";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {
|
||||
PROP_SERVLETCONTEXT, PROP_REQUEST, PROP_RESPONSE, PROP_NODEREF};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
ServletContext sc = (ServletContext)properties.get(PROP_SERVLETCONTEXT);
|
||||
ServletRequest req = (ServletRequest)properties.get(PROP_REQUEST);
|
||||
ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE);
|
||||
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
|
||||
BrowseBean browseBean = (BrowseBean)FacesHelper.getManagedBean(fc, BrowseBean.BEAN_NAME);
|
||||
|
||||
// setup context from url args in properties map
|
||||
String strNodeRef = (String)properties.get(PROP_NODEREF);
|
||||
ParameterCheck.mandatoryString(PROP_NODEREF, strNodeRef);
|
||||
browseBean.setDocument(new Node(new NodeRef(strNodeRef)));
|
||||
|
||||
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||
navigationHandler.handleNavigation(fc, null, "dialog:editContentProperties");
|
||||
String viewId = fc.getViewRoot().getViewId();
|
||||
try
|
||||
{
|
||||
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Command to execute the Edit Content Properties dialog via url.
|
||||
* <p>
|
||||
* Arguments: noderef - of the document to show the edit props dialog for
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class EditContentPropertiesCommand extends BaseUIActionCommand
|
||||
{
|
||||
public static final String PROP_NODEREF = "noderef";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {
|
||||
PROP_SERVLETCONTEXT, PROP_REQUEST, PROP_RESPONSE, PROP_NODEREF};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
ServletContext sc = (ServletContext)properties.get(PROP_SERVLETCONTEXT);
|
||||
ServletRequest req = (ServletRequest)properties.get(PROP_REQUEST);
|
||||
ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE);
|
||||
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
|
||||
BrowseBean browseBean = (BrowseBean)FacesHelper.getManagedBean(fc, BrowseBean.BEAN_NAME);
|
||||
|
||||
// setup context from url args in properties map
|
||||
String strNodeRef = (String)properties.get(PROP_NODEREF);
|
||||
ParameterCheck.mandatoryString(PROP_NODEREF, strNodeRef);
|
||||
browseBean.setDocument(new Node(new NodeRef(strNodeRef)));
|
||||
|
||||
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||
navigationHandler.handleNavigation(fc, null, "dialog:editContentProperties");
|
||||
String viewId = fc.getViewRoot().getViewId();
|
||||
try
|
||||
{
|
||||
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
}
|
||||
|
@@ -1,44 +1,44 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
|
||||
/**
|
||||
* End Task command implementation
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public final class EndTaskCommand implements Command
|
||||
{
|
||||
public static final String PROP_TASK_ID = "taskId";
|
||||
public static final String PROP_TRANSITION = "transition";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_TASK_ID, PROP_TRANSITION};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
String taskId = (String)properties.get(PROP_TASK_ID);
|
||||
if (taskId == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Unable to execute EndTaskCommand - mandatory parameter not supplied: " + PROP_TASK_ID);
|
||||
}
|
||||
String transition = (String)properties.get(PROP_TRANSITION);
|
||||
|
||||
// end task
|
||||
WorkflowService workflowService = serviceRegistry.getWorkflowService();
|
||||
return workflowService.endTask(taskId, transition);
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
|
||||
/**
|
||||
* End Task command implementation
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public final class EndTaskCommand implements Command
|
||||
{
|
||||
public static final String PROP_TASK_ID = "taskId";
|
||||
public static final String PROP_TRANSITION = "transition";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_TASK_ID, PROP_TRANSITION};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
String taskId = (String)properties.get(PROP_TASK_ID);
|
||||
if (taskId == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Unable to execute EndTaskCommand - mandatory parameter not supplied: " + PROP_TASK_ID);
|
||||
}
|
||||
String transition = (String)properties.get(PROP_TRANSITION);
|
||||
|
||||
// end task
|
||||
WorkflowService workflowService = serviceRegistry.getWorkflowService();
|
||||
return workflowService.endTask(taskId, transition);
|
||||
}
|
||||
}
|
||||
|
@@ -1,81 +1,81 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Execute Script command implementation.
|
||||
* <p>
|
||||
* Executes the supplied script against the default data-model.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class ExecuteScriptCommand implements Command
|
||||
{
|
||||
public static final String PROP_SCRIPT = "script";
|
||||
public static final String PROP_DOCUMENT = "document";
|
||||
public static final String PROP_USERPERSON = "person";
|
||||
public static final String PROP_ARGS = "args";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_SCRIPT, PROP_DOCUMENT, PROP_USERPERSON, PROP_ARGS};
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
// get the target Script node for the command
|
||||
NodeRef scriptRef = (NodeRef)properties.get(PROP_SCRIPT);
|
||||
if (scriptRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute ExecuteScriptCommand - mandatory parameter not supplied: " + PROP_SCRIPT);
|
||||
}
|
||||
|
||||
NodeRef personRef = (NodeRef)properties.get(PROP_USERPERSON);
|
||||
if (personRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute ExecuteScriptCommand - mandatory parameter not supplied: " + PROP_USERPERSON);
|
||||
}
|
||||
|
||||
// get the optional document and space context ref
|
||||
NodeService nodeService = serviceRegistry.getNodeService();
|
||||
NodeRef docRef = (NodeRef)properties.get(PROP_DOCUMENT);
|
||||
NodeRef spaceRef = null;
|
||||
if (docRef != null)
|
||||
{
|
||||
spaceRef = nodeService.getPrimaryParent(docRef).getParentRef();
|
||||
}
|
||||
|
||||
// build the model needed to execute the script
|
||||
Map<String, Object> model = serviceRegistry.getScriptService().buildDefaultModel(
|
||||
personRef,
|
||||
new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()),
|
||||
(NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER),
|
||||
scriptRef,
|
||||
docRef,
|
||||
spaceRef);
|
||||
|
||||
// add the url arguments map
|
||||
model.put("args", properties.get(PROP_ARGS));
|
||||
|
||||
// execute the script and return the result
|
||||
return serviceRegistry.getScriptService().executeScript(scriptRef, null, model);
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Execute Script command implementation.
|
||||
* <p>
|
||||
* Executes the supplied script against the default data-model.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class ExecuteScriptCommand implements Command
|
||||
{
|
||||
public static final String PROP_SCRIPT = "script";
|
||||
public static final String PROP_DOCUMENT = "document";
|
||||
public static final String PROP_USERPERSON = "person";
|
||||
public static final String PROP_ARGS = "args";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_SCRIPT, PROP_DOCUMENT, PROP_USERPERSON, PROP_ARGS};
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
// get the target Script node for the command
|
||||
NodeRef scriptRef = (NodeRef)properties.get(PROP_SCRIPT);
|
||||
if (scriptRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute ExecuteScriptCommand - mandatory parameter not supplied: " + PROP_SCRIPT);
|
||||
}
|
||||
|
||||
NodeRef personRef = (NodeRef)properties.get(PROP_USERPERSON);
|
||||
if (personRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute ExecuteScriptCommand - mandatory parameter not supplied: " + PROP_USERPERSON);
|
||||
}
|
||||
|
||||
// get the optional document and space context ref
|
||||
NodeService nodeService = serviceRegistry.getNodeService();
|
||||
NodeRef docRef = (NodeRef)properties.get(PROP_DOCUMENT);
|
||||
NodeRef spaceRef = null;
|
||||
if (docRef != null)
|
||||
{
|
||||
spaceRef = nodeService.getPrimaryParent(docRef).getParentRef();
|
||||
}
|
||||
|
||||
// build the model needed to execute the script
|
||||
Map<String, Object> model = serviceRegistry.getScriptService().buildDefaultModel(
|
||||
personRef,
|
||||
new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()),
|
||||
(NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER),
|
||||
scriptRef,
|
||||
docRef,
|
||||
spaceRef);
|
||||
|
||||
// add the url arguments map
|
||||
model.put("args", properties.get(PROP_ARGS));
|
||||
|
||||
// execute the script and return the result
|
||||
return serviceRegistry.getScriptService().executeScript(scriptRef, null, model);
|
||||
}
|
||||
}
|
||||
|
@@ -1,35 +1,35 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* This interfaces defines the contract and lifecycle of a Servlet Command Processor.
|
||||
* <p>
|
||||
* The ExtCommandProcessor adds an overloaded process() method to allow the
|
||||
* HttpServletResponse to be passed.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public interface ExtCommandProcessor extends CommandProcessor
|
||||
{
|
||||
/**
|
||||
* Process the supplied command name. It is the responsibility of the Command Processor
|
||||
* to lookup the specified command name using the CommandFactory registry. For that reason
|
||||
* it also has the responsiblity to initially register commands it is responsible for so
|
||||
* they can be constructed later. If the supplied command is unknown to it then an
|
||||
* exception should be thrown to indicate this.
|
||||
*
|
||||
* @param serviceRegistry ServiceRegistry
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param command Name of the command to construct and execute
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, HttpServletResponse response, String command);
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* This interfaces defines the contract and lifecycle of a Servlet Command Processor.
|
||||
* <p>
|
||||
* The ExtCommandProcessor adds an overloaded process() method to allow the
|
||||
* HttpServletResponse to be passed.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public interface ExtCommandProcessor extends CommandProcessor
|
||||
{
|
||||
/**
|
||||
* Process the supplied command name. It is the responsibility of the Command Processor
|
||||
* to lookup the specified command name using the CommandFactory registry. For that reason
|
||||
* it also has the responsiblity to initially register commands it is responsible for so
|
||||
* they can be constructed later. If the supplied command is unknown to it then an
|
||||
* exception should be thrown to indicate this.
|
||||
*
|
||||
* @param serviceRegistry ServiceRegistry
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param command Name of the command to construct and execute
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, HttpServletResponse response, String command);
|
||||
}
|
||||
|
@@ -1,75 +1,75 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.workflow.WorkflowBean;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Command to execute the Manage Task dialog via url.
|
||||
* <p>
|
||||
* Arguments: id = the id of the task
|
||||
* type = the qname type of the task
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class ManageTaskDialogCommand extends BaseUIActionCommand
|
||||
{
|
||||
public static final String PROP_TASKID = "id";
|
||||
public static final String PROP_TASKTYPE = "type";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {
|
||||
PROP_SERVLETCONTEXT, PROP_REQUEST, PROP_RESPONSE, PROP_TASKID, PROP_TASKTYPE};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
ServletContext sc = (ServletContext)properties.get(PROP_SERVLETCONTEXT);
|
||||
ServletRequest req = (ServletRequest)properties.get(PROP_REQUEST);
|
||||
ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE);
|
||||
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
|
||||
WorkflowBean wfBean = (WorkflowBean)FacesHelper.getManagedBean(fc, WorkflowBean.BEAN_NAME);
|
||||
|
||||
// setup dialog context from url args in properties map
|
||||
String taskId = (String)properties.get(PROP_TASKID);
|
||||
ParameterCheck.mandatoryString(PROP_TASKID, taskId);
|
||||
String taskType = (String)properties.get(PROP_TASKTYPE);
|
||||
ParameterCheck.mandatoryString(PROP_TASKTYPE, taskType);
|
||||
|
||||
wfBean.setupTaskDialog(taskId, taskType);
|
||||
|
||||
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||
navigationHandler.handleNavigation(fc, null, "dialog:manageTask");
|
||||
String viewId = fc.getViewRoot().getViewId();
|
||||
try
|
||||
{
|
||||
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.workflow.WorkflowBean;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Command to execute the Manage Task dialog via url.
|
||||
* <p>
|
||||
* Arguments: id = the id of the task
|
||||
* type = the qname type of the task
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class ManageTaskDialogCommand extends BaseUIActionCommand
|
||||
{
|
||||
public static final String PROP_TASKID = "id";
|
||||
public static final String PROP_TASKTYPE = "type";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {
|
||||
PROP_SERVLETCONTEXT, PROP_REQUEST, PROP_RESPONSE, PROP_TASKID, PROP_TASKTYPE};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
ServletContext sc = (ServletContext)properties.get(PROP_SERVLETCONTEXT);
|
||||
ServletRequest req = (ServletRequest)properties.get(PROP_REQUEST);
|
||||
ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE);
|
||||
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
|
||||
WorkflowBean wfBean = (WorkflowBean)FacesHelper.getManagedBean(fc, WorkflowBean.BEAN_NAME);
|
||||
|
||||
// setup dialog context from url args in properties map
|
||||
String taskId = (String)properties.get(PROP_TASKID);
|
||||
ParameterCheck.mandatoryString(PROP_TASKID, taskId);
|
||||
String taskType = (String)properties.get(PROP_TASKTYPE);
|
||||
ParameterCheck.mandatoryString(PROP_TASKTYPE, taskType);
|
||||
|
||||
wfBean.setupTaskDialog(taskId, taskType);
|
||||
|
||||
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||
navigationHandler.handleNavigation(fc, null, "dialog:manageTask");
|
||||
String viewId = fc.getViewRoot().getViewId();
|
||||
try
|
||||
{
|
||||
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
}
|
||||
|
@@ -1,45 +1,45 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
|
||||
/**
|
||||
* Reject Workflow command implementation
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class RejectWorkflowCommand implements Command
|
||||
{
|
||||
public static final String PROP_TARGET = "target";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_TARGET};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
// get the target Node for the command
|
||||
NodeRef nodeRef = (NodeRef)properties.get(PROP_TARGET);
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute RejectCommand - mandatory parameter not supplied: " + PROP_TARGET);
|
||||
}
|
||||
|
||||
WorkflowUtil.reject(nodeRef, serviceRegistry.getNodeService(), serviceRegistry.getCopyService());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
|
||||
/**
|
||||
* Reject Workflow command implementation
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class RejectWorkflowCommand implements Command
|
||||
{
|
||||
public static final String PROP_TARGET = "target";
|
||||
|
||||
private static final String[] PROPERTIES = new String[] {PROP_TARGET};
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#getPropertyNames()
|
||||
*/
|
||||
public String[] getPropertyNames()
|
||||
{
|
||||
return PROPERTIES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
|
||||
*/
|
||||
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties)
|
||||
{
|
||||
// get the target Node for the command
|
||||
NodeRef nodeRef = (NodeRef)properties.get(PROP_TARGET);
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to execute RejectCommand - mandatory parameter not supplied: " + PROP_TARGET);
|
||||
}
|
||||
|
||||
WorkflowUtil.reject(nodeRef, serviceRegistry.getNodeService(), serviceRegistry.getCopyService());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,143 +1,143 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.jscript.ScriptableHashMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.User;
|
||||
import org.alfresco.web.config.ClientConfigElement;
|
||||
import org.springframework.extensions.config.ConfigService;
|
||||
|
||||
/**
|
||||
* Script command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing 'execute' script commands on a Node.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class ScriptCommandProcessor implements CommandProcessor
|
||||
{
|
||||
private static final String ARG_SCRIPT_PATH = "scriptPath";
|
||||
private static final String ARG_CONTEXT_PATH = "contextPath";
|
||||
|
||||
private NodeRef scriptRef;
|
||||
private NodeRef docRef;
|
||||
private Object result;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand("execute", ExecuteScriptCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
boolean allowed = false;
|
||||
String scriptPath = args.get(ARG_SCRIPT_PATH);
|
||||
if (scriptPath != null)
|
||||
{
|
||||
// resolve path to a node
|
||||
this.scriptRef = BaseServlet.resolveNamePath(sc, scriptPath).NodeRef;
|
||||
|
||||
// same for the document context path if specified
|
||||
String docPath = args.get(ARG_CONTEXT_PATH);
|
||||
if (docPath != null)
|
||||
{
|
||||
this.docRef = BaseServlet.resolveNamePath(sc, docPath).NodeRef;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (urlElements.length < 3)
|
||||
{
|
||||
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
|
||||
}
|
||||
|
||||
// get NodeRef to the node script to execute
|
||||
StoreRef storeRef = new StoreRef(urlElements[0], urlElements[1]);
|
||||
this.scriptRef = new NodeRef(storeRef, urlElements[2]);
|
||||
|
||||
if (urlElements.length >= 6)
|
||||
{
|
||||
storeRef = new StoreRef(urlElements[3], urlElements[4]);
|
||||
this.docRef = new NodeRef(storeRef, urlElements[5]);
|
||||
}
|
||||
}
|
||||
|
||||
// check we can READ access the nodes specified
|
||||
PermissionService ps = Repository.getServiceRegistry(sc).getPermissionService();
|
||||
allowed = (ps.hasPermission(this.scriptRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
if (this.docRef != null)
|
||||
{
|
||||
allowed &= (ps.hasPermission(this.docRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
}
|
||||
|
||||
// check to see if user is allowed to execute arbituary javascript
|
||||
// by default only an admin authority can perform this action
|
||||
ConfigService configService = Application.getConfigService(sc);
|
||||
ClientConfigElement configElement = (ClientConfigElement)configService.getGlobalConfig().getConfigElement("client");
|
||||
boolean allowScriptExecute = configElement.getAllowUserScriptExecute();
|
||||
AuthorityService authService = Repository.getServiceRegistry(sc).getAuthorityService();
|
||||
allowed &= (allowScriptExecute || authService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser()));
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(4, 1.0f);
|
||||
|
||||
properties.put(ExecuteScriptCommand.PROP_SCRIPT, this.scriptRef);
|
||||
properties.put(ExecuteScriptCommand.PROP_DOCUMENT, this.docRef);
|
||||
User user = Application.getCurrentUser(request.getSession());
|
||||
properties.put(ExecuteScriptCommand.PROP_USERPERSON, user.getPerson());
|
||||
|
||||
// add URL arguments as a special Scriptable Map property called 'args'
|
||||
Map<String, String> args = new ScriptableHashMap<String, String>();
|
||||
Enumeration names = request.getParameterNames();
|
||||
while (names.hasMoreElements())
|
||||
{
|
||||
String name = (String)names.nextElement();
|
||||
args.put(name, request.getParameter(name));
|
||||
}
|
||||
properties.put(ExecuteScriptCommand.PROP_ARGS, args);
|
||||
|
||||
Command cmd = CommandFactory.getInstance().createCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered script command specified: " + command);
|
||||
}
|
||||
this.result = cmd.execute(serviceRegistry, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.write(this.result != null ? this.result.toString() : "Successfully executed script.");
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.jscript.ScriptableHashMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.BaseServlet;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.User;
|
||||
import org.alfresco.web.config.ClientConfigElement;
|
||||
import org.springframework.extensions.config.ConfigService;
|
||||
|
||||
/**
|
||||
* Script command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing 'execute' script commands on a Node.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class ScriptCommandProcessor implements CommandProcessor
|
||||
{
|
||||
private static final String ARG_SCRIPT_PATH = "scriptPath";
|
||||
private static final String ARG_CONTEXT_PATH = "contextPath";
|
||||
|
||||
private NodeRef scriptRef;
|
||||
private NodeRef docRef;
|
||||
private Object result;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand("execute", ExecuteScriptCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
boolean allowed = false;
|
||||
String scriptPath = args.get(ARG_SCRIPT_PATH);
|
||||
if (scriptPath != null)
|
||||
{
|
||||
// resolve path to a node
|
||||
this.scriptRef = BaseServlet.resolveNamePath(sc, scriptPath).NodeRef;
|
||||
|
||||
// same for the document context path if specified
|
||||
String docPath = args.get(ARG_CONTEXT_PATH);
|
||||
if (docPath != null)
|
||||
{
|
||||
this.docRef = BaseServlet.resolveNamePath(sc, docPath).NodeRef;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (urlElements.length < 3)
|
||||
{
|
||||
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
|
||||
}
|
||||
|
||||
// get NodeRef to the node script to execute
|
||||
StoreRef storeRef = new StoreRef(urlElements[0], urlElements[1]);
|
||||
this.scriptRef = new NodeRef(storeRef, urlElements[2]);
|
||||
|
||||
if (urlElements.length >= 6)
|
||||
{
|
||||
storeRef = new StoreRef(urlElements[3], urlElements[4]);
|
||||
this.docRef = new NodeRef(storeRef, urlElements[5]);
|
||||
}
|
||||
}
|
||||
|
||||
// check we can READ access the nodes specified
|
||||
PermissionService ps = Repository.getServiceRegistry(sc).getPermissionService();
|
||||
allowed = (ps.hasPermission(this.scriptRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
if (this.docRef != null)
|
||||
{
|
||||
allowed &= (ps.hasPermission(this.docRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
}
|
||||
|
||||
// check to see if user is allowed to execute arbituary javascript
|
||||
// by default only an admin authority can perform this action
|
||||
ConfigService configService = Application.getConfigService(sc);
|
||||
ClientConfigElement configElement = (ClientConfigElement)configService.getGlobalConfig().getConfigElement("client");
|
||||
boolean allowScriptExecute = configElement.getAllowUserScriptExecute();
|
||||
AuthorityService authService = Repository.getServiceRegistry(sc).getAuthorityService();
|
||||
allowed &= (allowScriptExecute || authService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser()));
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(4, 1.0f);
|
||||
|
||||
properties.put(ExecuteScriptCommand.PROP_SCRIPT, this.scriptRef);
|
||||
properties.put(ExecuteScriptCommand.PROP_DOCUMENT, this.docRef);
|
||||
User user = Application.getCurrentUser(request.getSession());
|
||||
properties.put(ExecuteScriptCommand.PROP_USERPERSON, user.getPerson());
|
||||
|
||||
// add URL arguments as a special Scriptable Map property called 'args'
|
||||
Map<String, String> args = new ScriptableHashMap<String, String>();
|
||||
Enumeration names = request.getParameterNames();
|
||||
while (names.hasMoreElements())
|
||||
{
|
||||
String name = (String)names.nextElement();
|
||||
args.put(name, request.getParameter(name));
|
||||
}
|
||||
properties.put(ExecuteScriptCommand.PROP_ARGS, args);
|
||||
|
||||
Command cmd = CommandFactory.getInstance().createCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered script command specified: " + command);
|
||||
}
|
||||
this.result = cmd.execute(serviceRegistry, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.write(this.result != null ? this.result.toString() : "Successfully executed script.");
|
||||
}
|
||||
}
|
||||
|
@@ -1,84 +1,84 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Task specific command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing workflow task operations.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public final class TaskCommandProcessor implements CommandProcessor
|
||||
{
|
||||
private String taskId;
|
||||
private String transition = null;
|
||||
private String command;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand("end", EndTaskCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String cmd, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
if (urlElements.length == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
|
||||
}
|
||||
taskId = urlElements[0];
|
||||
if (urlElements.length == 2)
|
||||
{
|
||||
transition = urlElements[1];
|
||||
}
|
||||
return WorkflowUtil.isTaskEditable(taskId, sc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String commandName)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(1, 1.0f);
|
||||
// all workflow commands use a "target" Node property as an argument
|
||||
properties.put(EndTaskCommand.PROP_TASK_ID, taskId);
|
||||
if (transition != null)
|
||||
{
|
||||
properties.put(EndTaskCommand.PROP_TRANSITION, transition);
|
||||
}
|
||||
Command cmd = CommandFactory.getInstance().createCommand(commandName);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered workflow command specified: " + commandName);
|
||||
}
|
||||
cmd.execute(serviceRegistry, properties);
|
||||
this.command = commandName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.print("Task command: '");
|
||||
out.print(Utils.encode(command));
|
||||
out.print("' executed against task: ");
|
||||
out.println(Utils.encode(taskId));
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Task specific command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing workflow task operations.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public final class TaskCommandProcessor implements CommandProcessor
|
||||
{
|
||||
private String taskId;
|
||||
private String transition = null;
|
||||
private String command;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand("end", EndTaskCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String cmd, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
if (urlElements.length == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Not enough URL arguments passed to command servlet.");
|
||||
}
|
||||
taskId = urlElements[0];
|
||||
if (urlElements.length == 2)
|
||||
{
|
||||
transition = urlElements[1];
|
||||
}
|
||||
return WorkflowUtil.isTaskEditable(taskId, sc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String commandName)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(1, 1.0f);
|
||||
// all workflow commands use a "target" Node property as an argument
|
||||
properties.put(EndTaskCommand.PROP_TASK_ID, taskId);
|
||||
if (transition != null)
|
||||
{
|
||||
properties.put(EndTaskCommand.PROP_TRANSITION, transition);
|
||||
}
|
||||
Command cmd = CommandFactory.getInstance().createCommand(commandName);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered workflow command specified: " + commandName);
|
||||
}
|
||||
cmd.execute(serviceRegistry, properties);
|
||||
this.command = commandName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.print("Task command: '");
|
||||
out.print(Utils.encode(command));
|
||||
out.print("' executed against task: ");
|
||||
out.println(Utils.encode(taskId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,112 +1,112 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* UI action command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing specific UI actions via a REST style URL interface.
|
||||
* <p>
|
||||
* The URL postfix for each specific command depends on the context that is required
|
||||
* for that command. For example, a command to launch the Create Web Content dialog may
|
||||
* require the current sandbox and the current web project as its context e.g.
|
||||
* <br>
|
||||
* http://server/alfresco/command/ui/createwebcontent?sandbox=website1&webproject=1234567890
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class UIActionCommandProcessor implements ExtCommandProcessor
|
||||
{
|
||||
private static final String MANAGE_TASK = "managetask";
|
||||
|
||||
public static final String PARAM_CONTAINER = "container";
|
||||
|
||||
private ServletContext sc = null;
|
||||
private String command = null;
|
||||
private Map<String, String> args = null;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand(MANAGE_TASK, ManageTaskDialogCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("editcontentprops", EditContentPropertiesCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("userprofile", UserProfileDialogCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("editspace", EditSpaceCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
this.sc = sc;
|
||||
if (args.size() != 0)
|
||||
{
|
||||
this.args = new HashMap<String, String>(args);
|
||||
}
|
||||
if (MANAGE_TASK.equals(command))
|
||||
{
|
||||
String taskId = args.get(ManageTaskDialogCommand.PROP_TASKID);
|
||||
return WorkflowUtil.isTaskEditable(taskId, sc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command)
|
||||
{
|
||||
// not implemented in ExtCommandProcessor!
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.ExtCommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, HttpServletResponse response, String command)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(this.args);
|
||||
|
||||
properties.put(BaseUIActionCommand.PROP_SERVLETCONTEXT, this.sc);
|
||||
properties.put(BaseUIActionCommand.PROP_REQUEST, request);
|
||||
properties.put(BaseUIActionCommand.PROP_RESPONSE, response);
|
||||
|
||||
// if the container parameter is present and equal to "plain" add the
|
||||
// external container object to the session
|
||||
String container = request.getParameter(PARAM_CONTAINER);
|
||||
if (container != null && container.equalsIgnoreCase("plain"))
|
||||
{
|
||||
request.getSession().setAttribute(
|
||||
AlfrescoNavigationHandler.EXTERNAL_CONTAINER_SESSION, Boolean.TRUE);
|
||||
}
|
||||
|
||||
Command cmd = CommandFactory.getInstance().createCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered UI Action command specified: " + command);
|
||||
}
|
||||
cmd.execute(serviceRegistry, properties);
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.print("UI Action command: '");
|
||||
out.print(Utils.encode(this.command));
|
||||
out.print("' executed with args: ");
|
||||
out.println(this.args != null ? (Utils.encode(this.args.toString())) : "");
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.bean.workflow.WorkflowUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* UI action command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing specific UI actions via a REST style URL interface.
|
||||
* <p>
|
||||
* The URL postfix for each specific command depends on the context that is required
|
||||
* for that command. For example, a command to launch the Create Web Content dialog may
|
||||
* require the current sandbox and the current web project as its context e.g.
|
||||
* <br>
|
||||
* http://server/alfresco/command/ui/createwebcontent?sandbox=website1&webproject=1234567890
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class UIActionCommandProcessor implements ExtCommandProcessor
|
||||
{
|
||||
private static final String MANAGE_TASK = "managetask";
|
||||
|
||||
public static final String PARAM_CONTAINER = "container";
|
||||
|
||||
private ServletContext sc = null;
|
||||
private String command = null;
|
||||
private Map<String, String> args = null;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand(MANAGE_TASK, ManageTaskDialogCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("editcontentprops", EditContentPropertiesCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("userprofile", UserProfileDialogCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("editspace", EditSpaceCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(javax.servlet.ServletContext, java.lang.String, java.util.Map, java.lang.String[])
|
||||
*/
|
||||
public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements)
|
||||
{
|
||||
this.sc = sc;
|
||||
if (args.size() != 0)
|
||||
{
|
||||
this.args = new HashMap<String, String>(args);
|
||||
}
|
||||
if (MANAGE_TASK.equals(command))
|
||||
{
|
||||
String taskId = args.get(ManageTaskDialogCommand.PROP_TASKID);
|
||||
return WorkflowUtil.isTaskEditable(taskId, sc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command)
|
||||
{
|
||||
// not implemented in ExtCommandProcessor!
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.ExtCommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, HttpServletResponse response, String command)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(this.args);
|
||||
|
||||
properties.put(BaseUIActionCommand.PROP_SERVLETCONTEXT, this.sc);
|
||||
properties.put(BaseUIActionCommand.PROP_REQUEST, request);
|
||||
properties.put(BaseUIActionCommand.PROP_RESPONSE, response);
|
||||
|
||||
// if the container parameter is present and equal to "plain" add the
|
||||
// external container object to the session
|
||||
String container = request.getParameter(PARAM_CONTAINER);
|
||||
if (container != null && container.equalsIgnoreCase("plain"))
|
||||
{
|
||||
request.getSession().setAttribute(
|
||||
AlfrescoNavigationHandler.EXTERNAL_CONTAINER_SESSION, Boolean.TRUE);
|
||||
}
|
||||
|
||||
Command cmd = CommandFactory.getInstance().createCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered UI Action command specified: " + command);
|
||||
}
|
||||
cmd.execute(serviceRegistry, properties);
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.print("UI Action command: '");
|
||||
out.print(Utils.encode(this.command));
|
||||
out.print("' executed with args: ");
|
||||
out.println(this.args != null ? (Utils.encode(this.args.toString())) : "");
|
||||
}
|
||||
}
|
||||
|
@@ -1,59 +1,59 @@
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Workflow specific command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing 'approve' and 'reject' workflow commands on a Node.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class WorkflowCommandProcessor extends BaseNodeCommandProcessor
|
||||
{
|
||||
private String command;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand("approve", ApproveWorkflowCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("reject", RejectWorkflowCommand.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(1, 1.0f);
|
||||
// all workflow commands use a "target" Node property as an argument
|
||||
properties.put(ApproveWorkflowCommand.PROP_TARGET, this.targetRef);
|
||||
Command cmd = CommandFactory.getInstance().createCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered workflow command specified: " + command);
|
||||
}
|
||||
cmd.execute(serviceRegistry, properties);
|
||||
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.print("Workflow command: '");
|
||||
out.print(Utils.encode(this.command));
|
||||
out.print("' executed against node: ");
|
||||
out.println(Utils.encode(this.targetRef.toString()));
|
||||
}
|
||||
}
|
||||
package org.alfresco.web.app.servlet.command;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Workflow specific command processor implementation.
|
||||
* <p>
|
||||
* Responsible for executing 'approve' and 'reject' workflow commands on a Node.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class WorkflowCommandProcessor extends BaseNodeCommandProcessor
|
||||
{
|
||||
private String command;
|
||||
|
||||
static
|
||||
{
|
||||
// add our commands to the command registry
|
||||
CommandFactory.getInstance().registerCommand("approve", ApproveWorkflowCommand.class);
|
||||
CommandFactory.getInstance().registerCommand("reject", RejectWorkflowCommand.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#process(org.alfresco.service.ServiceRegistry, javax.servlet.http.HttpServletRequest, java.lang.String)
|
||||
*/
|
||||
public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command)
|
||||
{
|
||||
Map<String, Object> properties = new HashMap<String, Object>(1, 1.0f);
|
||||
// all workflow commands use a "target" Node property as an argument
|
||||
properties.put(ApproveWorkflowCommand.PROP_TARGET, this.targetRef);
|
||||
Command cmd = CommandFactory.getInstance().createCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unregistered workflow command specified: " + command);
|
||||
}
|
||||
cmd.execute(serviceRegistry, properties);
|
||||
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.app.servlet.command.CommandProcessor#outputStatus(java.io.PrintWriter)
|
||||
*/
|
||||
public void outputStatus(PrintWriter out)
|
||||
{
|
||||
out.print("Workflow command: '");
|
||||
out.print(Utils.encode(this.command));
|
||||
out.print("' executed against node: ");
|
||||
out.println(Utils.encode(this.targetRef.toString()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user