public class TagPlugin extends XWikiDefaultPlugin implements XWikiPluginInterface
Modifier and Type | Field and Description |
---|---|
static String |
DOC_COMMENT_TAG_ADDED
L10N key for the "tag added" document edit comment.
|
static org.slf4j.Logger |
LOGGER
Logging helper object.
|
static String |
PLUGIN_NAME
The identifier for this plugin; used for accessing the plugin from velocity, and as the action returning the
extension content.
|
static String |
TAG_CLASS
XWiki class defining tags.
|
static String |
TAG_PROPERTY
XWiki property of XWiki.TagClass storing tags.
|
Constructor and Description |
---|
TagPlugin(String name,
String className,
XWikiContext context)
Tag plugin constructor.
|
Modifier and Type | Method and Description |
---|---|
TagOperationResult |
addTagsToDocument(String tags,
String documentName,
XWikiContext context)
Add a list of tags to a document.
|
TagOperationResult |
addTagsToDocument(String tags,
XWikiDocument document,
XWikiContext context)
Add a list of tags to a document.
|
TagOperationResult |
addTagToDocument(String tag,
String documentName,
XWikiContext context)
Add a tag to a document.
|
TagOperationResult |
addTagToDocument(String tag,
XWikiDocument document,
XWikiContext context)
Add a tag to a document.
|
protected TagOperationResult |
deleteTag(String tag,
XWikiContext context)
Delete a tag.
|
List<String> |
getAllTags(XWikiContext context)
Get all tags within the wiki.
|
List<String> |
getDocumentsWithTag(String tag,
boolean includeHiddenDocuments,
XWikiContext context)
Get documents with the given tags.
|
List<String> |
getDocumentsWithTag(String tag,
XWikiContext context)
Get non-hidden documents with the given tags.
|
Api |
getPluginApi(XWikiPluginInterface plugin,
XWikiContext context) |
Map<String,Integer> |
getTagCount(String spaceReference,
XWikiContext context)
Get cardinality map of tags for a specific wiki space (including sub spaces).
|
Map<String,Integer> |
getTagCount(XWikiContext context)
Get cardinality map of tags within the wiki.
|
Map<String,Integer> |
getTagCountForQuery(String fromHql,
String whereHql,
List<?> parameterValues,
XWikiContext context)
Get cardinality map of tags matching a parameterized hql query.
|
Map<String,Integer> |
getTagCountForQuery(String fromHql,
String whereHql,
Map<String,?> parameters,
XWikiContext context)
Get cardinality map of tags matching a parameterized hql query.
|
Map<String,Integer> |
getTagCountForQuery(String fromHql,
String whereHql,
XWikiContext context)
Get cardinality map of tags matching a hql query.
|
Map<String,Integer> |
getTagCountForSpaces(String spaces,
XWikiContext context)
Get cardinality map of tags for a list of wiki spaces (including sub spaces).
|
List<String> |
getTagsFromDocument(String documentName,
XWikiContext context)
Get tags from a document.
|
List<String> |
getTagsFromDocument(XWikiDocument document,
XWikiContext context)
Get tags from a document.
|
TagOperationResult |
removeTagFromDocument(String tag,
String documentName,
XWikiContext context)
Remove a tag from a document.
|
TagOperationResult |
removeTagFromDocument(String tag,
XWikiDocument document,
XWikiContext context)
Remove a tag from a document.
|
protected TagOperationResult |
renameTag(String tag,
String newTag,
XWikiContext context)
Rename a tag.
|
beginParsing, beginRendering, commonTagsHandler, downloadAttachment, endParsing, endRendering, endRenderingHandler, flushCache, flushCache, getClassName, getLocalization, getName, init, insidePREHandler, localizePlainOrKey, outsidePREHandler, setClassName, setName, startRenderingHandler, virtualInit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
beginParsing, beginRendering, commonTagsHandler, downloadAttachment, endParsing, endRendering, endRenderingHandler, flushCache, getName, init, insidePREHandler, outsidePREHandler, startRenderingHandler, virtualInit
public static final org.slf4j.Logger LOGGER
public static final String PLUGIN_NAME
public static final String TAG_CLASS
public static final String TAG_PROPERTY
public static final String DOC_COMMENT_TAG_ADDED
public TagPlugin(String name, String className, XWikiContext context)
name
- The name of the plugin, which can be used for retrieving the plugin API from velocity. Unused.className
- The canonical classname of the plugin. Unused.context
- The current request context.XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
getPluginApi
in interface XWikiPluginInterface
getPluginApi
in class XWikiDefaultPlugin
public List<String> getAllTags(XWikiContext context) throws XWikiException
context
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).public Map<String,Integer> getTagCount(XWikiContext context) throws XWikiException
context
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).public Map<String,Integer> getTagCount(String spaceReference, XWikiContext context) throws XWikiException
spaceReference
- the local reference of the space to get tags from. If blank, return tags for the whole
wiki.context
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).public Map<String,Integer> getTagCountForSpaces(String spaces, XWikiContext context) throws XWikiException
spaces
- the list of space to get tags in, as a comma separated, quoted space references strings.context
- XWiki context.XWikiException
- if search query fails (possible failures: space list parse error, DB problems, etc).public Map<String,Integer> getTagCountForQuery(String fromHql, String whereHql, XWikiContext context) throws XWikiException
fromHql
- the from
fragment of the hql querywhereHql
- the where
fragment of the hql querycontext
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).TagPluginApi.getTagCountForQuery(String, String)
public Map<String,Integer> getTagCountForQuery(String fromHql, String whereHql, List<?> parameterValues, XWikiContext context) throws XWikiException
fromHql
- the from
fragment of the hql querywhereHql
- the where
fragment of the hql queryparameterValues
- list of parameter values for the querycontext
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).TagPluginApi.getTagCountForQuery(String, String, java.util.List)
public Map<String,Integer> getTagCountForQuery(String fromHql, String whereHql, Map<String,?> parameters, XWikiContext context) throws XWikiException
fromHql
- the from
fragment of the hql querywhereHql
- the where
fragment of the hql queryparameters
- map of named parameters for the querycontext
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).TagPluginApi.getTagCountForQuery(String, String, java.util.List)
public List<String> getDocumentsWithTag(String tag, XWikiContext context) throws XWikiException
tag
- a list of tags to match.context
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).public List<String> getDocumentsWithTag(String tag, boolean includeHiddenDocuments, XWikiContext context) throws XWikiException
tag
- a list of tags to match.includeHiddenDocuments
- if true then also include hidden documentscontext
- XWiki context.XWikiException
- if search query fails (possible failures: DB access problems, etc).public List<String> getTagsFromDocument(String documentName, XWikiContext context) throws XWikiException
documentName
- name of the document.context
- XWiki context.XWikiException
- if document read fails (possible failures: insufficient rights, DB access problems, etc).public List<String> getTagsFromDocument(XWikiDocument document, XWikiContext context) throws XWikiException
document
- the document.context
- XWiki context.XWikiException
- if document read fails (possible failures: insufficient rights, DB access problems, etc).public TagOperationResult addTagToDocument(String tag, String documentName, XWikiContext context) throws XWikiException
tag
- tag to set.documentName
- name of the document.context
- XWiki context.result
of the operationXWikiException
- if document save fails (possible failures: insufficient rights, DB access problems, etc).public TagOperationResult addTagToDocument(String tag, XWikiDocument document, XWikiContext context) throws XWikiException
tag
- tag to set.document
- the document.context
- XWiki context.result
of the operationXWikiException
- if document save fails (possible failures: insufficient rights, DB access problems, etc).public TagOperationResult addTagsToDocument(String tags, String documentName, XWikiContext context) throws XWikiException
tags
- the comma separated list of tags to set; whitespace around the tags is strippeddocumentName
- the name of the target documentcontext
- the current request context.result
of the operation. TagOperationResult.NO_EFFECT
is returned
only if all the tags were already set on the document, TagOperationResult.OK
is returned even if
only some of the tags are new.XWikiException
- if document save fails (possible failures: insufficient rights, DB access problems, etc).public TagOperationResult addTagsToDocument(String tags, XWikiDocument document, XWikiContext context) throws XWikiException
tags
- the comma separated list of tags to set; whitespace around the tags is strippeddocument
- the target documentcontext
- the current request contextresult
of the operation. TagOperationResult.NO_EFFECT
is returned
only if all the tags were already set on the document, TagOperationResult.OK
is returned even if
only some of the tags are new.XWikiException
- if document save fails (possible failures: insufficient rights, DB access problems, etc).public TagOperationResult removeTagFromDocument(String tag, String documentName, XWikiContext context) throws XWikiException
tag
- tag to remove.documentName
- name of the document.context
- XWiki context.result
of the operationXWikiException
- if document save fails for some reason (Insufficient rights, DB access, etc).public TagOperationResult removeTagFromDocument(String tag, XWikiDocument document, XWikiContext context) throws XWikiException
tag
- tag to remove.document
- the document.context
- XWiki context.result
of the operationXWikiException
- if document save fails for some reason (Insufficient rights, DB access, etc).protected TagOperationResult renameTag(String tag, String newTag, XWikiContext context) throws XWikiException
tag
- tag to rename.newTag
- new tag.context
- XWiki context.result
of the operationXWikiException
- if document save fails for some reason (Insufficient rights, DB access, etc).protected TagOperationResult deleteTag(String tag, XWikiContext context) throws XWikiException
tag
- tag to delete.context
- XWiki context.result
of the operationXWikiException
- if document save fails for some reason (Insufficient rights, DB access, etc).Copyright © 2004–2022 XWiki. All rights reserved.