diff --git a/config/alfresco/remote-api-context.xml b/config/alfresco/remote-api-context.xml index fc0e3c5634..b3fa8af4b7 100644 --- a/config/alfresco/remote-api-context.xml +++ b/config/alfresco/remote-api-context.xml @@ -75,4 +75,12 @@ ${system.webdav.url.path.prefix} + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/status.get.xml.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/status.get.xml.ftl index 31b06f7da4..97f8462509 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/status.get.xml.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/status.get.xml.ftl @@ -21,7 +21,6 @@ [#if importStatus.targetSpace??] ${importStatus.targetSpace} [/#if] - ${importStatus.batchWeight?c} [#if importStatus.startDate??] ${importStatus.startDate?datetime?string("yyyy-MM-dd'T'HH:mm:ss.SSS")} [/#if] diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/assocdefinition.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/assocdefinition.lib.ftl index 94300952a0..24737bf71a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/assocdefinition.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/assocdefinition.lib.ftl @@ -4,13 +4,13 @@ <#if assocdefs.name?exists> "name" : "${assocdefs.name.toPrefixString()}", - <#if assocdefs.title?exists> - "title" : "${assocdefs.title}", + <#if assocdefs.getTitle(messages)?has_content> + "title" : "${assocdefs.getTitle(messages)}", <#else> "title" : "", - <#if assocdefs.description?exists> - "description" : "${assocdefs.description}", + <#if assocdefs.getDescription(messages)?has_content> + "description" : "${assocdefs.getDescription(messages)}", <#else> "description" : "", diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl index 57c0ab58ef..dccbf959ac 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl @@ -5,8 +5,8 @@ <#if classdef.name??>"name": "${classdef.name.toPrefixString()}", "isAspect": ${classdef.isAspect()?string}, "isContainer": ${classdef.isContainer()?string}, - "title": "${classdef.title!""}", - "description": "${classdef.description!""}", + "title": "${classdef.getTitle(messages)!""}", + "description": "${classdef.getDescription(messages)!""}", "parent": { <#if classdef.parentName??> @@ -22,7 +22,7 @@ "${aspectdef.name.toPrefixString()}": { "name": "${aspectdef.name.toPrefixString()}", - "title": "${aspectdef.title!""}", + "title": "${aspectdef.getTitle(messages)!""}", "url": "/api/classes/${classdefprefix}/property/${aspectdef.name.toPrefixString()?replace(":","_")}" }<#if aspectdef_has_next>, @@ -34,8 +34,8 @@ "${propertydef.name.toPrefixString()}": { "name": "${propertydef.name.toPrefixString()}", - "title": "${propertydef.title!""}", - "description": "${propertydef.description!""}", + "title": "${propertydef.getTitle(messages)!""}", + "description": "${propertydef.getDescription(messages)!""}", "dataType": <#if propertydef.dataType??>"${propertydef.dataType.name.toPrefixString()}"<#else>"", "defaultValue": <#if propertydef.defaultValue??>"${propertydef.defaultValue}"<#else>null, "multiValued": ${propertydef.multiValued?string}, @@ -57,7 +57,7 @@ "${assocdef.name.toPrefixString()}": { "name": "${assocdef.name.toPrefixString()}", - "title": "${assocdef.title!""}", + "title": "${assocdef.getTitle(messages)!""}", "url": "/api/classes/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","_")}", "source": { @@ -87,7 +87,7 @@ "${assocdef.name.toPrefixString()}": { <#if assocdef.name??>"name": "${assocdef.name.toPrefixString()}", - "title": "${assocdef.title!""}", + "title": "${assocdef.getTitle(messages)!""}", "url": "/api/classes/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","_")}", "source": { diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/assocdefinition.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/assocdefinition.lib.ftl index c2a1c2ae10..a452a6ad3f 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/assocdefinition.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/assocdefinition.lib.ftl @@ -4,13 +4,13 @@ <#if assocdefs.name?exists> "name" : "${assocdefs.name.toPrefixString()}", - <#if assocdefs.title?exists> - "title" : "${assocdefs.title}", + <#if assocdefs.getTitle(messages)?has_content> + "title" : "${assocdefs.getTitle(messages)}", <#else> "title" : "", - <#if assocdefs.description?exists> - "description" : "${assocdefs.description}", + <#if assocdefs.getDescription(messages)?has_content> + "description" : "${assocdefs.getDescription(messages)}", <#else> "description" : "", diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/classdetails.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/classdetails.lib.ftl index 3b078fc217..c580614f90 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/classdetails.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/classdetails.lib.ftl @@ -5,8 +5,8 @@ <#if classdef.name??>"name": "${classdef.name.toPrefixString()}", "isAspect": ${classdef.isAspect()?string}, "isContainer": ${classdef.isContainer()?string}, - "title": "${classdef.title!""}", - "description": "${classdef.description!""}", + "title": "${classdef.getTitle(messages)!""}", + "description": "${classdef.getDescription(messages)!""}", "parent": { <#if classdef.parentName??> @@ -22,7 +22,7 @@ "${aspectdef.name.toPrefixString()}": { "name": "${aspectdef.name.toPrefixString()}", - "title": "${aspectdef.title!""}", + "title": "${aspectdef.getTitle(messages)!""}", "url": "/api/defclasses/${classdefprefix}/property/${aspectdef.name.toPrefixString()?replace(":","/")}" }<#if aspectdef_has_next>, @@ -34,8 +34,8 @@ "${propertydef.name.toPrefixString()}": { "name": "${propertydef.name.toPrefixString()}", - "title": "${propertydef.title!""}", - "description": "${propertydef.description!""}", + "title": "${propertydef.getTitle(messages)!""}", + "description": "${propertydef.getDescription(messages)!""}", "dataType": <#if propertydef.dataType??>"${propertydef.dataType.name.toPrefixString()}"<#else>"", "defaultValue": <#if propertydef.defaultValue??>"${propertydef.defaultValue}"<#else>null, "multiValued": ${propertydef.multiValued?string}, @@ -57,7 +57,7 @@ "${assocdef.name.toPrefixString()}": { "name": "${assocdef.name.toPrefixString()}", - "title": "${assocdef.title!""}", + "title": "${assocdef.getTitle(messages)!""}", "url": "/api/defclasses/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","/")}", "source": { @@ -87,7 +87,7 @@ "${assocdef.name.toPrefixString()}": { <#if assocdef.name??>"name": "${assocdef.name.toPrefixString()}", - "title": "${assocdef.title!""}", + "title": "${assocdef.getTitle(messages)!""}", "url": "/api/defclasses/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","/")}", "source": { diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/propertydefinition.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/propertydefinition.lib.ftl index c204682101..bc316281cf 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/propertydefinition.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/prefixed/propertydefinition.lib.ftl @@ -4,11 +4,11 @@ <#if propertydefs.name?exists> "name" : "${propertydefs.name.toPrefixString()}", - <#if propertydefs.title?exists> - "title" : "${propertydefs.title}", + <#if propertydefs.getTitle(messages)?has_content> + "title" : "${propertydefs.getTitle(messages)}", - <#if propertydefs.description?exists> - "description" : "${propertydefs.description}", + <#if propertydefs.getDescription(messages)?has_content> + "description" : "${propertydefs.getDescription(messages)}", <#if propertydefs.defaultValues?exists> "defaultValues" : "${propertydefs.defaultValues}", diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/propertydefinition.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/propertydefinition.lib.ftl index c17c28bf70..066a342d55 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/propertydefinition.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/propertydefinition.lib.ftl @@ -4,11 +4,11 @@ <#if propertydefs.name?exists> "name" : "${propertydefs.name.toPrefixString()}", - <#if propertydefs.title?exists> - "title" : "${propertydefs.title}", + <#if propertydefs.getTitle(messages)?has_content> + "title" : "${propertydefs.getTitle(messages)}", - <#if propertydefs.description?exists> - "description" : "${propertydefs.description}", + <#if propertydefs.getDescription(messages)?has_content> + "description" : "${propertydefs.getDescription(messages)}", <#if propertydefs.defaultValues?exists> "defaultValues" : "${propertydefs.defaultValues}", diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/authority.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/authority.lib.ftl index f37979a6c3..5f13e678d1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/authority.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/authority.lib.ftl @@ -12,6 +12,14 @@ <#if authority.authorityType = "USER"> "url": "/api/people/${authority.shortName?url}" + <#if authority.zones?exists> + ,"zones": + [ + <#list authority.zones as zone> + "${zone}"<#if zone_has_next>, + + ] + } diff --git a/source/java/org/alfresco/repo/surf/policy/SurfConfigCleaner.java b/source/java/org/alfresco/repo/surf/policy/SurfConfigCleaner.java new file mode 100644 index 0000000000..9ad6fc5964 --- /dev/null +++ b/source/java/org/alfresco/repo/surf/policy/SurfConfigCleaner.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2005-2012 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco 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 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Alfresco. If not, see . + */ +package org.alfresco.repo.surf.policy; + +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.web.scripts.bean.ADMRemoteStore; +import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Delete Node Policy to remove surf-config files for a deleted user. + * + * @author Dmitry Velichkevich + * @author Kevin Roast + */ +public class SurfConfigCleaner extends ADMRemoteStore implements BeforeDeleteNodePolicy +{ + private PolicyComponent policyComponent; + + public void init() + { + this.policyComponent.bindClassBehaviour( + BeforeDeleteNodePolicy.QNAME, + ContentModel.TYPE_PERSON, + new JavaBehaviour(this, BeforeDeleteNodePolicy.QNAME.getLocalName())); + } + + @Override + public void beforeDeleteNode(NodeRef nodeRef) + { + final String userName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME); + final NodeRef componentsRef = getGlobalComponentsNodeRef(); + final NodeRef usersFolderRef = getGlobalUserFolderNodeRef(); + + // Remove the user Surf config folder, contains dynamic page definitions such as dashboard.xml + // For example, qname path to user folder: + // /app:company_home/st:sites/cm:surf-config/cm:pages/cm:user/cm:admin + // ^^^^^ encoded username + if (usersFolderRef != null) + { + NodeRef userFolderNodeRef = nodeService.getChildByName(usersFolderRef, ContentModel.ASSOC_CONTAINS, encodePath(userName)); + if (userFolderNodeRef != null) + { + nodeService.deleteNode(userFolderNodeRef); + } + } + + // Remove each component Surf config file related to the user, such as the dashboard dashlet component references + // For example, qname path to user component file: + // /app:company_home/st:sites/cm:surf-config/cm:components/cm:page.component-1-1.user~admin~dashboard.xml + // ^^^^^ encoded username + if (componentsRef != null) + { + List configNodes = getFileNodes( + fileFolderService.getFileInfo(componentsRef), + getSurfConfigNodeRef(siteService.getSiteRoot(), true), + buildUserConfigSearchPattern(userName), + true).getPage(); + + for (FileInfo fileInfo : configNodes) + { + nodeService.deleteNode(fileInfo.getNodeRef()); + } + } + } + + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } +} diff --git a/source/java/org/alfresco/repo/web/scripts/DeclarativeSpreadsheetWebScript.java b/source/java/org/alfresco/repo/web/scripts/DeclarativeSpreadsheetWebScript.java index 9b3c1130b9..af43d3a78b 100644 --- a/source/java/org/alfresco/repo/web/scripts/DeclarativeSpreadsheetWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/DeclarativeSpreadsheetWebScript.java @@ -179,11 +179,11 @@ public abstract class DeclarativeSpreadsheetWebScript extends DeclarativeWebScri // Ask the dictionary service nicely for the details PropertyDefinition pd = dictionaryService.getProperty(column); - if(pd != null && pd.getTitle() != null) + if(pd != null && pd.getTitle(dictionaryService) != null) { // Use the friendly titles, which may even be localised! - headings[i] = pd.getTitle(); - descriptions[i] = pd.getDescription(); + headings[i] = pd.getTitle(dictionaryService); + descriptions[i] = pd.getDescription(dictionaryService); } else { diff --git a/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java b/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java index 391796706d..bb86479ef1 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2012 Alfresco Software Limited. * * This file is part of Alfresco * @@ -97,29 +97,36 @@ public class ADMRemoteStore extends BaseRemoteStore // name of the surf config folder private static final String SURF_CONFIG = "surf-config"; - + // patterns used to match site and user specific configuration locations - private static final Pattern USER_PATTERN_1 = Pattern.compile(".*/components/.*\\.user~(.*)~.*"); - private static final Pattern USER_PATTERN_2 = Pattern.compile(".*/pages/user/(.*?)(/.*)?$"); - private static final Pattern SITE_PATTERN_1 = Pattern.compile(".*/components/.*\\.site~(.*)~.*"); - private static final Pattern SITE_PATTERN_2 = Pattern.compile(".*/pages/site/(.*?)(/.*)?$"); + private static final String PATH_COMPONENTS = "components"; + private static final String PATH_PAGES = "pages"; + private static final String PATH_USER = "user"; + private static final String PATH_SITE = "site"; + private static final String USER_CONFIG = ".*\\." + PATH_USER + "~(.*)~.*"; + private static final String USER_CONFIG_PATTERN = USER_CONFIG.replaceAll("\\.\\*", "*").replace("\\", ""); + private static final Pattern USER_PATTERN_1 = Pattern.compile(".*/" + PATH_COMPONENTS + "/" + USER_CONFIG); + private static final Pattern USER_PATTERN_2 = Pattern.compile(".*/" + PATH_PAGES + "/" + PATH_USER + "/(.*?)(/.*)?$"); + private static final Pattern SITE_PATTERN_1 = Pattern.compile(".*/" + PATH_COMPONENTS + "/.*\\." + PATH_SITE + "~(.*)~.*"); + private static final Pattern SITE_PATTERN_2 = Pattern.compile(".*/" + PATH_PAGES + "/" + PATH_SITE + "/(.*?)(/.*)?$"); + // service beans - private NodeService nodeService; - private NodeService unprotNodeService; - private FileFolderService fileFolderService; - private NamespaceService namespaceService; - private SiteService siteService; - private ContentService contentService; - private HiddenAspect hiddenAspect; + protected NodeService nodeService; + protected NodeService unprotNodeService; + protected FileFolderService fileFolderService; + protected NamespaceService namespaceService; + protected SiteService siteService; + protected ContentService contentService; + protected HiddenAspect hiddenAspect; /** * Date format pattern used to parse HTTP date headers in RFC 1123 format. */ private static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz"; private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); - - + + /** * @param nodeService the NodeService to set */ @@ -856,7 +863,7 @@ public class ADMRemoteStore extends BaseRemoteStore * * @return surf-config folder ref if found, null otherwise if not creating */ - private NodeRef getSurfConfigNodeRef(final NodeRef rootRef, final boolean create) + protected NodeRef getSurfConfigNodeRef(final NodeRef rootRef, final boolean create) { NodeRef surfConfigRef = this.unprotNodeService.getChildByName( rootRef, ContentModel.ASSOC_CONTAINS, SURF_CONFIG); @@ -875,7 +882,54 @@ public class ADMRemoteStore extends BaseRemoteStore } return surfConfigRef; } - + + /** + * @return NodeRef to the shared components config folder + */ + protected NodeRef getGlobalComponentsNodeRef() + { + NodeRef result = null; + + NodeRef surfRef = getSurfConfigNodeRef(siteService.getSiteRoot()); + if (surfRef != null) + { + result = nodeService.getChildByName(surfRef, ContentModel.ASSOC_CONTAINS, PATH_COMPONENTS); + } + + return result; + } + + /** + * @return NodeRef to the shared user config folder + */ + protected NodeRef getGlobalUserFolderNodeRef() + { + NodeRef result = null; + + NodeRef surfRef = getSurfConfigNodeRef(siteService.getSiteRoot()); + if (surfRef != null) + { + NodeRef pagesRef = nodeService.getChildByName(surfRef, ContentModel.ASSOC_CONTAINS, PATH_PAGES); + if (pagesRef != null) + { + result = nodeService.getChildByName(pagesRef, ContentModel.ASSOC_CONTAINS, PATH_USER); + } + } + + return result; + } + + /** + * Generate the search pattern for a Surf config location for a user name. + * + * @param userName to build pattern for + * @return the search pattern + */ + protected String buildUserConfigSearchPattern(String userName) + { + return USER_CONFIG_PATTERN.replace("(*)", encodePath(userName)); + } + /** * @return the Sites folder root node reference */ @@ -898,22 +952,19 @@ public class ADMRemoteStore extends BaseRemoteStore /** * Output the matching file paths a node contains based on a pattern search. * - * @param out Writer for output - relative paths separated by newline characters + * @param out Writer for output - relative paths separated by newline characters * @param surfConfigRef Surf-Config folder - * @param fileInfo The FileInfo node to use as the parent - * @param pattern Optional pattern to match filenames against ("*" is match all) - * @param recurse True to recurse sub-directories - * + * @param fileInfo The FileInfo node to use as the parent + * @param pattern Optional pattern to match filenames against ("*" is match all) + * @param recurse True to recurse sub-directories * @throws IOException */ - private void outputFileNodes(Writer out, FileInfo fileInfo, NodeRef surfConfigRef, String pattern, boolean recurse) - throws IOException + private void outputFileNodes(Writer out, FileInfo fileInfo, NodeRef surfConfigRef, String pattern, boolean recurse) throws IOException { final boolean debug = logger.isDebugEnabled(); + PagingResults files = getFileNodes(fileInfo, surfConfigRef, pattern, recurse); + final Map nameCache = new HashMap(); - PagingResults files = fileFolderService.list( - fileInfo.getNodeRef(), true, false, pattern, null, null, - new PagingRequest(CannedQueryPageDetails.DEFAULT_PAGE_SIZE)); for (final FileInfo file : files.getPage()) { // walking up the parent tree manually until the "surf-config" parent is hit @@ -925,7 +976,7 @@ public class ADMRemoteStore extends BaseRemoteStore String name = nameCache.get(ref); if (name == null) { - name = (String)unprotNodeService.getProperty(ref, ContentModel.PROP_NAME); + name = (String) unprotNodeService.getProperty(ref, ContentModel.PROP_NAME); nameCache.put(ref, name); } displayPath.insert(0, '/'); @@ -940,4 +991,12 @@ public class ADMRemoteStore extends BaseRemoteStore if (debug) logger.debug(" /alfresco/site-data/" + displayPath.toString() + file.getName()); } } + + protected PagingResults getFileNodes(FileInfo fileInfo, NodeRef surfConfigRef, String pattern, boolean recurse) + { + return fileFolderService.list( + fileInfo.getNodeRef(), true, false, + pattern, null, null, + new PagingRequest(CannedQueryPageDetails.DEFAULT_PAGE_SIZE)); + } } diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java b/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java index 88c135169b..b1227db88a 100644 --- a/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java +++ b/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java @@ -83,7 +83,9 @@ public class BlogPut extends AbstractBlogWebScript if (nodeService.hasAspect(node, BlogIntegrationModel.ASPECT_BLOG_DETAILS)) { - nodeService.setProperties(node, arr); + Map properties = nodeService.getProperties(node); + properties.putAll(arr); + nodeService.setProperties(node, properties); } else { diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java b/source/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java index 6ed5c5b06d..50efab867f 100644 --- a/source/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java +++ b/source/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java @@ -83,7 +83,7 @@ public class BlogPostsPost extends AbstractBlogWebScript jsonPostParams.getPage() != null && !isDraft) { - addActivityEntry("created", post, site, req, json, nodeRef); + addActivityEntry("created", post, site, req, json, post.getNodeRef()); } return model; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationGet.java index ec236f0501..551dd5d352 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationGet.java @@ -47,6 +47,7 @@ public abstract class AbstractAssociationGet extends DictionaryWebServiceBase if (this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname) != null) { model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); } return model; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationsGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationsGet.java index 673ab94b7a..4322c2f16d 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationsGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractAssociationsGet.java @@ -108,6 +108,8 @@ public abstract class AbstractAssociationsGet extends DictionaryWebServiceBase model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)); } + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); + return model; } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassGet.java index 71f8f3eeda..7ee0273875 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassGet.java @@ -59,6 +59,7 @@ public abstract class AbstractClassGet extends DictionaryWebServiceBase model.put(MODEL_PROP_KEY_CLASS_DETAILS, classdef.values()); model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values()); model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values()); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); return model; } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassesGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassesGet.java index 7371b1070c..3279b912b4 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassesGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractClassesGet.java @@ -160,10 +160,11 @@ public abstract class AbstractClassesGet extends DictionaryWebServiceBase } List classDefinitions = new ArrayList(classdef.values()); - Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator()); + Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice)); model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions); model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, reorderedValues(classDefinitions, propdef)); model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, reorderedValues(classDefinitions, assocdef)); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice); return model; } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertiesGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertiesGet.java index 6275f5b159..f2f36e7f41 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertiesGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertiesGet.java @@ -103,11 +103,12 @@ public abstract class AbstractPropertiesGet extends DictionaryWebServiceBase } // Order property definitions by title - Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator()); + Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator(dictionaryservice)); // Pass list of property definitions to template Map model = new HashMap(); model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, props); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice); return model; } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertyGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertyGet.java index ff53bbf809..d8232c6ff7 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertyGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractPropertyGet.java @@ -48,6 +48,7 @@ public abstract class AbstractPropertyGet extends DictionaryWebServiceBase if (this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname) != null) { model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname)); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); } return model; diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractSubClassesGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractSubClassesGet.java index 257c2a0836..1e7b2c9ba3 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractSubClassesGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/AbstractSubClassesGet.java @@ -134,10 +134,11 @@ public abstract class AbstractSubClassesGet extends DictionaryWebServiceBase } List classDefinitions = new ArrayList(classdef.values()); - Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator()); + Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice)); model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions); model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, reorderedValues(classDefinitions, propdef)); model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, reorderedValues(classDefinitions, assocdef)); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); return model; } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryComparators.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryComparators.java index 18c4634102..2d0de283d7 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryComparators.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryComparators.java @@ -23,6 +23,7 @@ import java.util.Comparator; import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.service.cmr.i18n.MessageLookup; /** * Comparators used when ordering dictionary elements @@ -38,16 +39,23 @@ public interface DictionaryComparators */ public class ClassDefinitionComparator implements Comparator { + private final MessageLookup messageLookup; + + public ClassDefinitionComparator(MessageLookup messageLookup) + { + this.messageLookup = messageLookup; + } + public int compare(ClassDefinition arg0, ClassDefinition arg1) { int result = 0; - String title0 = arg0.getTitle(); + String title0 = arg0.getTitle(messageLookup); if (title0 == null) { title0 = arg0.getName().toPrefixString(); } - String title1 = arg1.getTitle(); + String title1 = arg1.getTitle(messageLookup); if (title1 == null) { title1 = arg1.getName().getPrefixString(); @@ -77,16 +85,23 @@ public interface DictionaryComparators */ public class PropertyDefinitionComparator implements Comparator { + private final MessageLookup messageLookup; + + public PropertyDefinitionComparator(MessageLookup messageLookup) + { + this.messageLookup = messageLookup; + } + public int compare(PropertyDefinition arg0, PropertyDefinition arg1) { int result = 0; - String title0 = arg0.getTitle(); + String title0 = arg0.getTitle(messageLookup); if (title0 == null) { title0 = arg0.getName().toPrefixString(); } - String title1 = arg1.getTitle(); + String title1 = arg1.getTitle(messageLookup); if (title1 == null) { title1 = arg1.getName().getPrefixString(); diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java index b710870f66..d05351ebd2 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java @@ -103,6 +103,7 @@ public class DictionaryGet extends DictionaryWebServiceBase model.put(MODEL_CLASS_DEFS, classdef.values()); model.put(MODEL_PROPERTY_DEFS, propdef.values()); model.put(MODEL_ASSOCIATION_DEFS, assocdef.values()); + model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); return model; } } diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryRestApiTest.java index 318919cb0f..a7a534bb70 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryRestApiTest.java @@ -18,6 +18,7 @@ */ package org.alfresco.repo.web.scripts.dictionary; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.Response; @@ -44,12 +45,15 @@ public class DictionaryRestApiTest extends BaseWebScriptTest protected void setUp() throws Exception { super.setUp(); + getServer(); + AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); } @Override protected void tearDown() throws Exception { super.tearDown(); + AuthenticationUtil.clearCurrentSecurityContext(); } private void validatePropertyDef(JSONObject result) throws Exception diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java index e842443fe6..3399b34d20 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java @@ -40,6 +40,7 @@ import org.springframework.extensions.webscripts.WebScriptException; public abstract class DictionaryWebServiceBase extends DeclarativeWebScript { private static final String NAME_DELIMITER = "_"; + protected static final String MODEL_PROP_KEY_MESSAGE_LOOKUP = "messages"; /** Namespace service */ protected NamespaceService namespaceService; diff --git a/source/java/org/alfresco/repo/web/scripts/metadata/BulkMetadataGet.java b/source/java/org/alfresco/repo/web/scripts/metadata/BulkMetadataGet.java index 1fb5e86c26..6db9284927 100644 --- a/source/java/org/alfresco/repo/web/scripts/metadata/BulkMetadataGet.java +++ b/source/java/org/alfresco/repo/web/scripts/metadata/BulkMetadataGet.java @@ -107,7 +107,7 @@ public class BulkMetadataGet extends AbstractWebScript jsonOut.writeValue("type", type.toString()); jsonOut.writeValue("shortType", shortType); TypeDefinition typeDef = dictionaryService.getType(type); - jsonOut.writeValue("typeTitle", typeDef.getTitle()); + jsonOut.writeValue("typeTitle", typeDef.getTitle(dictionaryService)); jsonOut.writeValue("name", (String)properties.get(ContentModel.PROP_NAME)); jsonOut.writeValue("title", (String)properties.get(ContentModel.PROP_TITLE)); diff --git a/source/java/org/alfresco/repo/web/scripts/person/UserCSVUploadPost.java b/source/java/org/alfresco/repo/web/scripts/person/UserCSVUploadPost.java index 38b3b9e379..3f6be56219 100644 --- a/source/java/org/alfresco/repo/web/scripts/person/UserCSVUploadPost.java +++ b/source/java/org/alfresco/repo/web/scripts/person/UserCSVUploadPost.java @@ -467,10 +467,10 @@ public class UserCSVUploadPost extends DeclarativeWebScript PropertyDefinition unPD = dictionaryService.getProperty(ContentModel.PROP_USERNAME); if (unPD != null) { - if(unPD.getTitle() != null) - usernameIsUsername.add(unPD.getTitle().toLowerCase()); - if(unPD.getDescription() != null) - usernameIsUsername.add(unPD.getDescription().toLowerCase()); + if(unPD.getTitle(dictionaryService) != null) + usernameIsUsername.add(unPD.getTitle(dictionaryService).toLowerCase()); + if(unPD.getDescription(dictionaryService) != null) + usernameIsUsername.add(unPD.getDescription(dictionaryService).toLowerCase()); } diff --git a/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java index 1f45073b52..b3a1187ae4 100644 --- a/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java @@ -37,6 +37,7 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.repo.workflow.WorkflowAdminServiceImpl; import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.repo.workflow.WorkflowTestHelper; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.repository.NodeRef; @@ -109,6 +110,7 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest private NodeRef packageRef; private NodeRef contentNodeRef; private AuthenticationComponent authenticationComponent; + private DictionaryService dictionaryService; private List workflows = new LinkedList(); @@ -540,8 +542,8 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest assertNotNull(type); assertEquals(startType.getName().toPrefixString(), type.getString("name")); - assertEquals(startType.getTitle(), type.getString("title")); - assertEquals(startType.getDescription(), type.getString("description")); + assertEquals(startType.getTitle(this.dictionaryService), type.getString("title")); + assertEquals(startType.getDescription(this.dictionaryService), type.getString("description")); assertTrue(type.has("url")); JSONObject node = definition.getJSONObject("node"); @@ -1402,6 +1404,7 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest groupManager = new TestGroupManager(authorityService, searchService); authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent"); + dictionaryService = (DictionaryService) appContext.getBean("dictionaryService"); personManager.createPerson(USER1); personManager.createPerson(USER2); diff --git a/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowWebscript.java b/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowWebscript.java index aaeace423e..6cfdc79fb2 100644 --- a/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowWebscript.java +++ b/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowWebscript.java @@ -76,7 +76,7 @@ public abstract class AbstractWorkflowWebscript extends DeclarativeWebScript protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) { WorkflowModelBuilder modelBuilder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, - personService, workflowService); + personService, workflowService, dictionaryService); return buildModel(modelBuilder, req, status, cache); } diff --git a/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilder.java b/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilder.java index b89056cfc3..e313257910 100644 --- a/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilder.java +++ b/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilder.java @@ -36,6 +36,7 @@ import org.alfresco.repo.workflow.WorkflowQNameConverter; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.Constraint; import org.alfresco.service.cmr.dictionary.ConstraintDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.repository.AssociationRef; @@ -154,18 +155,20 @@ public class WorkflowModelBuilder private final NodeService nodeService; private final PersonService personService; private final WorkflowService workflowService; + private final DictionaryService dictionaryService; private final AuthenticationService authenticationService; private final WorkflowQNameConverter qNameConverter; public WorkflowModelBuilder(NamespaceService namespaceService, NodeService nodeService, AuthenticationService authenticationService, PersonService personService, - WorkflowService workflowService) + WorkflowService workflowService, DictionaryService dictionaryService) { this.nodeService = nodeService; this.personService = personService; this.workflowService = workflowService; this.authenticationService = authenticationService; this.qNameConverter = new WorkflowQNameConverter(namespaceService); + this.dictionaryService = dictionaryService; } /** @@ -439,7 +442,7 @@ public class WorkflowModelBuilder if (constraint instanceof ListOfValuesConstraint) { ListOfValuesConstraint listConstraint = (ListOfValuesConstraint) constraint; - String label = listConstraint.getDisplayLabel(String.valueOf(entry.getValue())); + String label = listConstraint.getDisplayLabel(String.valueOf(entry.getValue()), dictionaryService); return new Pair(propName, label); } } @@ -540,8 +543,8 @@ public class WorkflowModelBuilder Map model = new HashMap(); model.put(TYPE_DEFINITION_NAME, typeDefinition.getName()); - model.put(TYPE_DEFINITION_TITLE, typeDefinition.getTitle()); - model.put(TYPE_DEFINITION_DESCRIPTION, typeDefinition.getDescription()); + model.put(TYPE_DEFINITION_TITLE, typeDefinition.getTitle(dictionaryService)); + model.put(TYPE_DEFINITION_DESCRIPTION, typeDefinition.getDescription(dictionaryService)); model.put(TYPE_DEFINITION_URL, getUrl(typeDefinition)); return model; diff --git a/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilderTest.java b/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilderTest.java index d84aa3927c..6a7988959a 100644 --- a/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilderTest.java +++ b/source/java/org/alfresco/repo/web/scripts/workflow/WorkflowModelBuilderTest.java @@ -18,7 +18,8 @@ */ package org.alfresco.repo.web.scripts.workflow; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.io.Serializable; import java.util.ArrayList; @@ -32,6 +33,7 @@ import junit.framework.TestCase; import org.alfresco.model.ContentModel; import org.alfresco.repo.workflow.WorkflowModel; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -69,6 +71,7 @@ public class WorkflowModelBuilderTest extends TestCase private PersonService personService; private NodeService nodeService; private WorkflowService workflowService; + private DictionaryService dictionaryService; private AuthenticationService authenticationService; private WorkflowModelBuilder builder; @@ -183,8 +186,8 @@ public class WorkflowModelBuilderTest extends TestCase Map actualType = (Map) actualDefinition.get(WorkflowModelBuilder.TASK_DEFINITION_TYPE); TypeDefinition taskType = taskDef.getMetadata(); assertEquals(taskType.getName(), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_NAME)); - assertEquals(taskType.getTitle(), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_TITLE)); - assertEquals(taskType.getDescription(), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_DESCRIPTION)); + assertEquals(taskType.getTitle(dictionaryService), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_TITLE)); + assertEquals(taskType.getDescription(dictionaryService), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_DESCRIPTION)); Map actualNode = (Map) actualDefinition.get(WorkflowModelBuilder.TASK_DEFINITION_NODE); WorkflowNode taskNode = taskDef.getNode(); @@ -256,8 +259,8 @@ public class WorkflowModelBuilderTest extends TestCase WorkflowTaskDefinition workflowTaskDefinition = makeTaskDefinition(); QName taskTypeName = WorkflowModel.TYPE_WORKFLOW_TASK; when(workflowTaskDefinition.getMetadata().getName()).thenReturn(taskTypeName); - when(workflowTaskDefinition.getMetadata().getTitle()).thenReturn("The Type Title"); - when(workflowTaskDefinition.getMetadata().getDescription()).thenReturn("The Type Description"); + when(workflowTaskDefinition.getMetadata().getTitle(dictionaryService)).thenReturn("The Type Title"); + when(workflowTaskDefinition.getMetadata().getDescription(dictionaryService)).thenReturn("The Type Description"); WorkflowInstance workflowInstance = makeWorkflowInstance(workflowTaskDefinition); @@ -322,8 +325,8 @@ public class WorkflowModelBuilderTest extends TestCase { TypeDefinition typeDef = mock(TypeDefinition.class); when(typeDef.getName()).thenReturn(QName.createQName(URI, "The Type Name")); - when(typeDef.getTitle()).thenReturn("The Type Title"); - when(typeDef.getDescription()).thenReturn("The Type Description"); + when(typeDef.getTitle(dictionaryService)).thenReturn("The Type Title"); + when(typeDef.getDescription(dictionaryService)).thenReturn("The Type Description"); return typeDef; } @@ -406,8 +409,9 @@ public class WorkflowModelBuilderTest extends TestCase when(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)).thenReturn(lastName); workflowService = mock(WorkflowService.class); + dictionaryService = mock(DictionaryService.class); authenticationService = mock(AuthenticationService.class); - builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService); + builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService); } } diff --git a/source/java/org/alfresco/repo/webdav/MoveMethod.java b/source/java/org/alfresco/repo/webdav/MoveMethod.java index c15853f2e1..6ebb555e06 100644 --- a/source/java/org/alfresco/repo/webdav/MoveMethod.java +++ b/source/java/org/alfresco/repo/webdav/MoveMethod.java @@ -205,7 +205,18 @@ public class MoveMethod extends HierarchicalMethod setHidden(destFileInfo.getNodeRef(), false); if (isMove) { - fileFolderService.delete(sourceNodeRef); + if (getDAVHelper().isRenameShuffle(destPath) && !getDAVHelper().isRenameShuffle(sourcePath)) + { + // if temporary or backup file already exists + // don't delete source that is node with version history + setHidden(sourceNodeRef, true); + // As per the WebDAV spec, we make sure the node is unlocked once moved + getDAVHelper().getLockService().unlock(sourceNodeRef); + } + else + { + fileFolderService.delete(sourceNodeRef); + } } } // If this is a copy then the source is just copied to destination. diff --git a/source/java/org/alfresco/repo/webdav/OptionsMethod.java b/source/java/org/alfresco/repo/webdav/OptionsMethod.java index 347b93665e..e1869a26f2 100644 --- a/source/java/org/alfresco/repo/webdav/OptionsMethod.java +++ b/source/java/org/alfresco/repo/webdav/OptionsMethod.java @@ -18,6 +18,7 @@ */ package org.alfresco.repo.webdav; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileNotFoundException; @@ -79,17 +80,23 @@ public class OptionsMethod extends WebDAVMethod */ protected void executeImpl() throws WebDAVServerException { - boolean isFolder; - try + Boolean isFolder = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { - FileInfo fileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); - isFolder = fileInfo.isFolder(); - } - catch (FileNotFoundException e) - { - // Do nothing; just default to a folder - isFolder = true; - } + @Override + public Boolean doWork() throws FileNotFoundException + { + try + { + FileInfo fileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); + return fileInfo.isFolder(); + } + catch (FileNotFoundException e) + { + // Do nothing; just default to a folder + return true; + } + } + }, AuthenticationUtil.getSystemUserName()); // Add the header to advertise the level of support the server has m_response.addHeader(DAV_HEADER, DAV_HEADER_CONTENT); diff --git a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java index 8ddbcda227..c0c2af46ad 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java +++ b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java @@ -109,7 +109,7 @@ public class WebDAVHelper private HiddenAspect m_hiddenAspect; // pattern is tested against full path after it has been lower cased. - private Pattern m_renameShufflePattern = Pattern.compile("(.*/\\..*)|(.*[a-f0-9]{8}+$)|(.*\\.tmp$)|(.*\\.wbk$)|(.*\\.bak$)|(.*\\~$)"); + private Pattern m_renameShufflePattern = Pattern.compile("(.*/\\..*)|(.*[a-f0-9]{8}+$)|(.*\\.tmp$)|(.*\\.wbk$)|(.*\\.bak$)|(.*\\~$)|(.*backup.*\\.do[ct]{1}[x]?[m]?$)"); // Empty XML attribute list diff --git a/source/java/org/alfresco/repo/webdav/auth/AuthenticationFilter.java b/source/java/org/alfresco/repo/webdav/auth/AuthenticationFilter.java index dff44b42dc..7ae5547971 100644 --- a/source/java/org/alfresco/repo/webdav/auth/AuthenticationFilter.java +++ b/source/java/org/alfresco/repo/webdav/auth/AuthenticationFilter.java @@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.repo.SessionUser; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.web.filter.beans.DependencyInjectedFilter; +import org.alfresco.repo.webdav.WebDAV; import org.alfresco.service.cmr.security.NoSuchPersonException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; @@ -215,7 +216,7 @@ public class AuthenticationFilter extends BaseAuthenticationFilter implements De // Check if the user is authenticated, if not then prompt again - if ( user == null) + if ( user == null && !WebDAV.METHOD_OPTIONS.equalsIgnoreCase(httpReq.getMethod())) { if (logger.isDebugEnabled()) logger.debug("No user/ticket, force the client to prompt for logon details."); diff --git a/source/java/org/alfresco/repo/webservice/Utils.java b/source/java/org/alfresco/repo/webservice/Utils.java index b1c9a28cf3..c1041ea8af 100644 --- a/source/java/org/alfresco/repo/webservice/Utils.java +++ b/source/java/org/alfresco/repo/webservice/Utils.java @@ -663,19 +663,19 @@ public class Utils * @param ddClassDef The repository ClassDefinition to generate * @return The web service ClassDefinition representation */ - public static ClassDefinition setupClassDefObject(org.alfresco.service.cmr.dictionary.ClassDefinition ddClassDef) + public static ClassDefinition setupClassDefObject(DictionaryService dictionaryService, org.alfresco.service.cmr.dictionary.ClassDefinition ddClassDef) { ClassDefinition classDef = new ClassDefinition(); classDef.setName(ddClassDef.getName().toString()); classDef.setIsAspect(ddClassDef.isAspect()); - if (ddClassDef.getTitle() != null) + if (ddClassDef.getTitle(dictionaryService) != null) { - classDef.setTitle(ddClassDef.getTitle()); + classDef.setTitle(ddClassDef.getTitle(dictionaryService)); } - if (ddClassDef.getDescription() != null) + if (ddClassDef.getDescription(dictionaryService) != null) { - classDef.setDescription(ddClassDef.getDescription()); + classDef.setDescription(ddClassDef.getDescription(dictionaryService)); } if (ddClassDef.getParentName() != null) { @@ -690,7 +690,7 @@ public class Utils int pos = 0; for (org.alfresco.service.cmr.dictionary.PropertyDefinition ddPropDef : props.values()) { - PropertyDefinition propDef = setupPropertyDefObject(ddPropDef); + PropertyDefinition propDef = setupPropertyDefObject(dictionaryService, ddPropDef); propDefs[pos] = propDef; pos++; } @@ -707,7 +707,7 @@ public class Utils int pos = 0; for (org.alfresco.service.cmr.dictionary.AssociationDefinition ddAssocDef : assocs.values()) { - AssociationDefinition assocDef = setupAssociationDefObject(ddAssocDef); + AssociationDefinition assocDef = setupAssociationDefObject(dictionaryService, ddAssocDef); assocDefs[pos] = assocDef; pos++; } @@ -725,7 +725,7 @@ public class Utils * @param ddPropertyDef The repository PropertyDefinition to generate * @return The web service PropertyDefinition representation */ - public static PropertyDefinition setupPropertyDefObject(org.alfresco.service.cmr.dictionary.PropertyDefinition ddPropDef) + public static PropertyDefinition setupPropertyDefObject(DictionaryService dictionaryService, org.alfresco.service.cmr.dictionary.PropertyDefinition ddPropDef) { PropertyDefinition propDef = new PropertyDefinition(); propDef.setName(ddPropDef.getName().toString()); @@ -736,13 +736,13 @@ public class Utils { propDef.setDefaultValue(ddPropDef.getDefaultValue()); } - if (ddPropDef.getTitle() != null) + if (ddPropDef.getTitle(dictionaryService) != null) { - propDef.setTitle(ddPropDef.getTitle()); + propDef.setTitle(ddPropDef.getTitle(dictionaryService)); } - if (ddPropDef.getDescription() != null) + if (ddPropDef.getDescription(dictionaryService) != null) { - propDef.setDescription(ddPropDef.getDescription()); + propDef.setDescription(ddPropDef.getDescription(dictionaryService)); } return propDef; } @@ -754,18 +754,18 @@ public class Utils * @param ddAssociationDef The repository AssociationDefinition to generate * @return The web service AssociationDefinition representation */ - public static AssociationDefinition setupAssociationDefObject(org.alfresco.service.cmr.dictionary.AssociationDefinition ddAssocDef) + public static AssociationDefinition setupAssociationDefObject(DictionaryService dictionaryService, org.alfresco.service.cmr.dictionary.AssociationDefinition ddAssocDef) { AssociationDefinition assocDef = new AssociationDefinition(); assocDef.setName(ddAssocDef.getName().toString()); assocDef.setIsChild(ddAssocDef.isChild()); - if (ddAssocDef.getTitle() != null) + if (ddAssocDef.getTitle(dictionaryService) != null) { - assocDef.setTitle(ddAssocDef.getTitle()); + assocDef.setTitle(ddAssocDef.getTitle(dictionaryService)); } - if (ddAssocDef.getDescription() != null) + if (ddAssocDef.getDescription(dictionaryService) != null) { - assocDef.setDescription(ddAssocDef.getDescription()); + assocDef.setDescription(ddAssocDef.getDescription(dictionaryService)); } RoleDefinition sourceRole = new RoleDefinition(); diff --git a/source/java/org/alfresco/repo/webservice/classification/ClassificationWebService.java b/source/java/org/alfresco/repo/webservice/classification/ClassificationWebService.java index 122a8c0ceb..8de5f12a9a 100644 --- a/source/java/org/alfresco/repo/webservice/classification/ClassificationWebService.java +++ b/source/java/org/alfresco/repo/webservice/classification/ClassificationWebService.java @@ -126,7 +126,7 @@ public class ClassificationWebService extends AbstractWebService implements org.alfresco.service.cmr.dictionary.ClassDefinition aspectDefinition = ClassificationWebService.this.dictionaryService.getClass(aspect); if (aspectDefinition != null) { - title = aspectDefinition.getTitle(); + title = aspectDefinition.getTitle(dictionaryService); } if (logger.isDebugEnabled()) @@ -442,7 +442,7 @@ public class ClassificationWebService extends AbstractWebService implements public ClassDefinition execute() { org.alfresco.service.cmr.dictionary.ClassDefinition classDefinition = ClassificationWebService.this.dictionaryService.getClass(QName.createQName(classification)); - return Utils.setupClassDefObject(classDefinition); + return Utils.setupClassDefObject(dictionaryService, classDefinition); } }); } diff --git a/source/java/org/alfresco/repo/webservice/dictionary/DictionaryWebService.java b/source/java/org/alfresco/repo/webservice/dictionary/DictionaryWebService.java index fa3ef770a3..2edf0e723a 100644 --- a/source/java/org/alfresco/repo/webservice/dictionary/DictionaryWebService.java +++ b/source/java/org/alfresco/repo/webservice/dictionary/DictionaryWebService.java @@ -92,7 +92,7 @@ public class DictionaryWebService extends AbstractWebService implements Dictiona List wsClassDefs = new ArrayList(classDefs.size()); for (org.alfresco.service.cmr.dictionary.ClassDefinition classDef : classDefs) { - wsClassDefs.add(Utils.setupClassDefObject(classDef)); + wsClassDefs.add(Utils.setupClassDefObject(dictionaryService, classDef)); } return wsClassDefs.toArray(new ClassDefinition[wsClassDefs.size()]); @@ -127,7 +127,7 @@ public class DictionaryWebService extends AbstractWebService implements Dictiona { throw new AlfrescoRuntimeException("Property propertyName does not exist."); } - propDefs[i++] = Utils.setupPropertyDefObject(ddPropDef); + propDefs[i++] = Utils.setupPropertyDefObject(dictionaryService, ddPropDef); } return propDefs; @@ -162,7 +162,7 @@ public class DictionaryWebService extends AbstractWebService implements Dictiona { throw new AlfrescoRuntimeException("Property propertyName does not exist."); } - assocDefs[i++] = Utils.setupAssociationDefObject(ddAssocDef); + assocDefs[i++] = Utils.setupAssociationDefObject(dictionaryService, ddAssocDef); } return assocDefs; diff --git a/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java b/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java index c0161d4788..8aa57a34fd 100644 --- a/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java +++ b/source/java/org/alfresco/repo/webservice/repository/RepositoryWebService.java @@ -386,7 +386,7 @@ public class RepositoryWebService extends AbstractWebService implements .getType(this.nodeService.getType(nodeRef)); // create the web service ClassDefinition type from the data dictionary TypeDefinition - ClassDefinition typeDef = Utils.setupClassDefObject(ddTypeDef); + ClassDefinition typeDef = Utils.setupClassDefObject(this.dictionaryService, ddTypeDef); Set aspectsQNames = this.nodeService.getAspects(nodeRef); ClassDefinition[] aspectDefs = new ClassDefinition[aspectsQNames.size()]; @@ -394,7 +394,7 @@ public class RepositoryWebService extends AbstractWebService implements for (QName aspectQName : aspectsQNames) { AspectDefinition aspectDef = this.dictionaryService.getAspect(aspectQName); - aspectDefs[pos] = Utils.setupClassDefObject(aspectDef); + aspectDefs[pos] = Utils.setupClassDefObject(this.dictionaryService, aspectDef); pos++; }