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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanassertPlanPermission(@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 ImmutableJobgetMasterOfJob(@NotNull PlanKey masterChainKey, @NotNull PlanKey jobKey) @Nullable ImmutableChaingetMasterPlan(@NotNull PlanKey branchKey) Returns master branch for a given branchKey.<T extends ImmutablePlan>
TgetPlanById(long id, Class<T> planType) Returns aImmutablePlanby its database id andClass<T extends ImmutablePlan>
TgetPlanByIdNotThrowing(long id, Class<T> planType) Returns aImmutablePlanby its database id andClass.<T extends ImmutablePlan>
TgetPlanByIdNotThrowingWithConsistencyGuarantee(long id, Class<T> planType) Returns aImmutablePlanby its database id andClass.@Nullable ImmutablePlangetPlanByKey(@NotNull PlanKey planKey) Returns aImmutablePlanby its planKey.<T extends ImmutablePlan>
TgetPlanByKey(@NotNull PlanKey planKey, Class<T> planType) Returns aImmutablePlanby 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 ImmutablePlangetPlanByKeyWithConsistencyGuarantee(@NotNull PlanKey planKey) Returns aImmutablePlanby its planKey.<T extends ImmutablePlan>
TgetPlanByKeyWithConsistencyGuarantee(@NotNull PlanKey planKey, Class<T> planType) Returns aImmutablePlanby 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 byProjectignoring permissions.@NotNull List<ImmutableChain>Returns allImmutableChain's filtered byProjectignoring 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) booleanisBranchOf(@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:CachedPlanManagerReturns aImmutablePlanby its planKey. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlanByKeyin 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:CachedPlanManagerReturns aImmutablePlanby its planKey. There is a guarantee that the data will be up-to-date.- Specified by:
getPlanByKeyWithConsistencyGuaranteein 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:CachedPlanManagerReturns aImmutablePlanby its planKey andClass. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlanByKeyin 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:CachedPlanManagerReturns aImmutablePlanby its planKey andClass. There is a guarantee that the data will be up-to-date.- Specified by:
getPlanByKeyWithConsistencyGuaranteein 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:CachedPlanManagerReturns aPlanby 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:
getPlanByKeyIfOfTypein 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:CachedPlanManagerReturns aPlanby 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:
getPlanByKeyIfOfTypeWithConsistencyGuaranteein interfaceCachedPlanManager- Returns:
- null if the plan doesn't exist, or it's not of the found type
-
getPlans
Description copied from interface:FilteringPlanManagerReturns allTopLevelPlan's. This method is Acegi-filtered.- Specified by:
getPlansin interfaceFilteringPlanManager- Returns:
- plans
-
getPlansUnrestricted
Description copied from interface:CachedPlanManagerReturns allImmutableTopLevelPlan's ignoring permissions. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansUnrestrictedin interfaceCachedPlanManager
-
getPlansUnrestrictedWithConsistencyGuarantee
Description copied from interface:CachedPlanManagerReturns allImmutableTopLevelPlan's ignoring permissions. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansUnrestrictedWithConsistencyGuaranteein interfaceCachedPlanManager
-
getPlansByProjectUnrestricted
Description copied from interface:CachedPlanManagerReturns allImmutableChain's filtered byProjectignoring permissions. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansByProjectUnrestrictedin interfaceCachedPlanManager- Parameters:
project- - that the plans will belong to- Returns:
ImmutableChainplans contained within the given project
-
getPlansByProjectUnrestrictedWithConsistencyGuarantee
@NotNull public @NotNull List<ImmutableChain> getPlansByProjectUnrestrictedWithConsistencyGuarantee(Project project) Description copied from interface:CachedPlanManagerReturns allImmutableChain's filtered byProjectignoring permissions. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansByProjectUnrestrictedWithConsistencyGuaranteein interfaceCachedPlanManager- Parameters:
project- - that the plans will belong to- Returns:
ImmutableChainplans contained within the given project
-
getPlans
Description copied from interface:FilteringPlanManagerReturns allPlan's filtered byClass. Does not include plans marked for deletion. This method is Acegi-filtered.- Specified by:
getPlansin 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:FilteringPlanManagerReturns 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:
getPlansin 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:FilteringPlanManagerReturns 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:
getPlansWithConsistencyGuaranteein interfaceFilteringPlanManager- Parameters:
planType- - the type of the plan to retrieve- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getPlansByProject
Description copied from interface:FilteringPlanManagerReturns allImmutableTopLevelPlan's filtered byProject. This method is Acegi-filtered. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansByProjectin interfaceFilteringPlanManager- Parameters:
project- - that the plans will belong to- Returns:
ImmutableTopLevelPlanplans contained within the given project
-
getPlansByProjectWithConsistencyGuarantee
@NotNull public @NotNull List<ImmutableTopLevelPlan> getPlansByProjectWithConsistencyGuarantee(Project project) Description copied from interface:FilteringPlanManagerReturns allImmutableTopLevelPlan's filtered byProject. This method is Acegi-filtered. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansByProjectWithConsistencyGuaranteein interfaceFilteringPlanManager- Parameters:
project- - that the plans will belong to- Returns:
ImmutableTopLevelPlanplans contained within the given project
-
getEditablePlansByProject
Description copied from interface:FilteringPlanManagerReturns allPlan's filtered byProjectand user can edit (EDIT permission assigned for plan to user)- Specified by:
getEditablePlansByProjectin 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:FilteringPlanManagerReturns allPlan's filtered byProjectandClass. This method is Acegi-filtered. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansByProjectin 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:FilteringPlanManagerReturns allPlan's filtered byProjectandClass. This method is Acegi-filtered. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansByProjectWithConsistencyGuaranteein 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:
getPlansByProjectin interfaceFilteringPlanManager
-
getBranchesForChain
@NotNull public @NotNull List<ImmutableChainBranch> getBranchesForChain(@NotNull @NotNull PlanIdentifier chain) Description copied from interface:FilteringPlanManagerGet all feature branches associated with the given chain, sorted. In clustered mode, there is NO consistency guarantee.- Specified by:
getBranchesForChainin interfaceFilteringPlanManager- Parameters:
chain- - the master- Returns:
- List
ChainBranchs associated with the given chain.
-
getBranchesForChainWithConsistencyGuarantee
@NotNull public @NotNull List<ImmutableChainBranch> getBranchesForChainWithConsistencyGuarantee(@NotNull @NotNull PlanIdentifier chain) Description copied from interface:FilteringPlanManagerGet all feature branches associated with the given chain, sorted. There is a guarantee that the data will be up-to-date.- Specified by:
getBranchesForChainWithConsistencyGuaranteein interfaceFilteringPlanManager- Parameters:
chain- - the master- Returns:
- List
ChainBranchs associated with the given chain.
-
getBranchesOfChain
@NotNull public @NotNull Stream<ImmutableChainBranch> getBranchesOfChain(@NotNull @NotNull PlanKey chainKey) Description copied from interface:FilteringPlanManagerGet all feature branches associated with the given chain, unsorted. In clustered mode, there is NO consistency guarantee.- Specified by:
getBranchesOfChainin interfaceFilteringPlanManager- Parameters:
chainKey- - the master- Returns:
- List
ChainBranchs associated with the given chain.
-
getBranchesOfChainWithConsistencyGuarantee
@NotNull public @NotNull Stream<ImmutableChainBranch> getBranchesOfChainWithConsistencyGuarantee(@NotNull @NotNull PlanKey chainKey) Description copied from interface:FilteringPlanManagerGet all feature branches associated with the given chain, unsorted. There is a guarantee that the data will be up-to-date.- Specified by:
getBranchesOfChainWithConsistencyGuaranteein interfaceFilteringPlanManager- Parameters:
chainKey- - the master- Returns:
- List
ChainBranchs associated with the given chain.
-
getBranchKeysOfChain
Description copied from interface:CachedPlanManagerReturns keys of all branches for the supplied chain.- Specified by:
getBranchKeysOfChainin interfaceCachedPlanManager
-
getBranchGistsOfChain
@NotNull public @NotNull Set<PlanBranchGist> getBranchGistsOfChain(@NotNull @NotNull PlanKey chainKey) Description copied from interface:CachedPlanManagerReturns basic data of all branches for the supplied chain.- Specified by:
getBranchGistsOfChainin interfaceCachedPlanManager
-
getBranchGistsOfChainWithConsistencyGuarantee
@NotNull public @NotNull Set<PlanBranchGist> getBranchGistsOfChainWithConsistencyGuarantee(@NotNull @NotNull PlanKey chainKey) Description copied from interface:CachedPlanManagerReturns 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:
getBranchGistsOfChainWithConsistencyGuaranteein 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:CachedPlanManagerReturns 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:
getMasterPlanin 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:CachedPlanManagerTest if plan identified by branchKey is a branch of plan identified by chainKey. If branchKey identifies master plan method also returns true.- Specified by:
isBranchOfin 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:FilteringPlanManagerUsed to validate user permission for plan. This method is Acegi-filtered.- Specified by:
assertPlanPermissionin 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:FilteringPlanManagerReturns allChain's. Return list filtered to show only plans the current user is allowed to clone.- Specified by:
getPlansForClonein 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:
getRunnablePlansin 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:
getMasterOfJobin interfaceCachedPlanManager
-
getPlansWithRepository
Description copied from interface:CachedPlanManagerReturns chains that use repositories with given params. In clustered mode, there is NO consistency guarantee.- Specified by:
getPlansWithRepositoryin interfaceCachedPlanManager
-
getPlansWithRepositoryWithConsistencyGuarantee
public Iterable<ImmutableChain> getPlansWithRepositoryWithConsistencyGuarantee(@NotNull PlanRepositoryIndex.Query query) Description copied from interface:CachedPlanManagerReturns chains that use repositories with given params. There is a guarantee that the data will be up-to-date.- Specified by:
getPlansWithRepositoryWithConsistencyGuaranteein interfaceCachedPlanManager
-
getFilteredPlansWithRepository
public Stream<ImmutableChain> getFilteredPlansWithRepository(@NotNull PlanRepositoryIndex.Query query) Description copied from interface:FilteringPlanManagerReturns chains that use repositories with given params- Specified by:
getFilteredPlansWithRepositoryin interfaceFilteringPlanManager
-
getAnyPlan
Description copied from interface:CachedPlanManagerReturns a plan matching the supplied predicate, permission filtering is applied.- Specified by:
getAnyPlanin interfaceCachedPlanManager- Specified by:
getAnyPlanin interfaceFilteringPlanManager
-
getAnyPlanUnrestricted
Description copied from interface:CachedPlanManagerReturns a plan matching the supplied predicate.- Specified by:
getAnyPlanUnrestrictedin interfaceCachedPlanManager
-
getPlanById
Description copied from interface:CachedPlanManagerReturns aImmutablePlanby its database id andClass- Specified by:
getPlanByIdin 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:CachedPlanManagerReturns aImmutablePlanby 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:
getPlanByIdNotThrowingin 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:CachedPlanManagerReturns aImmutablePlanby 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:
getPlanByIdNotThrowingWithConsistencyGuaranteein 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:CachedPlanManagerReturns all projects which have at least one plan (plan is in the cache)- Specified by:
getAllProjectsWithPlanin interfaceCachedPlanManager- Returns:
-