com.atlassian.confluence.labels
Interface LabelManager

All Known Implementing Classes:
DefaultLabelManager

public interface LabelManager

The label manager provides all that is necessary for interacting with labels.


Field Summary
static java.util.List CONTENT_TYPES
          Content Types that can have a label applied.
static int DEFAULT_LABEL_COUNT
           
static java.lang.String FAVOURITE_LABEL
           
static java.lang.String FAVOURITE_LABEL_YANKEE
           
static int LABEL_ADDED
          Indicates that a label was added.
static int LABEL_CREATED
          Indicates that a label was created.
static int LABEL_DELETED
          Indicates that a label was deleted.
static int LABEL_REMOVED
          Indicates that a label was removed.
static int NO_CHANGE
          Indicates no change.
 
Method Summary
 int addLabel(ContentEntityObject content, Label label)
          Add a label to the specified content.
 Label createLabel(Label label)
           
 boolean deleteLabel(Label l)
          Delete the specified label.
 boolean deleteLabel(long id)
          Delete the label with the specified id.
 java.util.List getContent(Label label)
           
 int getContentCount(Label label)
           
 java.util.List<ContentEntityObject> getContentForAllLabels(java.util.Collection<Label> labels, int maxResults, int offset)
          Retrieve all ContentEntityObjects which are labelled with ALL provided labels.
 java.util.List<ContentEntityObject> getContentForLabel(Label label, int maxResults)
          Get all content associated with a label Get all versions of content associated with a label and any space.
 java.util.List getCurrentContentForLabel(Label label)
          Get all content associated with a label and space Get all current content associated with a label and any space.
 java.util.List getCurrentContentForLabelAndSpace(Label label, java.lang.String spaceKey)
          Get all current content associated with a label and space.
 java.util.List getCurrentContentWithPersonalLabel(java.lang.String username)
          Get all current content labelled by a user
 java.util.List getFavouriteSpaces(java.lang.String username)
           
 Label getLabel(Label label)
          Retrieve the persistent instance of the label with the exact same details as the specified label.
 Label getLabel(long id)
          Retrieve the label with the specified id.
 Label getLabel(ParsedLabelName parsedLabelName)
          Retrieve the label by name.
 Label getLabel(java.lang.String unparsedLabelName)
          convenience method to fetch a label without having to call the label parser
 java.util.List getLabels(java.util.Collection unparsedLabelNames)
          convenience method to fetch labels without having to call the label parser
 java.util.List getLabelsByDetail(java.lang.String labelName, java.lang.String namespace, java.lang.String spaceKey, java.lang.String owner)
          Retrieves the labels matching the given labelName, namespace or owner
 java.util.List getLabelsInSpace(java.lang.String key)
          Retrieve all of the labels that label content within the specified space.
 java.util.List getMostPopularLabels()
          Retrieve the list of the DEFAULT_LABEL_COUNT most popular labels within the system.
 java.util.List getMostPopularLabels(int maxResults)
          Retrieve the most popular labels within the system.
 java.util.List getMostPopularLabelsInSpace(java.lang.String key)
          Retrieve the list of the DEFAULT_LABEL_COUNT most used labels in the specific space, ordered from most popular to least popular.
 java.util.List getMostPopularLabelsInSpace(java.lang.String key, int maxResults)
          Retrieve a list of the 'n' most used labels in the specified space, ordered from most popular to least popular.
 java.util.Set getMostPopularLabelsWithRanks(java.util.Comparator comparator)
          Retrieve a set of the DEFAULT_LABEL_COUNT most popular labels within the system, including their ranks and ordered using the compartor provided.
 java.util.Set getMostPopularLabelsWithRanks(int maxResults, java.util.Comparator comparator)
          Retrieve the most popular labels within the system, including their ranks and ordered using the comparator provided.
 java.util.Set getMostPopularLabelsWithRanksInSpace(java.lang.String key, int maxResults, java.util.Comparator comparator)
          Retrieve a set of the 'n' most used labels in the specified space, ordered using the compartor given.
 java.util.List getRecentlyUsedLabellings(int maxResults)
           
 java.util.List getRecentlyUsedLabellingsInSpace(java.lang.String spaceKey, int maxResults)
           
 java.util.List getRecentlyUsedLabels()
          Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the system.
 java.util.List getRecentlyUsedLabels(int maxResults)
          Retrieve the x most recently used labels.
 java.util.List getRecentlyUsedLabelsInSpace(java.lang.String spaceKey)
          Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the specified space.
 java.util.List getRecentlyUsedLabelsInSpace(java.lang.String spaceKey, int maxResults)
          Retrieve the most recently used labels within the specified spae.
 java.util.List getRecentlyUsedPersonalLabellings(java.lang.String username, int maxResults)
           
 java.util.List getRecentlyUsedPersonalLabels(java.lang.String username)
          Retrieve the labels that were recently used by currently authenticated user.
 java.util.List getRecentlyUsedPersonalLabels(java.lang.String username, int maxResults)
          Retrieve the labels that were recently used by currently authenticated user.
 java.util.List getRelatedLabels(Label label)
          Retrieve the DEFAULT_LABEL_COUNT labels that are 'related' to the specified label.
 java.util.List getRelatedLabels(Label label, int maxResults)
          Retrieve the labels that are 'related' to the specified label.
 java.util.List getRelatedLabels(java.util.List labels, java.lang.String spaceKey, int maxResultsPerLabel)
          Retrieve the labels that are 'related' to the labels in the list.
 java.util.List getRelatedLabelsInSpace(Label label, java.lang.String spaceKey)
          Retrieve the DEFAULT_LABEL_COUNT labels that are 'related' to the specified label and that are used to label content within the specified space.
 java.util.List getRelatedLabelsInSpace(Label label, java.lang.String spaceKey, int maxResults)
          Retrieve the labels that are 'related' to the specified label and that are used to to label content within the specified space.
 java.util.List getSpacesContainingContentWithLabel(Label label)
          Look up the spaces that have been labelled by the specific label.
 java.util.List getSpacesWithLabel(Label label)
          Spaces cannot be directly labelled.
 java.util.List getSuggestedLabels(ContentEntityObject content)
          Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content.
 java.util.List getSuggestedLabels(ContentEntityObject content, int maxResults)
          Retrieve the suggested labels for the specified content.
 java.util.List getSuggestedLabelsInSpace(ContentEntityObject content, java.lang.String spaceKey)
          Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content bound to the specified space.
 java.util.List getSuggestedLabelsInSpace(ContentEntityObject content, java.lang.String spaceKey, int maxResults)
          Retrieve the suggested labels for the specified content bound to the specified space.
 java.util.List getTeamLabels()
          Retrieve all of the team labels in the system.
 java.util.List getTeamLabelsForSpace(java.lang.String spaceKey)
          Retrieve all of the team labels used to label content in the specified space.
 java.util.List getUsersLabels(java.lang.String owner)
          Retrieve the personal labels that belong to the specified user.
 void removeAllLabels(ContentEntityObject content)
          Remove all of the labels from the specified content.
 int removeLabel(ContentEntityObject object, Label label)
          Remove a label from the specified content.
 void removeLabels(ContentEntityObject object, java.util.List labels)
           
 

