org.alfresco.repo.tagging
Class TaggingServiceImpl

java.lang.Object
  extended by org.alfresco.repo.tagging.TaggingServiceImpl
All Implemented Interfaces:
CopyServicePolicies.BeforeCopyPolicy, CopyServicePolicies.OnCopyCompletePolicy, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnMoveNodePolicy, ClassPolicy, Policy, TransactionListener, TaggingService

public class TaggingServiceImpl
extends java.lang.Object
implements TaggingService, TransactionListener, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnMoveNodePolicy, CopyServicePolicies.OnCopyCompletePolicy, CopyServicePolicies.BeforeCopyPolicy

Tagging service implementation


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy
Policy.Arg
 
Field Summary
static java.lang.String TAG_UPDATES
           
protected static java.lang.String TAGGING_AUDIT_APPLICATION_NAME
           
protected static java.lang.String TAGGING_AUDIT_KEY_NODEREF
           
protected static java.lang.String TAGGING_AUDIT_KEY_TAGS
           
protected static java.lang.String TAGGING_AUDIT_ROOT_PATH
           
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.policy.Policy
NAMESPACE
 
Constructor Summary
TaggingServiceImpl()
           
 
Method Summary
 void addTag(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.lang.String tagName)
          Add a tag to a node.
 void addTags(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.List tags)
          Adds a list of tags to a node.
 void addTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Adds a tag scope to the specified node
 void afterCommit()
          Invoked after transaction commit.
 void afterRollback()
          Invoked after transaction rollback.
 void beforeCommit(boolean readOnly)
          Called before a transaction is committed.
 void beforeCompletion()
          Invoked before transaction commit/rollback.
 void beforeCopy(org.alfresco.service.namespace.QName classRef, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, org.alfresco.service.cmr.repository.NodeRef targetNodeRef)
          Fired once per node, before a copy overrides one node (which is possibly newly created) with the contents of another one.
 void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Called before a node is deleted.
 void clearTags(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Clears all tags from an already tagged node.
 org.alfresco.service.cmr.repository.NodeRef createTag(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String tag)
          Create a new tag
 void createTags(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
           
 void deleteTag(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String tag)
          Delete an existing tag
 java.util.List findAllTagScopes(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Finds all the tag scopes for the specified node.
 java.util.List findTaggedNodes(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String tag)
          Find all nodes that have been tagged with the specified tag.
 java.util.List findTaggedNodes(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String tag, org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Find all nodes that have been tagged with the specified tag and reside within the context of the node reference provided.
 TagScope findTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Finds the 'nearest' tag scope for the specified node.
 void flush()
           
 org.alfresco.service.cmr.repository.NodeRef getTagNodeRef(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String tag)
          Gets the node reference for a given tag.
 java.util.List getTags(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Get all the tags on a node
 java.util.List getTags(org.alfresco.service.cmr.repository.StoreRef storeRef)
          Get all the tags currently available
 java.util.List getTags(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String filter)
          Get all the tags currently available that match the provided filter.
 boolean hasTag(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.lang.String tag)
          Indicates whether a node has the specified tag or not.
 void init()
          Init method
 boolean isTag(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String tag)
          Indicates whether the tag already exists
 boolean isTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Indicates whether the node reference is a tag scope
 void onCopyComplete(org.alfresco.service.namespace.QName classRef, org.alfresco.service.cmr.repository.NodeRef sourceNodeRef, org.alfresco.service.cmr.repository.NodeRef targetNodeRef, boolean copyToNewNode, java.util.Map copyMap)
          Fired once per node that was copied, after the copy has completed.
 void onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef oldChildAssocRef, org.alfresco.service.cmr.repository.ChildAssociationRef newChildAssocRef)
          Called when a node has been moved.
 void refreshTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean async)
          Refreshes the tag count of the passed tag scope by recounting all the tags of the children of the scope.
 void removeTag(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.lang.String tag)
          Remove a tag from a node.
 void removeTags(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.List tags)
          Removes a list of tags from a node.
 void removeTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Removes a tag scope from a specified node.
 void setActionService(ActionService actionService)
          Set the action service
 void setAuditComponent(AuditComponent auditComponent)
          Set the audit component
 void setAuditService(AuditService auditService)
          Set the audit service
 void setCategoryService(CategoryService categoryService)
          Set the cateogry service
 void setContentService(ContentService contentService)
          Set the content service
 void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
          Set the namespace service
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
          Set the node service
 void setPolicyComponent(PolicyComponent policyComponent)
          Policy component
 void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
          Set the search service
 void setTags(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.List tags)
          Sets the list of tags that are applied to a node, replaces any existing tags with those provided.
 void updateTags(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.Map before, java.util.Map after)
          Update tag policy behaviour
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAGGING_AUDIT_APPLICATION_NAME

protected static final java.lang.String TAGGING_AUDIT_APPLICATION_NAME
See Also:
Constant Field Values

TAGGING_AUDIT_ROOT_PATH

protected static final java.lang.String TAGGING_AUDIT_ROOT_PATH
See Also:
Constant Field Values

TAGGING_AUDIT_KEY_NODEREF

protected static final java.lang.String TAGGING_AUDIT_KEY_NODEREF
See Also:
Constant Field Values

TAGGING_AUDIT_KEY_TAGS

protected static final java.lang.String TAGGING_AUDIT_KEY_TAGS
See Also:
Constant Field Values

TAG_UPDATES

public static final java.lang.String TAG_UPDATES
See Also:
Constant Field Values
Constructor Detail

TaggingServiceImpl

public TaggingServiceImpl()
Method Detail

setCategoryService

public void setCategoryService(CategoryService categoryService)
Set the cateogry service


setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Set the node service


setSearchService

public void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
Set the search service


setActionService

public void setActionService(ActionService actionService)
Set the action service


setContentService

public void setContentService(ContentService contentService)
Set the content service


setNamespaceService

public void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
Set the namespace service


setPolicyComponent

public void setPolicyComponent(PolicyComponent policyComponent)
Policy component


setAuditService

public void setAuditService(AuditService auditService)
Set the audit service


setAuditComponent

public void setAuditComponent(AuditComponent auditComponent)
Set the audit component


init

public void init()
Init method


beforeDeleteNode

public void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: NodeServicePolicies.BeforeDeleteNodePolicy
Called before a node is deleted.

Specified by:
beforeDeleteNode in interface NodeServicePolicies.BeforeDeleteNodePolicy
Parameters:
nodeRef - the node reference
See Also:
NodeServicePolicies.BeforeDeleteNodePolicy.beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)

beforeCopy

public void beforeCopy(org.alfresco.service.namespace.QName classRef,
                       org.alfresco.service.cmr.repository.NodeRef sourceNodeRef,
                       org.alfresco.service.cmr.repository.NodeRef targetNodeRef)
Fired once per node, before a copy overrides one node (which is possibly newly created) with the contents of another one. We should remove any tags from the scope, as they'll shortly be overwritten.

Specified by:
beforeCopy in interface CopyServicePolicies.BeforeCopyPolicy
Parameters:
classRef - the type of the node that will be copied
sourceNodeRef - the original node
targetNodeRef - the destination node

onCopyComplete

public void onCopyComplete(org.alfresco.service.namespace.QName classRef,
                           org.alfresco.service.cmr.repository.NodeRef sourceNodeRef,
                           org.alfresco.service.cmr.repository.NodeRef targetNodeRef,
                           boolean copyToNewNode,
                           java.util.Map copyMap)
Fired once per node that was copied, after the copy has completed. We need to add in all the tags to the scope.

Specified by:
onCopyComplete in interface CopyServicePolicies.OnCopyCompletePolicy
Parameters:
classRef - the type of the node that was copied
sourceNodeRef - the original node
targetNodeRef - the destination node
copyMap - a map containing all the nodes that have been created during the copy

onMoveNode

public void onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef oldChildAssocRef,
                       org.alfresco.service.cmr.repository.ChildAssociationRef newChildAssocRef)
Description copied from interface: NodeServicePolicies.OnMoveNodePolicy
Called when a node has been moved.

Specified by:
onMoveNode in interface NodeServicePolicies.OnMoveNodePolicy
Parameters:
oldChildAssocRef - the child association reference prior to the move
newChildAssocRef - the child association reference after the move

createTags

public void createTags(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)

updateTags

public void updateTags(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                       java.util.Map before,
                       java.util.Map after)
Update tag policy behaviour


isTag

public boolean isTag(org.alfresco.service.cmr.repository.StoreRef storeRef,
                     java.lang.String tag)
Description copied from interface: TaggingService
Indicates whether the tag already exists

Specified by:
isTag in interface TaggingService
Parameters:
storeRef - store reference
tag - tag name
Returns:
boolean true if the tag exists, false otherwise
See Also:
org.alfresco.service.cmr.tagging.TaggingService#isTag(java.lang.String)

createTag

public org.alfresco.service.cmr.repository.NodeRef createTag(org.alfresco.service.cmr.repository.StoreRef storeRef,
                                                             java.lang.String tag)
Description copied from interface: TaggingService
Create a new tag

Specified by:
createTag in interface TaggingService
Parameters:
storeRef - store reference
tag - tag name
See Also:
org.alfresco.service.cmr.tagging.TaggingService#createTag(java.lang.String)

deleteTag

public void deleteTag(org.alfresco.service.cmr.repository.StoreRef storeRef,
                      java.lang.String tag)
Description copied from interface: TaggingService
Delete an existing tag

Specified by:
deleteTag in interface TaggingService
Parameters:
storeRef - store reference
tag - tag name
See Also:
TaggingService.deleteTag(org.alfresco.service.cmr.repository.StoreRef, java.lang.String)

getTags

public java.util.List getTags(org.alfresco.service.cmr.repository.StoreRef storeRef)
Description copied from interface: TaggingService
Get all the tags currently available

Specified by:
getTags in interface TaggingService
Returns:
List list of tags
See Also:
org.alfresco.service.cmr.tagging.TaggingService#getTags()

getTags

public java.util.List getTags(org.alfresco.service.cmr.repository.StoreRef storeRef,
                              java.lang.String filter)
Description copied from interface: TaggingService
Get all the tags currently available that match the provided filter.

Specified by:
getTags in interface TaggingService
Parameters:
storeRef - store reference
filter - tag filter
Returns:
List list of tags
See Also:
TaggingService.getTags(org.alfresco.service.cmr.repository.StoreRef, java.lang.String)

hasTag

public boolean hasTag(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                      java.lang.String tag)
Description copied from interface: TaggingService
Indicates whether a node has the specified tag or not.

Specified by:
hasTag in interface TaggingService
Parameters:
nodeRef - node reference
tag - tag name
Returns:
boolean true if the node has the tag, false otherwise
See Also:
TaggingService.hasTag(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)

addTag

public void addTag(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                   java.lang.String tagName)
Description copied from interface: TaggingService
Add a tag to a node. Creating the tag if it does not already exist.

Specified by:
addTag in interface TaggingService
Parameters:
nodeRef - node reference
tagName - tag name
See Also:
TaggingService.addTag(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)

addTags

public void addTags(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                    java.util.List tags)
Description copied from interface: TaggingService
Adds a list of tags to a node.

Tags are created if they do not exist.

Specified by:
addTags in interface TaggingService
Parameters:
nodeRef - node reference
tags - list of tags
See Also:
TaggingService.addTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)

