Copyright© 2008-2022 Sitevision AB, all rights reserved.
@Requireable(value="TagUtil") public interface TagUtil
This sv:tag utility operates on taggable nodes of type: sv:page
, sv:article
, sv:sitePage
,
sv:collaborationGroupPage
, sv:file
and sv:image
.
Related: Use NodeResolverUtil.getTagsResolver()
to resolve sv:tag's from other node types
(e.g. sv:timelineEntry, sv:comment, sv:tagGroup etc). Use MetadataUtil
to set tag metadata.
Modifier and Type | Method and Description |
---|---|
void |
addTag(Node aTaggableNode,
Node aTagNode)
Adds a sv:tag to a Node.
|
void |
addTags(Node aTaggableNode,
Node... aTagNodes)
Adds multiple sv:tag to a Node.
|
Node |
getOrCreateTagByName(String aTagName)
Gets or creates a sv:tag Node by name.
|
Node |
getTagByName(String aTagName)
Gets a sv:tag Node by name.
|
List<Node> |
getTags(Node aTaggableNode)
Gets all sv:tag's for a Node.
|
boolean |
removeTag(Node aTaggableNode,
Node aTagNode)
Removes a sv:tag from a Node.
|
Node getTagByName(String aTagName) throws IllegalArgumentException
aTagName
- the tag name. Must not be null, whitespace-only or shebang-onlyIllegalArgumentException
- if aTagName is invalidNode getOrCreateTagByName(String aTagName) throws IllegalArgumentException, RepositoryException
Permission note: Current user must be authenticated (i.e. non-anonymous).
aTagName
- the tag name. Must not be null, whitespace-only or shebang-onlyIllegalArgumentException
- if aTagName is invalidRepositoryException
- if current user is anonymous or the sv:tag could not be found or createdvoid addTag(Node aTaggableNode, Node aTagNode) throws IllegalArgumentException, RepositoryException
Permission note: Current user must have WRITE
permission on the taggable Node that is mutated.
Versioning note: Mutation of the taggable Node is always executed in the
OFFLINE
version.
In other words - if you mutate the sv:tag entries on a sv:page, you must also
publish
the sv:page for changes to affect the
ONLINE/published
version.
aTaggableNode
- a taggable node (sv:page, sv:article, sv:sitePage, sv:collaborationGroupPage, sv:file or sv:image)aTagNode
- a sv:tagIllegalArgumentException
- if aTaggableNode or aTagNode is null or an unsupported typeRepositoryException
- if mutation is not allowed or failsvoid addTags(Node aTaggableNode, Node... aTagNodes) throws IllegalArgumentException, RepositoryException
Permission note: Current user must have WRITE
permission on the taggable Node that is mutated.
Versioning note: Mutation of the taggable Node is always executed in the
OFFLINE
version.
In other words - if you mutate the sv:tag entries on a sv:page, you must also
publish
the sv:page for changes to affect the
ONLINE/published
version.
Server-side Javascript example:
const tagUtil = require('TagUtil');
...
let tags = [];
tags.push(tagUtil.getOrCreateTagByName('mytag'));
tags.push(tagUtil.getOrCreateTagByName('myothertag'));
tagUtil.addTags(pageNode, tags);
aTaggableNode
- a taggable node (sv:page, sv:article, sv:sitePage, sv:collaborationGroupPage, sv:file or sv:image)aTagNodes
- a var-args array of sv:tag nodesIllegalArgumentException
- if aTaggableNode is null or an unsupported type,
or if or aTagNodes is null, empty or contains an unsupported typeRepositoryException
- if mutation is not allowed or failsboolean removeTag(Node aTaggableNode, Node aTagNode) throws IllegalArgumentException, RepositoryException
Permission note: Current user must have WRITE
permission on the taggable Node that is mutated.
Versioning note: Mutation of the taggable Node is always executed in the
OFFLINE
version.
In other words - if you mutate the sv:tag entries on a sv:page, you must also
publish
the sv:page for changes to affect the
ONLINE/published
version.
aTaggableNode
- a taggable node (sv:page, sv:article, sv:sitePage, sv:collaborationGroupPage, sv:file or sv:image)aTagNode
- a sv:tagIllegalArgumentException
- if aTaggableNode or aTagNode is null or an unsupported typeRepositoryException
- if mutation is not allowed or failsList<Node> getTags(Node aTaggableNode) throws IllegalArgumentException
Version note! This method executes in current version, i.e. it will return the list of sv:tag's
in current version (OFFLINE_VERSION
or
ONLINE_VERSION
).
aTaggableNode
- a taggable node (sv:page, sv:article, sv:sitePage, sv:collaborationGroupPage, sv:file or sv:image)IllegalArgumentException
- if aTaggableNode is null or an unsupported typeSitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.