From f1fe03239ee82fe2decb1bbab4c0c2abee805bb4 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Tue, 26 Jul 2011 05:03:44 +0000 Subject: [PATCH] ALF-9542 - SVC 65: Contribution: Share Tag Management Console * based on contribution from iptech * replaced origional web scripts with versions that compliement and extend exitsing tagging REST API * updated UI to use changed webScripts * fixed rename action caps sensitivity (rename with different capitalisation, but same name deleted tag!) * tested Also fixes: * ALF-8688 - Can't remove a tag from the tag list * ALF-4710 - Share Impossible to Permanently Remove Content Tags git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29327 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/tagging/TaggingServiceImpl.java | 26 ++++++++++++++----- .../tagging/script/ScriptTaggingService.java | 14 +++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java b/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java index 0f3af8a0e0..1a3a938f13 100644 --- a/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java +++ b/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java @@ -66,6 +66,7 @@ import org.alfresco.service.cmr.tagging.TaggingService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.ISO9075; +import org.alfresco.util.ParameterCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -476,6 +477,8 @@ public class TaggingServiceImpl implements TaggingService, */ public List getTags(StoreRef storeRef) { + ParameterCheck.mandatory("storeRef", storeRef); + Collection rootCategories = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE); List result = new ArrayList(rootCategories.size()); for (ChildAssociationRef rootCategory : rootCategories) @@ -491,16 +494,27 @@ public class TaggingServiceImpl implements TaggingService, */ public List getTags(StoreRef storeRef, String filter) { - Collection rootCategories = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE); - List result = new ArrayList(rootCategories.size()); - for (ChildAssociationRef rootCategory : rootCategories) + ParameterCheck.mandatory("storeRef", storeRef); + + List result = null; + if (filter == null || filter.length() == 0) { - String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME); - if (name.contains(filter.toLowerCase()) == true) + result = getTags(storeRef); + } + else + { + Collection rootCategories = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE); + result = new ArrayList(rootCategories.size()); + for (ChildAssociationRef rootCategory : rootCategories) { - result.add(name); + String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME); + if (name.contains(filter.toLowerCase()) == true) + { + result.add(name); + } } } + return result; } diff --git a/source/java/org/alfresco/repo/tagging/script/ScriptTaggingService.java b/source/java/org/alfresco/repo/tagging/script/ScriptTaggingService.java index b7254d9b9d..65c01ba46c 100644 --- a/source/java/org/alfresco/repo/tagging/script/ScriptTaggingService.java +++ b/source/java/org/alfresco/repo/tagging/script/ScriptTaggingService.java @@ -87,7 +87,7 @@ public class ScriptTaggingService extends BaseScopableProcessorExtension NodeRef result = this.serviceRegistry.getTaggingService().getTagNodeRef(storeRef, tag); if (result != null) { - return new ScriptNode(result, this.serviceRegistry); + return new ScriptNode(result, this.serviceRegistry, this.getScope()); } return null; } @@ -109,4 +109,16 @@ public class ScriptTaggingService extends BaseScopableProcessorExtension } return null; } + + /** + * delete tag at the given store + * + * @param store store reference + * @param tag tag name + */ + public void deleteTag(String store, String tag) + { + StoreRef storeRef = new StoreRef(store); + this.serviceRegistry.getTaggingService().deleteTag(storeRef, tag); + } }