Humongous merge. It is incomplete, however; faces-config-navigation.xml and ClientConfigElement

were both beyond me, and are just the raw conflict merge data.  If Kev can't figure out how they should
go together by tomorrow AM (for me) I'll dig back in.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4306 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-11-08 05:17:40 +00:00
parent c5c18185cf
commit 99486032e1
46 changed files with 5805 additions and 3529 deletions

View File

@@ -21,7 +21,6 @@ import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.util.ISO9075;
import org.alfresco.web.action.ActionEvaluator;
@@ -45,37 +44,28 @@ public class CancelWorkflowEvaluator implements ActionEvaluator
public boolean evaluate(Node node)
{
boolean result = false;
// get the id of the task
String taskId = (String)node.getProperties().get("id");
if (taskId != null)
FacesContext context = FacesContext.getCurrentInstance();
// get the task from the node
WorkflowTask task = (WorkflowTask)node.getProperties().get("workflowTask");
if (task != null)
{
FacesContext context = FacesContext.getCurrentInstance();
// get the initiator of the workflow the task belongs to
WorkflowService workflowSvc = Repository.getServiceRegistry(
context).getWorkflowService();
WorkflowTask task = workflowSvc.getTaskById(taskId);
if (task != null)
NodeRef initiator = task.path.instance.initiator;
if (initiator != null)
{
NodeRef initiator = task.path.instance.initiator;
if (initiator != null)
// find the current username
User user = Application.getCurrentUser(context);
String currentUserName = ISO9075.encode(user.getUserName());
// get the username of the initiator
NodeService nodeSvc = Repository.getServiceRegistry(
context).getNodeService();
String userName = (String)nodeSvc.getProperty(initiator, ContentModel.PROP_USERNAME);
// if the current user started the workflow allow the cancel action
if (currentUserName.equals(userName))
{
// find the current username
User user = Application.getCurrentUser(context);
String currentUserName = ISO9075.encode(user.getUserName());
// get the username of the initiator
NodeService nodeSvc = Repository.getServiceRegistry(
context).getNodeService();
String userName = (String)nodeSvc.getProperty(initiator, ContentModel.PROP_USERNAME);
// if the current user started the workflow allow the cancel action
if (currentUserName.equals(userName))
{
result = true;
}
result = true;
}
}
}

View File

@@ -0,0 +1,305 @@
/*
* 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.net.SocketException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
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.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateException;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
/**
* Base class for the template content servlets. Provides common
* processing for the request.
*
* @see org.alfresco.web.app.servlet.TemplateContentServlet
* @see org.alfresco.web.app.servlet.GuestTemplateContentServlet
*
* @author Kevin Roast
* @author gavinc
*/
public abstract class BaseTemplateContentServlet extends BaseServlet
{
private static final String MIMETYPE_HTML = "text/html";
private static final long serialVersionUID = -4123407921997235977L;
private static final String ARG_MIMETYPE = "mimetype";
private static final String ARG_TEMPLATE_PATH = "templatePath";
private static final String ARG_CONTEXT_PATH = "contextPath";
/**
* Gets the logger to use for this request.
* <p>
* This will show all debug entries from this class as though they
* came from the subclass.
*
* @return The logger
*/
protected abstract Log getLogger();
/**
* Builds the FreeMarker model
*
* @param services Service Registry instance
* @param req Http request
* @param templateRef The node ref of the template to process
* @return The FreeMarker model
*/
protected abstract Map<String, Object> buildModel(ServiceRegistry services,
HttpServletRequest req, NodeRef templateRef);
/**
* Processes the template request using the current context i.e. no
* authentication checks are made, it is presumed they have already
* been done.
*
* @param req The HTTP request
* @param res The HTTP response
* @param redirectToLogin Flag to determine whether to redirect to the login
* page if the user does not have the correct permissions
*/
protected void processTemplateRequest(HttpServletRequest req, HttpServletResponse res,
boolean redirectToLogin) throws ServletException, IOException
{
Log logger = getLogger();
String uri = req.getRequestURI();
if (logger.isDebugEnabled())
{
String queryString = req.getQueryString();
logger.debug("Processing URL: " + uri +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
uri = uri.substring(req.getContextPath().length());
StringTokenizer t = new StringTokenizer(uri, "/");
int tokenCount = t.countTokens();
t.nextToken(); // skip servlet name
NodeRef nodeRef = null;
NodeRef templateRef = null;
String contentPath = req.getParameter(ARG_CONTEXT_PATH);
if (contentPath != null && contentPath.length() != 0)
{
// process the name based path to resolve the NodeRef
PathRefInfo pathInfo = resolveNamePath(getServletContext(), contentPath);
nodeRef = pathInfo.NodeRef;
}
else if (tokenCount > 3)
{
// get NodeRef to the content from the URL elements
StoreRef storeRef = new StoreRef(t.nextToken(), t.nextToken());
nodeRef = new NodeRef(storeRef, t.nextToken());
}
// get NodeRef to the template if supplied
String templatePath = req.getParameter(ARG_TEMPLATE_PATH);
if (templatePath != null && templatePath.length() != 0)
{
// process the name based path to resolve the NodeRef
PathRefInfo pathInfo = resolveNamePath(getServletContext(), templatePath);
templateRef = pathInfo.NodeRef;
}
else if (tokenCount >= 7)
{
StoreRef storeRef = new StoreRef(t.nextToken(), t.nextToken());
templateRef = new NodeRef(storeRef, t.nextToken());
}
// if no context is specified, use the template itself
// TODO: should this default to something else?
if (nodeRef == null && templateRef != null)
{
nodeRef = templateRef;
}
if (nodeRef == null)
{
throw new TemplateException("Not enough elements supplied in URL or no 'path' argument specified.");
}
// get the services we need to retrieve the content
ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext());
NodeService nodeService = serviceRegistry.getNodeService();
TemplateService templateService = serviceRegistry.getTemplateService();
PermissionService permissionService = serviceRegistry.getPermissionService();
// check that the user has at least READ access on any nodes - else redirect to the login page
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED ||
(templateRef != null && permissionService.hasPermission(templateRef, PermissionService.READ) == AccessStatus.DENIED))
{
if (redirectToLogin)
{
if (logger.isDebugEnabled())
logger.debug("Redirecting to login page...");
redirectToLoginPage(req, res, getServletContext());
}
else
{
if (logger.isDebugEnabled())
logger.debug("Returning 403 Forbidden error...");
res.sendError(HttpServletResponse.SC_FORBIDDEN);
}
return;
}
String mimetype = MIMETYPE_HTML;
if (req.getParameter(ARG_MIMETYPE) != null)
{
mimetype = req.getParameter(ARG_MIMETYPE);
}
res.setContentType(mimetype);
try
{
UserTransaction txn = null;
try
{
txn = serviceRegistry.getTransactionService().getUserTransaction(true);
txn.begin();
// if template not supplied, then use the default against the node
if (templateRef == null)
{
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPLATABLE))
{
templateRef = (NodeRef)nodeService.getProperty(nodeRef, ContentModel.PROP_TEMPLATE);
}
if (templateRef == null)
{
throw new TemplateException("Template reference not set against node or not supplied in URL.");
}
}
// create the model - put the supplied noderef in as space/document as appropriate
Object model = getModel(serviceRegistry, req, templateRef, nodeRef);
// process the template against the node content directly to the response output stream
// assuming the repo is capable of streaming in chunks, this should allow large files
// to be streamed directly to the browser response stream.
try
{
templateService.processTemplate(
null,
templateRef.toString(),
model,
res.getWriter());
// commit the transaction
txn.commit();
}
catch (SocketException e)
{
if (e.getMessage().contains("ClientAbortException"))
{
// the client cut the connection - our mission was accomplished apart from a little error message
logger.error("Client aborted stream read:\n node: " + nodeRef + "\n template: " + templateRef);
try { if (txn != null) {txn.rollback();} } catch (Exception tex) {}
}
else
{
throw e;
}
}
}
catch (Throwable txnErr)
{
try { if (txn != null) {txn.rollback();} } catch (Exception tex) {}
throw txnErr;
}
}
catch (Throwable err)
{
throw new AlfrescoRuntimeException("Error during template servlet processing: " + err.getMessage(), err);
}
}
/**
* Build the model that to process the template against.
* <p>
* The model includes the usual template root objects such as 'companyhome', 'userhome',
* 'person' and also includes the node specified on the servlet URL as 'space' and 'document'
*
* @param services ServiceRegistry required for TemplateNode construction
* @param req Http request - for accessing Session and url args
* @param templateRef NodeRef of the template itself
* @param nodeRef NodeRef of the space/document to process template against
*
* @return an object model ready for executing template against
*/
@SuppressWarnings("unchecked")
private Object getModel(ServiceRegistry services, HttpServletRequest req, NodeRef templateRef, NodeRef nodeRef)
{
// build FreeMarker default model and merge
Map<String, Object> root = buildModel(services, req, templateRef);
// put the current NodeRef in as "space" and "document"
TemplateNode node = new TemplateNode(nodeRef, services, this.imageResolver);
root.put("space", node);
root.put("document", node);
// 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);
Enumeration names = req.getParameterNames();
while (names.hasMoreElements())
{
String name = (String)names.nextElement();
args.put(name, req.getParameter(name));
}
root.put("args", args);
return root;
}
/** Template Image resolver helper */
private TemplateImageResolver imageResolver = new TemplateImageResolver()
{
public String resolveImagePathForName(String filename, boolean small)
{
return Utils.getFileTypeImage(getServletContext(), filename, small);
}
};
}

