public interface LabelManager
The label manager provides all that is necessary for interacting with labels.
Modifier and Type | Field and Description |
---|---|
static List<String> |
CONTENT_TYPES
Content Types that can have a label applied.
|
static int |
DEFAULT_LABEL_COUNT |
static String |
FAVOURITE_LABEL |
static 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.
|
static int |
NO_MAX_RESULTS
Indicates no maximum (i.e.
|
static int |
NO_OFFSET
Indicates zero offset to methods accepting an 'offset' parameter.
|
Modifier and Type | Method and Description |
---|---|
int |
addLabel(Labelable content,
Label label)
Add a label to the specified content.
|
Set<RankedLiteLabelSearchResult> |
calculateRanksForLiteLabels(List<LiteLabelSearchResult> labelList,
Comparator<? super RankedLiteLabelSearchResult> comparator)
Calculate ranks for input labels.
|
Label |
createLabel(Label label) |
boolean |
deleteLabel(Label l)
Delete the specified label.
|
boolean |
deleteLabel(long id)
Delete the label with the specified id.
|
PartialList<ContentEntityObject> |
getAllContentForAllLabels(int offset,
int maxResults,
Label... labels)
Retrieve all ContentEntityObjects, current or deleted which are labelled with ALL provided labels.
|
PartialList<ContentEntityObject> |
getAllContentForLabel(int offset,
int maxResults,
Label label)
Retrieve all ContentEntityObjects, current or deleted which are labelled with the provided label.
|
List |
getContent(Label label)
Deprecated.
since 5.3. Use a method like
getContentForLabel(int, int, Label) that provides a specific return type. |
int |
getContentCount(Label label) |
List<? extends Labelable> |
getContentForAllLabels(Collection<Label> labels,
int maxResults,
int offset)
Deprecated.
since 5.3. Use
getContentForAllLabels(int, int, Label...) instead. |
PartialList<ContentEntityObject> |
getContentForAllLabels(int offset,
int maxResults,
Label... labels)
Retrieve current ContentEntityObjects which are labelled with ALL provided labels.
|
PartialList<ContentEntityObject> |
getContentForLabel(int offset,
int maxResults,
Label label)
Retrieve current ContentEntityObjects which are labelled with the provided label.
|
PartialList<ContentEntityObject> |
getContentInSpaceForAllLabels(int offset,
int maxResults,
String spaceKey,
Label... labels)
Retrieve current ContentEntityObjects in the given space which are labelled with ALL provided labels.
|
PartialList<ContentEntityObject> |
getContentInSpaceForLabel(int offset,
int maxResults,
String spaceKey,
Label label)
Retrieve current ContentEntityObjects in the given space which are labelled with the provided label.
|
PartialList<ContentEntityObject> |
getContentInSpacesForAllLabels(int offset,
int maxResults,
Set<String> spaceKeys,
Label... labels)
Retrieve current ContentEntityObjects in the given spaces which are labelled with ALL provided labels.
|
List<? extends Labelable> |
getCurrentContentForLabel(Label label)
Deprecated.
since 5.3. Use
getContentForLabel(int, int, Label) . |
List<? extends Labelable> |
getCurrentContentForLabelAndSpace(Label label,
String spaceKey)
Deprecated.
since 5.3. Use the
getContentInSpaceForLabel(int, int, String, Label) . |
List<? extends Labelable> |
getCurrentContentWithPersonalLabel(String username)
Get all current content labelled by a user
|
List<Labelling> |
getFavouriteLabellingsByContentIds(Collection<ContentId> contentIds,
com.atlassian.sal.api.user.UserKey userKey)
Get the labellings that represent the favourite labellings for the given user on the given content.
|
List<Space> |
getFavouriteSpaces(String username) |
<T extends EditableLabelable> |
getForLabel(Class<T> labelableClass,
int offset,
int maxResults,
Label label)
Retrieve EditableLabelables of the supplied type which are labelled with the provided label.
|
<T extends EditableLabelable> |
getForLabels(Class<T> labelableClass,
int offset,
int maxResults,
Label... labels)
Retrieve EditableLabelables of the supplied type which are labelled with the provided labels.
|
PartialList<EditableLabelable> |
getForLabels(int offset,
int maxResults,
Label... labels)
Retrieve EditableLabelables of any type which are labelled with the provided labels.
|
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(String unparsedLabelName)
convenience method to fetch a label without having to call the label parser
|
Label |
getLabel(String labelName,
Namespace namespace)
Convenience method to fetch a label without having to create a Label object
|
List<Label> |
getLabels(Collection<String> unparsedLabelNames)
convenience method to fetch labels without having to call the label parser
|
List<Label> |
getLabelsByDetail(String labelName,
String namespace,
String spaceKey,
String owner)
Retrieves the labels matching the given labelName, namespace or owner
|
List<Label> |
getLabelsInSpace(String key)
Retrieve all of the labels that label content within the specified space.
|
List<LabelSearchResult> |
getMostPopularLabels()
Retrieve the list of the DEFAULT_LABEL_COUNT most popular labels within the system.
|
List<LabelSearchResult> |
getMostPopularLabels(int maxResults)
Retrieve the most popular labels within the system.
|
List<LiteLabelSearchResult> |
getMostPopularLabelsInSiteLite(int maxResults)
Returns most used labels across the site.
|
List<LabelSearchResult> |
getMostPopularLabelsInSpace(String key)
Retrieve the list of the DEFAULT_LABEL_COUNT most used labels in the specific space, ordered from most
popular to least popular.
|
List<LabelSearchResult> |
getMostPopularLabelsInSpace(String key,
int maxResults)
Retrieve a list of the 'n' most used labels in the specified space, ordered from most popular to least
popular.
|
List<LiteLabelSearchResult> |
getMostPopularLabelsInSpaceLite(String spaceKey,
int maxResults)
Returns most used labels.
|
Set<RankedLabelSearchResult> |
getMostPopularLabelsWithRanks(Comparator<? super RankedLabelSearchResult> comparator)
Retrieve a set of the DEFAULT_LABEL_COUNT most popular labels within the system, including their ranks and
ordered using the compartor provided.
|
Set<RankedLabelSearchResult> |
getMostPopularLabelsWithRanks(int maxResults,
Comparator<? super RankedLabelSearchResult> comparator)
Retrieve the most popular labels within the system, including their ranks and ordered using the comparator
provided.
|
Set<RankedLabelSearchResult> |
getMostPopularLabelsWithRanksInSpace(String key,
int maxResults,
Comparator<? super RankedLabelSearchResult> comparator)
Retrieve a set of the 'n' most used labels in the specified space, ordered using the compartor given.
|
List<Labelling> |
getRecentlyUsedLabellings(int maxResults) |
List<Labelling> |
getRecentlyUsedLabellingsInSpace(String spaceKey,
int maxResults) |
List<Label> |
getRecentlyUsedLabels()
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the system.
|
List<Label> |
getRecentlyUsedLabels(int maxResults)
Retrieve the x most recently used labels.
|
List<Label> |
getRecentlyUsedLabelsInSpace(String spaceKey)
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the specified space.
|
List<Label> |
getRecentlyUsedLabelsInSpace(String spaceKey,
int maxResults)
Retrieve the most recently used labels within the specified spae.
|
List<Labelling> |
getRecentlyUsedPersonalLabellings(String username,
int maxResults) |
List<Label> |
getRecentlyUsedPersonalLabels(String username)
Retrieve the labels that were recently used by currently authenticated user.
|
List<Label> |
getRecentlyUsedPersonalLabels(String username,
int maxResults)
Retrieve the labels that were recently used by currently authenticated user.
|
List<Label> |
getRelatedLabels(Label label)
Retrieve the DEFAULT_LABEL_COUNT labels that are 'related' to the specified label.
|
List<Label> |
getRelatedLabels(Label label,
int maxResults)
Retrieve the labels that are 'related' to the specified label.
|
List<Label> |
getRelatedLabels(List<? extends Label> labels,
String spaceKey,
int maxResultsPerLabel)
Retrieve the labels that are 'related' to the labels in the list.
|
List<Label> |
getRelatedLabelsInSpace(Label label,
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.
|
List<Label> |
getRelatedLabelsInSpace(Label label,
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.
|
List<Space> |
getSpacesContainingContentWithLabel(Label label)
Look up the spaces that have been labelled by the specific label.
|
List<Space> |
getSpacesWithLabel(Label label)
Spaces cannot be directly labelled.
|
List<Label> |
getSuggestedLabels(Labelable content)
Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content.
|
List<Label> |
getSuggestedLabels(Labelable content,
int maxResults)
Retrieve the suggested labels for the specified content.
|
List<Label> |
getSuggestedLabelsInSpace(Labelable content,
String spaceKey)
Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content bound to the specified space.
|
List<Label> |
getSuggestedLabelsInSpace(Labelable content,
String spaceKey,
int maxResults)
Retrieve the suggested labels for the specified content bound to the specified space.
|
List<Label> |
getTeamLabels()
Retrieve all of the team labels in the system.
|
default List<Label> |
getTeamLabels(String name)
Retrieve all of the team labels in the system with name.
|
List<Label> |
getTeamLabelsForSpace(String spaceKey)
Retrieve all of the team labels used to label content in the specified space.
|
List<Label> |
getTeamLabelsForSpaces(Collection<Space> spaces)
Retrieve all of the team labels used to label content in the specified spaces.
|
List<Label> |
getUsersLabels(String owner)
Retrieve the personal labels that belong to the specified user.
|
void |
removeAllLabels(Labelable content)
Remove all of the labels from the specified content.
|
int |
removeLabel(Labelable object,
Label label)
Remove a label from the specified content.
|
void |
removeLabels(Labelable object,
List labels)
removes a list of labels from the labelable object
|
static final String FAVOURITE_LABEL
static final String FAVOURITE_LABEL_YANKEE
static final int DEFAULT_LABEL_COUNT
static final int NO_CHANGE
static final int LABEL_ADDED
addLabel(Labelable, Label)
,
Constant Field Valuesstatic final int LABEL_CREATED
addLabel(Labelable, Label)
,
Constant Field Valuesstatic final int LABEL_REMOVED
static final int LABEL_DELETED
static final int NO_OFFSET
static final int NO_MAX_RESULTS
int addLabel(Labelable content, Label label)
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"));
content
- label
- int removeLabel(Labelable object, Label label)
object
- label
- void removeLabels(Labelable object, List labels)
void removeAllLabels(Labelable content)
content
- boolean deleteLabel(long id)
id
- boolean deleteLabel(Label l)
NOTE: The specified label does note need to be the persistent instance of the label, it simply needs to uniquely identify the label.
l
- Label getLabel(long id)
id
- Label getLabel(ParsedLabelName parsedLabelName)
parsedLabelName
- for details on the format of the labelReference parameter.
Label getLabel(String unparsedLabelName)
unparsedLabelName
- - example - my:fooList<Label> getLabels(Collection<String> unparsedLabelNames)
unparsedLabelNames
- - example - my:foo, barLabel getLabel(Label label)
label
- Label getLabel(String labelName, Namespace namespace)
labelName
- The label namenamespace
- The namespace of the labelList<Label> getLabelsByDetail(String labelName, String namespace, String spaceKey, String owner)
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)List<Label> getLabelsInSpace(String key)
key
- identifying the space to be queried.List<LabelSearchResult> getMostPopularLabels()
DEFAULT_LABEL_COUNT
,
LabelSearchResult
List<LabelSearchResult> getMostPopularLabels(int maxResults)
This function does not return the labels itself, but wrapped into a search result with a count!
maxResults
- is the maximum number of labels to be returned.LabelSearchResult
List<LabelSearchResult> getMostPopularLabelsInSpace(String key)
This function does not return the labels itself, but wrapped into a search result with a count!
key
- the space keyDEFAULT_LABEL_COUNT
,
LabelSearchResult
List<LabelSearchResult> getMostPopularLabelsInSpace(String key, int maxResults)
This function does not return the labels itself, but wrapped into a search result with a count!
key
- is the space keymaxResults
- is the maximum number of labels to be returned.LabelSearchResult
Set<RankedLabelSearchResult> getMostPopularLabelsWithRanks(Comparator<? super RankedLabelSearchResult> comparator)
DEFAULT_LABEL_COUNT
,
RankedLabelSearchResult
Set<RankedLabelSearchResult> getMostPopularLabelsWithRanks(int maxResults, Comparator<? super RankedLabelSearchResult> comparator)
This function does not return the labels itself, but wrapped into a search result with a count!
maxResults
- is the maximum number of labels to be returned.RankedLabelSearchResult
Set<RankedLabelSearchResult> getMostPopularLabelsWithRanksInSpace(String key, int maxResults, Comparator<? super RankedLabelSearchResult> comparator)
This function does not return the labels itself, but wrapped into a search result with a count!
key
- is the space keymaxResults
- is the maximum number of labels to be returned.RankedLabelSearchResult
List<Label> getRecentlyUsedLabels()
DEFAULT_LABEL_COUNT
List<Label> getRecentlyUsedLabels(int maxResults)
maxResults
- is the maximum number of labels to be returned.List<Label> getRecentlyUsedLabelsInSpace(String spaceKey)
spaceKey
- identifies the space to which the results are restricted.DEFAULT_LABEL_COUNT
List<Label> getRecentlyUsedLabelsInSpace(String spaceKey, int maxResults)
spaceKey
- maxResults
- is the maximum number of labels to be returned.List<Labelling> getRecentlyUsedLabellingsInSpace(String spaceKey, int maxResults)
List<Label> getSuggestedLabels(Labelable content)
content
- DEFAULT_LABEL_COUNT
List<Label> getSuggestedLabels(Labelable content, int maxResults)
maxResults
- is the maximum number of labels to be returned.List<Label> getSuggestedLabelsInSpace(Labelable content, String spaceKey)
content
- spaceKey
- DEFAULT_LABEL_COUNT
List<Label> getSuggestedLabelsInSpace(Labelable content, String spaceKey, int maxResults)
content
- spaceKey
- maxResults
- is the maximum number of labels to be returned.List<Label> getRelatedLabels(Label label)
label
- DEFAULT_LABEL_COUNT
List<Label> getRelatedLabels(Label label, int maxResults)
maxResults
- is the maximum number of labels to be returned.List<Label> getRelatedLabels(List<? extends Label> labels, String spaceKey, int maxResultsPerLabel)
spaceKey
- - may be null to search globallymaxResultsPerLabel
- is the maximum number of labels to be returned for each label.List<Label> getRelatedLabelsInSpace(Label label, String spaceKey)
label
- spaceKey
- DEFAULT_LABEL_COUNT
List<Label> getRelatedLabelsInSpace(Label label, String spaceKey, int maxResults)
label
- spaceKey
- maxResults
- List<Space> getSpacesContainingContentWithLabel(Label label)
label
- List<Label> getUsersLabels(String owner)
owner
- List<Label> getTeamLabels()
default List<Label> getTeamLabels(String name)
List<Label> getTeamLabelsForSpace(String spaceKey)
spaceKey
- List<Label> getTeamLabelsForSpaces(Collection<Space> spaces)
spaces
- collection of spaces whose labels to get@Deprecated List<? extends Labelable> getCurrentContentForLabel(Label label)
getContentForLabel(int, int, Label)
.@Deprecated List<? extends Labelable> getCurrentContentForLabelAndSpace(Label label, String spaceKey)
getContentInSpaceForLabel(int, int, String, Label)
.List<? extends Labelable> getCurrentContentWithPersonalLabel(String username)
List<Space> getSpacesWithLabel(Label label)
label
- List<Space> getFavouriteSpaces(String username)
username
- username of label ownerList<Labelling> getFavouriteLabellingsByContentIds(Collection<ContentId> contentIds, com.atlassian.sal.api.user.UserKey userKey)
contentIds
- the contentIds to get favourite labellings foruserKey
- the key of the user to get favourite labellings forList<Label> getRecentlyUsedPersonalLabels(String username)
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)
username
- the user history from the sessionList<Label> getRecentlyUsedPersonalLabels(String username, int maxResults)
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)
maxResults
- the maximum number of results to return to the userusername
- the user history from the sessionList<Labelling> getRecentlyUsedPersonalLabellings(String username, int maxResults)
@Deprecated List getContent(Label label)
getContentForLabel(int, int, Label)
that provides a specific return type.int getContentCount(Label label)
@Deprecated List<? extends Labelable> getContentForAllLabels(Collection<Label> labels, int maxResults, int offset)
getContentForAllLabels(int, int, Label...)
instead.PartialList<ContentEntityObject> getContentForLabel(int offset, int maxResults, Label label)
ContentEntityObjects in the Trash will *not* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on ContentEntityObjects<T extends EditableLabelable> PartialList<T> getForLabel(Class<T> labelableClass, int offset, int maxResults, Label label)
ContentEntityObjects in the Trash *will* be returned.
labelableClass
- the type of labelable to return. Use one of these values:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on labelables<T extends EditableLabelable> PartialList<T> getForLabels(Class<T> labelableClass, int offset, int maxResults, Label... labels)
ContentEntityObjects in the Trash will *not* be returned.
labelableClass
- the type of labelable to return. Use one of these values:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must all appear on labelablesPartialList<EditableLabelable> getForLabels(int offset, int maxResults, Label... labels)
ContentEntityObjects in the Trash *will* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must all appear on labelablesPartialList<ContentEntityObject> getContentForAllLabels(int offset, int maxResults, Label... labels)
ContentEntityObjects in the Trash will *not* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must appear on ContentEntityObjectsPartialList<ContentEntityObject> getContentInSpaceForLabel(int offset, int maxResults, String spaceKey, Label label)
ContentEntityObjects in the Trash will *not* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnspaceKey
- the key of the space to search content inlabel
- label which must appear on ContentEntityObjectsPartialList<ContentEntityObject> getContentInSpaceForAllLabels(int offset, int maxResults, String spaceKey, Label... labels)
ContentEntityObjects in the Trash will *not* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnspaceKey
- the key of the space to search content inlabels
- labels which must appear on ContentEntityObjectsPartialList<ContentEntityObject> getContentInSpacesForAllLabels(int offset, int maxResults, Set<String> spaceKeys, Label... labels)
ContentEntityObjects in the Trash will *not* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnspaceKeys
- the keys of the spaces to search content inlabels
- labels which must appear on ContentEntityObjectsPartialList<ContentEntityObject> getAllContentForLabel(int offset, int maxResults, Label label)
ContentEntityObjects in the Trash *will* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on ContentEntityObjectsPartialList<ContentEntityObject> getAllContentForAllLabels(int offset, int maxResults, Label... labels)
ContentEntityObjects in the Trash *will* be returned.
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must appear on ContentEntityObjects@ExperimentalApi List<LiteLabelSearchResult> getMostPopularLabelsInSpaceLite(String spaceKey, int maxResults)
spaceKey
- - space keymaxResults
- - limit@ExperimentalApi List<LiteLabelSearchResult> getMostPopularLabelsInSiteLite(int maxResults)
maxResults
- - max results@ExperimentalApi Set<RankedLiteLabelSearchResult> calculateRanksForLiteLabels(List<LiteLabelSearchResult> labelList, Comparator<? super RankedLiteLabelSearchResult> comparator)
labelList
- - list of labelscomparator
- - comparatorCopyright © 2003–2021 Atlassian. All rights reserved.