Field Detail

CONTENT_TYPES

static final java.util.List CONTENT_TYPES
Content Types that can have a label applied.


FAVOURITE_LABEL

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

FAVOURITE_LABEL_YANKEE

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

DEFAULT_LABEL_COUNT

static final int DEFAULT_LABEL_COUNT
See Also:
Constant Field Values

NO_CHANGE

static final int NO_CHANGE
Indicates no change.

See Also:
addLabel(com.atlassian.confluence.core.ContentEntityObject, Label), removeLabel(com.atlassian.confluence.core.ContentEntityObject, Label), Constant Field Values

LABEL_ADDED

static final int LABEL_ADDED
Indicates that a label was added.

See Also:
addLabel(com.atlassian.confluence.core.ContentEntityObject, Label), Constant Field Values

LABEL_CREATED

static final int LABEL_CREATED
Indicates that a label was created.

See Also:
addLabel(com.atlassian.confluence.core.ContentEntityObject, Label), Constant Field Values

LABEL_REMOVED

static final int LABEL_REMOVED
Indicates that a label was removed.

See Also:
removeLabel(com.atlassian.confluence.core.ContentEntityObject, Label), Constant Field Values

LABEL_DELETED

static final int LABEL_DELETED
Indicates that a label was deleted.

See Also:
removeLabel(com.atlassian.confluence.core.ContentEntityObject, Label), Constant Field Values
Method Detail

addLabel

int addLabel(ContentEntityObject content,
             Label label)
Add a label to the specified content.

Note: the specified label does not need to be persistent. A persistent instance of the label will be created if necessary. eg: you can write code like: labelManager.addLabel(page, new Label("name", "namespace", "owner"));

Parameters:
content -
label -
Returns:
one of NO_CHANGE, LABEL_ADDED or LABEL_CREATED

removeLabel

int removeLabel(ContentEntityObject object,
                Label label)
Remove a label from the specified content.

Parameters:
object -
label -
Returns:
one of NO_CHANGE, LABEL_DELETED, LABEL_REMOVED