View File

@@ -0,0 +1,188 @@
/*
* 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.text.MessageFormat;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.ui.repo.component.template.DefaultModelHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* Servlet responsible for streaming content from a template processed against a node directly
* to the response stream.
* <p>
* The URL to the servlet should be generated thus:
* <pre>/alfresco/template/workspace/SpacesStore/0000-0000-0000-0000</pre>
* or
* <pre>/alfresco/template/workspace/SpacesStore/0000-0000-0000-0000/workspace/SpacesStore/0000-0000-0000-0000</pre>
* or
* <pre>/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/doc_info.ftl&contextPath=/Company%20Home/mydoc.txt</pre>
* <p>
* The store protocol, followed by the store ID, followed by the content Node Id used to
* identify the node to execute the default template for. The second set of elements encode
* the store and node Id of the template to used if a default is not set or not requested. Instead
* of using NodeRef references to the template and context, path arguments can be used. The URL args
* of 'templatePath' and 'contextPath' can be used instead to specify name based encoded Paths to the
* template and its context.
* <p>
* The URL may be followed by a 'mimetype' argument specifying the mimetype to return the result as
* on the stream. Otherwise it is assumed that HTML is the default response mimetype.
* <p>
* Like most Alfresco servlets, the URL may be followed by a valid 'ticket' argument for authentication:
* ?ticket=1234567890
* <p>
* And/or also followed by the "?guest=true" argument to force guest access login for the URL. If the
* guest=true parameter is used the current session will be logged out and the guest user logged in.
* Therefore upon completion of this request the current user will be "guest".
* <p>
* This servlet only accesses content available to the guest user. If the guest user does not
* have access to the requested a 401 Forbidden response is returned to the caller.
* <p>
* This servlet does not effect the current session, therefore if guest access is required to a
* resource this servlet can be used without logging out the current user.
*
* @author gavinc
*/
public class GuestTemplateContentServlet extends BaseTemplateContentServlet
{
private static final long serialVersionUID = -2510767849932627519L;
private static final Log logger = LogFactory.getLog(GuestTemplateContentServlet.class);
private static final String DEFAULT_URL = "/guestTemplate/{0}/{1}/{2}";
private static final String TEMPLATE_URL = "/guestTemplate/{0}/{1}/{2}/{3}/{4}/{5}";
@Override
protected Log getLogger()
{
return logger;
}
@Override
protected Map<String, Object> buildModel(ServiceRegistry services, HttpServletRequest req,
NodeRef templateRef)
{
// setup the guest user to pass to the build model helper method
AuthenticationService auth = (AuthenticationService)services.getAuthenticationService();
PersonService personService = (PersonService)services.getPersonService();
NodeService nodeService = (NodeService)services.getNodeService();
NodeRef guestRef = personService.getPerson(PermissionService.GUEST_AUTHORITY);
User guestUser = new User(PermissionService.GUEST_AUTHORITY, auth.getCurrentTicket(), guestRef);
NodeRef guestHomeRef = (NodeRef)nodeService.getProperty(guestRef, ContentModel.PROP_HOMEFOLDER);
if (nodeService.exists(guestHomeRef) == false)
{
throw new InvalidNodeRefException(guestHomeRef);
}
guestUser.setHomeSpaceId(guestHomeRef.getId());
// build the default model
return DefaultModelHelper.buildDefaultModel(services, guestUser, templateRef);
}
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
if (logger.isDebugEnabled())
{
String queryString = req.getQueryString();
logger.debug("Setting up guest access to URL: " + req.getRequestURI() +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
TemplateContentWork tcw = new TemplateContentWork(req, res);
AuthenticationUtil.runAs(tcw, PermissionService.GUEST_AUTHORITY);
}
/**
* Helper to generate a URL to process a template against a node.
* <p>
* The result of the template is supplied returned as the response.
*
* @param nodeRef NodeRef of the content node to generate URL for (cannot be null)
* @param templateRef NodeRef of the template to process against, or null to use default
*
* @return URL to process the template
*/
public final static String generateURL(NodeRef nodeRef, NodeRef templateRef)
{
if (templateRef == null)
{
return MessageFormat.format(DEFAULT_URL, new Object[] {
nodeRef.getStoreRef().getProtocol(),
nodeRef.getStoreRef().getIdentifier(),
nodeRef.getId() } );
}
else
{
return MessageFormat.format(TEMPLATE_URL, new Object[] {
nodeRef.getStoreRef().getProtocol(),
nodeRef.getStoreRef().getIdentifier(),
nodeRef.getId(),
templateRef.getStoreRef().getProtocol(),
templateRef.getStoreRef().getIdentifier(),
templateRef.getId()} );
}
}
/**
* Class to wrap the call to processTemplateRequest.
*
* @author gavinc
*/
public class TemplateContentWork implements RunAsWork<Object>
{
private HttpServletRequest req = null;
private HttpServletResponse res = null;
public TemplateContentWork(HttpServletRequest req, HttpServletResponse res)
{
this.req = req;
this.res = res;
}
public Object doWork() throws Exception
{
processTemplateRequest(this.req, this.res, false);
return null;
}
}
}

View File

@@ -0,0 +1,65 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.alfresco.web.app.servlet;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
//
//
// TODO: DC: Tidy up
//
//
public class JBPMProcessImageServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
long processDefinitionId = Long.parseLong( request.getParameter( "definitionId" ) );
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId);
byte[] bytes = processDefinition.getFileDefinition().getBytes("processimage.jpg");
OutputStream out = response.getOutputStream();
out.write(bytes);
out.flush();
// leave this in. it is in case we want to set the mime type later.
// get the mime type
// String contentType = URLConnection.getFileNameMap().getContentTypeFor( fileName );
// set the content type (=mime type)
// response.setContentType( contentType );
}
}

View File

