From a3bbee67392dac23c50b4818779c2895190c4404 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 3 Mar 2008 13:35:10 +0000 Subject: [PATCH] Merged V2.2 to HEAD 7534: Merged V2.1 to HEAD 7398: XPath metadata extractor selector handles malformed and empty XML files 7401: Fix AR-1879: JBPM Timer never fires 7413: Contribution: Integrity checker ignores exceptions that would normally trigger transaction retries. 7416: AR-1884.Unicode wildcard processing. 7417: Added filtering of pseudo files when a partial wildcard search path is used, such as '*.csv'. AR-1889. 7436: AR-1863: major version's can now be created via the web service API; 7451: Fix for handling of UTF-8 application/x-www-form-urlencoded encoded form arguments as raised in support ticket 242 7458: Fix for AR-1900 7520: Fix to Template API where content was not retrievable from custom d:content properties on a node git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8413 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../servlet/BaseTemplateContentServlet.java | 82 +++++++++++++------ 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java b/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java index 4c34fc34cf..c0f3965741 100644 --- a/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java +++ b/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java @@ -25,6 +25,7 @@ package org.alfresco.web.app.servlet; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.SocketException; import java.util.Enumeration; import java.util.HashMap; @@ -38,6 +39,7 @@ import javax.transaction.UserTransaction; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.FileTypeImageSize; import org.alfresco.service.cmr.repository.NodeRef; @@ -124,34 +126,56 @@ public abstract class BaseTemplateContentServlet extends BaseServlet NodeRef nodeRef = null; NodeRef templateRef = null; - String contentPath = req.getParameter(ARG_CONTEXT_PATH); - if (contentPath != null && contentPath.length() != 0) + try { - // process the name based path to resolve the NodeRef - PathRefInfo pathInfo = resolveNamePath(getServletContext(), contentPath); + 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()); + } + } + catch (AccessDeniedException err) + { + 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); + } - 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()); + return; } // if no context is specified, use the template itself @@ -293,7 +317,11 @@ public abstract class BaseTemplateContentServlet extends BaseServlet while (names.hasMoreElements()) { String name = (String)names.nextElement(); - args.put(name, req.getParameter(name)); + try + { + args.put(name, new String(req.getParameter(name).getBytes(), "UTF-8")); + } + catch (UnsupportedEncodingException err) {} } root.put("args", args);