mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
18383: ETHREEOH-4028: Tags added to the documents are not dispalyed in Tags pane git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18388 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -39,6 +39,8 @@ import java.util.Map;
|
|||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.node.NodeServicePolicies;
|
import org.alfresco.repo.node.NodeServicePolicies;
|
||||||
|
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||||
|
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||||
@@ -96,6 +98,10 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
/** Tag Details Delimiter */
|
/** Tag Details Delimiter */
|
||||||
private static final String TAG_DETAILS_DELIMITER = "|";
|
private static final String TAG_DETAILS_DELIMITER = "|";
|
||||||
|
|
||||||
|
/** Policy behaviour */
|
||||||
|
private JavaBehaviour updateTagBehaviour;
|
||||||
|
private JavaBehaviour createTagBehaviour;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cateogry service
|
* Set the cateogry service
|
||||||
*/
|
*/
|
||||||
@@ -162,6 +168,18 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||||
ContentModel.ASPECT_TAGGABLE,
|
ContentModel.ASPECT_TAGGABLE,
|
||||||
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT));
|
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT));
|
||||||
|
|
||||||
|
// Update tag behaviour
|
||||||
|
createTagBehaviour = new JavaBehaviour(this, "createTags", NotificationFrequency.FIRST_EVENT);
|
||||||
|
this.policyComponent.bindClassBehaviour(
|
||||||
|
OnCreateNodePolicy.QNAME,
|
||||||
|
ContentModel.ASPECT_TAGGABLE,
|
||||||
|
createTagBehaviour);
|
||||||
|
updateTagBehaviour = new JavaBehaviour(this, "updateTags", NotificationFrequency.EVERY_EVENT);
|
||||||
|
this.policyComponent.bindClassBehaviour(
|
||||||
|
OnUpdatePropertiesPolicy.QNAME,
|
||||||
|
ContentModel.TYPE_CONTENT,
|
||||||
|
updateTagBehaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,6 +209,70 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createTags(ChildAssociationRef childAssocRef)
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||||
|
Map<QName, Serializable> before = new HashMap<QName, Serializable>(0);
|
||||||
|
Map<QName, Serializable> after = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
|
updateTags(nodeRef, before, after);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update tag policy behaviour
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void updateTags(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||||
|
{
|
||||||
|
List<NodeRef> beforeNodeRefs = (List<NodeRef>)before.get(ContentModel.PROP_TAGS);
|
||||||
|
List<NodeRef> afterNodeRefs = (List<NodeRef>)after.get(ContentModel.PROP_TAGS);
|
||||||
|
|
||||||
|
if (beforeNodeRefs == null && afterNodeRefs != null)
|
||||||
|
{
|
||||||
|
// Queue all the after's for addition to the tag scopes
|
||||||
|
for (NodeRef afterNodeRef : afterNodeRefs)
|
||||||
|
{
|
||||||
|
String tagName = getTagName(afterNodeRef);
|
||||||
|
queueTagUpdate(nodeRef, tagName, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (afterNodeRefs == null && beforeNodeRefs != null)
|
||||||
|
{
|
||||||
|
// Queue all the before's for removal to the tag scope
|
||||||
|
for (NodeRef beforeNodeRef : beforeNodeRefs)
|
||||||
|
{
|
||||||
|
String tagName = getTagName(beforeNodeRef);
|
||||||
|
queueTagUpdate(nodeRef, tagName, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (afterNodeRefs != null && beforeNodeRefs != null)
|
||||||
|
{
|
||||||
|
for (NodeRef beforeNodeRef : beforeNodeRefs)
|
||||||
|
{
|
||||||
|
if (afterNodeRefs.contains(beforeNodeRef) == true)
|
||||||
|
{
|
||||||
|
// remove the node ref from the after list
|
||||||
|
afterNodeRefs.remove(beforeNodeRef);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String tagName = getTagName(beforeNodeRef);
|
||||||
|
queueTagUpdate(nodeRef, tagName, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (NodeRef afterNodeRef : afterNodeRefs)
|
||||||
|
{
|
||||||
|
String tagName = getTagName(afterNodeRef);
|
||||||
|
queueTagUpdate(nodeRef, tagName, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTagName(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
return (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.tagging.TaggingService#isTag(java.lang.String)
|
* @see org.alfresco.service.cmr.tagging.TaggingService#isTag(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@@ -270,6 +352,10 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void addTag(final NodeRef nodeRef, final String tagName)
|
public void addTag(final NodeRef nodeRef, final String tagName)
|
||||||
|
{
|
||||||
|
updateTagBehaviour.disable();
|
||||||
|
createTagBehaviour.disable();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Lower the case of the tag
|
// Lower the case of the tag
|
||||||
String tag = tagName.toLowerCase();
|
String tag = tagName.toLowerCase();
|
||||||
@@ -306,6 +392,12 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
queueTagUpdate(nodeRef, tag, true);
|
queueTagUpdate(nodeRef, tag, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
updateTagBehaviour.enable();
|
||||||
|
createTagBehaviour.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.tagging.TaggingService#addTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
* @see org.alfresco.service.cmr.tagging.TaggingService#addTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||||
@@ -346,6 +438,10 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void removeTag(NodeRef nodeRef, String tag)
|
public void removeTag(NodeRef nodeRef, String tag)
|
||||||
|
{
|
||||||
|
updateTagBehaviour.disable();
|
||||||
|
createTagBehaviour.disable();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Lower the case of the tag
|
// Lower the case of the tag
|
||||||
tag = tag.toLowerCase();
|
tag = tag.toLowerCase();
|
||||||
@@ -370,6 +466,12 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
updateTagBehaviour.enable();
|
||||||
|
createTagBehaviour.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.tagging.TaggingService#removeTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
* @see org.alfresco.service.cmr.tagging.TaggingService#removeTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||||
@@ -412,6 +514,10 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
* @see org.alfresco.service.cmr.tagging.TaggingService#setTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
* @see org.alfresco.service.cmr.tagging.TaggingService#setTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||||
*/
|
*/
|
||||||
public void setTags(NodeRef nodeRef, List<String> tags)
|
public void setTags(NodeRef nodeRef, List<String> tags)
|
||||||
|
{
|
||||||
|
updateTagBehaviour.disable();
|
||||||
|
createTagBehaviour.disable();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List<NodeRef> tagNodeRefs = new ArrayList<NodeRef>(tags.size());
|
List<NodeRef> tagNodeRefs = new ArrayList<NodeRef>(tags.size());
|
||||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == false)
|
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == false)
|
||||||
@@ -463,6 +569,12 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
// Update category property
|
// Update category property
|
||||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_TAGS, (Serializable)tagNodeRefs);
|
this.nodeService.setProperty(nodeRef, ContentModel.PROP_TAGS, (Serializable)tagNodeRefs);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
updateTagBehaviour.enable();
|
||||||
|
createTagBehaviour.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.service.cmr.tagging.TaggingService#clearTags(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.tagging.TaggingService#clearTags(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
@@ -722,6 +834,7 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
* @param updates
|
* @param updates
|
||||||
* @param async indicates whether the action is execute asynchronously
|
* @param async indicates whether the action is execute asynchronously
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void updateTagScope(NodeRef nodeRef, Map<String, Boolean> updates, boolean async)
|
private void updateTagScope(NodeRef nodeRef, Map<String, Boolean> updates, boolean async)
|
||||||
{
|
{
|
||||||
// The map must be serializable
|
// The map must be serializable
|
||||||
@@ -820,7 +933,6 @@ public class TaggingServiceImpl implements TaggingService,
|
|||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#flush()
|
* @see org.alfresco.repo.transaction.TransactionListener#flush()
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void flush()
|
public void flush()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user