Class TaggingServiceImpl
- All Implemented Interfaces:
CopyServicePolicies.BeforeCopyPolicy,CopyServicePolicies.OnCopyCompletePolicy,NodeServicePolicies.BeforeDeleteNodePolicy,NodeServicePolicies.OnMoveNodePolicy,ClassPolicy,Policy,TransactionListener,TaggingService,org.alfresco.util.transaction.TransactionListener
- Author:
- Roy Wetherall
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy
Policy.Arg -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields inherited from interface org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy
QNAMEFields inherited from interface org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy
QNAMEFields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy
QNAMEFields inherited from interface org.alfresco.service.cmr.tagging.TaggingService
TAG_ROOT_NODE_REF -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a tag to a node.Adds a list of tags to a node.voidaddTagScope(NodeRef nodeRef) Adds a tag scope to the specified nodevoidafterCheckOut(NodeRef workingCopy) voidInvoked after transaction commit.voidInvoked after transaction rollback.voidbeforeCommit(boolean readOnly) Called before a transaction is committed.voidInvoked before transaction commit/rollback.voidbeforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef) Fired once per node, before a copy overrides one node (which is possibly newly created) with the contents of another one.voidbeforeDeleteNode(NodeRef nodeRef) Called before a node is deleted.calculateCount(StoreRef storeRef) voidClears all tags from an already tagged node.Create a new tagvoidcreateTags(ChildAssociationRef childAssocRef) createTags(StoreRef storeRef, List<String> tagNames) Creates orphan tags.voidDelete an existing tag and any references to it(cascade delete).findAllTagScopes(NodeRef nodeRef) Finds all the tag scopes for the specified node.longfindCountByTagName(StoreRef storeRef, String name) Get the number of tagged nodes for a given tag.findTaggedNodes(StoreRef storeRef, String tag) Find all nodes that have been tagged with the specified tag.findTaggedNodes(StoreRef storeRef, String tag, NodeRef nodeRef) Find all nodes that have been tagged with the specified tag and reside within the context of the node reference provided.findTaggedNodesAndCountByTagName(StoreRef storeRef) Get tagged nodes and count of nodes group by tag namefindTagScope(NodeRef nodeRef) Finds the 'nearest' tag scope for the specified node.voidflush()getPagedTags(StoreRef storeRef, int fromTag, int pageSize) Get page of the tags currently availablegetPagedTags(StoreRef storeRef, String filter, int fromTag, int pageSize) getTagName(NodeRef nodeRef) getTagNodeRef(StoreRef storeRef, String tag) Gets the node reference for a given tag.Get all the tags on a nodeGet a paged list of all the tags on a nodeGet all the tags currently availableGet all the tags currently available that match the provided filter.getTags(StoreRef storeRef, List<String> parameterIncludes, Pair<String, Boolean> sorting, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter) Get a map of tag NodeRefs and their respective usage count filtered by name and sorted by tag name or countGet a paged list of all the tags currently availablegetTags(StoreRef storeRef, org.alfresco.query.PagingRequest pagingRequest, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter) Get a paged list of tags filtered by namebooleanIndicates whether a node has the specified tag or not.voidinit()Init methodbooleanIndicates whether the tag already existsbooleanisTagScope(NodeRef nodeRef) Indicates whether the node reference is a tag scopevoidonCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef, boolean copyToNewNode, Map<NodeRef, NodeRef> copyMap) Fired once per node that was copied, after the copy has completed.voidonMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) Called when a node has been moved.voidrefreshTagScope(NodeRef nodeRef, boolean async) Refreshes the tag count of the passed tag scope by recounting all the tags of the children of the scope.voidRemove a tag from a node.voidremoveTags(NodeRef nodeRef, List<String> tags) Removes a list of tags from a node.voidremoveTagScope(NodeRef nodeRef) Removes a tag scope from a specified node.voidsetActionService(ActionService actionService) Set the action servicevoidsetAuditComponent(AuditComponent auditComponent) Set the audit componentvoidsetCategoryService(CategoryService categoryService) Set the cateogry servicevoidsetContentService(ContentService contentService) Set the content servicevoidsetEventGenerator(EventGenerator eventGenerator) Set the event generator.voidsetNamespaceService(NamespaceService namespaceService) Set the namespace servicevoidsetNodeService(NodeService nodeService) Set the node servicevoidsetNodeServiceInternal(NodeService nodeServiceInternal) voidsetPolicyComponent(PolicyComponent policyComponent) Policy componentvoidsetSearchService(SearchService searchService) Set the search servicevoidSets the list of tags that are applied to a node, replaces any existing tags with those provided.voidupdateTags(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) Update tag policy behaviour
-
Field Details
-
TAGGING_AUDIT_APPLICATION_NAME
- See Also:
-
TAGGING_AUDIT_ROOT_PATH
- See Also:
-
TAGGING_AUDIT_KEY_NODEREF
- See Also:
-
TAGGING_AUDIT_KEY_TAGS
- See Also:
-
TAG_UPDATES
- See Also:
-
-
Constructor Details
-
TaggingServiceImpl
public TaggingServiceImpl()
-
-
Method Details
-
setCategoryService
Set the cateogry service -
setNodeService
Set the node service -
setNodeServiceInternal
- Parameters:
nodeServiceInternal- service to use when permission checks are not required
-
setSearchService
Set the search service -
setActionService
Set the action service -
setContentService
Set the content service -
setNamespaceService
Set the namespace service -
setPolicyComponent
Policy component -
setAuditComponent
Set the audit component -
setEventGenerator
Set the event generator.- Parameters:
eventGenerator-
-
init
public void init()Init method -
beforeDeleteNode
Description copied from interface:NodeServicePolicies.BeforeDeleteNodePolicyCalled before a node is deleted.- Specified by:
beforeDeleteNodein interfaceNodeServicePolicies.BeforeDeleteNodePolicy- Parameters:
nodeRef- the node reference- See Also:
-
beforeCopy
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:
beforeCopyin interfaceCopyServicePolicies.BeforeCopyPolicy- Parameters:
classRef- the type of the node that will be copiedsourceNodeRef- the original nodetargetNodeRef- the destination node
-
onCopyComplete
public void onCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef, boolean copyToNewNode, Map<NodeRef, NodeRef> 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:
onCopyCompletein interfaceCopyServicePolicies.OnCopyCompletePolicy- Parameters:
classRef- the type of the node that was copiedsourceNodeRef- the original nodetargetNodeRef- the destination nodecopyMap- a map containing all the nodes that have been created during the copy
-
onMoveNode
Description copied from interface:NodeServicePolicies.OnMoveNodePolicyCalled when a node has been moved.- Specified by:
onMoveNodein interfaceNodeServicePolicies.OnMoveNodePolicy- Parameters:
oldChildAssocRef- the child association reference prior to the movenewChildAssocRef- the child association reference after the move
-
createTags
-
updateTags
public void updateTags(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) Update tag policy behaviour -
getTagName
- Specified by:
getTagNamein interfaceTaggingService
-
isTag
Description copied from interface:TaggingServiceIndicates whether the tag already exists- Specified by:
isTagin interfaceTaggingService- Parameters:
storeRef- store referencetag- tag name- Returns:
- boolean true if the tag exists, false otherwise
- See Also:
-
createTag
Description copied from interface:TaggingServiceCreate a new tag- Specified by:
createTagin interfaceTaggingService- Parameters:
storeRef- store referencetag- tag name- See Also:
-
deleteTag
Description copied from interface:TaggingServiceDelete an existing tag and any references to it(cascade delete).- Specified by:
deleteTagin interfaceTaggingService- Parameters:
storeRef- store referencetag- tag name- See Also:
-
changeTag
- Specified by:
changeTagin interfaceTaggingService
-
getTags
Description copied from interface:TaggingServiceGet all the tags currently available- Specified by:
getTagsin interfaceTaggingService- Returns:
- list of tags
- See Also:
-
getPagedTags
Description copied from interface:TaggingServiceGet page of the tags currently available- Specified by:
getPagedTagsin interfaceTaggingService- Parameters:
storeRef- node referencefromTag- offsetpageSize- page size- Returns:
- pair of tag names and total count
-
getTags
Description copied from interface:TaggingServiceGet all the tags currently available that match the provided filter.- Specified by:
getTagsin interfaceTaggingService- Parameters:
storeRef- store referencefilter- tag filter- Returns:
- list of tags
- See Also:
-
getPagedTags
public Pair<List<String>,Integer> getPagedTags(StoreRef storeRef, String filter, int fromTag, int pageSize) - Specified by:
getPagedTagsin interfaceTaggingService- Parameters:
storeRef- node referencefilter- tag filterfromTag- page offsetpageSize- page size- Returns:
- pair of tag names and total count
-
calculateCount
- Specified by:
calculateCountin interfaceTaggingService- Returns:
- a map with each tag name and its usage count
-
hasTag
Description copied from interface:TaggingServiceIndicates whether a node has the specified tag or not.- Specified by:
hasTagin interfaceTaggingService- Parameters:
nodeRef- node referencetag- tag name- Returns:
- boolean true if the node has the tag, false otherwise
- See Also:
-
addTag
Description copied from interface:TaggingServiceAdd a tag to a node. Creating the tag if it does not already exist.- Specified by:
addTagin interfaceTaggingService- Parameters:
nodeRef- node referencetagName- tag name- See Also:
-
addTags
Description copied from interface:TaggingServiceAdds a list of tags to a node.Tags are created if they do not exist.
- Specified by:
addTagsin interfaceTaggingService- Parameters:
nodeRef- node referencetags- list of tags- See Also:
-
getTagNodeRef
Gets the node reference for a given tag.Returns null if tag is not present.
- Specified by:
getTagNodeRefin interfaceTaggingService- Parameters:
storeRef- store referencetag- tag- Returns:
- NodeRef tag node reference or null not exist
-
removeTag
Description copied from interface:TaggingServiceRemove a tag from a node.- Specified by:
removeTagin interfaceTaggingService- Parameters:
nodeRef- node referencetag- tag name- See Also:
-
removeTags
Description copied from interface:TaggingServiceRemoves a list of tags from a node.- Specified by:
removeTagsin interfaceTaggingService- Parameters:
nodeRef- node referencetags- list of tags- See Also:
-
getTags
public org.alfresco.query.PagingResults<Pair<NodeRef,String>> getTags(NodeRef nodeRef, org.alfresco.query.PagingRequest pagingRequest) Description copied from interface:TaggingServiceGet a paged list of all the tags on a node- Specified by:
getTagsin interfaceTaggingService- Parameters:
nodeRef- node reference- Returns:
- list of tags on the node
- See Also:
-
getTags
public org.alfresco.query.PagingResults<Pair<NodeRef,String>> getTags(StoreRef storeRef, org.alfresco.query.PagingRequest pagingRequest) Description copied from interface:TaggingServiceGet a paged list of all the tags currently available- Specified by:
getTagsin interfaceTaggingService- Parameters:
storeRef- StoreRefpagingRequest- PagingRequest- Returns:
- PagingResults
-
getTags
public org.alfresco.query.PagingResults<Pair<NodeRef,String>> getTags(StoreRef storeRef, org.alfresco.query.PagingRequest pagingRequest, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter) Description copied from interface:TaggingServiceGet a paged list of tags filtered by name- Specified by:
getTagsin interfaceTaggingService- Parameters:
storeRef- StoreRefpagingRequest- PagingRequestexactNamesFilter- PagingRequestalikeNamesFilter- PagingRequest- Returns:
- PagingResults
- See Also:
-
getTags
public Map<NodeRef,Long> getTags(StoreRef storeRef, List<String> parameterIncludes, Pair<String, Boolean> sorting, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter) Description copied from interface:TaggingServiceGet a map of tag NodeRefs and their respective usage count filtered by name and sorted by tag name or count- Specified by:
getTagsin interfaceTaggingService- Returns:
-
getTags
Description copied from interface:TaggingServiceGet all the tags on a node- Specified by:
getTagsin interfaceTaggingService- Parameters:
nodeRef- node reference- Returns:
- list of tags on the node
- See Also:
-
setTags
Description copied from interface:TaggingServiceSets the list of tags that are applied to a node, replaces any existing tags with those provided.- Specified by:
setTagsin interfaceTaggingService- Parameters:
nodeRef- node referencetags- list of tags- See Also:
-
clearTags
Description copied from interface:TaggingServiceClears all tags from an already tagged node.- Specified by:
clearTagsin interfaceTaggingService- Parameters:
nodeRef- node reference- See Also:
-
isTagScope
Description copied from interface:TaggingServiceIndicates whether the node reference is a tag scope- Specified by:
isTagScopein interfaceTaggingService- Parameters:
nodeRef- node reference- Returns:
- boolean true if node is a tag scope, false otherwise
- See Also:
-
addTagScope
Description copied from interface:TaggingServiceAdds a tag scope to the specified node- Specified by:
addTagScopein interfaceTaggingService- Parameters:
nodeRef- node reference- See Also:
-
refreshTagScope
Description copied from interface:TaggingServiceRefreshes the tag count of the passed tag scope by recounting all the tags of the children of the scope.- Specified by:
refreshTagScopein interfaceTaggingService- Parameters:
nodeRef- tag scope node referenceasync- indicates whether the tag scope refresh should happen asynchronously or not- See Also:
-
removeTagScope
Description copied from interface:TaggingServiceRemoves a tag scope from a specified node. Note that any tag count information will be lost when the scope if removed.- Specified by:
removeTagScopein interfaceTaggingService- Parameters:
nodeRef- node reference- See Also:
-
findTagScope
Description copied from interface:TaggingServiceFinds 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:
findTagScopein interfaceTaggingService- Parameters:
nodeRef- node reference- Returns:
- the 'nearest' tag scope or null if none found
- See Also:
-
findAllTagScopes
Description copied from interface:TaggingServiceFinds 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:
findAllTagScopesin interfaceTaggingService- Parameters:
nodeRef- node reference- Returns:
- list of tag scopes
- See Also:
-
findTaggedNodes
Description copied from interface:TaggingServiceFind all nodes that have been tagged with the specified tag.- Specified by:
findTaggedNodesin interfaceTaggingServicetag- tag name- Returns:
- list of nodes tagged with specified tag, empty of none found
- See Also:
-
findTaggedNodes
Description copied from interface:TaggingServiceFind all nodes that have been tagged with the specified tag and reside within the context of the node reference provided.- Specified by:
findTaggedNodesin interfaceTaggingServicetag- tag namenodeRef- node providing context for the search- Returns:
- list of nodes tagged in the context specified, empty if none found
- See Also:
-
afterCommit
public void afterCommit()Description copied from interface:TransactionListenerInvoked after transaction commit.Any exceptions generated here will only be logged and will have no effect on the state of the transaction.
Although all transaction resources are still available, this method should be used only for cleaning up resources after a commit has occured.
- Specified by:
afterCommitin interfaceTransactionListener- Specified by:
afterCommitin interfaceorg.alfresco.util.transaction.TransactionListener- See Also:
-
afterRollback
public void afterRollback()Description copied from interface:TransactionListenerInvoked after transaction rollback.Any exceptions generated here will only be logged and will have no effect on the state of the transaction.
Although all transaction resources are still available, this method should be used only for cleaning up resources after a rollback has occured.
- Specified by:
afterRollbackin interfaceTransactionListener- Specified by:
afterRollbackin interfaceorg.alfresco.util.transaction.TransactionListener- See Also:
-
beforeCommit
public void beforeCommit(boolean readOnly) Description copied from interface:TransactionListenerCalled before a transaction is committed.All transaction resources are still available.
- Specified by:
beforeCommitin interfaceTransactionListener- Specified by:
beforeCommitin interfaceorg.alfresco.util.transaction.TransactionListener- Parameters:
readOnly- true if the transaction is read-only- See Also:
-
beforeCompletion
public void beforeCompletion()Description copied from interface:TransactionListenerInvoked before transaction commit/rollback. Will be called afterTransactionListener.beforeCommit(boolean)even ifTransactionListener.beforeCommit(boolean)failed.All transaction resources are still available.
- Specified by:
beforeCompletionin interfaceTransactionListener- Specified by:
beforeCompletionin interfaceorg.alfresco.util.transaction.TransactionListener- See Also:
-
flush
public void flush()- Specified by:
flushin interfaceTransactionListener- See Also:
-
afterCheckOut
-
findTaggedNodesAndCountByTagName
Description copied from interface:TaggingServiceGet tagged nodes and count of nodes group by tag name- Specified by:
findTaggedNodesAndCountByTagNamein interfaceTaggingService- Returns:
- See Also:
-
findCountByTagName
Get the number of tagged nodes for a given tag.- Specified by:
findCountByTagNamein interfaceTaggingService- Parameters:
storeRef- The store containing the nodes.name- The name of the tag.- Returns:
- The number of nodes tagged with the specified tag.
-
createTags
Description copied from interface:TaggingServiceCreates orphan tags. Tag names case will be lowered.- Specified by:
createTagsin interfaceTaggingService- Parameters:
storeRef- Reference to node store.tagNames- List of tag names.- Returns:
ListofPairs of tag names and node references.
-