From 5cab4a5e9c2cc05bddb57561dda114abf529e56d Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 10 Jul 2008 14:24:32 +0000 Subject: [PATCH] Tagging Service: fixed issue when using scriptNode.save() with tagging API git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9722 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/repo/jscript/ScriptNode.java | 15 +++++++++++++++ .../repo/tagging/script/test_taggingService.js | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index da76a9bc8f..5208c71f3b 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -2034,6 +2034,7 @@ public class ScriptNode implements Serializable, Scopeable public void clearTags() { this.services.getTaggingService().clearTags(this.nodeRef); + updateTagProperty(); } /** @@ -2044,6 +2045,7 @@ public class ScriptNode implements Serializable, Scopeable public void addTag(String tag) { this.services.getTaggingService().addTag(this.nodeRef, tag); + updateTagProperty(); } /** @@ -2054,6 +2056,7 @@ public class ScriptNode implements Serializable, Scopeable public void addTags(String[] tags) { this.services.getTaggingService().addTags(this.nodeRef, Arrays.asList(tags)); + updateTagProperty(); } /** @@ -2064,6 +2067,7 @@ public class ScriptNode implements Serializable, Scopeable public void removeTag(String tag) { this.services.getTaggingService().removeTag(this.nodeRef, tag); + updateTagProperty(); } /** @@ -2074,6 +2078,7 @@ public class ScriptNode implements Serializable, Scopeable public void removeTags(String[] tags) { this.services.getTaggingService().removeTags(this.nodeRef, Arrays.asList(tags)); + updateTagProperty(); } /** @@ -2096,6 +2101,16 @@ public class ScriptNode implements Serializable, Scopeable public void setTags(String[] tags) { this.services.getTaggingService().setTags(this.nodeRef, Arrays.asList(tags)); + updateTagProperty(); + } + + private void updateTagProperty() + { + Serializable tags = this.services.getNodeService().getProperty(this.nodeRef, ContentModel.PROP_TAGS); + if (this.properties != null) + { + this.properties.put(ContentModel.PROP_TAGS.toString(), getValueConverter().convertValueForScript(ContentModel.PROP_TAGS, tags)); + } } /** diff --git a/source/java/org/alfresco/repo/tagging/script/test_taggingService.js b/source/java/org/alfresco/repo/tagging/script/test_taggingService.js index 0eb37b70cf..1e8dc44c7a 100644 --- a/source/java/org/alfresco/repo/tagging/script/test_taggingService.js +++ b/source/java/org/alfresco/repo/tagging/script/test_taggingService.js @@ -16,9 +16,11 @@ function testAddRemoveTag() test.assertNotNull(tags); test.assertEquals(0, tags.length); + document.properties.title = "A change is as good as a rest!"; document.addTag("mouse"); document.addTag("snake"); document.addTag("snail"); + document.save(); tags = document.tags; test.assertNotNull(tags); @@ -32,7 +34,8 @@ function testAddRemoveTag() test.assertEquals(2, tags.length); document.tags = ["moo", "quack", "squeak"]; - + document.properties.title = "A change is as good as a rest!"; + document.save(); tags = document.tags; test.assertNotNull(tags); test.assertEquals(3, tags.length);