removeLabels

void removeLabels(ContentEntityObject object,
                  java.util.List labels)

removeAllLabels

void removeAllLabels(ContentEntityObject content)
Remove all of the labels from the specified content. Any labels that then no longer label content will be deleted.

Parameters:
content -

deleteLabel

boolean deleteLabel(long id)
Delete the label with the specified id.

Parameters:
id -
Returns:
true if the label was deleted, false otherwise.

deleteLabel

boolean deleteLabel(Label l)
Delete the specified label.

NOTE: The specified label does note need to be the persistent instance of the label, it simply needs to uniquely identify the label.

Parameters:
l -
Returns:
true if the label was deleted, false otherwise.

getLabel

Label getLabel(long id)
Retrieve the label with the specified id.

Parameters:
id -
Returns:
the persistent instance of label with the specified id, or null if none exists.

getLabel

Label getLabel(ParsedLabelName parsedLabelName)
Retrieve the label by name.

Parameters:
parsedLabelName -
Returns:
a persistent instance of the label or null if it can not be found.
See Also:
for details on the format of the labelReference parameter.

getLabel

Label getLabel(java.lang.String unparsedLabelName)
convenience method to fetch a label without having to call the label parser

Parameters:
unparsedLabelName - - example - my:foo

getLabels

java.util.List getLabels(java.util.Collection unparsedLabelNames)
convenience method to fetch labels without having to call the label parser

Parameters:
unparsedLabelNames - - example - my:foo, bar

getLabel

Label getLabel(Label label)
Retrieve the persistent instance of the label with the exact same details as the specified label. Note, the specified label does not need to contain an id.

Parameters:
label -
Returns:
a persistent instance of the label, or null if it does not exist.

getLabelsByDetail

java.util.List getLabelsByDetail(java.lang.String labelName,
                                 java.lang.String namespace,
                                 java.lang.String spaceKey,
                                 java.lang.String owner)
Retrieves the labels matching the given labelName, namespace or owner

Parameters:
labelName - The name of the label (null to ignore)
namespace - The namespace of the labels (null to ignore)
spaceKey - The spaceKey to restrict by (null to ignore)
owner - The owner of the labels (null to ignore)
Returns:
a list of Label instances

getLabelsInSpace

java.util.List getLabelsInSpace(java.lang.String key)
Retrieve all of the labels that label content within the specified space.

Parameters:
key - identifying the space to be queried.
Returns:
a list of labels that appear in the space.

getMostPopularLabels

java.util.List getMostPopularLabels()
Retrieve the list of the DEFAULT_LABEL_COUNT most popular labels within the system.

Returns:
a list of label search result instances in order of their popularity.
See Also:
DEFAULT_LABEL_COUNT, LabelSearchResult

getMostPopularLabels

java.util.List getMostPopularLabels(int maxResults)
Retrieve the most popular labels within the system. The number of labels returned can be specified through the count parameter. If the count value is greater than the number of labels, then all labels will be returned.

This function does not return the labels itself, but wrapped into a search result with a count!

Parameters:
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label search result instances in order of their popularity.
See Also:
LabelSearchResult

getMostPopularLabelsInSpace

java.util.List getMostPopularLabelsInSpace(java.lang.String key)
Retrieve the list of the DEFAULT_LABEL_COUNT most used labels in the specific space, ordered from most popular to least popular.

This function does not return the labels itself, but wrapped into a search result with a count!

Parameters:
key - the space key
Returns:
a list of label search result instances in order of their popularity.
See Also:
DEFAULT_LABEL_COUNT, LabelSearchResult

getMostPopularLabelsInSpace

java.util.List getMostPopularLabelsInSpace(java.lang.String key,
                                           int maxResults)
Retrieve a list of the 'n' most used labels in the specified space, ordered from most popular to least popular.

This function does not return the labels itself, but wrapped into a search result with a count!

Parameters:
key - is the space key
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label search result instances in order of their popularity.
See Also:
LabelSearchResult

getMostPopularLabelsWithRanks

java.util.Set getMostPopularLabelsWithRanks(java.util.Comparator comparator)
Retrieve a set of the DEFAULT_LABEL_COUNT most popular labels within the system, including their ranks and ordered using the compartor provided.

Returns:
an ordered set of ranked label search result instances
See Also:
DEFAULT_LABEL_COUNT, RankedLabelSearchResult

getMostPopularLabelsWithRanks

java.util.Set getMostPopularLabelsWithRanks(int maxResults,
                                            java.util.Comparator comparator)
Retrieve the most popular labels within the system, including their ranks and ordered using the comparator provided. The number of labels returned can be specified through the count parameter. If the count value is greater than the number of labels, then all labels will be returned.