@@ -17,32 +17,16 @@
package org.alfresco.web.app.servlet;
import java.io.IOException;
import java.net.SocketException;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
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.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateException;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.repo.component.template.DefaultModelHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -71,24 +55,37 @@ import org.apache.commons.logging.LogFactory;
* Like most Alfresco servlets, the URL may be followed by a valid 'ticket' argument for authentication:
* ?ticket=1234567890
* <p>
* And/or also followed by the "?guest=true" argument to force guest access login for the URL.
* And/or also followed by the "?guest=true" argument to force guest access login for the URL. If the
* guest=true parameter is used the current session will be logged out and the guest user logged in.
* Therefore upon completion of this request the current user will be "guest".
* <p>
* If the user attempting the request is not authorised to access the requested node the login page
* will be redirected to.
*
* @author Kevin Roast
*/
public class TemplateContentServlet extends BaseServlet
{
private static final String MIMETYPE_HTML = "text/html";
public class TemplateContentServlet extends BaseTemplateContentServlet
{
private static final long serialVersionUID = -2510767849932627519L;
private static final long serialVersionUID = -4123407921997235977L;
private static Log logger = LogFactory.getLog(TemplateContentServlet.class);
private static final Log logger = LogFactory.getLog(TemplateContentServlet.class);
private static final String DEFAULT_URL = "/template/{0}/{1}/{2}";
private static final String TEMPLATE_URL = "/template/{0}/{1}/{2}/{3}/{4}/{5}";
private static final String ARG_MIMETYPE = "mimetype";
private static final String ARG_TEMPLATE_PATH = "templatePath";
private static final String ARG_CONTEXT_PATH = "contextPath";
@Override
protected Log getLogger()
{
return logger;
}
@Override
protected Map<String, Object> buildModel(ServiceRegistry services, HttpServletRequest req,
NodeRef templateRef)
{
return DefaultModelHelper.buildDefaultModel(services,
Application.getCurrentUser(req.getSession()), templateRef);
}
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
@@ -96,12 +93,10 @@ public class TemplateContentServlet extends BaseServlet
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String uri = req.getRequestURI();
if (logger.isDebugEnabled())
{
String queryString = req.getQueryString();
logger.debug("Processing URL: " + uri +
logger.debug("Authenticating request to URL: " + req.getRequestURI() +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
@@ -111,189 +106,9 @@ public class TemplateContentServlet extends BaseServlet
return;
}
uri = uri.substring(req.getContextPath().length());
StringTokenizer t = new StringTokenizer(uri, "/");
int tokenCount = t.countTokens();
t.nextToken(); // skip servlet name
NodeRef nodeRef = null;
NodeRef templateRef = null;
String contentPath = req.getParameter(ARG_CONTEXT_PATH);
if (contentPath != null && contentPath.length() != 0)
{
// process the name based path to resolve the NodeRef
PathRefInfo pathInfo = resolveNamePath(getServletContext(), contentPath);
nodeRef = pathInfo.NodeRef;
}
else if (tokenCount > 3)
{
// get NodeRef to the content from the URL elements
StoreRef storeRef = new StoreRef(t.nextToken(), t.nextToken());
nodeRef = new NodeRef(storeRef, t.nextToken());
}
// get NodeRef to the template if supplied
String templatePath = req.getParameter(ARG_TEMPLATE_PATH);
if (templatePath != null && templatePath.length() != 0)
{
// process the name based path to resolve the NodeRef
PathRefInfo pathInfo = resolveNamePath(getServletContext(), templatePath);
templateRef = pathInfo.NodeRef;
}
else if (tokenCount >= 7)
{
StoreRef storeRef = new StoreRef(t.nextToken(), t.nextToken());
templateRef = new NodeRef(storeRef, t.nextToken());
}
// if no context is specified, use the template itself
// TODO: should this default to something else?
if (nodeRef == null && templateRef != null)
{
nodeRef = templateRef;
}
if (nodeRef == null)
{
throw new TemplateException("Not enough elements supplied in URL or no 'path' argument specified.");
}
// get the services we need to retrieve the content
ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext());
NodeService nodeService = serviceRegistry.getNodeService();
TemplateService templateService = serviceRegistry.getTemplateService();
PermissionService permissionService = serviceRegistry.getPermissionService();
// check that the user has at least READ access on any nodes - else redirect to the login page
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED ||
(templateRef != null && permissionService.hasPermission(templateRef, PermissionService.READ) == AccessStatus.DENIED))
{
redirectToLoginPage(req, res, getServletContext());
return;
}
String mimetype = MIMETYPE_HTML;
if (req.getParameter(ARG_MIMETYPE) != null)
{
mimetype = req.getParameter(ARG_MIMETYPE);
}
res.setContentType(mimetype);
try
{
UserTransaction txn = null;
try
{
txn = serviceRegistry.getTransactionService().getUserTransaction(true);
txn.begin();
// if template not supplied, then use the default against the node
if (templateRef == null)
{
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPLATABLE))
{
templateRef = (NodeRef)nodeService.getProperty(nodeRef, ContentModel.PROP_TEMPLATE);
}
if (templateRef == null)
{
throw new TemplateException("Template reference not set against node or not supplied in URL.");
}
}
// create the model - put the supplied noderef in as space/document as appropriate
Object model = getModel(serviceRegistry, req, templateRef, nodeRef);
// process the template against the node content directly to the response output stream
// assuming the repo is capable of streaming in chunks, this should allow large files
// to be streamed directly to the browser response stream.
try
{
templateService.processTemplate(
null,
templateRef.toString(),
model,
res.getWriter());
// commit the transaction
txn.commit();
}
catch (SocketException e)
{
if (e.getMessage().contains("ClientAbortException"))
{
// the client cut the connection - our mission was accomplished apart from a little error message
logger.error("Client aborted stream read:\n node: " + nodeRef + "\n template: " + templateRef);
try { if (txn != null) {txn.rollback();} } catch (Exception tex) {}
}
else
{
throw e;
}
}
}
catch (Throwable txnErr)
{
try { if (txn != null) {txn.rollback();} } catch (Exception tex) {}
throw txnErr;
}
}
catch (Throwable err)
{
throw new AlfrescoRuntimeException("Error during template servlet processing: " + err.getMessage(), err);
}
processTemplateRequest(req, res, true);
}
/**
* Build the model that to process the template against.
* <p>
* The model includes the usual template root objects such as 'companyhome', 'userhome',
* 'person' and also includes the node specified on the servlet URL as 'space' and 'document'
*
* @param services ServiceRegistry required for TemplateNode construction
* @param req Http request - for accessing Session and url args
* @param templateRef NodeRef of the template itself
* @param nodeRef NodeRef of the space/document to process template against
*
* @return an object model ready for executing template against
*/
@SuppressWarnings("unchecked")
private Object getModel(ServiceRegistry services, HttpServletRequest req, NodeRef templateRef, NodeRef nodeRef)
{
// build FreeMarker default model and merge
Map root = DefaultModelHelper.buildDefaultModel(
services, Application.getCurrentUser(req.getSession()), templateRef);
// put the current NodeRef in as "space" and "document"
TemplateNode node = new TemplateNode(nodeRef, services, this.imageResolver);
root.put("space", node);
root.put("document", node);
// 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);
Enumeration names = req.getParameterNames();
while (names.hasMoreElements())
{
String name = (String)names.nextElement();
args.put(name, req.getParameter(name));
}
root.put("args", args);
return root;
}
/** Template Image resolver helper */
private TemplateImageResolver imageResolver = new TemplateImageResolver()
{
public String resolveImagePathForName(String filename, boolean small)
{
return Utils.getFileTypeImage(getServletContext(), filename, small);
}
};
/**
* Helper to generate a URL to process a template against a node.
* <p>

View File

@@ -20,7 +20,7 @@ import java.util.Map;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.bean.WorkflowUtil;
import org.alfresco.web.bean.workflow.WorkflowUtil;
/**
* Approve Workflow command implementation

View File

@@ -20,7 +20,7 @@ import java.util.Map;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.bean.WorkflowUtil;
import org.alfresco.web.bean.workflow.WorkflowUtil;
/**
* Reject Workflow command implementation

View File

@@ -39,6 +39,7 @@ import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.bean.actions.handlers.SimpleWorkflowHandler;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.workflow.WorkflowUtil;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.Utils.URLMode;
import org.alfresco.web.ui.common.component.UIActionLink;

File diff suppressed because it is too large Load Diff

View File

@@ -86,6 +86,7 @@ public final class SearchContext implements Serializable
private static final char OP_WILDCARD = '*';
private static final char OP_AND = '+';
private static final char OP_NOT = '-';
private static final String STR_OP_WILDCARD = "" + OP_WILDCARD;
/** Search mode constants */
public final static int SEARCH_ALL = 0;
@@ -174,21 +175,7 @@ public final class SearchContext implements Serializable
nameAttrBuf.append(OP_NOT);
}
// simple single word text search
if (text.charAt(0) != OP_WILDCARD)
{
// escape characters and append the wildcard character
String safeText = QueryParser.escape(text);
fullTextBuf.append("TEXT:").append(safeText).append(OP_WILDCARD);
nameAttrBuf.append("@").append(nameAttr).append(":").append(safeText).append(OP_WILDCARD);
}
else
{
// found a leading wildcard - prepend it again after escaping the other characters
String safeText = QueryParser.escape(text.substring(1));
fullTextBuf.append("TEXT:*").append(safeText).append(OP_WILDCARD);
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeText).append(OP_WILDCARD);
}
processSearchTextAttribute(nameAttr, text, nameAttrBuf, fullTextBuf);
}
}
else
@@ -253,18 +240,8 @@ public final class SearchContext implements Serializable
nameAttrBuf.append(OP_AND);
}
if (term.charAt(0) != OP_WILDCARD)
{
String safeTerm = QueryParser.escape(term);
fullTextBuf.append("TEXT:").append(safeTerm).append(OP_WILDCARD);
nameAttrBuf.append("@").append(nameAttr).append(":").append(safeTerm).append(OP_WILDCARD);
}
else
{
String safeTerm = QueryParser.escape(term.substring(1));
fullTextBuf.append("TEXT:*").append(safeTerm).append(OP_WILDCARD);
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeTerm).append(OP_WILDCARD);
}
processSearchTextAttribute(nameAttr, term, nameAttrBuf, fullTextBuf);
fullTextBuf.append(' ');
nameAttrBuf.append(' ');
@@ -317,11 +294,9 @@ public final class SearchContext implements Serializable
for (QName qname : queryAttributes.keySet())
{
String value = queryAttributes.get(qname).trim();
if (value.length() != 0 && value.length() >= minimum)
if (value.length() >= minimum)
{
String escapedName = Repository.escapeQName(qname);
attributeQuery.append(" +@").append(escapedName)
.append(":").append(QueryParser.escape(value)).append(OP_WILDCARD);
processSearchAttribute(qname, value, attributeQuery);
}
}
@@ -480,6 +455,114 @@ public final class SearchContext implements Serializable
return query;
}
/**
* Build the lucene search terms required for the specified attribute and append to a buffer.
* Supports text values with a wildcard '*' character as the prefix and/or the suffix.
*
* @param qname QName of the attribute
* @param value Non-null value of the attribute
* @param buf Buffer to append lucene terms to
*/
private static void processSearchAttribute(QName qname, String value, StringBuilder buf)
{
if (value.indexOf(' ') == -1)
{
String safeValue;
String prefix = "";
String suffix = "";
// look for a wildcard suffix
if (value.charAt(value.length() - 1) != OP_WILDCARD)
{
// look for wildcard prefix
if (value.charAt(0) != OP_WILDCARD)
{
safeValue = QueryParser.escape(value);
}
else
{
safeValue = QueryParser.escape(value.substring(1));
prefix = STR_OP_WILDCARD;
}
}
else
{
// found a wildcard suffix - append it again after escaping the other characters
suffix = STR_OP_WILDCARD;
// look for wildcard prefix
if (value.charAt(0) != OP_WILDCARD)
{
safeValue = QueryParser.escape(value.substring(0, value.length() - 1));
}
else
{
safeValue = QueryParser.escape(value.substring(1, value.length() - 1));
prefix = STR_OP_WILDCARD;
}
}
buf.append(" +@").append(Repository.escapeQName(qname)).append(":")
.append(prefix).append(safeValue).append(suffix);
}
else
{
// phrase multi-word search
String safeValue = QueryParser.escape(value);
buf.append(" +@").append(Repository.escapeQName(qname)).append(":\"").append(safeValue).append('"');
}
}
/**
* Build the lucene search terms required for the specified attribute and append to multiple buffers.
* Supports text values with a wildcard '*' character as the prefix and/or the suffix.
*
* @param qname QName.toString() of the attribute
* @param value Non-null value of the attribute
* @param attrBuf Attribute search buffer to append lucene terms to
* @param textBuf Text search buffer to append lucene terms to
*/
private static void processSearchTextAttribute(String qname, String value, StringBuilder attrBuf, StringBuilder textBuf)
{
String safeValue;
String suffix = "";
String prefix = "";
if (value.charAt(value.length() - 1) != OP_WILDCARD)
{
// look for wildcard prefix
if (value.charAt(0) != OP_WILDCARD)
{
safeValue = QueryParser.escape(value);
}
else
{
// found a leading wildcard - prepend it again after escaping the other characters
prefix = STR_OP_WILDCARD;
safeValue = QueryParser.escape(value.substring(1));
}
}
else
{
suffix = STR_OP_WILDCARD;
// look for wildcard prefix
if (value.charAt(0) != OP_WILDCARD)
{
safeValue = QueryParser.escape(value.substring(0, value.length() - 1));
}
else
{
prefix = STR_OP_WILDCARD;
safeValue = QueryParser.escape(value.substring(1, value.length() - 1));
}
}
textBuf.append("TEXT:").append(prefix).append(safeValue).append(suffix);
attrBuf.append("@").append(qname).append(":")
.append(prefix).append(safeValue).append(suffix);
}
/**
* Generate a search XPATH pointing to the specified node, optionally return an XPATH
* that includes the child nodes.

View File

@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.GuestTemplateContentServlet;
import org.alfresco.web.app.servlet.TemplateContentServlet;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
@@ -506,9 +507,9 @@ public class SpaceDetailsBean extends BaseDetailsBean
// build RSS feed template URL from selected template and the space NodeRef and
// add the guest=true URL parameter - this is required for no login access and
// add the mimetype=text/xml URL parameter - required to return correct stream type
return TemplateContentServlet.generateURL(space.getNodeRef(),
return GuestTemplateContentServlet.generateURL(space.getNodeRef(),
(NodeRef)space.getProperties().get(ContentModel.PROP_FEEDTEMPLATE))
+ "/rss.xml?guest=true" + "&mimetype=text%2Fxml";
+ "/rss.xml?mimetype=text%2Fxml";
}
/**

View File

@@ -71,14 +71,14 @@ public final class DialogManager
"' does not implement the required IDialogBean interface");
}
// create the DialogState object
this.currentDialogState = new DialogState(config, dialog);
// initialise the managed bean
dialog.init(this.paramsToApply);
// reset the current parameters so subsequent dialogs don't get them
this.paramsToApply = null;
// create the DialogState object
this.currentDialogState = new DialogState(config, dialog);
}
/**

View File

@@ -89,7 +89,7 @@ public class Node implements Serializable
/**
* @return All the properties known about this node.
*/
public Map<String, Object> getProperties()
public final Map<String, Object> getProperties()
{
if (this.propsRetrieved == false)
{

View File

@@ -70,6 +70,9 @@ public class TransientNode extends Node
// setup the transient node so that the super class methods work
// and do not need to go back to the repository
if (logger.isDebugEnabled())
logger.debug("Initialising transient node with data: " + data);
DictionaryService ddService = this.getServiceRegistry().getDictionaryService();
// marshall the given properties and associations into the internal maps
@@ -94,25 +97,11 @@ public class TransientNode extends Node
{
if (assocDef.isChild())
{
// TODO: handle lists of NodeRef's
NodeRef child = null;
Object obj = data.get(item);
if (obj instanceof String)
{
child = new NodeRef((String)obj);
}
else if (obj instanceof NodeRef)
{
child = (NodeRef)obj;
}
else if (obj instanceof List)
{
if (logger.isWarnEnabled())
logger.warn("0..* child associations are not supported yet");
}
if (child != null)
if (obj instanceof NodeRef)
{
NodeRef child = (NodeRef)obj;
// create a child association reference, add it to a list and add the list
// to the list of child associations for this node
List<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>(1);
@@ -122,28 +111,36 @@ public class TransientNode extends Node
this.childAssociations.put(item, assocs);
}
else if (obj instanceof List)
{
List targets = (List)obj;
List<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>(targets.size());
for (Object target : targets)
{
if (target instanceof NodeRef)
{
NodeRef currentChild = (NodeRef)target;
ChildAssociationRef childRef = new ChildAssociationRef(assocDef.getName(),
this.nodeRef, null, currentChild);
assocs.add(childRef);
}
}
if (assocs.size() > 0)
{
this.childAssociations.put(item, assocs);
}
}
}
else
{
// TODO: handle lists of NodeRef's
NodeRef target = null;
Object obj = data.get(item);
if (obj instanceof String)
{
target = new NodeRef((String)obj);
}
else if (obj instanceof NodeRef)
{
target = (NodeRef)obj;
}
else if (obj instanceof List)
{
if (logger.isWarnEnabled())
logger.warn("0..* associations are not supported yet");
}
if (target != null)
if (obj instanceof NodeRef)
{
NodeRef target = (NodeRef)obj;
// create a association reference, add it to a list and add the list
// to the list of associations for this node
List<AssociationRef> assocs = new ArrayList<AssociationRef>(1);
@@ -152,6 +149,27 @@ public class TransientNode extends Node
this.associations.put(item, assocs);
}
else if (obj instanceof List)
{
List targets = (List)obj;
List<AssociationRef> assocs = new ArrayList<AssociationRef>(targets.size());
for (Object target : targets)
{
if (target instanceof NodeRef)
{
NodeRef currentTarget = (NodeRef)target;
AssociationRef assocRef = new AssociationRef(this.nodeRef, assocDef.getName(), currentTarget);
assocs.add(assocRef);
}
}
if (assocs.size() > 0)
{
this.associations.put(item, assocs);
}
}
}
}
}

View File

@@ -136,7 +136,7 @@ public class ManageTaskDialog extends BaseDialogBean
logger.debug("Saving task: " + this.task.id);
// prepare the edited parameters for saving
Map<QName, Serializable> params = WorkflowBean.prepareTaskParams(this.taskNode);
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.taskNode);
if (logger.isDebugEnabled())
logger.debug("Saving task with parameters: " + params);
@@ -262,7 +262,7 @@ public class ManageTaskDialog extends BaseDialogBean
tx.begin();
// prepare the edited parameters for saving
Map<QName, Serializable> params = WorkflowBean.prepareTaskParams(this.taskNode);
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.taskNode);
if (logger.isDebugEnabled())
logger.debug("Transitioning task with parameters: " + params);
@@ -399,7 +399,7 @@ public class ManageTaskDialog extends BaseDialogBean
*/
public void togglePackageItemComplete(ActionEvent event)
{
// TODO: implement this!
// TODO: not supported yet
}
// ------------------------------------------------------------------------------

