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
This commit is contained in:
Roy Wetherall
2008-07-03 09:45:48 +00:00
parent f13e6f19f2
commit 4fb860407c
3 changed files with 33 additions and 12 deletions

View File

@@ -132,6 +132,9 @@ public class TaggingServiceImpl implements TaggingService
*/ */
public boolean isTag(StoreRef storeRef, String tag) public boolean isTag(StoreRef storeRef, String tag)
{ {
// Lower the case of the tag
tag = tag.toLowerCase();
return (getTagNodeRef(storeRef, tag) != null); return (getTagNodeRef(storeRef, tag) != null);
} }
@@ -140,6 +143,9 @@ public class TaggingServiceImpl implements TaggingService
*/ */
public void createTag(StoreRef storeRef, String tag) public void createTag(StoreRef storeRef, String tag)
{ {
// Lower the case of the tag
tag = tag.toLowerCase();
if (isTag(storeRef, tag) == false) if (isTag(storeRef, tag) == false)
{ {
this.categoryService.createRootCategory(storeRef, ContentModel.ASPECT_TAGGABLE, tag); this.categoryService.createRootCategory(storeRef, ContentModel.ASPECT_TAGGABLE, tag);
@@ -166,6 +172,9 @@ public class TaggingServiceImpl implements TaggingService
*/ */
public void addTag(NodeRef nodeRef, String tag) public void addTag(NodeRef nodeRef, String tag)
{ {
// Lower the case of the tag
tag = tag.toLowerCase();
// Get the tag node reference // Get the tag node reference
NodeRef newTagNodeRef = getTagNodeRef(nodeRef.getStoreRef(), tag); NodeRef newTagNodeRef = getTagNodeRef(nodeRef.getStoreRef(), tag);
if (newTagNodeRef == null) if (newTagNodeRef == null)
@@ -241,6 +250,9 @@ public class TaggingServiceImpl implements TaggingService
*/ */
public void removeTag(NodeRef nodeRef, String tag) public void removeTag(NodeRef nodeRef, String tag)
{ {
// Lower the case of the tag
tag = tag.toLowerCase();
// Check for the taggable aspect // Check for the taggable aspect
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true) if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true)
{ {
@@ -406,6 +418,9 @@ public class TaggingServiceImpl implements TaggingService
*/ */
public List<NodeRef> findTaggedNodes(String tag) public List<NodeRef> findTaggedNodes(String tag)
{ {
// Lower the case of the tag
tag = tag.toLowerCase();
// TODO // TODO
return null; return null;
} }
@@ -415,6 +430,9 @@ public class TaggingServiceImpl implements TaggingService
*/ */
public List<NodeRef> findTaggedNodes(String tag, TagScope tagScope) public List<NodeRef> findTaggedNodes(String tag, TagScope tagScope)
{ {
// Lower the case of the tag
tag = tag.toLowerCase();
// TODO // TODO
return null; return null;
} }

View File

@@ -64,9 +64,12 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest
private NodeRef document; private NodeRef document;
private NodeRef subDocument; private NodeRef subDocument;
private static final String TAG_1 = "tagOne"; private static final String TAG_1 = "tag one";
private static final String TAG_2 = "tagTwo"; private static final String TAG_2 = "tag two";
private static final String TAG_3 = "tagThree"; 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; private static boolean init = false;
@@ -173,6 +176,7 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest
// Create a tag // Create a tag
this.taggingService.createTag(TaggingServiceImplTest.storeRef, TAG_1); this.taggingService.createTag(TaggingServiceImplTest.storeRef, TAG_1);
this.taggingService.createTag(TaggingServiceImplTest.storeRef, UPPER_TAG);
setComplete(); setComplete();
endTransaction(); endTransaction();
@@ -183,13 +187,15 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest
// Get all the tags // Get all the tags
tags = this.taggingService.getTags(TaggingServiceImplTest.storeRef); tags = this.taggingService.getTags(TaggingServiceImplTest.storeRef);
assertNotNull(tags); assertNotNull(tags);
assertEquals(1, tags.size()); assertEquals(2, tags.size());
assertTrue(tags.contains(TAG_1)); assertTrue(tags.contains(TAG_1));
assertTrue(tags.contains(LOWER_TAG));
// Check isTag method // Check isTag method
assertFalse(this.taggingService.isTag(TaggingServiceImplTest.storeRef, TAG_2)); assertFalse(this.taggingService.isTag(TaggingServiceImplTest.storeRef, TAG_2));
assertTrue(this.taggingService.isTag(TaggingServiceImplTest.storeRef, TAG_1)); 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(); tx.commit();
} }
@@ -315,7 +321,7 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest
assertEquals(2, ts2.getTags().get(1).getTagCount()); assertEquals(2, ts2.getTags().get(1).getTagCount());
assertEquals(TAG_1, ts2.getTags().get(1).getTagName()); assertEquals(TAG_1, ts2.getTags().get(1).getTagName());
assertEquals(1, ts2.getTags().get(2).getTagCount()); 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(); tx.commit();
@@ -341,6 +347,8 @@ public class TaggingServiceImplTest extends BaseAlfrescoSpringTest
private void addTag(NodeRef nodeRef, String tag, int tagCount, NodeRef tagScopeNodeRef) private void addTag(NodeRef nodeRef, String tag, int tagCount, NodeRef tagScopeNodeRef)
throws Exception throws Exception
{ {
tag = tag.toLowerCase();
UserTransaction tx = this.transactionService.getUserTransaction(); UserTransaction tx = this.transactionService.getUserTransaction();
tx.begin(); tx.begin();

View File

@@ -24,12 +24,7 @@
*/ */
package org.alfresco.repo.thumbnail.script; package org.alfresco.repo.thumbnail.script;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension; 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.repo.thumbnail.ThumbnailDetails;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;