This function does not return the labels itself, but wrapped into a search result with a count!

Parameters:
maxResults - is the maximum number of labels to be returned.
Returns:
an ordered set of ranked label search result instances
See Also:
RankedLabelSearchResult

getMostPopularLabelsWithRanksInSpace

java.util.Set getMostPopularLabelsWithRanksInSpace(java.lang.String key,
                                                   int maxResults,
                                                   java.util.Comparator comparator)
Retrieve a set of the 'n' most used labels in the specified space, ordered using the compartor given.

This function does not return the labels itself, but wrapped into a search result with a count!

Parameters:
key - is the space key
maxResults - is the maximum number of labels to be returned.
Returns:
an ordered set of rankded label search result instances
See Also:
RankedLabelSearchResult

getRecentlyUsedLabels

java.util.List getRecentlyUsedLabels()
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the system.

Returns:
a list of label instances in order of most recently used to least recently used.
See Also:
DEFAULT_LABEL_COUNT

getRecentlyUsedLabels

java.util.List getRecentlyUsedLabels(int maxResults)
Retrieve the x most recently used labels.

Parameters:
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label instances in order of most recently used to least recently used.

getRecentlyUsedLabellings

java.util.List getRecentlyUsedLabellings(int maxResults)

getRecentlyUsedLabelsInSpace

java.util.List getRecentlyUsedLabelsInSpace(java.lang.String spaceKey)
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the specified space.

Parameters:
spaceKey - identifies the space to which the results are restricted.
Returns:
a list of label instances in order of most recently used to least recently used.
See Also:
DEFAULT_LABEL_COUNT

getRecentlyUsedLabelsInSpace

java.util.List getRecentlyUsedLabelsInSpace(java.lang.String spaceKey,
                                            int maxResults)
Retrieve the most recently used labels within the specified spae.

Parameters:
spaceKey -
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label instances in order of the most recently used to least recently used.

getRecentlyUsedLabellingsInSpace

java.util.List getRecentlyUsedLabellingsInSpace(java.lang.String spaceKey,
                                                int maxResults)

getSuggestedLabels

java.util.List getSuggestedLabels(ContentEntityObject content)
Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content. The process used to identify 'suggested' labels may change and therefore is not defined here.

Parameters:
content -
Returns:
a list of label instances. The order of these labels is undefined.
See Also:
DEFAULT_LABEL_COUNT

getSuggestedLabels

java.util.List getSuggestedLabels(ContentEntityObject content,
                                  int maxResults)
Retrieve the suggested labels for the specified content. The process used to identify 'suggested' labels may change and therefore is not defined here.

Parameters:
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label instances. The order of these labels is undefined.

getSuggestedLabelsInSpace

java.util.List getSuggestedLabelsInSpace(ContentEntityObject content,
                                         java.lang.String spaceKey)
Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content bound to the specified space.

Parameters:
content -
spaceKey -
Returns:
a list of label instances. The order of these labels is undefined.
See Also:
DEFAULT_LABEL_COUNT

getSuggestedLabelsInSpace

java.util.List getSuggestedLabelsInSpace(ContentEntityObject content,
                                         java.lang.String spaceKey,
                                         int maxResults)
Retrieve the suggested labels for the specified content bound to the specified space.

Parameters:
content -
spaceKey -
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label instances. The order of these labels is undefined.

getRelatedLabels

java.util.List getRelatedLabels(Label label)
Retrieve the DEFAULT_LABEL_COUNT labels that are 'related' to the specified label. The process used to identify 'related' labels may change and therefore is not define here.

Parameters:
label -
Returns:
a list of label instances. The order of these labels is undefined.
See Also:
DEFAULT_LABEL_COUNT

getRelatedLabels

java.util.List getRelatedLabels(Label label,
                                int maxResults)
Retrieve the labels that are 'related' to the specified label. The process used to identify 'related' labels may change and therefore is not defined here.

Parameters:
maxResults - is the maximum number of labels to be returned.
Returns:
a list of label instances. The order of these labels is undefined.

getRelatedLabels

java.util.List getRelatedLabels(java.util.List labels,
                                java.lang.String spaceKey,
                                int maxResultsPerLabel)
Retrieve the labels that are 'related' to the labels in the list. The process used to identify 'related' labels may change and therefore is not defined here.

Parameters:
spaceKey - - may be null to search globally
maxResultsPerLabel - is the maximum number of labels to be returned for each label.
Returns:
a list of label instances. The order of these labels is undefined.

getRelatedLabelsInSpace