View File

@@ -119,7 +119,7 @@ public class StartWorkflowWizard extends BaseWizardBean
logger.debug("Starting workflow: " + this.selectedWorkflow);
// prepare the parameters from the current state of the property sheet
Map<QName, Serializable> params = WorkflowBean.prepareTaskParams(this.startTaskNode);
Map<QName, Serializable> params = WorkflowUtil.prepareTaskParams(this.startTaskNode);
if (logger.isDebugEnabled())
logger.debug("Starting workflow with parameters: " + params);

View File

@@ -1,25 +1,19 @@
package org.alfresco.web.bean.workflow;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
import org.alfresco.service.cmr.workflow.WorkflowTransition;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ISO9075;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
@@ -31,7 +25,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Managed bean used for handling workflow related features
* Managed bean used for providing support for the workflow task dashlets
*
* @author gavinc
*/
@@ -55,40 +49,43 @@ public class WorkflowBean
*/
public List<Node> getTasksToDo()
{
// get the current username
FacesContext context = FacesContext.getCurrentInstance();
User user = Application.getCurrentUser(context);
String userName = ISO9075.encode(user.getUserName());
UserTransaction tx = null;
try
if (this.tasks == null)
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
// get the current username
FacesContext context = FacesContext.getCurrentInstance();
User user = Application.getCurrentUser(context);
String userName = ISO9075.encode(user.getUserName());
// get the current in progress tasks for the current user
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(
userName, WorkflowTaskState.IN_PROGRESS);
// create a list of transient nodes to represent
this.tasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
UserTransaction tx = null;
try
{
Node node = createTask(task);
this.tasks.add(node);
tx = Repository.getUserTransaction(context, true);
tx.begin();
if (logger.isDebugEnabled())
logger.debug("Added to do task: " + node);
// get the current in progress tasks for the current user
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(
userName, WorkflowTaskState.IN_PROGRESS);
// create a list of transient nodes to represent
this.tasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
{
Node node = createTask(task);
this.tasks.add(node);
if (logger.isDebugEnabled())
logger.debug("Added to do task: " + node);
}
// commit the changes
tx.commit();
}
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage("Failed to get to do tasks: " + e.toString(), e);
}
// commit the changes
tx.commit();
}
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage("Failed to get to do tasks: " + e.toString(), e);
}
return this.tasks;
@@ -102,40 +99,43 @@ public class WorkflowBean
*/
public List<Node> getTasksCompleted()
{
// get the current username
FacesContext context = FacesContext.getCurrentInstance();
User user = Application.getCurrentUser(context);
String userName = ISO9075.encode(user.getUserName());
UserTransaction tx = null;
try
if (this.completedTasks == null)
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
// get the current username
FacesContext context = FacesContext.getCurrentInstance();
User user = Application.getCurrentUser(context);
String userName = ISO9075.encode(user.getUserName());
// get the current in progress tasks for the current user
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(
userName, WorkflowTaskState.COMPLETED);
// create a list of transient nodes to represent
this.completedTasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
UserTransaction tx = null;
try
{
Node node = createTask(task);
this.completedTasks.add(node);
tx = Repository.getUserTransaction(context, true);
tx.begin();
if (logger.isDebugEnabled())
logger.debug("Added completed task: " + node);
// get the current in progress tasks for the current user
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(
userName, WorkflowTaskState.COMPLETED);
// create a list of transient nodes to represent
this.completedTasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
{
Node node = createTask(task);
this.completedTasks.add(node);
if (logger.isDebugEnabled())
logger.debug("Added completed task: " + node);
}
// commit the changes
tx.commit();
}
// commit the changes
tx.commit();
}
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage("Failed to get completed tasks: " + e.toString(), e);
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage("Failed to get completed tasks: " + e.toString(), e);
}
}
return this.completedTasks;
@@ -163,47 +163,6 @@ public class WorkflowBean
// ------------------------------------------------------------------------------
// Helper methods
public static Map<QName, Serializable> prepareTaskParams(Node node)
{
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
// marshal the properties and associations captured by the property sheet
// back into a Map to pass to the workflow service
// go through all the properties in the transient node and add them to
// params map
Map<String, Object> props = node.getProperties();
for (String propName : props.keySet())
{
QName propQName = Repository.resolveToQName(propName);
params.put(propQName, (Serializable)props.get(propName));
}
// go through any associations that have been added to the start task
// and build a list of NodeRefs representing the targets
Map<String, Map<String, AssociationRef>> assocs = node.getAddedAssociations();
for (String assocName : assocs.keySet())
{
QName assocQName = Repository.resolveToQName(assocName);
// get the associations added and create list of targets
Map<String, AssociationRef> addedAssocs = assocs.get(assocName);
List<NodeRef> targets = new ArrayList<NodeRef>(addedAssocs.size());
for (AssociationRef assoc : addedAssocs.values())
{
targets.add(assoc.getTargetRef());
}
// add the targets for this particular association
if (targets.size() > 0)
{
params.put(assocQName, (Serializable)targets);
}
}
return params;
}
/**
* Creates and populates a TransientNode to represent the given
@@ -225,15 +184,6 @@ public class WorkflowBean
node.getProperties().put("type", taskDef.metadata.getTitle());
node.getProperties().put("id", task.id);
// add the name of the source space (if there is one)
NodeRef context = (NodeRef)task.properties.get(WorkflowModel.PROP_CONTEXT);
if (context != null && this.nodeService.exists(context))
{
String name = Repository.getNameForNode(this.nodeService, context);
node.getProperties().put("sourceSpaceName", name);
node.getProperties().put("sourceSpaceId", context.getId());
}
// add extra properties for completed tasks
if (task.state.equals(WorkflowTaskState.COMPLETED))
{
@@ -260,6 +210,9 @@ public class WorkflowBean
// add the workflow instance id and name this taks belongs to
node.getProperties().put("workflowInstanceId", task.path.instance.id);
// add the task itself as a property
node.getProperties().put("workflowTask", task);
}
return node;

View File

@@ -0,0 +1,184 @@
/*
* 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.bean.workflow;
import org.alfresco.repo.workflow.WorkflowInterpreter;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
/**
* Backing bean to support the Workflow Console
*/
public class WorkflowConsoleBean
{
// command
private String command = "";
private String submittedCommand = "none";
private long duration = 0L;
private String result = null;
// supporting repository services
private WorkflowInterpreter workflowInterpreter;
/**
* @param nodeService node service
*/
public void setWorkflowInterpreter(WorkflowInterpreter workflowInterpreter)
{
this.workflowInterpreter = workflowInterpreter;
}
/**
* Gets the command result
*
* @return result
*/
public String getResult()
{
if (result == null)
{
interpretCommand("help");
}
return result;
}
/**
* Sets the command result
*
* @param result
*/
public void setResult(String result)
{
this.result = result;
}
/**
* Gets the current query
*
* @return query statement
*/
public String getCommand()
{
return command;
}
/**
* Set the current query
*
* @param query query statement
*/
public void setCommand(String command)
{
this.command = command;
}
/**
* Gets the submitted command
*
* @return submitted command
*/
public String getSubmittedCommand()
{
return submittedCommand;
}
/**
* Set the current query
*
* @param query query statement
*/
public void setSubmittedCommand(String submittedCommand)
{
this.submittedCommand = submittedCommand;
}
/**
* Gets the last command duration
*
* @return command duration
*/
public long getDuration()
{
return duration;
}
/**
* Set the current query
*
* @param query query statement
*/
public void setDuration(long duration)
{
this.duration = duration;
}
/**
* Action to submit command
*
* @return next action
*/
public String submitCommand()
{
interpretCommand(command);
return "success";
}
/**
* Gets the current user name
*
* @return user name
*/
public String getCurrentUserName()
{
return workflowInterpreter.getCurrentUserName();
}
/**
* Gets the current workflow definition
*
* @return workflow definition
*/
public String getCurrentWorkflowDef()
{
WorkflowDefinition def = workflowInterpreter.getCurrentWorkflowDef();
return (def == null) ? "None" : def.title + " v" + def.version;
}
/**
* Interpret workflow console command
*
* @param command command
*/
private void interpretCommand(String command)
{
try
{
long startms = System.currentTimeMillis();
String result = workflowInterpreter.interpretCommand(command);
setDuration(System.currentTimeMillis() - startms);
setResult(result);
setCommand("");
setSubmittedCommand(command);
}
catch (Exception e)
{
setResult(e.toString());
}
}
}

