From 4fb860407c4c7fd06733dd04eccb55fb0b825401 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 3 Jul 2008 09:45:48 +0000 Subject: [PATCH] Tagging Service: tags are case insensitive git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9632 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/tagging/TaggingServiceImpl.java | 18 +++++++++++++++ .../repo/tagging/TaggingServiceImplTest.java | 22 +++++++++++++------ .../script/ScriptThumbnailService.java | 5 ----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java b/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java index e2fcc4e534..31df2c17e3 100644 --- a/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java +++ b/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java @@ -132,6 +132,9 @@ public class TaggingServiceImpl implements TaggingService */ public boolean isTag(StoreRef storeRef, String tag) { + // Lower the case of the tag + tag = tag.toLowerCase(); + return (getTagNodeRef(storeRef, tag) != null); } @@ -140,6 +143,9 @@ public class TaggingServiceImpl implements TaggingService */ public void createTag(StoreRef storeRef, String tag) { + // Lower the case of the tag + tag = tag.toLowerCase(); + if (isTag(storeRef, tag) == false) { this.categoryService.createRootCategory(storeRef, ContentModel.ASPECT_TAGGABLE, tag); @@ -166,6 +172,9 @@ public class TaggingServiceImpl implements TaggingService */ public void addTag(NodeRef nodeRef, String tag) { + // Lower the case of the tag + tag = tag.toLowerCase(); + // Get the tag node reference NodeRef newTagNodeRef = getTagNodeRef(nodeRef.getStoreRef(), tag); if (newTagNodeRef == null) @@ -241,6 +250,9 @@ public class TaggingServiceImpl implements TaggingService */ public void removeTag(NodeRef nodeRef, String tag) { + // Lower the case of the tag + tag = tag.toLowerCase(); + // Check for the taggable aspect if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true) { @@ -406,6 +418,9 @@ public class TaggingServiceImpl implements TaggingService */ public List findTaggedNodes(String tag) { + // Lower the case of the tag + tag = tag.toLowerCase(); + // TODO return null; } @@ -415,6 +430,9 @@ public class TaggingServiceImpl implements TaggingService */ public List findTaggedNodes(String tag, TagScope tagScope) { + // Lower the case of the tag + tag = tag.toLowerCase(); + // TODO return null; } diff --git a/source/java/org/alfresco/repo/tagging/TaggingServiceImplTest.java b/source/java/org/alfresco/repo/tagging/TaggingServiceImplTest.java index 6ff2e08f68..70a6ccb827 100644 --- a/source/java/org/alfresco/repo/tagging/TaggingServiceImplTest.java +++ b/source/java/org/alfresco/repo/tagging/TaggingServiceImplTest.java @@ -64,9 +64,12 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest private NodeRef document; private NodeRef subDocument; - private static final String TAG_1 = "tagOne"; - private static final String TAG_2 = "tagTwo"; - private static final String TAG_3 = "tagThree"; + private static final String TAG_1 = "tag one"; + private static final String TAG_2 = "tag two"; + private static final String TAG_3 = "Tag Three"; + + private static final String UPPER_TAG = "House"; + private static final String LOWER_TAG = "house"; private static boolean init = false; @@ -173,6 +176,7 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest // Create a tag this.taggingService.createTag(TaggingServiceImplTest.storeRef, TAG_1); + this.taggingService.createTag(TaggingServiceImplTest.storeRef, UPPER_TAG); setComplete(); endTransaction(); @@ -183,13 +187,15 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest // Get all the tags tags = this.taggingService.getTags(TaggingServiceImplTest.storeRef); assertNotNull(tags); - assertEquals(1, tags.size()); + assertEquals(2, tags.size()); assertTrue(tags.contains(TAG_1)); - + assertTrue(tags.contains(LOWER_TAG)); + // Check isTag method assertFalse(this.taggingService.isTag(TaggingServiceImplTest.storeRef, TAG_2)); assertTrue(this.taggingService.isTag(TaggingServiceImplTest.storeRef, TAG_1)); - + assertTrue(this.taggingService.isTag(TaggingServiceImplTest.storeRef, UPPER_TAG)); + assertTrue(this.taggingService.isTag(TaggingServiceImplTest.storeRef, LOWER_TAG)); tx.commit(); } @@ -315,7 +321,7 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest assertEquals(2, ts2.getTags().get(1).getTagCount()); assertEquals(TAG_1, ts2.getTags().get(1).getTagName()); assertEquals(1, ts2.getTags().get(2).getTagCount()); - assertEquals(TAG_3, ts2.getTags().get(2).getTagName()); + assertEquals(TAG_3.toLowerCase(), ts2.getTags().get(2).getTagName()); tx.commit(); @@ -341,6 +347,8 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest private void addTag(NodeRef nodeRef, String tag, int tagCount, NodeRef tagScopeNodeRef) throws Exception { + tag = tag.toLowerCase(); + UserTransaction tx = this.transactionService.getUserTransaction(); tx.begin(); diff --git a/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java b/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java index 3500266d8e..0d1f779382 100644 --- a/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java +++ b/source/java/org/alfresco/repo/thumbnail/script/ScriptThumbnailService.java @@ -24,12 +24,7 @@ */ package org.alfresco.repo.thumbnail.script; -import java.util.ArrayList; -import java.util.List; - import org.alfresco.repo.jscript.BaseScopableProcessorExtension; -import org.alfresco.repo.site.SiteInfo; -import org.alfresco.repo.site.SiteService; import org.alfresco.repo.thumbnail.ThumbnailDetails; import org.alfresco.service.ServiceRegistry;