Class CachingLabelManager
- java.lang.Object
-
- com.atlassian.confluence.impl.labels.CachingLabelManager
-
- All Implemented Interfaces:
LabelManagerInternal
,LabelManager
public class CachingLabelManager extends Object implements LabelManagerInternal
- Since:
- 7.5
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.labels.LabelManager
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 Summary
Constructors Constructor Description CachingLabelManager(LabelManagerInternal delegate, com.atlassian.cache.CacheFactory cacheFactory, com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar, AdaptiveMostUsedLabelsCache adaptiveLabelManagerCache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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(long id)
Delete the label with the specified id.boolean
deleteLabel(Label l)
Delete the specified label.void
destroy()
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)
PartialList<ContentEntityObject>
getContentForAllLabels(int offset, int maxResults, Label... labels)
Retrieve current ContentEntityObjects which are labelled with ALL provided labels.List<? extends Labelable>
getContentForAllLabels(Collection<Label> labels, int maxResults, int offset)
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 userList<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>
PartialList<T>getForLabel(Class<T> labelableClass, int offset, int maxResults, Label label)
Retrieve EditableLabelables of the supplied type which are labelled with the provided label.PartialList<EditableLabelable>
getForLabels(int offset, int maxResults, Label... labels)
Retrieve EditableLabelables of any type which are labelled with the provided labels.<T extends EditableLabelable>
PartialList<T>getForLabels(Class<T> labelableClass, int offset, int maxResults, Label... labels)
Retrieve EditableLabelables of the supplied type which are labelled with the provided labels.Label
getLabel(long id)
Retrieve the label with the specified id.Label
getLabel(Label label)
Retrieve the persistent instance of the label with the exact same details as the specified label.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 parserLabel
getLabel(String labelName, Namespace namespace)
Convenience method to fetch a label without having to create a Label objectList<Label>
getLabels(Collection<String> unparsedLabelNames)
convenience method to fetch labels without having to call the label parserList<Label>
getLabelsByDetail(String labelName, String namespace, String spaceKey, String owner)
Retrieves the labels matching the given labelName, namespace or ownerList<Label>
getLabelsInSpace(String key)
Retrieve all of the labels that label content within the specified space.List<Label>
getLabelsInSpace(String key, LimitedRequest pageRequest)
Get all label in Space with paginationList<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 spaceKey, 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(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>
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>
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.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.long
getTotalLabelInSpace(String key)
Get total label in a particular spaceList<Label>
getUsersLabels(String owner)
Retrieve the personal labels that belong to the specified user.void
init()
void
onPagesMoved(BlogPostMovedEvent event)
void
onPagesMoved(PageMoveCompletedEvent event)
void
onRestore(Restore restore)
void
onSpaceRemove(SpaceRemoveEvent event)
void
onTrash(Trashed trashed)
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-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.internal.labels.LabelManagerInternal
findGlobalLabelsByNamePrefix, findTeamLabelsByNamePrefix
-
-
-
-
Constructor Detail
-
CachingLabelManager
public CachingLabelManager(LabelManagerInternal delegate, com.atlassian.cache.CacheFactory cacheFactory, com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar, AdaptiveMostUsedLabelsCache adaptiveLabelManagerCache)
-
-
Method Detail
-
init
@PostConstruct public void init()
-
destroy
@PreDestroy public void destroy()
-
onTrash
@EventListener public void onTrash(Trashed trashed)
-
onRestore
@EventListener public void onRestore(Restore restore)
-
onSpaceRemove
@EventListener public void onSpaceRemove(SpaceRemoveEvent event)
-
onPagesMoved
@EventListener public void onPagesMoved(PageMoveCompletedEvent event)
-
onPagesMoved
@EventListener public void onPagesMoved(BlogPostMovedEvent event)
-
addLabel
public int addLabel(Labelable content, Label label)
Description copied from interface:LabelManager
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"));
- Specified by:
addLabel
in interfaceLabelManager
- Returns:
- one of NO_CHANGE, LABEL_ADDED or LABEL_CREATED
-
removeLabel
public int removeLabel(Labelable object, Label label)
Description copied from interface:LabelManager
Remove a label from the specified content.- Specified by:
removeLabel
in interfaceLabelManager
- Returns:
- one of NO_CHANGE, LABEL_DELETED, LABEL_REMOVED
-
removeLabels
public void removeLabels(Labelable object, List labels)
Description copied from interface:LabelManager
removes a list of labels from the labelable object- Specified by:
removeLabels
in interfaceLabelManager
-
removeAllLabels
public void removeAllLabels(Labelable content)
Description copied from interface:LabelManager
Remove all of the labels from the specified content. Any labels that then no longer label content will be deleted.- Specified by:
removeAllLabels
in interfaceLabelManager
-
deleteLabel
public boolean deleteLabel(long id)
Description copied from interface:LabelManager
Delete the label with the specified id.- Specified by:
deleteLabel
in interfaceLabelManager
- Returns:
- true if the label was deleted, false otherwise.
-
deleteLabel
public boolean deleteLabel(Label l)
Description copied from interface:LabelManager
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.
- Specified by:
deleteLabel
in interfaceLabelManager
- Returns:
- true if the label was deleted, false otherwise.
-
getLabel
public Label getLabel(long id)
Description copied from interface:LabelManager
Retrieve the label with the specified id.- Specified by:
getLabel
in interfaceLabelManager
- Returns:
- the persistent instance of label with the specified id, or null if none exists.
-
getLabel
public Label getLabel(ParsedLabelName parsedLabelName)
Description copied from interface:LabelManager
Retrieve the label by name.- Specified by:
getLabel
in interfaceLabelManager
- 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
public Label getLabel(String unparsedLabelName)
Description copied from interface:LabelManager
convenience method to fetch a label without having to call the label parser- Specified by:
getLabel
in interfaceLabelManager
- Parameters:
unparsedLabelName
- - example - my:foo
-
getLabels
public List<Label> getLabels(Collection<String> unparsedLabelNames)
Description copied from interface:LabelManager
convenience method to fetch labels without having to call the label parser- Specified by:
getLabels
in interfaceLabelManager
- Parameters:
unparsedLabelNames
- - example - my:foo, bar
-
getLabel
public Label getLabel(Label label)
Description copied from interface:LabelManager
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.- Specified by:
getLabel
in interfaceLabelManager
- Returns:
- a persistent instance of the label, or null if it does not exist.
-
getLabel
public Label getLabel(String labelName, Namespace namespace)
Description copied from interface:LabelManager
Convenience method to fetch a label without having to create a Label object- Specified by:
getLabel
in interfaceLabelManager
- Parameters:
labelName
- The label namenamespace
- The namespace of the label- Returns:
- a label instance or null if no such label exists
-
getLabelsByDetail
public List<Label> getLabelsByDetail(String labelName, String namespace, String spaceKey, String owner)
Description copied from interface:LabelManager
Retrieves the labels matching the given labelName, namespace or owner- Specified by:
getLabelsByDetail
in interfaceLabelManager
- 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
public List<Label> getLabelsInSpace(String key)
Description copied from interface:LabelManager
Retrieve all of the labels that label content within the specified space.- Specified by:
getLabelsInSpace
in interfaceLabelManager
- Parameters:
key
- identifying the space to be queried.- Returns:
- a list of labels that appear in the space.
-
getMostPopularLabels
public List<LabelSearchResult> getMostPopularLabels()
Description copied from interface:LabelManager
Retrieve the list of the DEFAULT_LABEL_COUNT most popular labels within the system.- Specified by:
getMostPopularLabels
in interfaceLabelManager
- Returns:
- a list of label search result instances in order of their popularity.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
,LabelSearchResult
-
getMostPopularLabels
public List<LabelSearchResult> getMostPopularLabels(int maxResults)
Description copied from interface:LabelManager
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!
- Specified by:
getMostPopularLabels
in interfaceLabelManager
- 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
public List<LabelSearchResult> getMostPopularLabelsInSpace(String key)
Description copied from interface:LabelManager
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!
- Specified by:
getMostPopularLabelsInSpace
in interfaceLabelManager
- Parameters:
key
- the space key- Returns:
- a list of label search result instances in order of their popularity.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
,LabelSearchResult
-
getMostPopularLabelsInSpace
public List<LabelSearchResult> getMostPopularLabelsInSpace(String spaceKey, int maxResults)
Description copied from interface:LabelManager
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!
- Specified by:
getMostPopularLabelsInSpace
in interfaceLabelManager
- Parameters:
spaceKey
- is the space keymaxResults
- 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
public Set<RankedLabelSearchResult> getMostPopularLabelsWithRanks(Comparator<? super RankedLabelSearchResult> comparator)
Description copied from interface:LabelManager
Retrieve a set of the DEFAULT_LABEL_COUNT most popular labels within the system, including their ranks and ordered using the compartor provided.- Specified by:
getMostPopularLabelsWithRanks
in interfaceLabelManager
- Returns:
- an ordered set of ranked label search result instances
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
,RankedLabelSearchResult
-
getMostPopularLabelsWithRanks
public Set<RankedLabelSearchResult> getMostPopularLabelsWithRanks(int maxResults, Comparator<? super RankedLabelSearchResult> comparator)
Description copied from interface:LabelManager
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!
- Specified by:
getMostPopularLabelsWithRanks
in interfaceLabelManager
- 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
public Set<RankedLabelSearchResult> getMostPopularLabelsWithRanksInSpace(String key, int maxResults, Comparator<? super RankedLabelSearchResult> comparator)
Description copied from interface:LabelManager
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!
- Specified by:
getMostPopularLabelsWithRanksInSpace
in interfaceLabelManager
- Parameters:
key
- is the space keymaxResults
- is the maximum number of labels to be returned.- Returns:
- an ordered set of rankded label search result instances
- See Also:
RankedLabelSearchResult
-
getRecentlyUsedLabels
public List<Label> getRecentlyUsedLabels()
Description copied from interface:LabelManager
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the system.- Specified by:
getRecentlyUsedLabels
in interfaceLabelManager
- Returns:
- a list of label instances in order of most recently used to least recently used.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
-
getRecentlyUsedLabels
public List<Label> getRecentlyUsedLabels(int maxResults)
Description copied from interface:LabelManager
Retrieve the x most recently used labels.- Specified by:
getRecentlyUsedLabels
in interfaceLabelManager
- 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
public List<Labelling> getRecentlyUsedLabellings(int maxResults)
- Specified by:
getRecentlyUsedLabellings
in interfaceLabelManager
-
getRecentlyUsedLabelsInSpace
public List<Label> getRecentlyUsedLabelsInSpace(String spaceKey)
Description copied from interface:LabelManager
Retrieve the DEFAULT_LABEL_COUNT most recently used labels within the specified space.- Specified by:
getRecentlyUsedLabelsInSpace
in interfaceLabelManager
- 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:
LabelManager.DEFAULT_LABEL_COUNT
-
getRecentlyUsedLabelsInSpace
public List<Label> getRecentlyUsedLabelsInSpace(String spaceKey, int maxResults)
Description copied from interface:LabelManager
Retrieve the most recently used labels within the specified spae.- Specified by:
getRecentlyUsedLabelsInSpace
in interfaceLabelManager
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
public List<Labelling> getRecentlyUsedLabellingsInSpace(String spaceKey, int maxResults)
- Specified by:
getRecentlyUsedLabellingsInSpace
in interfaceLabelManager
-
getSuggestedLabels
public List<Label> getSuggestedLabels(Labelable content)
Description copied from interface:LabelManager
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.- Specified by:
getSuggestedLabels
in interfaceLabelManager
- Returns:
- a list of label instances. The order of these labels is undefined.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
-
getSuggestedLabels
public List<Label> getSuggestedLabels(Labelable content, int maxResults)
Description copied from interface:LabelManager
Retrieve the suggested labels for the specified content. The process used to identify 'suggested' labels may change and therefore is not defined here.- Specified by:
getSuggestedLabels
in interfaceLabelManager
maxResults
- is the maximum number of labels to be returned.- Returns:
- a list of label instances. The order of these labels is undefined.
-
getSuggestedLabelsInSpace
public List<Label> getSuggestedLabelsInSpace(Labelable content, String spaceKey)
Description copied from interface:LabelManager
Retrieve the DEFAULT_LABEL_COUNT suggested labels for the specified content bound to the specified space.- Specified by:
getSuggestedLabelsInSpace
in interfaceLabelManager
- Returns:
- a list of label instances. The order of these labels is undefined.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
-
getSuggestedLabelsInSpace
public List<Label> getSuggestedLabelsInSpace(Labelable content, String spaceKey, int maxResults)
Description copied from interface:LabelManager
Retrieve the suggested labels for the specified content bound to the specified space.- Specified by:
getSuggestedLabelsInSpace
in interfaceLabelManager
maxResults
- is the maximum number of labels to be returned.- Returns:
- a list of label instances. The order of these labels is undefined.
-
getRelatedLabels
public List<Label> getRelatedLabels(Label label)
Description copied from interface:LabelManager
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.- Specified by:
getRelatedLabels
in interfaceLabelManager
- Returns:
- a list of label instances. The order of these labels is undefined.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
-
getRelatedLabels
public List<Label> getRelatedLabels(Label label, int maxResults)
Description copied from interface:LabelManager
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.- Specified by:
getRelatedLabels
in interfaceLabelManager
maxResults
- is the maximum number of labels to be returned.- Returns:
- a list of label instances. The order of these labels is undefined.
-
getRelatedLabels
public List<Label> getRelatedLabels(List<? extends Label> labels, String spaceKey, int maxResultsPerLabel)
Description copied from interface:LabelManager
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.- Specified by:
getRelatedLabels
in interfaceLabelManager
spaceKey
- - may be null to search globallymaxResultsPerLabel
- 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
public List<Label> getRelatedLabelsInSpace(Label label, String spaceKey)
Description copied from interface:LabelManager
Retrieve the DEFAULT_LABEL_COUNT labels that are 'related' to the specified label and that are used to label content within the specified space.- Specified by:
getRelatedLabelsInSpace
in interfaceLabelManager
- Returns:
- a list of label instances. The order of these labels is undefined.
- See Also:
LabelManager.DEFAULT_LABEL_COUNT
-
getRelatedLabelsInSpace
public List<Label> getRelatedLabelsInSpace(Label label, String spaceKey, int maxResults)
Description copied from interface:LabelManager
Retrieve the labels that are 'related' to the specified label and that are used to to label content within the specified space.- Specified by:
getRelatedLabelsInSpace
in interfaceLabelManager
- Returns:
- a list of label instance. The order of these labels is undefined.
-
getSpacesContainingContentWithLabel
public List<Space> getSpacesContainingContentWithLabel(Label label)
Description copied from interface:LabelManager
Look up the spaces that have been labelled by the specific label.- Specified by:
getSpacesContainingContentWithLabel
in interfaceLabelManager
- Returns:
- a list of Spaces. The order of these labels is undefined.
-
getUsersLabels
public List<Label> getUsersLabels(String owner)
Description copied from interface:LabelManager
Retrieve the personal labels that belong to the specified user.- Specified by:
getUsersLabels
in interfaceLabelManager
-
getTeamLabels
public List<Label> getTeamLabels()
Description copied from interface:LabelManager
Retrieve all of the team labels in the system.- Specified by:
getTeamLabels
in interfaceLabelManager
- Returns:
- a list of labels with the namespace Namespace.TEAM
-
getTeamLabels
public List<Label> getTeamLabels(String name)
Description copied from interface:LabelManager
Retrieve all of the team labels in the system with name.- Specified by:
getTeamLabels
in interfaceLabelManager
- Returns:
- a list of labels with the namespace Namespace.TEAM
-
getTeamLabelsForSpace
public List<Label> getTeamLabelsForSpace(String spaceKey)
Description copied from interface:LabelManager
Retrieve all of the team labels used to label content in the specified space.- Specified by:
getTeamLabelsForSpace
in interfaceLabelManager
- Returns:
- a list of team labels with the namespace Namespace.TEAM. The order of the list is undefined.
-
getTeamLabelsForSpaces
public List<Label> getTeamLabelsForSpaces(Collection<Space> spaces)
Description copied from interface:LabelManager
Retrieve all of the team labels used to label content in the specified spaces.- Specified by:
getTeamLabelsForSpaces
in interfaceLabelManager
- Parameters:
spaces
- collection of spaces whose labels to get- Returns:
- a list of team labels with the namespace Namespace.TEAM. The order of the list is undefined.
-
getCurrentContentForLabel
public List<? extends Labelable> getCurrentContentForLabel(Label label)
Description copied from interface:LabelManager
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.- Specified by:
getCurrentContentForLabel
in interfaceLabelManager
- Returns:
- a list of Labelables, sorted by last modification date
-
getCurrentContentForLabelAndSpace
public List<? extends Labelable> getCurrentContentForLabelAndSpace(Label label, String spaceKey)
Description copied from interface:LabelManager
Get all current content associated with a label and space. Content in the trash will not be returned.- Specified by:
getCurrentContentForLabelAndSpace
in interfaceLabelManager
- Returns:
- a list of Labelable
-
getCurrentContentWithPersonalLabel
public List<? extends Labelable> getCurrentContentWithPersonalLabel(String username)
Description copied from interface:LabelManager
Get all current content labelled by a user- Specified by:
getCurrentContentWithPersonalLabel
in interfaceLabelManager
-
getSpacesWithLabel
public List<Space> getSpacesWithLabel(Label label)
Description copied from interface:LabelManager
Spaces cannot be directly labelled. Howevever, their space descriptions can. This method searches for all space descriptions with the label passed in- Specified by:
getSpacesWithLabel
in interfaceLabelManager
- Returns:
- list of spaces associated with matching space descriptions
-
getFavouriteSpaces
public List<Space> getFavouriteSpaces(String username)
- Specified by:
getFavouriteSpaces
in interfaceLabelManager
- Parameters:
username
- username of label owner
-
getFavouriteLabellingsByContentIds
public List<Labelling> getFavouriteLabellingsByContentIds(Collection<ContentId> contentIds, com.atlassian.sal.api.user.UserKey userKey)
Description copied from interface:LabelManager
Get the labellings that represent the favourite labellings for the given user on the given content.- Specified by:
getFavouriteLabellingsByContentIds
in interfaceLabelManager
- Parameters:
contentIds
- the contentIds to get favourite labellings foruserKey
- the key of the user to get favourite labellings for- Returns:
- the labellings that represent the favourite labellings for the given user on the given content.
-
getRecentlyUsedPersonalLabels
public List<Label> getRecentlyUsedPersonalLabels(String username)
Description copied from interface:LabelManager
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)
- Specified by:
getRecentlyUsedPersonalLabels
in interfaceLabelManager
- Parameters:
username
- the user history from the session- Returns:
- a list of labels
-
getRecentlyUsedPersonalLabels
public List<Label> getRecentlyUsedPersonalLabels(String username, int maxResults)
Description copied from interface:LabelManager
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)
- Specified by:
getRecentlyUsedPersonalLabels
in interfaceLabelManager
- Parameters:
username
- the user history from the sessionmaxResults
- the maximum number of results to return to the user- Returns:
- a list of labels
-
getRecentlyUsedPersonalLabellings
public List<Labelling> getRecentlyUsedPersonalLabellings(String username, int maxResults)
- Specified by:
getRecentlyUsedPersonalLabellings
in interfaceLabelManager
-
getContent
public List getContent(Label label)
Description copied from interface:LabelManager
Get all content associated with a label Get all versions of content associated with a label and any space. Content in the trash WILL be returned.- Specified by:
getContent
in interfaceLabelManager
- Returns:
- a list of Labelables
-
getContentCount
public int getContentCount(Label label)
- Specified by:
getContentCount
in interfaceLabelManager
-
createLabel
public Label createLabel(Label label)
- Specified by:
createLabel
in interfaceLabelManager
-
getContentForAllLabels
public List<? extends Labelable> getContentForAllLabels(Collection<Label> labels, int maxResults, int offset)
- Specified by:
getContentForAllLabels
in interfaceLabelManager
-
getContentForLabel
public PartialList<ContentEntityObject> getContentForLabel(int offset, int maxResults, Label label)
Description copied from interface:LabelManager
Retrieve current ContentEntityObjects which are labelled with the provided label.ContentEntityObjects in the Trash will *not* be returned.
- Specified by:
getContentForLabel
in interfaceLabelManager
- Parameters:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
getForLabel
public <T extends EditableLabelable> PartialList<T> getForLabel(Class<T> labelableClass, int offset, int maxResults, Label label)
Description copied from interface:LabelManager
Retrieve EditableLabelables of the supplied type which are labelled with the provided label.ContentEntityObjects in the Trash *will* be returned.
- Specified by:
getForLabel
in interfaceLabelManager
- Parameters:
labelableClass
- the type of labelable to return. Use one of these values:- ContentEntityObject.class - all CEO labelings except Attachments
- Attachment.class - all attachment labellings
- PageTemplate.class - all page template labellings
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on labelables- Returns:
- a partial list of EditableLabelables labelled with the labels provided
-
getForLabels
public <T extends EditableLabelable> PartialList<T> getForLabels(Class<T> labelableClass, int offset, int maxResults, Label... labels)
Description copied from interface:LabelManager
Retrieve EditableLabelables of the supplied type which are labelled with the provided labels.ContentEntityObjects in the Trash will *not* be returned.
- Specified by:
getForLabels
in interfaceLabelManager
- Parameters:
labelableClass
- the type of labelable to return. Use one of these values:- ContentEntityObject.class - all CEO labelings except Attachments
- Attachment.class - all attachment labellings
- PageTemplate.class - all page template labellings
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must all appear on labelables- Returns:
- a partial list of EditableLabelables labelled with the labels provided
-
getForLabels
public PartialList<EditableLabelable> getForLabels(int offset, int maxResults, Label... labels)
Description copied from interface:LabelManager
Retrieve EditableLabelables of any type which are labelled with the provided labels.ContentEntityObjects in the Trash *will* be returned.
- Specified by:
getForLabels
in interfaceLabelManager
- Parameters:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must all appear on labelables- Returns:
- a partial list of EditableLabelables labelled with the labels provided
-
getContentForAllLabels
public PartialList<ContentEntityObject> getContentForAllLabels(int offset, int maxResults, Label... labels)
Description copied from interface:LabelManager
Retrieve current ContentEntityObjects which are labelled with ALL provided labels.ContentEntityObjects in the Trash will *not* be returned.
- Specified by:
getContentForAllLabels
in interfaceLabelManager
- Parameters:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must appear on ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
getContentInSpaceForLabel
public PartialList<ContentEntityObject> getContentInSpaceForLabel(int offset, int maxResults, String spaceKey, Label label)
Description copied from interface:LabelManager
Retrieve current ContentEntityObjects in the given space which are labelled with the provided label.ContentEntityObjects in the Trash will *not* be returned.
- Specified by:
getContentInSpaceForLabel
in interfaceLabelManager
- Parameters:
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 ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
getContentInSpaceForAllLabels
public PartialList<ContentEntityObject> getContentInSpaceForAllLabels(int offset, int maxResults, String spaceKey, Label... labels)
Description copied from interface:LabelManager
Retrieve current ContentEntityObjects in the given space which are labelled with ALL provided labels.ContentEntityObjects in the Trash will *not* be returned.
- Specified by:
getContentInSpaceForAllLabels
in interfaceLabelManager
- Parameters:
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 ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
getContentInSpacesForAllLabels
public PartialList<ContentEntityObject> getContentInSpacesForAllLabels(int offset, int maxResults, Set<String> spaceKeys, Label... labels)
Description copied from interface:LabelManager
Retrieve current ContentEntityObjects in the given spaces which are labelled with ALL provided labels.ContentEntityObjects in the Trash will *not* be returned.
- Specified by:
getContentInSpacesForAllLabels
in interfaceLabelManager
- Parameters:
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 ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
getAllContentForLabel
public PartialList<ContentEntityObject> getAllContentForLabel(int offset, int maxResults, Label label)
Description copied from interface:LabelManager
Retrieve all ContentEntityObjects, current or deleted which are labelled with the provided label.ContentEntityObjects in the Trash *will* be returned.
- Specified by:
getAllContentForLabel
in interfaceLabelManager
- Parameters:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabel
- label which must appear on ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
getAllContentForAllLabels
public PartialList<ContentEntityObject> getAllContentForAllLabels(int offset, int maxResults, Label... labels)
Description copied from interface:LabelManager
Retrieve all ContentEntityObjects, current or deleted which are labelled with ALL provided labels.ContentEntityObjects in the Trash *will* be returned.
- Specified by:
getAllContentForAllLabels
in interfaceLabelManager
- Parameters:
offset
- the offset into the resultsmaxResults
- the maximum number of results to returnlabels
- labels which must appear on ContentEntityObjects- Returns:
- a partial list of ContentEntityObjects labelled with the labels provided
-
findGlobalLabelsByNamePrefix
public PageResponse<Label> findGlobalLabelsByNamePrefix(String namePrefix, LimitedRequest pageRequest)
Description copied from interface:LabelManagerInternal
Returns global-namespaced labels starting with the given string.- Specified by:
findGlobalLabelsByNamePrefix
in interfaceLabelManagerInternal
-
findTeamLabelsByNamePrefix
public PageResponse<Label> findTeamLabelsByNamePrefix(String namePrefix, LimitedRequest pageRequest)
Description copied from interface:LabelManagerInternal
Returns team-namespaced labels starting with the given string.- Specified by:
findTeamLabelsByNamePrefix
in interfaceLabelManagerInternal
-
getLabelsInSpace
public List<Label> getLabelsInSpace(String key, LimitedRequest pageRequest)
Description copied from interface:LabelManagerInternal
Get all label in Space with pagination- Specified by:
getLabelsInSpace
in interfaceLabelManagerInternal
- Returns:
-
getTotalLabelInSpace
public long getTotalLabelInSpace(String key)
Description copied from interface:LabelManagerInternal
Get total label in a particular space- Specified by:
getTotalLabelInSpace
in interfaceLabelManagerInternal
- Returns:
-
getMostPopularLabelsInSpaceLite
public List<LiteLabelSearchResult> getMostPopularLabelsInSpaceLite(String spaceKey, int maxResults)
Returns most used labels. Similar to getMostPopularLabelsInSpace, but returns lite objects (no references to hibernate objects).- Specified by:
getMostPopularLabelsInSpaceLite
in interfaceLabelManager
- Parameters:
spaceKey
- - space keymaxResults
- - limit- Returns:
- list of LiteLabelSearchResult
-
getMostPopularLabelsInSiteLite
public List<LiteLabelSearchResult> getMostPopularLabelsInSiteLite(int maxResults)
Returns most used labels across the site. Similar to getMostPopularLabels, but returns lite objects (no references to hibernate objects). Note: implementation would limit the amount of labels.- Specified by:
getMostPopularLabelsInSiteLite
in interfaceLabelManager
- Parameters:
maxResults
- - max results- Returns:
- list of LiteLabelSearchResult
-
calculateRanksForLiteLabels
public Set<RankedLiteLabelSearchResult> calculateRanksForLiteLabels(List<LiteLabelSearchResult> labelList, Comparator<? super RankedLiteLabelSearchResult> comparator)
Calculate ranks for input labels. Ranks reflect the frequency of labels. Rank 1 is used for the most popular labels. Rank 10 is used for the least popular labels- Specified by:
calculateRanksForLiteLabels
in interfaceLabelManager
- Parameters:
labelList
- - list of labelscomparator
- - comparator- Returns:
- list of labels with calculated ranks
-
-