View File

@@ -14,22 +14,29 @@
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean;
package org.alfresco.web.bean.workflow;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.apache.log4j.Logger;
import org.alfresco.web.bean.repository.Repository;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Helper class for common Simple Workflow functionality.
* Helper class for common Workflow functionality.
* <p>
* This class should be replaced with calls to a WorkflowService once it is available.
*
@@ -37,7 +44,7 @@ import org.apache.log4j.Logger;
*/
public class WorkflowUtil
{
private static Logger logger = Logger.getLogger(WorkflowUtil.class);
private static Log logger = LogFactory.getLog(WorkflowUtil.class);
/**
* Execute the Approve step for the Simple Workflow on a node.
@@ -139,9 +146,14 @@ public class WorkflowUtil
else
{
// copy the document to the specified folder
String qname = QName.createValidLocalName(docNode.getName());
copyService.copy(ref, rejectFolder, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, qname));
String name = docNode.getName();
String qname = QName.createValidLocalName(name);
NodeRef newNode = copyService.copy(ref, rejectFolder, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, qname), true);
// the copy service does not copy the name of the node so we
// need to update the property on the copied item
nodeService.setProperty(newNode, ContentModel.PROP_NAME, name);
}
if (logger.isDebugEnabled())
@@ -151,4 +163,60 @@ public class WorkflowUtil
rejectFolder.getId());
}
}
/**
* Prepares the given node for persistence in the workflow engine.
*
* @param node The node to package up for persistence
* @return The map of data representing the node
*/
public static Map<QName, Serializable> prepareTaskParams(Node node)
{
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
// marshal the properties and associations captured by the property sheet
// back into a Map to pass to the workflow service
// go through all the properties in the transient node and add them to
// params map
Map<String, Object> props = node.getProperties();
for (String propName : props.keySet())
{
QName propQName = Repository.resolveToQName(propName);
params.put(propQName, (Serializable)props.get(propName));
}
// go through any associations that have been added to the start task
// and build a list of NodeRefs representing the targets
Map<String, Map<String, AssociationRef>> assocs = node.getAddedAssociations();
for (String assocName : assocs.keySet())
{
QName assocQName = Repository.resolveToQName(assocName);
// get the associations added and create list of targets
Map<String, AssociationRef> addedAssocs = assocs.get(assocName);
List<NodeRef> targets = new ArrayList<NodeRef>(addedAssocs.size());
for (AssociationRef assoc : addedAssocs.values())
{
targets.add(assoc.getTargetRef());
}
// add the targets for this particular association
if (targets.size() > 0)
{
params.put(assocQName, (Serializable)targets);
}
}
// TODO: Deal with child associations if and when we need to support
// them for workflow tasks, for now warn that they are being used
Map childAssocs = node.getAddedChildAssociations();
if (childAssocs.size() > 0)
{
if (logger.isWarnEnabled())
logger.warn("Child associations are present but are not supported for workflow tasks, ignoring...");
}
return params;
}
}