getTagNodeRef

public org.alfresco.service.cmr.repository.NodeRef getTagNodeRef(org.alfresco.service.cmr.repository.StoreRef storeRef,
                                                                 java.lang.String tag)
Gets the node reference for a given tag.

Returns null if tag is not present.

Specified by:
getTagNodeRef in interface TaggingService
Parameters:
storeRef - store reference
tag - tag
Returns:
NodeRef tag node reference or null not exist

removeTag

public void removeTag(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                      java.lang.String tag)
Description copied from interface: TaggingService
Remove a tag from a node.

Specified by:
removeTag in interface TaggingService
Parameters:
nodeRef - node reference
tag - tag name
See Also:
TaggingService.removeTag(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)

removeTags

public void removeTags(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                       java.util.List tags)
Description copied from interface: TaggingService
Removes a list of tags from a node.

Specified by:
removeTags in interface TaggingService
Parameters:
nodeRef - node reference
tags - list of tags
See Also:
TaggingService.removeTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)

getTags

public java.util.List getTags(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Get all the tags on a node

Specified by:
getTags in interface TaggingService
Parameters:
nodeRef - node reference
Returns:
List list of tags on the node
See Also:
TaggingService.getTags(org.alfresco.service.cmr.repository.NodeRef)

setTags

public void setTags(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                    java.util.List tags)
Description copied from interface: TaggingService
Sets the list of tags that are applied to a node, replaces any existing tags with those provided.

Specified by:
setTags in interface TaggingService
Parameters:
nodeRef - node reference
tags - list of tags
See Also:
TaggingService.setTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)

