mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Big honkin' merge from head. Sheesh!
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,7 @@ import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.config.Config;
|
||||
import org.alfresco.config.ConfigService;
|
||||
import org.alfresco.web.app.servlet.ExternalAccessServlet;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
import org.alfresco.web.bean.dialog.DialogManager;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
@@ -623,14 +624,28 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are trying to close a dialog when one hasn't been opened!
|
||||
// log a warning and return a null outcome to stay on the same page
|
||||
if (logger.isWarnEnabled())
|
||||
// the details pages can be loaded via the external access servlet,
|
||||
// if this is the case the details page would not have been loaded as
|
||||
// a dialog, in this scenario just use the global "browse" outcome.
|
||||
String referer = (String)context.getExternalContext().
|
||||
getRequestHeaderMap().get("referer");
|
||||
if ((referer != null) &&
|
||||
((referer.indexOf(ExternalAccessServlet.OUTCOME_DOCDETAILS) != -1) ||
|
||||
(referer.indexOf(ExternalAccessServlet.OUTCOME_SPACEDETAILS) != -1)))
|
||||
{
|
||||
logger.warn("Attempting to close a " + closingItem + " with an empty view stack, returning null outcome");
|
||||
navigate(context, fromAction, "browse");
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are trying to close a dialog when one hasn't been opened!
|
||||
// log a warning and return a null outcome to stay on the same page
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("Attempting to close a " + closingItem + " with an empty view stack, returning null outcome");
|
||||
}
|
||||
|
||||
navigate(context, fromAction, null);
|
||||
}
|
||||
|
||||
navigate(context, fromAction, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -71,6 +71,7 @@ public class Application
|
||||
private static String spaceTemplatesFolderName;
|
||||
private static String contentTemplatesFolderName;
|
||||
private static String emailTemplatesFolderName;
|
||||
private static String rssTemplatesFolderName;
|
||||
private static String savedSearchesFolderName;
|
||||
private static String scriptsFolderName;
|
||||
private static String guestHomeFolderName;
|
||||
@@ -376,6 +377,22 @@ public class Application
|
||||
return getEmailTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the RSS templates folder name
|
||||
*/
|
||||
public static String getRSSTemplatesFolderName(ServletContext context)
|
||||
{
|
||||
return getRSSTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the RSS templates folder name
|
||||
*/
|
||||
public static String getRSSTemplatesFolderName(FacesContext context)
|
||||
{
|
||||
return getRSSTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the Saved Searches folder name
|
||||
*/
|
||||
@@ -750,6 +767,24 @@ public class Application
|
||||
return emailTemplatesFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RSS Templates folder name
|
||||
*
|
||||
* @param context The spring context
|
||||
* @return The RSS folder name
|
||||
*/
|
||||
private static String getRSSTemplatesFolderName(WebApplicationContext context)
|
||||
{
|
||||
if (rssTemplatesFolderName == null)
|
||||
{
|
||||
ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP);
|
||||
Properties configuration = bootstrap.getConfiguration();
|
||||
rssTemplatesFolderName = configuration.getProperty("spaces.templates.rss.childname");
|
||||
}
|
||||
|
||||
return rssTemplatesFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Saved Searches folder name
|
||||
*
|
||||
|
@@ -146,17 +146,7 @@ public class ContextListener implements ServletContextListener, HttpSessionListe
|
||||
*/
|
||||
public void contextDestroyed(ServletContextEvent event)
|
||||
{
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
|
||||
Scheduler quartz = (Scheduler) ctx.getBean("schedulerFactory");
|
||||
try
|
||||
{
|
||||
quartz.shutdown(true);
|
||||
}
|
||||
catch (SchedulerException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.app.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.faces.webapp.FacesServlet;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Wrapper around standard faces servlet to provide error handling
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AlfrescoFacesServlet extends FacesServlet
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(AlfrescoFacesServlet.class);
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Servlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
|
||||
*/
|
||||
public void service(ServletRequest request, ServletResponse response)
|
||||
throws IOException, ServletException
|
||||
{
|
||||
try
|
||||
{
|
||||
super.service(request, response);
|
||||
}
|
||||
catch (Throwable error)
|
||||
{
|
||||
String returnPage = ((HttpServletRequest)request).getRequestURI();
|
||||
|
||||
Application.handleServletError(getServletConfig().getServletContext(), (HttpServletRequest)request,
|
||||
(HttpServletResponse)response, error, logger, returnPage);
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.SocketException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
@@ -35,6 +36,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
@@ -170,6 +172,7 @@ public class DownloadContentServlet extends BaseServlet
|
||||
|
||||
// get the services we need to retrieve the content
|
||||
ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext());
|
||||
NodeService nodeService = serviceRegistry.getNodeService();
|
||||
ContentService contentService = serviceRegistry.getContentService();
|
||||
PermissionService permissionService = serviceRegistry.getPermissionService();
|
||||
|
||||
@@ -184,6 +187,21 @@ public class DownloadContentServlet extends BaseServlet
|
||||
return;
|
||||
}
|
||||
|
||||
// check If-Modified-Since header and set Last-Modified header as appropriate
|
||||
Date modified = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
|
||||
long modifiedSince = req.getDateHeader("If-Modified-Since");
|
||||
if (modifiedSince > 0L)
|
||||
{
|
||||
// round the date to the ignore millisecond value which is not supplied by header
|
||||
long modDate = (modified.getTime() / 1000L) * 1000L;
|
||||
if (modDate <= modifiedSince)
|
||||
{
|
||||
res.setStatus(304);
|
||||
return;
|
||||
}
|
||||
}
|
||||
res.setDateHeader("Last-Modified", modified.getTime());
|
||||
|
||||
if (attachment == true)
|
||||
{
|
||||
// set header based on filename - will force a Save As from the browse if it doesn't recognise it
|
||||
|
@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.dashboard.DashboardManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -61,12 +62,14 @@ public class ExternalAccessServlet extends BaseServlet
|
||||
|
||||
private static Log logger = LogFactory.getLog(ExternalAccessServlet.class);
|
||||
|
||||
private final static String OUTCOME_DOCDETAILS = "showDocDetails";
|
||||
private final static String OUTCOME_SPACEDETAILS = "showSpaceDetails";
|
||||
private final static String OUTCOME_BROWSE = "browse";
|
||||
private final static String OUTCOME_LOGOUT = "logout";
|
||||
public final static String OUTCOME_DOCDETAILS = "showDocDetails";
|
||||
public final static String OUTCOME_SPACEDETAILS = "showSpaceDetails";
|
||||
public final static String OUTCOME_BROWSE = "browse";
|
||||
public final static String OUTCOME_MYALFRESCO = "myalfresco";
|
||||
public final static String OUTCOME_LOGOUT = "logout";
|
||||
|
||||
private static final String ARG_TEMPLATE = "template";
|
||||
private static final String ARG_PAGE = "page";
|
||||
|
||||
/**
|
||||
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
@@ -224,6 +227,19 @@ public class ExternalAccessServlet extends BaseServlet
|
||||
navigationHandler.handleNavigation(fc, null, outcome);
|
||||
}
|
||||
}
|
||||
else if (OUTCOME_MYALFRESCO.equals(outcome))
|
||||
{
|
||||
// setup the Dashboard Manager ready for the page we want to display
|
||||
if (req.getParameter(ARG_PAGE) != null)
|
||||
{
|
||||
DashboardManager manager = (DashboardManager)FacesHelper.getManagedBean(fc, "DashboardManager");
|
||||
manager.getPageConfig().setCurrentPage(req.getParameter(ARG_PAGE));
|
||||
}
|
||||
|
||||
// perform the appropriate JSF navigation outcome
|
||||
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||
navigationHandler.handleNavigation(fc, null, outcome);
|
||||
}
|
||||
else if (OUTCOME_LOGOUT.equals(outcome))
|
||||
{
|
||||
// special case for logout
|
||||
|
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.app.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.workflow.WorkflowComponent;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowException;
|
||||
import org.apache.commons.fileupload.DiskFileUpload;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileUpload;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Servlet for handling process deployments from jBPM process designer.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class JBPMDeployProcessServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 8002539291245090187L;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
public void service(HttpServletRequest request, HttpServletResponse response)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
response.setContentType("text/html");
|
||||
InputStream deploymentArchive = getDeploymentArchive(request);
|
||||
WorkflowDefinition workflowDef = deployArchive(deploymentArchive);
|
||||
response.getWriter().println("Deployed archive " + workflowDef.title + " successfully");
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
// NOTE: according to original jBPM deployment servlet
|
||||
response.getWriter().println("IOException");
|
||||
}
|
||||
catch(FileUploadException e)
|
||||
{
|
||||
// NOTE: according to original jBPM deployment servlet
|
||||
response.getWriter().println("FileUploadException");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the JBPM Process Designer deployment archive from the request
|
||||
*
|
||||
* @param request the request
|
||||
* @return the input stream onto the deployment archive
|
||||
* @throws WorkflowException
|
||||
* @throws FileUploadException
|
||||
* @throws IOException
|
||||
*/
|
||||
private InputStream getDeploymentArchive(HttpServletRequest request)
|
||||
throws FileUploadException, IOException
|
||||
{
|
||||
if (!FileUpload.isMultipartContent(request))
|
||||
{
|
||||
throw new FileUploadException("Not a multipart request");
|
||||
}
|
||||
|
||||
GPDUpload fileUpload = new GPDUpload();
|
||||
List list = fileUpload.parseRequest(request);
|
||||
Iterator iterator = list.iterator();
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
throw new FileUploadException("No process file in the request");
|
||||
}
|
||||
|
||||
FileItem fileItem = (FileItem) iterator.next();
|
||||
if (fileItem.getContentType().indexOf("application/x-zip-compressed") == -1)
|
||||
{
|
||||
throw new FileUploadException("Not a process archive");
|
||||
}
|
||||
|
||||
return fileItem.getInputStream();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deploy the jBPM process archive to the Alfresco Repository
|
||||
*
|
||||
* @param deploymentArchive the archive to deploy
|
||||
* @return the deployed workflow definition
|
||||
*/
|
||||
private WorkflowDefinition deployArchive(InputStream deploymentArchive)
|
||||
{
|
||||
// NOTE: retrieve jbpm engine directly as this servlet only serves JBPM process designer deployments
|
||||
WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
|
||||
WorkflowComponent jbpmEngine = (WorkflowComponent)wc.getBean("jbpm_engine");
|
||||
WorkflowDeployment deployment = jbpmEngine.deployDefinition(deploymentArchive, MimetypeMap.MIMETYPE_ZIP);
|
||||
return deployment.definition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NOTE: Workaround...
|
||||
*
|
||||
* The JBPM process designer (as of 3.1.2) issues a request with a multi-part line
|
||||
* delimited by ",". It should be ":" according to the HTTP specification which
|
||||
* the commons file-upload is adhering to.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private class GPDUpload extends DiskFileUpload
|
||||
{
|
||||
@Override
|
||||
protected byte[] getBoundary(String contentType)
|
||||
{
|
||||
return super.getBoundary(contentType.replace(",", ";"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -142,7 +142,7 @@ public class TemplateContentServlet extends BaseServlet
|
||||
|
||||
templateRef = pathInfo.NodeRef;
|
||||
}
|
||||
else if (tokenCount == 7)
|
||||
else if (tokenCount >= 7)
|
||||
{
|
||||
StoreRef storeRef = new StoreRef(t.nextToken(), t.nextToken());
|
||||
templateRef = new NodeRef(storeRef, t.nextToken());
|
||||
@@ -157,7 +157,7 @@ public class TemplateContentServlet extends BaseServlet
|
||||
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new TemplateException("Not enough arguments supplied in URL.");
|
||||
throw new TemplateException("Not enough elements supplied in URL or no 'path' argument specified.");
|
||||
}
|
||||
|
||||
// get the services we need to retrieve the content
|
||||
@@ -268,7 +268,6 @@ public class TemplateContentServlet extends BaseServlet
|
||||
TemplateNode node = new TemplateNode(nodeRef, services, this.imageResolver);
|
||||
root.put("space", node);
|
||||
root.put("document", node);
|
||||
root.put("template", new TemplateNode(templateRef, services, this.imageResolver));
|
||||
|
||||
// add URL arguments as a map called 'args' to the root of the model
|
||||
Map<String, String> args = new HashMap<String, String>(8, 1.0f);
|
||||
|
@@ -28,14 +28,10 @@ public interface AjaxCommand
|
||||
*
|
||||
* @param facesContext FacesContext
|
||||
* @param expression The binding expression
|
||||
* <!-- @param responseMimeType The response mime-type -->
|
||||
* @param request The request
|
||||
* @param response The response
|
||||
*/
|
||||
public abstract void execute(FacesContext facesContext,
|
||||
String expression,
|
||||
// String responseMimeType,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException;
|
||||
public abstract void execute(FacesContext facesContext, String expression,
|
||||
HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException;
|
||||
}
|
||||
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 command, 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 true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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(EndTaskCommand.PROP_TASK_ID, taskId);
|
||||
if (transition != null)
|
||||
{
|
||||
properties.put(EndTaskCommand.PROP_TRANSITION, transition);
|
||||
}
|
||||
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("Task command: '");
|
||||
out.print(command);
|
||||
out.print("' executed against task: ");
|
||||
out.println(taskId);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user