View File

@@ -36,13 +36,19 @@ public class ClientConfigElement extends ConfigElementAdapter
private int searchMinimum = 3;
private boolean forceAndTerms = false;
private int searchMaxResults = -1;
private int selectorsSearchMaxResults = 500;
private String helpUrl = null;
private String editLinkType = "http";
private String homeSpacePermission = null;
<<<<<<< .working
private boolean ajaxEnabled = false;
private String initialLocation = "myalfresco";
private String wcmDomain = null;
private String wcmPort = null;
=======
private boolean ajaxEnabled = false;
private String initialLocation = "myalfresco";
>>>>>>> .merge-right.r4305
/**
* Default Constructor
@@ -137,17 +143,34 @@ public class ClientConfigElement extends ConfigElementAdapter
combinedElement.setSearchMaxResults(newElement.getSearchMaxResults());
}
<<<<<<< .working
if (newElement.isShelfVisible() != combinedElement.isShelfVisible())
=======
if (newElement.getSelectorsSearchMaxResults() != combinedElement.getSelectorsSearchMaxResults())
>>>>>>> .merge-right.r4305
{
<<<<<<< .working
combinedElement.setShelfVisible(newElement.isShelfVisible());
=======
combinedElement.setSelectorsSearchMaxResults(newElement.getSelectorsSearchMaxResults());
>>>>>>> .merge-right.r4305
}
<<<<<<< .working
if (newElement.getFromEmailAddress() != null &&
(newElement.getFromEmailAddress().equals(combinedElement.getFromEmailAddress()) == false))
=======
if (newElement.isShelfVisible() != combinedElement.isShelfVisible())
>>>>>>> .merge-right.r4305
{
<<<<<<< .working
combinedElement.setFromEmailAddress(newElement.getFromEmailAddress());
=======
combinedElement.setShelfVisible(newElement.isShelfVisible());
>>>>>>> .merge-right.r4305
}
<<<<<<< .working
if (newElement.isAjaxEnabled() != combinedElement.isAjaxEnabled())
{
combinedElement.setAjaxEnabled(newElement.isAjaxEnabled());
@@ -178,6 +201,26 @@ public class ClientConfigElement extends ConfigElementAdapter
}
return combinedElement;
=======
if (newElement.getFromEmailAddress() != null &&
(newElement.getFromEmailAddress().equals(combinedElement.getFromEmailAddress()) == false))
{
combinedElement.setFromEmailAddress(newElement.getFromEmailAddress());
}
if (newElement.isAjaxEnabled() != combinedElement.isAjaxEnabled())
{
combinedElement.setAjaxEnabled(newElement.isAjaxEnabled());
}
if (newElement.getInitialLocation() != null &&
newElement.getInitialLocation().equals(combinedElement.getInitialLocation()) == false)
{
combinedElement.setInitialLocation(newElement.getInitialLocation());
}
return combinedElement;
>>>>>>> .merge-right.r4305
}
/**
@@ -330,10 +373,9 @@ public class ClientConfigElement extends ConfigElementAdapter
*
* @return
*/
public int getSearchMaxResults()
{
return searchMaxResults;
return this.searchMaxResults;
}
/**
@@ -346,6 +388,29 @@ public class ClientConfigElement extends ConfigElementAdapter
{
this.searchMaxResults = searchMaxResults;
}
/**
* If positive, this will limit the size of the result set from the search
* used in selector components.
*
* @return The maximum number of results to display
*/
public int getSelectorsSearchMaxResults()
{
return this.selectorsSearchMaxResults;
}
/**
* Set if the the result set from a search for the selector components
* will be of limited size. If negative it is unlimited, by default,
* this is set to 500.
*
* @param selectorsSearchMaxResults
*/
/*package*/ void setSelectorsSearchMaxResults(int selectorsSearchMaxResults)
{
this.selectorsSearchMaxResults = selectorsSearchMaxResults;
}
/**
* @return Returns the default Home Space permissions.
@@ -362,6 +427,7 @@ public class ClientConfigElement extends ConfigElementAdapter
{
this.homeSpacePermission = homeSpacePermission;
}
<<<<<<< .working
/**
* @return Returns whether AJAX support is enabled in the client
@@ -428,4 +494,40 @@ public class ClientConfigElement extends ConfigElementAdapter
{
this.wcmPort = wcmPort;
}
=======
/**
* @return Returns whether AJAX support is enabled in the client
*/
public boolean isAjaxEnabled()
{
return this.ajaxEnabled;
}
/**
* Sets whether AJAX support is enabled in the client
*
* @param ajaxEnabled
*/
/*package*/ void setAjaxEnabled(boolean ajaxEnabled)
{
this.ajaxEnabled = ajaxEnabled;
}
/**
* @return Returns the default initial location for the user.
*/
public String getInitialLocation()
{
return this.initialLocation;
}
/**
* @param initialLocation The initial location to set.
*/
/*package*/ void setInitialLocation(String initialLocation)
{
this.initialLocation = initialLocation;
}
>>>>>>> .merge-right.r4305
}