clearTags

public void clearTags(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Clears all tags from an already tagged node.

Specified by:
clearTags in interface TaggingService
Parameters:
nodeRef - node reference
See Also:
TaggingService.clearTags(org.alfresco.service.cmr.repository.NodeRef)

isTagScope

public boolean isTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Indicates whether the node reference is a tag scope

Specified by:
isTagScope in interface TaggingService
Parameters:
nodeRef - node reference
Returns:
boolean true if node is a tag scope, false otherwise
See Also:
TaggingService.isTagScope(org.alfresco.service.cmr.repository.NodeRef)

addTagScope

public void addTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Adds a tag scope to the specified node

Specified by:
addTagScope in interface TaggingService
Parameters:
nodeRef - node reference
See Also:
TaggingService.addTagScope(org.alfresco.service.cmr.repository.NodeRef)

refreshTagScope

public void refreshTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                            boolean async)
Description copied from interface: TaggingService
Refreshes the tag count of the passed tag scope by recounting all the tags of the children of the scope.

Specified by:
refreshTagScope in interface TaggingService
Parameters:
nodeRef - tag scope node reference
async - indicates whether the tag scope refresh should happen asynchronously or not
See Also:
org.alfresco.service.cmr.tagging.TaggingService#refreshTagScopt(org.alfresco.service.cmr.repository.NodeRef, boolean)

