From 3ad54f19336f018835e3959f3dc9e486bf7ae482 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 12 Mar 2009 11:58:13 +0000 Subject: [PATCH] Merged V3.1 to HEAD 13356: Fix for ETHREEOH-1297. Fixes the more general issue that content related FreeMarker APIs on AVM Template Nodes were broken since 3.0. 13357: Fix for ETHREEOH-1445 - missing I18N labels for Site Invite workflow. 13375: Another I18N missing label patch to workflow tasks from wabson. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13595 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- ...ion-moderated-workflow-messages.properties | 3 +- ...ion-nominated-workflow-messages.properties | 6 +- .../repo/template/AVMTemplateNode.java | 106 ++++++++++++++++++ 3 files changed, 113 insertions(+), 2 deletions(-) diff --git a/config/alfresco/workflow/invitation-moderated-workflow-messages.properties b/config/alfresco/workflow/invitation-moderated-workflow-messages.properties index 3291337cdd..582d1988ce 100644 --- a/config/alfresco/workflow/invitation-moderated-workflow-messages.properties +++ b/config/alfresco/workflow/invitation-moderated-workflow-messages.properties @@ -23,4 +23,5 @@ wf_invitation-moderated.node.review.transition.approve.title=Approve wf_invitation-moderated.node.review.transition.approve.description=Approve wf_invitation-moderated.node.review.transition.cancel.title=Cancel wf_invitation-moderated.node.review.transition.cancel.description=Cancel - +wf_invitation-moderated.node.end.title=End +wf_invitation-moderated.node.end.description=End \ No newline at end of file diff --git a/config/alfresco/workflow/invitation-nominated-workflow-messages.properties b/config/alfresco/workflow/invitation-nominated-workflow-messages.properties index b637081737..d0375d1b1b 100644 --- a/config/alfresco/workflow/invitation-nominated-workflow-messages.properties +++ b/config/alfresco/workflow/invitation-nominated-workflow-messages.properties @@ -31,11 +31,15 @@ wf_invitation-nominated.node.invitePending.transition.cancel.title=Cancel wf_invitation-nominated.node.invitePending.transition.cancel.description=Cancel wf_invitation-nominated.node.inviteRejected.title=Rejected wf_invitation-nominated.node.inviteRejected.description=Rejected +wf_invitation-nominated.node.inviteRejected.transition.end.title=End +wf_invitation-nominated.node.inviteRejected.transition.end.description=End wf_invitation-nominated.task.wf_rejectInviteTask.title=Rejected wf_invitation-nominated.task.wf_rejectInviteTask.description=Rejected wf_invitation-nominated.node.inviteAccepted.title=Accepted wf_invitation-nominated.node.inviteAccepted.description=Accepted +wf_invitation-nominated.node.inviteAccepted.transition.end.title=End +wf_invitation-nominated.node.inviteAccepted.transition.end.description=End wf_invitation-nominated.task.wf_acceptInviteTask.title=Accepted wf_invitation-nominated.task.wf_acceptInviteTask.description=Accepted wf_invitation-nominated.node.end.title=End -wf_invitation-nominated.node.end.description=End +wf_invitation-nominated.node.end.description=End \ No newline at end of file diff --git a/source/java/org/alfresco/repo/template/AVMTemplateNode.java b/source/java/org/alfresco/repo/template/AVMTemplateNode.java index 7a4562ffa6..a10a222423 100644 --- a/source/java/org/alfresco/repo/template/AVMTemplateNode.java +++ b/source/java/org/alfresco/repo/template/AVMTemplateNode.java @@ -26,6 +26,7 @@ package org.alfresco.repo.template; import java.io.Serializable; import java.io.StringReader; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; @@ -33,9 +34,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.alfresco.model.ContentModel; import org.alfresco.model.WCMModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.repo.template.BaseContentNode.TemplateContentData; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.audit.AuditInfo; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; @@ -43,6 +46,8 @@ import org.alfresco.service.cmr.avm.locking.AVMLock; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.TemplateImageResolver; @@ -51,8 +56,10 @@ import org.alfresco.service.namespace.NamespacePrefixResolverProvider; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QNameMap; import org.alfresco.util.Pair; +import org.alfresco.util.URLEncoder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.util.StringUtils; import org.xml.sax.InputSource; import freemarker.ext.dom.NodeModel; @@ -430,6 +437,105 @@ public class AVMTemplateNode extends BasePermissionsNode implements NamespacePre } + // ------------------------------------------------------------------------------ + // Content API + + /** + * @return the content String for this node from the default content property + * (@see ContentModel.PROP_CONTENT) + */ + public String getContent() + { + ContentReader reader = this.services.getAVMService().getContentReader(this.version, this.path); + + return (reader != null && reader.exists()) ? reader.getContentString() : ""; + } + + /** + * @return For a content document, this method returns the URL to the content stream for + * the default content property (@see ContentModel.PROP_CONTENT) + *

+ * For a container node, this method return the URL to browse to the folder in the web-client + */ + public String getUrl() + { + if (getIsDocument() == true) + { + return MessageFormat.format(CONTENT_GET_URL, new Object[] { + getNodeRef().getStoreRef().getProtocol(), + getNodeRef().getStoreRef().getIdentifier(), + getNodeRef().getId(), + URLEncoder.encode(getName()) } ); + } + else + { + return MessageFormat.format(FOLDER_BROWSE_URL, new Object[] { + getNodeRef().getStoreRef().getProtocol(), + getNodeRef().getStoreRef().getIdentifier(), + getNodeRef().getId() } ); + } + } + + /** + * @return For a content document, this method returns the download URL to the content for + * the default content property (@see ContentModel.PROP_CONTENT) + *

+ * For a container node, this method returns an empty string + */ + public String getDownloadUrl() + { + if (getIsDocument() == true) + { + return MessageFormat.format(CONTENT_DOWNLOAD_URL, new Object[] { + getNodeRef().getStoreRef().getProtocol(), + getNodeRef().getStoreRef().getIdentifier(), + getNodeRef().getId(), + URLEncoder.encode(getName()) } ); + } + else + { + return ""; + } + } + + /** + * @return The mimetype encoding for content attached to the node from the default content property + * (@see ContentModel.PROP_CONTENT) + */ + public String getMimetype() + { + return this.services.getAVMService().getContentDataForRead(this.avmRef).getMimetype(); + } + + /** + * @return The display label of the mimetype encoding for content attached to the node from the default + * content property (@see ContentModel.PROP_CONTENT) + */ + public String getDisplayMimetype() + { + final String mimetype = this.services.getAVMService().getContentDataForRead(this.avmRef).getMimetype(); + return services.getMimetypeService().getDisplaysByMimetype().get(mimetype); + } + + /** + * @return The character encoding for content attached to the node from the default content property + * (@see ContentModel.PROP_CONTENT) + */ + public String getEncoding() + { + return this.services.getAVMService().getContentDataForRead(this.avmRef).getEncoding(); + } + + /** + * @return The size in bytes of the content attached to the node from the default content property + * (@see ContentModel.PROP_CONTENT) + */ + public long getSize() + { + return this.services.getAVMService().getContentDataForRead(this.avmRef).getSize(); + } + + // ------------------------------------------------------------------------------ // Audit API