java.util.List getRelatedLabelsInSpace(Label label,
                                       java.lang.String spaceKey)
Retrieve the DEFAULT_LABEL_COUNT labels that are 'related' to the specified label and that are used to label content within the specified space.

Parameters:
label -
spaceKey -
Returns:
a list of label instances. The order of these labels is undefined.
See Also:
DEFAULT_LABEL_COUNT

getRelatedLabelsInSpace

java.util.List getRelatedLabelsInSpace(Label label,
                                       java.lang.String spaceKey,
                                       int maxResults)
Retrieve the labels that are 'related' to the specified label and that are used to to label content within the specified space.

Parameters:
label -
spaceKey -
maxResults -
Returns:
a list of label instance. The order of these labels is undefined.

getSpacesContainingContentWithLabel

java.util.List getSpacesContainingContentWithLabel(Label label)
Look up the spaces that have been labelled by the specific label.

Parameters:
label -
Returns:
a list of Spaces. The order of these labels is undefined.

getUsersLabels

java.util.List getUsersLabels(java.lang.String owner)
Retrieve the personal labels that belong to the specified user.

Parameters:
owner -

getTeamLabels

java.util.List getTeamLabels()
Retrieve all of the team labels in the system.

Returns:
a list of labels with the namespace Namespace.TEAM

getTeamLabelsForSpace

java.util.List getTeamLabelsForSpace(java.lang.String spaceKey)
Retrieve all of the team labels used to label content in the specified space.

Parameters:
spaceKey -
Returns:
a list of team labels with the namespace Namespace.TEAM. The order of the list is undefined.

getCurrentContentForLabel

java.util.List getCurrentContentForLabel(Label label)
Get all content associated with a label and space Get all current content associated with a label and any space. Content in the trash will not be returned.

Returns:
a list of ContentEntityObjects

getContentForLabel

java.util.List<ContentEntityObject> getContentForLabel(Label label,
                                                       int maxResults)
Get all content associated with a label Get all versions of content associated with a label and any space. Content in the trash will not be returned.

Returns:
a list of ContentEntityObjects

getCurrentContentForLabelAndSpace

java.util.List getCurrentContentForLabelAndSpace(Label label,
                                                 java.lang.String spaceKey)
Get all current content associated with a label and space. Content in the trash will not be returned.

Returns:
a list of ContentEntityObjects

getCurrentContentWithPersonalLabel

java.util.List getCurrentContentWithPersonalLabel(java.lang.String username)
Get all current content labelled by a user


getSpacesWithLabel

java.util.List getSpacesWithLabel(Label label)
Spaces cannot be directly labelled. Howevever, their space descriptions can. This method searches for all space descriptions with the label passed in

Parameters:
label -
Returns:
list of spaces associated with matching space descriptions

getFavouriteSpaces

java.util.List getFavouriteSpaces(java.lang.String username)
Parameters:
username - username of label owner

getRecentlyUsedPersonalLabels

java.util.List getRecentlyUsedPersonalLabels(java.lang.String username)
Retrieve the labels that were recently used by currently authenticated user. 'Recently Used' includes labels that the user recently added, created, removed and deleted.

Note: labels in this list may or may not exist.

The UserHistory can be retrieved from the session via the ActionContext (if using an action) or the Execution Context (DWR)

Parameters:
username - the user history from the session
Returns:
a list of labels

getRecentlyUsedPersonalLabels

java.util.List getRecentlyUsedPersonalLabels(java.lang.String username,
                                             int maxResults)
Retrieve the labels that were recently used by currently authenticated user. 'Recently Used' includes labels that the user recently added, created, removed and deleted.

Note: labels in this list may or may not exist.

The UserHistory can be retrieved from the session via the ActionContext (if using an action) or the Execution Context (DWR)

Parameters:
maxResults - the maximum number of results to return to the user
username - the user history from the session
Returns:
a list of labels

getRecentlyUsedPersonalLabellings

java.util.List getRecentlyUsedPersonalLabellings(java.lang.String username,
                                                 int maxResults)

getContent

java.util.List getContent(Label label)

getContentCount

int getContentCount(Label label)

createLabel

Label createLabel(Label label)

getContentForAllLabels

java.util.List<ContentEntityObject> getContentForAllLabels(java.util.Collection<Label> labels,
                                                           int maxResults,
                                                           int offset)
Retrieve all ContentEntityObjects which are labelled with ALL provided labels.

Parameters:
labels - labels which must appear on ContentEntityObjects
maxResults - the maximum number of results to return
offset - the offset into the results
Returns:
a list of ContentEntityObjects labelled with the labels provided


Copyright © 2003-2010 Atlassian. All Rights Reserved.