removeTagScope

public void removeTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Removes a tag scope from a specified node. Note that any tag count information will be lost when the scope if removed.

Specified by:
removeTagScope in interface TaggingService
Parameters:
nodeRef - node reference
See Also:
TaggingService.removeTagScope(org.alfresco.service.cmr.repository.NodeRef)

findTagScope

public TagScope findTagScope(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Finds the 'nearest' tag scope for the specified node.

The 'nearest' tag scope is discovered by walking up the primary parent path until a tag scope is found or the root node is reached.

If no tag scope if found then a null value is returned.

Specified by:
findTagScope in interface TaggingService
Parameters:
nodeRef - node reference
Returns:
the 'nearest' tag scope or null if none found
See Also:
TaggingService.findTagScope(org.alfresco.service.cmr.repository.NodeRef)

findAllTagScopes

public java.util.List findAllTagScopes(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Finds all the tag scopes for the specified node.

The resulting list of tag scopes is ordered with the 'nearest' at the bedining of the list.

If no tag scopes are found an empty list is returned.

Specified by:
findAllTagScopes in interface TaggingService
Parameters:
nodeRef - node reference
Returns:
List list of tag scopes
See Also:
TaggingService.findAllTagScopes(org.alfresco.service.cmr.repository.NodeRef)

findTaggedNodes

public java.util.List findTaggedNodes(org.alfresco.service.cmr.repository.StoreRef storeRef,
                                      java.lang.String tag)
Description copied from interface: TaggingService
Find all nodes that have been tagged with the specified tag.

Specified by:
findTaggedNodes in interface TaggingService
tag - tag name
Returns:
List list of nodes tagged with specified tag, empty of none found
See Also:
org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(java.lang.String)

findTaggedNodes

public java.util.List findTaggedNodes(org.alfresco.service.cmr.repository.StoreRef storeRef,
                                      java.lang.String tag,
                                      org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: TaggingService
Find all nodes that have been tagged with the specified tag and reside within the context of the node reference provided.

Specified by:
findTaggedNodes in interface TaggingService
tag - tag name
nodeRef - node providing context for the search
Returns:
List list of nodes tagged in the context specified, empty if none found
See Also:
org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)

afterCommit

public void afterCommit()
Description copied from interface: TransactionListener
Invoked after transaction commit.

Any exceptions generated here will cause the transaction to rollback.

Although all transaction resources are still available, this method should be used only for cleaning up resources after a commit has occured.

Specified by:
afterCommit in interface TransactionListener
See Also:
TransactionListener.afterCommit()

afterRollback

public void afterRollback()
Description copied from interface: TransactionListener
Invoked after transaction rollback.

Although all transaction resources are still available, this method should be used only for cleaning up resources after a rollback has occured.

Specified by:
afterRollback in interface TransactionListener
See Also:
TransactionListener.afterRollback()

beforeCommit

public void beforeCommit(boolean readOnly)
Description copied from interface: TransactionListener
Called before a transaction is committed.

All transaction resources are still available.

Specified by:
beforeCommit in interface TransactionListener
Parameters:
readOnly - true if the transaction is read-only
See Also:
TransactionListener.beforeCommit(boolean)

beforeCompletion

public void beforeCompletion()
Description copied from interface: TransactionListener
Invoked before transaction commit/rollback. Will be called after TransactionListener.beforeCommit(boolean) even if TransactionListener.beforeCommit(boolean) failed.

Any exceptions generated here will only be logged and will have no effect on the state of the transaction.

All transaction resources are still available.

Specified by:
beforeCompletion in interface TransactionListener
See Also:
TransactionListener.beforeCompletion()

flush

public void flush()
Specified by:
flush in interface TransactionListener
See Also:
TransactionListener.flush()


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.