From 62bfb6356a836d10ee31ad00a09bb8f5cfd57820 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 3 Jul 2007 09:58:09 +0000 Subject: [PATCH] Support for Liferay user login in WebScript JSR-168 portlet authenticators. Fix to add missing downloadUrl property to TemplateContentData object for non-standard content property values. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6137 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/template/BaseContentNode.java | 31 ++++++++++++++----- .../repo/template/VersionHistoryNode.java | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/source/java/org/alfresco/repo/template/BaseContentNode.java b/source/java/org/alfresco/repo/template/BaseContentNode.java index 91ba982f6e..b905f42774 100644 --- a/source/java/org/alfresco/repo/template/BaseContentNode.java +++ b/source/java/org/alfresco/repo/template/BaseContentNode.java @@ -55,10 +55,11 @@ import org.springframework.util.StringUtils; */ public abstract class BaseContentNode implements TemplateContent { - protected final static String CONTENT_DEFAULT_URL = "/d/d/{0}/{1}/{2}/{3}"; + protected final static String CONTENT_GET_URL = "/d/d/{0}/{1}/{2}/{3}"; protected final static String CONTENT_DOWNLOAD_URL = "/d/a/{0}/{1}/{2}/{3}"; - protected final static String CONTENT_PROP_URL = "/d/d/{0}/{1}/{2}/{3}?property={4}"; - protected final static String FOLDER_BROWSE_URL = "/n/browse/{0}/{1}/{2}"; + protected final static String CONTENT_GET_PROP_URL = "/d/d/{0}/{1}/{2}/{3}?property={4}"; + protected final static String CONTENT_DOWNLOAD_PROP_URL = "/d/a/{0}/{1}/{2}/{3}?property={4}"; + protected final static String FOLDER_BROWSE_URL = "/n/browse/{0}/{1}/{2}"; protected final static String NAMESPACE_BEGIN = "" + QName.NAMESPACE_BEGIN; @@ -334,7 +335,7 @@ public abstract class BaseContentNode implements TemplateContent { try { - return MessageFormat.format(CONTENT_DEFAULT_URL, new Object[] { + return MessageFormat.format(CONTENT_GET_URL, new Object[] { getNodeRef().getStoreRef().getProtocol(), getNodeRef().getStoreRef().getIdentifier(), getNodeRef().getId(), @@ -493,14 +494,11 @@ public abstract class BaseContentNode implements TemplateContent return result; } - /** - * @return - */ public String getUrl() { try { - return MessageFormat.format(CONTENT_PROP_URL, new Object[] { + return MessageFormat.format(CONTENT_GET_PROP_URL, new Object[] { getNodeRef().getStoreRef().getProtocol(), getNodeRef().getStoreRef().getIdentifier(), getNodeRef().getId(), @@ -513,6 +511,23 @@ public abstract class BaseContentNode implements TemplateContent } } + public String getDownloadUrl() + { + try + { + return MessageFormat.format(CONTENT_DOWNLOAD_PROP_URL, new Object[] { + getNodeRef().getStoreRef().getProtocol(), + getNodeRef().getStoreRef().getIdentifier(), + getNodeRef().getId(), + StringUtils.replace(URLEncoder.encode(getName(), "UTF-8"), "+", "%20"), + StringUtils.replace(URLEncoder.encode(property.toString(), "UTF-8"), "+", "%20") }); + } + catch (UnsupportedEncodingException err) + { + throw new TemplateException("Failed to encode content download URL for node: " + getNodeRef(), err); + } + } + public long getSize() { return contentData.getSize(); diff --git a/source/java/org/alfresco/repo/template/VersionHistoryNode.java b/source/java/org/alfresco/repo/template/VersionHistoryNode.java index 76da7e0b41..24696389ce 100644 --- a/source/java/org/alfresco/repo/template/VersionHistoryNode.java +++ b/source/java/org/alfresco/repo/template/VersionHistoryNode.java @@ -277,7 +277,7 @@ public class VersionHistoryNode extends BaseContentNode NodeRef nodeRef = this.version.getFrozenStateNodeRef(); try { - return MessageFormat.format(parent.CONTENT_DEFAULT_URL, new Object[] { + return MessageFormat.format(parent.CONTENT_GET_URL, new Object[] { nodeRef.getStoreRef().getProtocol(), nodeRef.getStoreRef().getIdentifier(), nodeRef.getId(),