View File

@@ -36,6 +36,7 @@ public class ClientElementReader implements ConfigElementReader
public static final String ELEMENT_SEARCHMINIMUM = "search-minimum";
public static final String ELEMENT_SEARCHANDTERMS = "search-and-terms";
public static final String ELEMENT_SEARCHMAXRESULTS = "search-max-results";
public static final String ELEMENT_SELECTORSSEARCHMAXRESULTS = "selectors-search-max-results";
public static final String ELEMENT_HOMESPACEPERMISSION = "home-space-permission";
public static final String ELEMENT_FROMEMAILADDRESS = "from-email-address";
public static final String ELEMENT_SHELFVISIBLE = "shelf-visible";
@@ -113,6 +114,14 @@ public class ClientElementReader implements ConfigElementReader
configElement.setSearchMaxResults(Integer.parseInt(searchMaxResults.getTextTrim()));
}
// get the selectors search max results size
Element selectorsSearchMaxResults = element.element(ELEMENT_SELECTORSSEARCHMAXRESULTS);
if (selectorsSearchMaxResults != null)
{
configElement.setSelectorsSearchMaxResults(
Integer.parseInt(selectorsSearchMaxResults.getTextTrim()));
}
// get the default permission for newly created users Home Spaces
Element permission = element.element(ELEMENT_HOMESPACEPERMISSION);
if (permission != null)

View File

