Package com.xpn.xwiki.plugin.tag
Class TagPluginApi
- java.lang.Object
-
- com.xpn.xwiki.api.Api
-
- com.xpn.xwiki.plugin.PluginApi<TagPlugin>
-
- com.xpn.xwiki.plugin.tag.TagPluginApi
-
-
Constructor Summary
Constructors Constructor Description TagPluginApi(TagPlugin plugin, XWikiContext context)XWiki Plugin API constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TagOperationResultaddTagsToDocument(String tags, String documentName)Add a list of tags to a document.TagOperationResultaddTagToDocument(String tag, String documentName)Add a tag to a document.TagOperationResultdeleteTag(String tag)Delete a tag from all the documents that contains it.List<String>getAllTags()Get tags within the wiki.List<String>getDocumentsWithTag(String tag)Get all the documents containing the given tag.Map<String,Integer>getTagCount()Get cardinality map of tags within the wiki.Map<String,Integer>getTagCount(String space)Get cardinality map of tags for a specific wiki space.Map<String,Integer>getTagCountForQuery(String from, String where)Get cardinality map of tags matching an hql query.Map<String,Integer>getTagCountForQuery(String from, String where, List<?> parameterValues)Get cardinality map of tags matching an hql query (parameterized version).Map<String,Integer>getTagCountForQuery(String from, String where, Map<String,?> parameters)Get cardinality map of tags matching an hql query (parameterized version).Map<String,Integer>getTagCountForSpaces(String spaces)Get cardinality map of tags for list wiki spaces.List<String>getTagsFromDocument(String documentName)Get tags from a document.TagOperationResultremoveTagFromDocument(String tag, String documentName)Remove a tag from a document.TagOperationResultrenameTag(String tag, String newTag)Rename a tag in all the documents that contains it.-
Methods inherited from class com.xpn.xwiki.plugin.PluginApi
getInternalPlugin, getProtectedPlugin, setPlugin
-
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
-
-
-
-
Constructor Detail
-
TagPluginApi
public TagPluginApi(TagPlugin plugin, XWikiContext context)
XWiki Plugin API constructor.- Parameters:
plugin- The wrapped plugin.context- The current request context.- See Also:
PluginApi(com.xpn.xwiki.plugin.XWikiPluginInterface, XWikiContext)
-
-
Method Detail
-
getAllTags
public List<String> getAllTags() throws XWikiException
Get tags within the wiki.- Returns:
- list of tags.
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, etc).
-
getTagCount
public Map<String,Integer> getTagCount() throws XWikiException
Get cardinality map of tags within the wiki.- Returns:
- map of tags with their occurences counts.
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, etc).
-
getTagCount
public Map<String,Integer> getTagCount(String space) throws XWikiException
Get cardinality map of tags for a specific wiki space.- Parameters:
space- the space to get tags in- Returns:
- map of tags with their occurences counts
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, etc).- Since:
- 1.2
-
getTagCountForSpaces
public Map<String,Integer> getTagCountForSpaces(String spaces) throws XWikiException
Get cardinality map of tags for list wiki spaces.- Parameters:
spaces- the list of space to get tags in, as a comma separated, quoted string- Returns:
- map of tags with their occurences counts
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, etc).- Since:
- 8.1
-
getTagCountForQuery
public Map<String,Integer> getTagCountForQuery(String from, String where) throws XWikiException
Get cardinality map of tags matching an hql query. Examples of usage:$xwiki.tag.getTagCountForQuery("","doc.creator='XWiki.JohnDoe'")will return the cardinality map of tags for documents created by user XWiki.JohnDoe$xwiki.tag.getTagCountForQuery(", BaseObject as obj", "obj.name=doc.fullName and obj.className='Blog.BlogPostClass'")will return the cardinality map of tags associated to blog post documents$xwiki.tag.getTagCountForQuery("", "")will return all tags within the wiki
- Parameters:
from- the from fragment of the querywhere- the where fragment from the query- Returns:
- map of tags with their occurrences counts
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, incorrect query fragments).- Since:
- 1.2
- See Also:
getTagCountForQuery(String, String, java.util.List)
-
getTagCountForQuery
public Map<String,Integer> getTagCountForQuery(String from, String where, List<?> parameterValues) throws XWikiException
Get cardinality map of tags matching an hql query (parameterized version). Example of usage:$xwiki.tag.getTagCountForQuery("", "doc.creator = ?1", ["$!{request.creator}"])will return the cardinality map of tags for documents created by user-provided creator name
- Parameters:
from- the from fragment of the querywhere- the parameterized where fragment from the queryparameterValues- list of parameter values for the query- Returns:
- map of tags with their occurrences counts
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, incorrect query fragments).- Since:
- 1.18
-
getTagCountForQuery
public Map<String,Integer> getTagCountForQuery(String from, String where, Map<String,?> parameters) throws XWikiException
Get cardinality map of tags matching an hql query (parameterized version). Example of usage:$xwiki.tag.getTagCountForQuery("", "doc.creator = :creator", {'creator' : "$!{request.creator}"})will return the cardinality map of tags for documents created by user-provided creator name
- Parameters:
from- the from fragment of the querywhere- the parameterized where fragment from the queryparameters- map of named parameters for the query- Returns:
- map of tags with their occurrences counts
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, incorrect query fragments).- Since:
- 11.7RC1
-
getDocumentsWithTag
public List<String> getDocumentsWithTag(String tag) throws XWikiException
Get all the documents containing the given tag.- Parameters:
tag- tag to match.- Returns:
- list of pages.
- Throws:
XWikiException- if search query fails (possible failures: DB access problems, etc).
-
getTagsFromDocument
public List<String> getTagsFromDocument(String documentName) throws XWikiException
Get tags from a document.- Parameters:
documentName- name of the document.- Returns:
- list of tags.
- Throws:
XWikiException- if document read fails (possible failures: insufficient rights, DB access problems, etc).
-
addTagToDocument
public TagOperationResult addTagToDocument(String tag, String documentName)
Add a tag to a document. The document is saved (minor edit) after this operation.- Parameters:
tag- tag to set.documentName- name of the document.- Returns:
- the
resultof the operation
-
addTagsToDocument
public TagOperationResult addTagsToDocument(String tags, String documentName)
Add a list of tags to a document. The document is saved (minor edit) after this operation- Parameters:
tags- the comma separated list of tags to set; whitespace around the tags is strippeddocumentName- the name of the target document- Returns:
- the
resultof the operation.TagOperationResult.NO_EFFECTis returned only if all the tags were already set on the document,TagOperationResult.OKis returned even if only some of the tags are new.
-
removeTagFromDocument
public TagOperationResult removeTagFromDocument(String tag, String documentName)
Remove a tag from a document. The document is saved (minor edit) after this operation.- Parameters:
tag- tag to remove.documentName- name of the document.- Returns:
- the
resultof the operation
-
renameTag
public TagOperationResult renameTag(String tag, String newTag)
Rename a tag in all the documents that contains it. Requires admin rights. Document containing this tag are saved (minor edit) during this operation.- Parameters:
tag- tag to rename.newTag- new tag.- Returns:
- the
resultof the operation
-
deleteTag
public TagOperationResult deleteTag(String tag)
Delete a tag from all the documents that contains it. Requires admin rights. Document containing this tag are saved (minor edit) during this operation.- Parameters:
tag- tag to delete.- Returns:
- the
resultof the operation
-
-