public class DefaultLabelManager extends Object implements LabelManagerInternal
CONTENT_TYPES, DEFAULT_LABEL_COUNT, FAVOURITE_LABEL, FAVOURITE_LABEL_YANKEE, LABEL_ADDED, LABEL_CREATED, LABEL_DELETED, LABEL_REMOVED, NO_CHANGE, NO_MAX_RESULTS, NO_OFFSET
Constructor and Description |
---|
DefaultLabelManager() |
Modifier and Type | Method and Description |
---|---|
int |
addLabel(Labelable labelable,
Label label)
Add a label to the specified content.
|
Label |
createLabel(Label label) |
boolean |
deleteLabel(Label label)
Delete the specified label.
|
boolean |
deleteLabel(long id)
Delete the label with the specified id.
|
PageResponse<Label> |
findGlobalLabelsByNamePrefix(String namePrefix,
LimitedRequest pageRequest)
Returns global-namespaced labels starting with the given string.
|
PageResponse<Label> |
findTeamLabelsByNamePrefix(String namePrefix,
LimitedRequest pageRequest)
Returns team-namespaced labels starting with the given string.
|
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)
Get all content associated with a label
Get all versions of content associated with a label and any space.
|
int |
getContentCount(Label label) |
List<? extends Labelable> |
getContentForAllLabels(Collection<Label> labels,
int maxResults,
int offset) |
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)
Get all content associated with a label and space
Get all current content associated with a label and any space.
|
List<? extends Labelable> |
getCurrentContentForLabelAndSpace(Label label,
String spaceKey)
Get all current content associated with a label and space.
|
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 a label based on its 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 count)
Retrieve the most popular labels within the system.
|
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 count)
Retrieve a list of the 'n' most used labels in the specified space, ordered from most popular to least
popular.
|
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 key)
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the specified space.
|
List<Label> |
getRecentlyUsedLabelsInSpace(String key,
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 count)
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 count)
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.
|
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 name)
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 content,
Label label)
Remove a label from the specified content.
|
void |
removeLabels(Labelable content,
List labels)
removes a list of labels from the labelable object
|
void |
setEventManager(com.atlassian.event.EventManager manager) |
void |
setIndexer(ConfluenceIndexer indexer) |
void |
setLabelDao(LabelDao dao) |
public void setLabelDao(LabelDao dao)
public void setEventManager(com.atlassian.event.EventManager manager)
public void setIndexer(ConfluenceIndexer indexer)
public int addLabel(Labelable labelable, Label label)
LabelManager
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"));
addLabel
in interface LabelManager
public int removeLabel(Labelable content, Label label)
LabelManager
removeLabel
in interface LabelManager
public void removeLabels(Labelable content, List labels)
LabelManager
removeLabels
in interface LabelManager
public void removeAllLabels(Labelable content)
LabelManager
removeAllLabels
in interface LabelManager
public Label getLabel(long id)
getLabel
in interface LabelManager
public List<Label> getSuggestedLabels(Labelable content)
LabelManager
getSuggestedLabels
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
public List<Label> getSuggestedLabels(Labelable content, int count)
LabelManager
getSuggestedLabels
in interface LabelManager
count
- is the maximum number of labels to be returned.public List<Label> getSuggestedLabelsInSpace(Labelable content, String spaceKey)
LabelManager
getSuggestedLabelsInSpace
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
public List<Label> getSuggestedLabelsInSpace(Labelable content, String spaceKey, int maxResults)
LabelManager
getSuggestedLabelsInSpace
in interface LabelManager
maxResults
- is the maximum number of labels to be returned.public List<Label> getRelatedLabels(Label label)
LabelManager
getRelatedLabels
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
public List<Label> getRelatedLabels(Label label, int count)
LabelManager
getRelatedLabels
in interface LabelManager
count
- is the maximum number of labels to be returned.public List<Label> getRelatedLabels(List<? extends Label> labels, String spaceKey, int maxResultsPerLabel)
LabelManager
getRelatedLabels
in interface LabelManager
spaceKey
- - may be null to search globallymaxResultsPerLabel
- is the maximum number of labels to be returned for each label.public List<Label> getRelatedLabelsInSpace(Label label, String spaceKey)
LabelManager
getRelatedLabelsInSpace
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
public List<Label> getRelatedLabelsInSpace(Label label, String spaceKey, int maxResults)
LabelManager
getRelatedLabelsInSpace
in interface LabelManager
public List<Space> getSpacesContainingContentWithLabel(Label label)
LabelManager
getSpacesContainingContentWithLabel
in interface LabelManager
public List<Label> getUsersLabels(String name)
LabelManager
getUsersLabels
in interface LabelManager
public List<Label> getTeamLabels()
LabelManager
getTeamLabels
in interface LabelManager
public List<Label> getTeamLabels(String name)
LabelManager
getTeamLabels
in interface LabelManager
public List<Label> getTeamLabelsForSpace(String spaceKey)
LabelManager
getTeamLabelsForSpace
in interface LabelManager
public List<Label> getTeamLabelsForSpaces(Collection<Space> spaces)
LabelManager
getTeamLabelsForSpaces
in interface LabelManager
spaces
- collection of spaces whose labels to getpublic List<Label> getRecentlyUsedLabelsInSpace(String key)
LabelManager
getRecentlyUsedLabelsInSpace
in interface LabelManager
key
- identifies the space to which the results are restricted.LabelManager.DEFAULT_LABEL_COUNT
public List<Label> getRecentlyUsedLabelsInSpace(String key, int maxResults)
LabelManager
getRecentlyUsedLabelsInSpace
in interface LabelManager
maxResults
- is the maximum number of labels to be returned.public List<Label> getRecentlyUsedLabels(int maxResults)
LabelManager
getRecentlyUsedLabels
in interface LabelManager
maxResults
- is the maximum number of labels to be returned.public List<Label> getRecentlyUsedLabels()
LabelManager
getRecentlyUsedLabels
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
public List<Label> getRecentlyUsedPersonalLabels(String username)
LabelManager
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)
getRecentlyUsedPersonalLabels
in interface LabelManager
username
- the user history from the sessionpublic List<Label> getRecentlyUsedPersonalLabels(String username, int maxResults)
LabelManager
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)
getRecentlyUsedPersonalLabels
in interface LabelManager
username
- the user history from the sessionmaxResults
- the maximum number of results to return to the userpublic List<Labelling> getRecentlyUsedPersonalLabellings(String username, int maxResults)
getRecentlyUsedPersonalLabellings
in interface LabelManager
public List<? extends Labelable> getCurrentContentForLabel(Label label)
LabelManager
getCurrentContentForLabel
in interface LabelManager
public List<? extends Labelable> getContentForAllLabels(Collection<Label> labels, int maxResults, int offset)
getContentForAllLabels
in interface LabelManager
public PartialList<ContentEntityObject> getContentForLabel(int offset, int maxResults, Label label)
LabelManager
ContentEntityObjects in the Trash will *not* be returned.
getContentForLabel
in interface LabelManager
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on ContentEntityObjectspublic PartialList<ContentEntityObject> getContentForAllLabels(int offset, int maxResults, Label... labels)
LabelManager
ContentEntityObjects in the Trash will *not* be returned.
getContentForAllLabels
in interface LabelManager
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must appear on ContentEntityObjectspublic <T extends EditableLabelable> PartialList<T> getForLabel(Class<T> labelableClass, int offset, int maxResults, Label label)
LabelManager
ContentEntityObjects in the Trash *will* be returned.
getForLabel
in interface LabelManager
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 labelablespublic <T extends EditableLabelable> PartialList<T> getForLabels(Class<T> labelableClass, int offset, int maxResults, Label... labels)
LabelManager
ContentEntityObjects in the Trash will *not* be returned.
getForLabels
in interface LabelManager
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 labelablespublic PartialList<EditableLabelable> getForLabels(int offset, int maxResults, Label... labels)
LabelManager
ContentEntityObjects in the Trash *will* be returned.
getForLabels
in interface LabelManager
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must all appear on labelablespublic PartialList<ContentEntityObject> getContentInSpaceForLabel(int offset, int maxResults, String spaceKey, Label label)
LabelManager
ContentEntityObjects in the Trash will *not* be returned.
getContentInSpaceForLabel
in interface LabelManager
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 ContentEntityObjectspublic PartialList<ContentEntityObject> getContentInSpaceForAllLabels(int offset, int maxResults, String spaceKey, Label... labels)
LabelManager
ContentEntityObjects in the Trash will *not* be returned.
getContentInSpaceForAllLabels
in interface LabelManager
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 ContentEntityObjectspublic PartialList<ContentEntityObject> getContentInSpacesForAllLabels(int offset, int maxResults, Set<String> spaceKeys, Label... labels)
LabelManager
ContentEntityObjects in the Trash will *not* be returned.
getContentInSpacesForAllLabels
in interface LabelManager
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 ContentEntityObjectspublic PartialList<ContentEntityObject> getAllContentForLabel(int offset, int maxResults, Label label)
LabelManager
ContentEntityObjects in the Trash *will* be returned.
getAllContentForLabel
in interface LabelManager
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on ContentEntityObjectspublic PartialList<ContentEntityObject> getAllContentForAllLabels(int offset, int maxResults, Label... labels)
LabelManager
ContentEntityObjects in the Trash *will* be returned.
getAllContentForAllLabels
in interface LabelManager
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must appear on ContentEntityObjectspublic List<? extends Labelable> getCurrentContentForLabelAndSpace(Label label, String spaceKey)
LabelManager
getCurrentContentForLabelAndSpace
in interface LabelManager
public List<? extends Labelable> getCurrentContentWithPersonalLabel(String username)
LabelManager
getCurrentContentWithPersonalLabel
in interface LabelManager
public List<Space> getSpacesWithLabel(Label label)
LabelManager
getSpacesWithLabel
in interface LabelManager
public boolean deleteLabel(long id)
LabelManager
deleteLabel
in interface LabelManager
public List<Space> getFavouriteSpaces(String username)
getFavouriteSpaces
in interface LabelManager
username
- username of label ownerpublic List<Labelling> getFavouriteLabellingsByContentIds(Collection<ContentId> contentIds, com.atlassian.sal.api.user.UserKey userKey)
LabelManager
getFavouriteLabellingsByContentIds
in interface LabelManager
contentIds
- the contentIds to get favourite labellings foruserKey
- the key of the user to get favourite labellings forpublic boolean deleteLabel(Label label)
LabelManager
NOTE: The specified label does note need to be the persistent instance of the label, it simply needs to uniquely identify the label.
deleteLabel
in interface LabelManager
public Label getLabel(ParsedLabelName parsedLabelName)
LabelManager
getLabel
in interface LabelManager
for details on the format of the labelReference parameter.
public Label getLabel(String unparsedLabelName)
LabelManager
getLabel
in interface LabelManager
unparsedLabelName
- - example - my:foopublic List<Label> getLabels(Collection<String> unparsedLabelNames)
LabelManager
getLabels
in interface LabelManager
unparsedLabelNames
- - example - my:foo, barpublic Label getLabel(Label label)
LabelManager
getLabel
in interface LabelManager
public Label getLabel(String labelName, Namespace namespace)
LabelManager
getLabel
in interface LabelManager
labelName
- The label namenamespace
- The namespace of the labelpublic List<Label> getLabelsByDetail(String labelName, String namespace, String spaceKey, String owner)
LabelManager
getLabelsByDetail
in interface LabelManager
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)public List<Label> getLabelsInSpace(String key)
LabelManager
getLabelsInSpace
in interface LabelManager
key
- public List<LabelSearchResult> getMostPopularLabels()
LabelManager
getMostPopularLabels
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
,
LabelSearchResult
public List<LabelSearchResult> getMostPopularLabels(int count)
LabelManager
This function does not return the labels itself, but wrapped into a search result with a count!
getMostPopularLabels
in interface LabelManager
count
- is the maximum number of labels to be returned.LabelSearchResult
public List<LabelSearchResult> getMostPopularLabelsInSpace(String key)
LabelManager
This function does not return the labels itself, but wrapped into a search result with a count!
getMostPopularLabelsInSpace
in interface LabelManager
key
- the space keyLabelManager.DEFAULT_LABEL_COUNT
,
LabelSearchResult
public List<LabelSearchResult> getMostPopularLabelsInSpace(String key, int count)
LabelManager
This function does not return the labels itself, but wrapped into a search result with a count!
getMostPopularLabelsInSpace
in interface LabelManager
key
- is the space keycount
- is the maximum number of labels to be returned.LabelSearchResult
public Set<RankedLabelSearchResult> getMostPopularLabelsWithRanks(Comparator<? super RankedLabelSearchResult> comparator)
LabelManager
getMostPopularLabelsWithRanks
in interface LabelManager
LabelManager.DEFAULT_LABEL_COUNT
,
RankedLabelSearchResult
public Set<RankedLabelSearchResult> getMostPopularLabelsWithRanks(int maxResults, Comparator<? super RankedLabelSearchResult> comparator)
LabelManager
This function does not return the labels itself, but wrapped into a search result with a count!
getMostPopularLabelsWithRanks
in interface LabelManager
maxResults
- is the maximum number of labels to be returned.RankedLabelSearchResult
public Set<RankedLabelSearchResult> getMostPopularLabelsWithRanksInSpace(String key, int maxResults, Comparator<? super RankedLabelSearchResult> comparator)
LabelManager
This function does not return the labels itself, but wrapped into a search result with a count!
getMostPopularLabelsWithRanksInSpace
in interface LabelManager
key
- is the space keymaxResults
- is the maximum number of labels to be returned.RankedLabelSearchResult
public List getContent(Label label)
LabelManager
getContent
in interface LabelManager
public int getContentCount(Label label)
getContentCount
in interface LabelManager
public Label createLabel(Label label)
createLabel
in interface LabelManager
public List<Labelling> getRecentlyUsedLabellings(int maxResults)
getRecentlyUsedLabellings
in interface LabelManager
public List<Labelling> getRecentlyUsedLabellingsInSpace(String spaceKey, int maxResults)
getRecentlyUsedLabellingsInSpace
in interface LabelManager
public PageResponse<Label> findGlobalLabelsByNamePrefix(String namePrefix, LimitedRequest pageRequest)
LabelManagerInternal
findGlobalLabelsByNamePrefix
in interface LabelManagerInternal
public PageResponse<Label> findTeamLabelsByNamePrefix(String namePrefix, LimitedRequest pageRequest)
LabelManagerInternal
findTeamLabelsByNamePrefix
in interface LabelManagerInternal
Copyright © 2003–2020 Atlassian. All rights reserved.