@@ -37,8 +37,6 @@ import javax.faces.model.SelectItem;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author kevinr
@@ -58,8 +56,6 @@ public class DatePickerRenderer extends BaseRenderer
private static final int CMD_SET = 1;
private static final int CMD_RESET = 2;
private static final int CMD_TODAY = 3;
private static final Log logger = LogFactory.getLog(DatePickerRenderer.class);
/**
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)

View File

@@ -30,7 +30,9 @@ import javax.faces.el.ValueBinding;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -353,15 +355,30 @@ public class UIContentSelector extends UIInput
query.append(":*" + safeContains + "*");
}
int maxResults = Application.getClientConfig(context).getSelectorsSearchMaxResults();
if (logger.isDebugEnabled())
{
logger.debug("Query: " + query.toString());
logger.debug("Max results size: " + maxResults);
}
// setup search parameters, including limiting the results
SearchParameters searchParams = new SearchParameters();
searchParams.addStore(Repository.getStoreRef());
searchParams.setLanguage(SearchService.LANGUAGE_LUCENE);
searchParams.setQuery(query.toString());
if (maxResults > 0)
{
searchParams.setLimit(maxResults);
searchParams.setLimitBy(LimitBy.FINAL_SIZE);
}
ResultSet results = null;
try
{
results = Repository.getServiceRegistry(context).getSearchService().query(
Repository.getStoreRef(), SearchService.LANGUAGE_LUCENE, query.toString());
results = Repository.getServiceRegistry(context).getSearchService().query(searchParams);
this.availableOptions = results.getNodeRefs();
}
finally

View File

@@ -36,6 +36,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
@@ -914,8 +915,31 @@ public abstract class BaseAssociationEditor extends UIInput
}
}
int maxResults = Application.getClientConfig(context).getSelectorsSearchMaxResults();
if (logger.isDebugEnabled())
{
logger.debug("Query: " + query.toString());
logger.debug("Max results size: " + maxResults);
}
SearchParameters searchParams = new SearchParameters();
searchParams.addStore(Repository.getStoreRef());
searchParams.setLanguage(SearchService.LANGUAGE_LUCENE);
searchParams.setQuery(query.toString());
if (maxResults > 0)
{
searchParams.setLimit(maxResults);
searchParams.setLimitBy(LimitBy.FINAL_SIZE);
}
if (type.equals(ContentModel.TYPE_PERSON.toString()))
{
searchParams.addSort("@" + ContentModel.PROP_LASTNAME, true);
if (logger.isDebugEnabled())
logger.debug("Added lastname as sort column to query for people");
}
SearchParameters searchParams = new SearchParameters();
searchParams.addStore(Repository.getStoreRef());

View File

@@ -176,10 +176,11 @@ public class UIProperty extends PropertySheetItem
// if we're in edit mode ensure that we don't allow editing of system properties or scenarios we don't support
if (propSheet.inEditMode())
{
// if we are trying to edit a NodeRef or Path property type set it to read-only as
// these are internal properties that shouldn't be edited.
// if we are trying to edit a system property type set it to read-only as these are internal
// properties that shouldn't be edited.
if (typeName.equals(DataTypeDefinition.NODE_REF) || typeName.equals(DataTypeDefinition.PATH) ||
typeName.equals(DataTypeDefinition.CONTENT))
typeName.equals(DataTypeDefinition.CONTENT) || typeName.equals(DataTypeDefinition.QNAME) ||
typeName.equals(DataTypeDefinition.CHILD_ASSOC_REF) || typeName.equals(DataTypeDefinition.ASSOC_REF))
{
logger.warn("Setting property " + propDef.getName().toString() + " to read-only as it can not be edited");
control.getAttributes().put("disabled", Boolean.TRUE);

View File

@@ -0,0 +1,254 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.alfresco.web.ui.repo.tag;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.xpath.DefaultXPath;
import org.jbpm.JbpmContext;
import org.jbpm.file.def.FileDefinition;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
//
//
// TODO: DC - Tidy up
//
//
public class JBPMProcessImageTag extends TagSupport {
private static final long serialVersionUID = 1L;
private long taskInstanceId = -1;
private long tokenInstanceId = -1;
private byte[] gpdBytes = null;
private byte[] imageBytes = null;
private Token currentToken = null;
private ProcessDefinition processDefinition = null;
static String currentTokenColor = "red";
static String childTokenColor = "blue";
static String tokenNameColor = "blue";
public void release() {
taskInstanceId = -1;
gpdBytes = null;
imageBytes = null;
currentToken = null;
}
public int doEndTag() throws JspException {
try {
initialize();
retrieveByteArrays();
if (gpdBytes != null && imageBytes != null) {
writeTable();
}
} catch (IOException e) {
e.printStackTrace();
throw new JspException("table couldn't be displayed", e);
} catch (DocumentException e) {
e.printStackTrace();
throw new JspException("table couldn't be displayed", e);
}
release();
return EVAL_PAGE;
}
private void retrieveByteArrays() {
try {
FileDefinition fileDefinition = processDefinition.getFileDefinition();
gpdBytes = fileDefinition.getBytes("gpd.xml");
imageBytes = fileDefinition.getBytes("processimage.jpg");
} catch (Exception e) {
e.printStackTrace();
}
}
private void writeTable() throws IOException, DocumentException {
int borderWidth = 4;
Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement();
int[] boxConstraint;
int[] imageDimension = extractImageDimension(rootDiagramElement);
String imageLink = "/alfresco/processimage?definitionId=" + processDefinition.getId();
JspWriter jspOut = pageContext.getOut();
if (tokenInstanceId > 0) {
List allTokens = new ArrayList();
walkTokens(currentToken, allTokens);
jspOut.println("<div style='position:relative; background-image:url(" + imageLink + "); width: " + imageDimension[0] + "px; height: " + imageDimension[1] + "px;'>");
for (int i = 0; i < allTokens.size(); i++)
{
Token token = (Token) allTokens.get(i);
//check how many tokens are on teh same level (= having the same parent)
int offset = i;
if(i > 0) {
while(offset > 0 && ((Token) allTokens.get(offset - 1)).getParent().equals(token.getParent())) {
offset--;
}
}
boxConstraint = extractBoxConstraint(rootDiagramElement, token);
//Adjust for borders
//boxConstraint[2]-=borderWidth*2;
//boxConstraint[3]-=borderWidth*2;
jspOut.println("<div style='position:absolute; left: "+ boxConstraint[0] +"px; top: "+ boxConstraint[1] +"px; ");
if (i == (allTokens.size() - 1)) {
jspOut.println("border: " + currentTokenColor);
}
else {
jspOut.println("border: " + childTokenColor);
}
jspOut.println(" " + borderWidth + "px groove; "+
"width: "+ boxConstraint[2] +"px; height: "+ boxConstraint[3] +"px;'>");
if(token.getName()!=null)
{
jspOut.println("<span style='color:" + tokenNameColor + ";font-style:italic;position:absolute;left:"+ (boxConstraint[2] + 10) +"px;top:" +((i - offset) * 20) +";'>&nbsp;" + token.getName() +"</span>");
}
jspOut.println("</div>");
}
jspOut.println("</div>");
}
else
{
boxConstraint = extractBoxConstraint(rootDiagramElement);
jspOut.println("<table border=0 cellspacing=0 cellpadding=0 width=" + imageDimension[0] + " height=" + imageDimension[1] + ">");
jspOut.println(" <tr>");
jspOut.println(" <td width=" + imageDimension[0] + " height=" + imageDimension[1] + " style=\"background-image:url(" + imageLink + ")\" valign=top>");
jspOut.println(" <table border=0 cellspacing=0 cellpadding=0>");
jspOut.println(" <tr>");
jspOut.println(" <td width=" + (boxConstraint[0] - borderWidth) + " height=" + (boxConstraint[1] - borderWidth)
+ " style=\"background-color:transparent;\"></td>");
jspOut.println(" </tr>");
jspOut.println(" <tr>");
jspOut.println(" <td style=\"background-color:transparent;\"></td>");
jspOut.println(" <td style=\"border-color:" + currentTokenColor + "; border-width:" + borderWidth + "px; border-style:groove; background-color:transparent;\" width="
+ boxConstraint[2] + " height=" + (boxConstraint[3] + (2 * borderWidth)) + ">&nbsp;</td>");
jspOut.println(" </tr>");
jspOut.println(" </table>");
jspOut.println(" </td>");
jspOut.println(" </tr>");
jspOut.println("</table>");
}
}
private int[] extractBoxConstraint(Element root) {
int[] result = new int[4];
String nodeName = currentToken.getNode().getName();
XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
Element node = (Element) xPath.selectSingleNode(root);
result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
return result;
}
private int[] extractBoxConstraint(Element root, Token token) {
int[] result = new int[4];
String nodeName = token.getNode().getName();
XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
Element node = (Element) xPath.selectSingleNode(root);
result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
return result;
}
private int[] extractImageDimension(Element root) {
int[] result = new int[2];
result[0] = Integer.valueOf(root.attribute("width").getValue()).intValue();
result[1] = Integer.valueOf(root.attribute("height").getValue()).intValue();
return result;
}
private void initialize() {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
if (this.taskInstanceId > 0) {
TaskInstance taskInstance = jbpmContext.getTaskMgmtSession().loadTaskInstance(taskInstanceId);
currentToken = taskInstance.getToken();
}
else
{
if (this.tokenInstanceId > 0)
currentToken = jbpmContext.getGraphSession().loadToken(this.tokenInstanceId);
}
processDefinition = currentToken.getProcessInstance().getProcessDefinition();
}
private void walkTokens(Token parent, List allTokens)
{
Map children = parent.getChildren();
if(children != null && children.size() > 0)
{
Collection childTokens = children.values();
for (Iterator iterator = childTokens.iterator(); iterator.hasNext();)
{
Token child = (Token) iterator.next();
walkTokens(child, allTokens);
}
}
allTokens.add(parent);
}
public void setTask(long id) {
this.taskInstanceId = id;
}
public void setToken(long id) {
this.tokenInstanceId = id;
}
}

View File

@@ -47,7 +47,7 @@ public class PageTag extends TagSupport
*/
private final static String ALF_URL = "http://www.alfresco.com";
private final static String ALF_LOGO = "http://www.alfresco.com/images/alfresco_community_horizont.gif";
private final static String ALF_LOGO = "http://www.alfresco.com/images/alfresco_community_horiz14.gif";
private final static String SF_LOGO = "/images/logo/sflogo.php.png";
private final static String ALF_TEXT = "Alfresco Community";
private final static String ALF_COPY = "Supplied free of charge with " +