Package com.atlassian.bamboo.plan.cache
Class CachedPlanManagerImpl
java.lang.Object
com.atlassian.bamboo.plan.cache.CachedPlanManagerImpl
- All Implemented Interfaces:
CachedPlanManager
,FilteringPlanManager
public class CachedPlanManagerImpl
extends Object
implements CachedPlanManager, FilteringPlanManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
assertPlanPermission
(@NotNull PlanIdentifier plan) Used to validate user permission for plan.Returns all projects which have at least one plan (plan is in the cache)getAnyPlan
(Predicate<? super ImmutableChain> predicate) Returns a plan matching the supplied predicate, permission filtering is applied.getAnyPlanUnrestricted
(Predicate<? super ImmutableChain> predicate) Returns a plan matching the supplied predicate.@NotNull List<ImmutableChainBranch>
getBranchesForChain
(@NotNull PlanIdentifier chain) Get all feature branches associated with the given chain, sorted.@NotNull List<ImmutableChainBranch>
getBranchesForChainWithConsistencyGuarantee
(@NotNull PlanIdentifier chain) Get all feature branches associated with the given chain, sorted.@NotNull Stream<ImmutableChainBranch>
getBranchesOfChain
(@NotNull PlanKey chainKey) Get all feature branches associated with the given chain, unsorted.@NotNull Stream<ImmutableChainBranch>
getBranchesOfChainWithConsistencyGuarantee
(@NotNull PlanKey chainKey) Get all feature branches associated with the given chain, unsorted.@NotNull Set<PlanBranchGist>
getBranchGistsOfChain
(@NotNull PlanKey chainKey) Returns basic data of all branches for the supplied chain.@NotNull Set<PlanBranchGist>
getBranchGistsOfChainWithConsistencyGuarantee
(@NotNull PlanKey chainKey) Returns basic data of all branches for the supplied chain with guarantee that eventual new plan branches not present in the cache will be taken in consideration.getBranchKeysOfChain
(@NotNull PlanKey chainKey) Returns keys of all branches for the supplied chain.@NotNull Iterable<ImmutableTopLevelPlan>
getEditablePlansByProject
(Project project) Returns chains that use repositories with given params@Nullable ImmutableJob
getMasterOfJob
(@NotNull PlanKey masterChainKey, @NotNull PlanKey jobKey) @Nullable ImmutableChain
getMasterPlan
(@NotNull PlanKey branchKey) Returns master branch for a given branchKey.<T extends ImmutablePlan>
TgetPlanById
(long id, Class<T> planType) Returns aImmutablePlan
by its database id andClass
<T extends ImmutablePlan>
TgetPlanByIdNotThrowing
(long id, Class<T> planType) Returns aImmutablePlan
by its database id andClass
.<T extends ImmutablePlan>
TgetPlanByIdNotThrowingWithConsistencyGuarantee
(long id, Class<T> planType) Returns aImmutablePlan
by its database id andClass
.@Nullable ImmutablePlan
getPlanByKey
(@NotNull PlanKey planKey) Returns aImmutablePlan
by its planKey.<T extends ImmutablePlan>
TgetPlanByKey
(@NotNull PlanKey planKey, Class<T> planType) Returns aImmutablePlan
by its planKey andClass
.<T extends ImmutablePlan>
TgetPlanByKeyIfOfType
(@NotNull PlanKey planKey, @NotNull Class<T> planType) <T extends ImmutablePlan>
TgetPlanByKeyIfOfTypeWithConsistencyGuarantee
(@NotNull PlanKey planKey, @NotNull Class<T> planType) @Nullable ImmutablePlan
getPlanByKeyWithConsistencyGuarantee
(@NotNull PlanKey planKey) Returns aImmutablePlan
by its planKey.<T extends ImmutablePlan>
TgetPlanByKeyWithConsistencyGuarantee
(@NotNull PlanKey planKey, Class<T> planType) Returns aImmutablePlan
by its planKey andClass
.@NotNull List<ImmutableTopLevelPlan>
getPlans()
Returns allTopLevelPlan
's.<T extends ImmutablePlan>
@NotNull List<T><T extends ImmutablePlan>
@NotNull List<T><T extends ImmutablePlan>
List<T>getPlansByProject
(@NotNull Project project, @NotNull Class<T> planType, @NotNull Predicate<? super T> filter) @NotNull List<ImmutableTopLevelPlan>
getPlansByProject
(Project project) Returns allImmutableTopLevelPlan
's filtered byProject
.<T extends ImmutablePlan>
@NotNull List<T>getPlansByProject
(Project project, Class<T> planType) @NotNull List<ImmutableChain>
getPlansByProjectUnrestricted
(Project project) Returns allImmutableChain
's filtered byProject
ignoring permissions.@NotNull List<ImmutableChain>
Returns allImmutableChain
's filtered byProject
ignoring permissions.@NotNull List<ImmutableTopLevelPlan>
Returns allImmutableTopLevelPlan
's filtered byProject
.<T extends ImmutablePlan>
@NotNull List<T>getPlansByProjectWithConsistencyGuarantee
(Project project, Class<T> planType) @NotNull List<ImmutableChain>
Returns allChain
's.@NotNull List<ImmutableTopLevelPlan>
Returns allImmutableTopLevelPlan
's ignoring permissions.@NotNull List<ImmutableTopLevelPlan>
Returns allImmutableTopLevelPlan
's ignoring permissions.<T extends ImmutablePlan>
@NotNull List<T>getPlansWithConsistencyGuarantee
(Class<T> planType, @NotNull Predicate<? super T> filter) Returns chains that use repositories with given params.Returns chains that use repositories with given params.<T extends ImmutablePlan>
@NotNull List<T>getRunnablePlans
(@NotNull Project project, @NotNull Class<T> planType) boolean
isBranchOf
(@NotNull PlanKey chainKey, @NotNull PlanKey branchKey) Test if plan identified by branchKey is a branch of plan identified by chainKey.
-
Constructor Details
-
CachedPlanManagerImpl
public CachedPlanManagerImpl()
-
-
Method Details
-
getPlanByKey
Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its planKey. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlanByKey
in interfaceCachedPlanManager
- Parameters:
planKey
- to search for- Returns:
- plan with the given plan key or null if not found
-
getPlanByKeyWithConsistencyGuarantee
@Nullable public @Nullable ImmutablePlan getPlanByKeyWithConsistencyGuarantee(@NotNull @NotNull PlanKey planKey) Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its planKey. There is a guarantee that the data will be up-to-date.- Specified by:
getPlanByKeyWithConsistencyGuarantee
in interfaceCachedPlanManager
- Parameters:
planKey
- to search for- Returns:
- plan with the given plan key or null if not found
-
getPlanByKey
@Nullable public <T extends ImmutablePlan> T getPlanByKey(@NotNull @NotNull PlanKey planKey, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its planKey andClass
. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlanByKey
in interfaceCachedPlanManager
- Parameters:
planKey
- to search forplanType
- - the type of the plan to retrieve- Returns:
- plan with the given plan key, if found AND is of the correct type.
- Throws:
IncorrectPlanTypeException
- if plan cannot be found with the correct type
-
getPlanByKeyWithConsistencyGuarantee
@Nullable public <T extends ImmutablePlan> T getPlanByKeyWithConsistencyGuarantee(@NotNull @NotNull PlanKey planKey, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its planKey andClass
. There is a guarantee that the data will be up-to-date.- Specified by:
getPlanByKeyWithConsistencyGuarantee
in interfaceCachedPlanManager
- Parameters:
planKey
- to search forplanType
- - the type of the plan to retrieve- Returns:
- plan with the given plan key, if found AND is of the correct type.
- Throws:
IncorrectPlanTypeException
- if plan cannot be found with the correct type
-
getPlanByKeyIfOfType
@Nullable public <T extends ImmutablePlan> T getPlanByKeyIfOfType(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Class<T> planType) Description copied from interface:CachedPlanManager
Returns aPlan
by its planKey and if it's of the typeClass
. Does not throwIncorrectPlanTypeException
. Should only be used when the type of the plan can not be known. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlanByKeyIfOfType
in interfaceCachedPlanManager
- Returns:
- null if the plan doesn't exist, or it's not of the found type
-
getPlanByKeyIfOfTypeWithConsistencyGuarantee
@Nullable public <T extends ImmutablePlan> T getPlanByKeyIfOfTypeWithConsistencyGuarantee(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Class<T> planType) Description copied from interface:CachedPlanManager
Returns aPlan
by its planKey and if it's of the typeClass
. Does not throwIncorrectPlanTypeException
. Should only be used when the type of the plan can not be known. There is a guarantee that the data will be up-to-date.- Specified by:
getPlanByKeyIfOfTypeWithConsistencyGuarantee
in interfaceCachedPlanManager
- Returns:
- null if the plan doesn't exist, or it's not of the found type
-
getPlans
Description copied from interface:FilteringPlanManager
Returns allTopLevelPlan
's. This method is Acegi-filtered.- Specified by:
getPlans
in interfaceFilteringPlanManager
- Returns:
- plans
-
getPlansUnrestricted
Description copied from interface:CachedPlanManager
Returns allImmutableTopLevelPlan
's ignoring permissions. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansUnrestricted
in interfaceCachedPlanManager
-
getPlansUnrestrictedWithConsistencyGuarantee
Description copied from interface:CachedPlanManager
Returns allImmutableTopLevelPlan
's ignoring permissions. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansUnrestrictedWithConsistencyGuarantee
in interfaceCachedPlanManager
-
getPlansByProjectUnrestricted
Description copied from interface:CachedPlanManager
Returns allImmutableChain
's filtered byProject
ignoring permissions. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansByProjectUnrestricted
in interfaceCachedPlanManager
- Parameters:
project
- - that the plans will belong to- Returns:
ImmutableChain
plans contained within the given project
-
getPlansByProjectUnrestrictedWithConsistencyGuarantee
@NotNull public @NotNull List<ImmutableChain> getPlansByProjectUnrestrictedWithConsistencyGuarantee(Project project) Description copied from interface:CachedPlanManager
Returns allImmutableChain
's filtered byProject
ignoring permissions. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansByProjectUnrestrictedWithConsistencyGuarantee
in interfaceCachedPlanManager
- Parameters:
project
- - that the plans will belong to- Returns:
ImmutableChain
plans contained within the given project
-
getPlans
Description copied from interface:FilteringPlanManager
Returns allPlan
's filtered byClass
. Does not include plans marked for deletion. This method is Acegi-filtered.- Specified by:
getPlans
in interfaceFilteringPlanManager
- Parameters:
planType
- - the type of the plan to retrieve- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getPlans
@NotNull public <T extends ImmutablePlan> @NotNull List<T> getPlans(Class<T> planType, @NotNull @NotNull Predicate<? super T> filter) Description copied from interface:FilteringPlanManager
Returns allPlan
's filtered byClass
. Does not include plans marked for deletion. This method is Acegi-filtered. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlans
in interfaceFilteringPlanManager
- Parameters:
planType
- - the type of the plan to retrieve- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getPlansWithConsistencyGuarantee
@NotNull public <T extends ImmutablePlan> @NotNull List<T> getPlansWithConsistencyGuarantee(Class<T> planType, @NotNull @NotNull Predicate<? super T> filter) Description copied from interface:FilteringPlanManager
Returns allPlan
's filtered byClass
. Does not include plans marked for deletion. This method is Acegi-filtered. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansWithConsistencyGuarantee
in interfaceFilteringPlanManager
- Parameters:
planType
- - the type of the plan to retrieve- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getPlansByProject
Description copied from interface:FilteringPlanManager
Returns allImmutableTopLevelPlan
's filtered byProject
. This method is Acegi-filtered. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansByProject
in interfaceFilteringPlanManager
- Parameters:
project
- - that the plans will belong to- Returns:
ImmutableTopLevelPlan
plans contained within the given project
-
getPlansByProjectWithConsistencyGuarantee
@NotNull public @NotNull List<ImmutableTopLevelPlan> getPlansByProjectWithConsistencyGuarantee(Project project) Description copied from interface:FilteringPlanManager
Returns allImmutableTopLevelPlan
's filtered byProject
. This method is Acegi-filtered. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansByProjectWithConsistencyGuarantee
in interfaceFilteringPlanManager
- Parameters:
project
- - that the plans will belong to- Returns:
ImmutableTopLevelPlan
plans contained within the given project
-
getEditablePlansByProject
Description copied from interface:FilteringPlanManager
Returns allPlan
's filtered byProject
and user can edit (EDIT permission assigned for plan to user)- Specified by:
getEditablePlansByProject
in interfaceFilteringPlanManager
- Parameters:
project
- - that the plans will belong to- Returns:
- editable plans for project
-
getPlansByProject
@NotNull public <T extends ImmutablePlan> @NotNull List<T> getPlansByProject(Project project, Class<T> planType) Description copied from interface:FilteringPlanManager
Returns allPlan
's filtered byProject
andClass
. This method is Acegi-filtered. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansByProject
in interfaceFilteringPlanManager
- Parameters:
project
- - that the plans will belong toplanType
- - the type of the plan to retrieve- Returns:
- plans contained within the given project and of the given type
-
getPlansByProjectWithConsistencyGuarantee
@NotNull public <T extends ImmutablePlan> @NotNull List<T> getPlansByProjectWithConsistencyGuarantee(Project project, Class<T> planType) Description copied from interface:FilteringPlanManager
Returns allPlan
's filtered byProject
andClass
. This method is Acegi-filtered. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansByProjectWithConsistencyGuarantee
in interfaceFilteringPlanManager
- Parameters:
project
- - that the plans will belong toplanType
- - the type of the plan to retrieve- Returns:
- plans contained within the given project and of the given type
-
getPlansByProject
public <T extends ImmutablePlan> List<T> getPlansByProject(@NotNull @NotNull Project project, @NotNull @NotNull Class<T> planType, @NotNull @NotNull Predicate<? super T> filter) - Specified by:
getPlansByProject
in interfaceFilteringPlanManager
-
getBranchesForChain
@NotNull public @NotNull List<ImmutableChainBranch> getBranchesForChain(@NotNull @NotNull PlanIdentifier chain) Description copied from interface:FilteringPlanManager
Get all feature branches associated with the given chain, sorted. In clustered mode, there is NO consistency guarantee.- Specified by:
getBranchesForChain
in interfaceFilteringPlanManager
- Parameters:
chain
- - the master- Returns:
- List
ChainBranch
s associated with the given chain.
-
getBranchesForChainWithConsistencyGuarantee
@NotNull public @NotNull List<ImmutableChainBranch> getBranchesForChainWithConsistencyGuarantee(@NotNull @NotNull PlanIdentifier chain) Description copied from interface:FilteringPlanManager
Get all feature branches associated with the given chain, sorted. There is a guarantee that the data will be up-to-date.- Specified by:
getBranchesForChainWithConsistencyGuarantee
in interfaceFilteringPlanManager
- Parameters:
chain
- - the master- Returns:
- List
ChainBranch
s associated with the given chain.
-
getBranchesOfChain
@NotNull public @NotNull Stream<ImmutableChainBranch> getBranchesOfChain(@NotNull @NotNull PlanKey chainKey) Description copied from interface:FilteringPlanManager
Get all feature branches associated with the given chain, unsorted. In clustered mode, there is NO consistency guarantee.- Specified by:
getBranchesOfChain
in interfaceFilteringPlanManager
- Parameters:
chainKey
- - the master- Returns:
- List
ChainBranch
s associated with the given chain.
-
getBranchesOfChainWithConsistencyGuarantee
@NotNull public @NotNull Stream<ImmutableChainBranch> getBranchesOfChainWithConsistencyGuarantee(@NotNull @NotNull PlanKey chainKey) Description copied from interface:FilteringPlanManager
Get all feature branches associated with the given chain, unsorted. There is a guarantee that the data will be up-to-date.- Specified by:
getBranchesOfChainWithConsistencyGuarantee
in interfaceFilteringPlanManager
- Parameters:
chainKey
- - the master- Returns:
- List
ChainBranch
s associated with the given chain.
-
getBranchKeysOfChain
Description copied from interface:CachedPlanManager
Returns keys of all branches for the supplied chain.- Specified by:
getBranchKeysOfChain
in interfaceCachedPlanManager
-
getBranchGistsOfChain
@NotNull public @NotNull Set<PlanBranchGist> getBranchGistsOfChain(@NotNull @NotNull PlanKey chainKey) Description copied from interface:CachedPlanManager
Returns basic data of all branches for the supplied chain.- Specified by:
getBranchGistsOfChain
in interfaceCachedPlanManager
-
getBranchGistsOfChainWithConsistencyGuarantee
@NotNull public @NotNull Set<PlanBranchGist> getBranchGistsOfChainWithConsistencyGuarantee(@NotNull @NotNull PlanKey chainKey) Description copied from interface:CachedPlanManager
Returns basic data of all branches for the supplied chain with guarantee that eventual new plan branches not present in the cache will be taken in consideration.- Specified by:
getBranchGistsOfChainWithConsistencyGuarantee
in interfaceCachedPlanManager
- Parameters:
chainKey
- the key of the chain- Returns:
- highly-consistent list of branches' gists associated with a master plan identified by the given key, including eventual new branches not present in the database
-
getMasterPlan
Description copied from interface:CachedPlanManager
Returns master branch for a given branchKey. If branchKey identifies plan which has no master (is a master itself) then this plan is returned, otherwise a master of a plan is returned.- Specified by:
getMasterPlan
in interfaceCachedPlanManager
- Parameters:
branchKey
- key of a branch- Returns:
- master branch for a given branchKey or null if branchKey doesn't identify a plan
-
isBranchOf
Description copied from interface:CachedPlanManager
Test if plan identified by branchKey is a branch of plan identified by chainKey. If branchKey identifies master plan method also returns true.- Specified by:
isBranchOf
in interfaceCachedPlanManager
- Parameters:
chainKey
- key of master branchbranchKey
- key of alleged branch- Returns:
- true if plan identified by branchKey is a branch of plan identified by chainKey, false otherwise
-
assertPlanPermission
Description copied from interface:FilteringPlanManager
Used to validate user permission for plan. This method is Acegi-filtered.- Specified by:
assertPlanPermission
in interfaceFilteringPlanManager
- Parameters:
plan
- to check the permissions of- Returns:
- true if the current user has read(?) permissions on the plan
-
getPlansForClone
Description copied from interface:FilteringPlanManager
Returns allChain
's. Return list filtered to show only plans the current user is allowed to clone.- Specified by:
getPlansForClone
in interfaceFilteringPlanManager
- Returns:
- plans
-
getRunnablePlans
@NotNull public <T extends ImmutablePlan> @NotNull List<T> getRunnablePlans(@NotNull @NotNull Project project, @NotNull @NotNull Class<T> planType) Description copied from interface:FilteringPlanManager
- Specified by:
getRunnablePlans
in interfaceFilteringPlanManager
- Parameters:
project
- - that the plans will belong toplanType
- - the type of the plan to retrieve- Returns:
- plans contained within the given project and of the given type
-
getMasterOfJob
@Nullable public @Nullable ImmutableJob getMasterOfJob(@NotNull @NotNull PlanKey masterChainKey, @NotNull @NotNull PlanKey jobKey) - Specified by:
getMasterOfJob
in interfaceCachedPlanManager
-
getPlansWithRepository
Description copied from interface:CachedPlanManager
Returns chains that use repositories with given params. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansWithRepository
in interfaceCachedPlanManager
-
getPlansWithRepositoryWithConsistencyGuarantee
public Iterable<ImmutableChain> getPlansWithRepositoryWithConsistencyGuarantee(@NotNull PlanRepositoryIndex.Query query) Description copied from interface:CachedPlanManager
Returns chains that use repositories with given params. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansWithRepositoryWithConsistencyGuarantee
in interfaceCachedPlanManager
-
getFilteredPlansWithRepository
public Stream<ImmutableChain> getFilteredPlansWithRepository(@NotNull PlanRepositoryIndex.Query query) Description copied from interface:FilteringPlanManager
Returns chains that use repositories with given params- Specified by:
getFilteredPlansWithRepository
in interfaceFilteringPlanManager
-
getAnyPlan
Description copied from interface:CachedPlanManager
Returns a plan matching the supplied predicate, permission filtering is applied.- Specified by:
getAnyPlan
in interfaceCachedPlanManager
- Specified by:
getAnyPlan
in interfaceFilteringPlanManager
-
getAnyPlanUnrestricted
Description copied from interface:CachedPlanManager
Returns a plan matching the supplied predicate.- Specified by:
getAnyPlanUnrestricted
in interfaceCachedPlanManager
-
getPlanById
Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its database id andClass
- Specified by:
getPlanById
in interfaceCachedPlanManager
- Parameters:
id
- to search forplanType
- - the type of the plan to retrieve- Returns:
- plan with the given database id, if found AND is of the correct type.
-
getPlanByIdNotThrowing
Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its database id andClass
. This method does not throw exception if plan is not found. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlanByIdNotThrowing
in interfaceCachedPlanManager
- Parameters:
id
- to search forplanType
- - the type of the plan to retrieve- Returns:
- plan with the given database id, if found AND is of the correct type, null otherwise
-
getPlanByIdNotThrowingWithConsistencyGuarantee
@Nullable public <T extends ImmutablePlan> T getPlanByIdNotThrowingWithConsistencyGuarantee(long id, Class<T> planType) Description copied from interface:CachedPlanManager
Returns aImmutablePlan
by its database id andClass
. This method does not throw exception if plan is not found. There is a guarantee that the data will be up-to-date.- Specified by:
getPlanByIdNotThrowingWithConsistencyGuarantee
in interfaceCachedPlanManager
- Parameters:
id
- to search forplanType
- - the type of the plan to retrieve- Returns:
- plan with the given database id, if found AND is of the correct type, null otherwise
-
getAllProjectsWithPlan
Description copied from interface:CachedPlanManager
Returns all projects which have at least one plan (plan is in the cache)- Specified by:
getAllProjectsWithPlan
in interfaceCachedPlanManager
- Returns:
-