Package com.atlassian.bamboo.plan
Interface PlanManager
- All Known Implementing Classes:
PlanManagerImpl
@PublicApi
public interface PlanManager
Manager for all Plan types within Bamboo
Use this manager if you need to address Builds, Plans, etc.
- Since:
- 2.7
-
Method Summary
Modifier and TypeMethodDescriptionbooleanassertPlanPermission(@NotNull PlanIdentifier plan) Used to validate user permission for plan.voidcreatePlan(Plan plan) Same as savePlan, but create permissions used instead of edit permissions.voiddeletePlan(@NotNull Plan plan) Removes the plan object from the database.@NotNull Set<ImmutableChain>filterFavouritedPlans(@NotNull Collection<? extends ImmutableChain> plans, @NotNull com.atlassian.user.User user) Return a set ofPlans that are a subset of the givenTopLevelPlans collection that are favourited by theUser.WARNING this is probably a bad idea from a performance perspective, only do this if you're going to traverse through all theChainStageandJobof allChains returned.getAllPlans(Class<T> planType) getAllPlans(Class<T> planType, int firstResult, int maxResults) getAllPlansByProject(Project project, Class<T> planType) <T extends Plan>
longgetAllPlansMarkedForDeletionCount(Class<T> planType) Returns a count ofPlans that areImmutableDeletable.isMarkedForDeletion()for the given typeReturns allTopLevelPlan's ignoring permissionsgetFavouritePlans(@NotNull com.atlassian.user.User user) getFavouritePlansIds(@NotNull com.atlassian.user.User user) Return a collection of Favourite plan ids.@Nullable PlangetPlanById(long id) Returns aPlanby its id<T extends Plan>
TgetPlanById(long id, Class<T> planType) @Nullable PlangetPlanByKey(@NotNull PlanKey planKey) <T extends Plan>
TgetPlanByKey(@NotNull PlanKey planKey, Class<T> planType) @Nullable PlangetPlanByKey(@NotNull String planKey) Deprecated.since 4.2<T extends Plan>
TgetPlanByKey(@NotNull String planKey, Class<T> planType) Deprecated.since 4.2<T extends Plan>
TgetPlanByKeyIfOfType(@NotNull PlanKey planKey, @NotNull Class<T> planType) <T extends Plan>
TgetPlanByOid(BambooEntityOid oid, Class<T> planType) <T extends Plan>
TgetPlanByPartialKeyAndName(@NotNull PlanKey partialPlanKey, @NotNull String planName, Class<T> planType) Deprecated.since 4.2getPlanClass(@NotNull PlanKey planKey) intintgetPlanCount(@NotNull ProjectIdentifier projectIdentifier) How many plans currently exist in aproject.<T extends Plan>
intgetPlanCount(Class<T> planType) How many plans filtered byClasscurrently exist@Nullable PlanIdentifiergetPlanIdentifierForPermissionCheckingByKey(@NotNull String planKey) Returns aPlanskeleton skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi<T extends Plan>
@NotNull List<PlanIdentifier>getPlanIdentifiersForProject(@NotNull ProjectIdentifier project, @NotNull Class<T> planType, boolean includeMarkedForDeletion) Retrieve a list of plans for a given project.@NotNull List<TopLevelPlan>getPlansByProject(Project project) Returns allTopLevelPlan's filtered byProjectResult of this method is filtered by Acegi.getPlansByProject(Project project, Class<T> planType) <T extends Plan>
@NotNull Map<Project,Collection<T>> getProjectPlanMap(Class<T> planType, boolean includeEmptyProjects) booleanisChainNameConflicting(@NotNull String projectKey, long planIdToIgnore, @NotNull String planName) Verifies whether aChainname is unique with the given projectbooleanCheck whether or not a plan can be created or not (based on licensing etc)booleanisPlanKeyConflicting(@NotNull PlanKey planKey) Verifies whether aPlankey is unique within whole Bamboo installationbooleanisPlanKeyConflicting(@NotNull PlanKey planKey, long planIdToIgnore) Verifies whether aPlankey is unique within whole Bamboo installationvoidmarkPlansForDeletion(PlanKey planKey) Efficiently marks a plan to be deletedvoidremoveStages(@NotNull PlanKey key, @NotNull Collection<Long> stageIds) Remove the tages from the plan specified. key must be for aChainvoidSaves thePlanvoidsavePlanWithSchedulesStopped(@NotNull Plan plan) Saves thePlanwhile polling jobs are stopped.voidsetPlanSuspendedState(PlanKey planKey, boolean isSuspended) voidtriggerConfigUpdatedEventsForPlansInProject(@NotNull Project project) Triggers updated events for every plan in a project regardless of permissions.
-
Method Details
-
getPlanIdentifierForPermissionCheckingByKey
@Nullable @Nullable PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull @NotNull String planKey) Returns aPlanskeleton skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using AcegiIf
Jobkey is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only forTopLevelPlans- Parameters:
planKey- of the plan to find- Returns:
- plan by the id if found, otherwise null
- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type (should never happen)
-
getPlanById
Returns aPlanby its id- Parameters:
id- of the plan- Returns:
- plan with the given id, null if it doesn't exist
- Throws:
IncorrectPlanTypeException- if plan cannot be found
-
getPlanById
@Nullable <T extends Plan> T getPlanById(long id, Class<T> planType) throws IncorrectPlanTypeException - Parameters:
id- of the planplanType- - the type of the plan to retrieve- Returns:
- plan with the given id, if found AND is of the correct type.
- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type
-
getPlanByOid
@Nullable <T extends Plan> T getPlanByOid(BambooEntityOid oid, Class<T> planType) throws IncorrectPlanTypeException - Parameters:
oid- of the planplanType- - the type of the plan to retrieve- Returns:
- plan with the given oid, if found AND is of the correct type.
- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type
-
getPlanByKey
@Nullable @Nullable Plan getPlanByKey(@NotNull @NotNull PlanKey planKey) throws IncorrectPlanTypeException - Parameters:
planKey- to search for- Returns:
- plan
- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type (should never happen)
-
getPlanByKey
@Nullable <T extends Plan> T getPlanByKey(@NotNull @NotNull PlanKey planKey, Class<T> planType) throws IncorrectPlanTypeException - Parameters:
planKey- to search forplanType- - the type of the plan to retrieve- Returns:
- plan with the given key, if found AND is of the correct type.
- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type
-
getPlanByKeyIfOfType
@Nullable <T extends Plan> T getPlanByKeyIfOfType(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Class<T> planType) Returns 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.- Parameters:
planKey- to search forplanType- the type of the plan to retrieve- Returns:
- null if the plan doesn't exist, or it's not of the found type
-
getAllPlansUnrestricted
List<TopLevelPlan> getAllPlansUnrestricted()Returns allTopLevelPlan's ignoring permissions- Returns:
-
getAllPlans
- Parameters:
planType- - the type of the plan to retrieve- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getAllPlans
@NotNull <T extends Plan> @NotNull List<T> getAllPlans(Class<T> planType, int firstResult, int maxResults) - Parameters:
planType- - the type of the plan to retrievefirstResult- firstResult for a paginated resultsmaxResults- maximum number of results to return- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getAllChainsAndJobsUnrestricted
WARNING this is probably a bad idea from a performance perspective, only do this if you're going to traverse through all theChainStageandJobof allChains returned.- Returns:
-
getPlansByProject
Returns allTopLevelPlan's filtered byProjectResult of this method is filtered by Acegi.- Parameters:
project- - that the plans will belong to- Returns:
TopLevelPlanplans contained within the given project
-
getPlansByProject
- 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
-
getAllPlansByProject
- 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
-
getProjectPlanMap
@NotNull <T extends Plan> @NotNull Map<Project,Collection<T>> getProjectPlanMap(Class<T> planType, boolean includeEmptyProjects) -
getPlanIdentifiersForProject
@NotNull <T extends Plan> @NotNull List<PlanIdentifier> getPlanIdentifiersForProject(@NotNull @NotNull ProjectIdentifier project, @NotNull @NotNull Class<T> planType, boolean includeMarkedForDeletion) Retrieve a list of plans for a given project. Only minimal data about the plans is returned.- Parameters:
project- to get plans forplanType- to filter plans byincludeMarkedForDeletion- set to true if you want to return plans marked for deletion- Returns:
- PlanIdentifiers meeting the above criteria.
-
getFavouritePlans
-
getFavouritePlansIds
Return a collection of Favourite plan ids.- Parameters:
user-- Returns:
- favouritePlansIds
-
filterFavouritedPlans
@NotNull @NotNull Set<ImmutableChain> filterFavouritedPlans(@NotNull @NotNull Collection<? extends ImmutableChain> plans, @NotNull @NotNull com.atlassian.user.User user) Return a set ofPlans that are a subset of the givenTopLevelPlans collection that are favourited by theUser. Plans are not filtered by read permission.- Parameters:
plans- to filteruser- to return the favourites of- Returns:
- a set of
Chains that are a subset of the givenTopLevelPlans collection that are favourited by theUser
-
getPlanCount
int getPlanCount()- Returns:
- How many
Buildable's exists
-
getPlanCount
How many plans filtered byClasscurrently exist- Parameters:
planType- - the type of the plan to retrieve- Returns:
- how many plans exist in the datbase
-
getPlanCount
How many plans currently exist in aproject.- Parameters:
projectIdentifier- identifier of the project- Returns:
- number of plans in the project, excluding ones marked for deletion
-
isChainNameConflicting
boolean isChainNameConflicting(@NotNull @NotNull String projectKey, long planIdToIgnore, @NotNull @NotNull String planName) Verifies whether aChainname is unique with the given project- Parameters:
projectKey- of the project to look for the plan inplanIdToIgnore- the id of the plan that has to be ignored during lookup (when you're saving a Plan, you should supply the plan id here)planName- - name of the plan inside the project: this is just the plan component of the name (i.e does not include the project component)- Returns:
- true if the name is in conflict
- Since:
- 4.0
-
isPlanKeyConflicting
Verifies whether aPlankey is unique within whole Bamboo installation- Parameters:
planKey- key of the plan to be searched for in the database- Returns:
- true if plan key is conflicting
- Since:
- 4.3
-
isPlanKeyConflicting
Verifies whether aPlankey is unique within whole Bamboo installation- Parameters:
planKey-planIdToIgnore- id of plan which we want to set key for, if the key is used by that plan, it's not really conflicting- Returns:
- true if plan key is conflicting
- Since:
- 5.15
-
getPlanByPartialKeyAndName
@Nullable @Deprecated <T extends Plan> T getPlanByPartialKeyAndName(@NotNull @NotNull PlanKey partialPlanKey, @NotNull @NotNull String planName, Class<T> planType) throws IncorrectPlanTypeException Deprecated.since 4.2Used for Job validation. Should update to be a specialised method- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type
-
getPlanClass
-
assertPlanPermission
Used to validate user permission for plan.- Parameters:
plan- to check the permissions of- Returns:
- true if the current user has read(?) permissions on the plan
-
isPlanCreationAllowed
boolean isPlanCreationAllowed()Check whether or not a plan can be created or not (based on licensing etc)- Returns:
- true if a plan can be created otherwise false;
-
savePlan
Saves thePlan- Parameters:
plan- to be saved
-
savePlanWithSchedulesStopped
Saves thePlanwhile polling jobs are stopped.- Parameters:
plan-- Since:
- 5.0
-
setPlanSuspendedState
-
triggerConfigUpdatedEventsForPlansInProject
Triggers updated events for every plan in a project regardless of permissions.- Parameters:
project- to trigger event for.
-
createPlan
Same as savePlan, but create permissions used instead of edit permissions. -
deletePlan
Removes the plan object from the database. Does not do any other clean up work at all Please use theDeletionServicerather than using this method directly- Parameters:
plan- to delete.
-
markPlansForDeletion
Efficiently marks a plan to be deleted- Parameters:
planKey-
-
removeStages
Remove the tages from the plan specified. key must be for aChain- Parameters:
key-stageIds-
-
getPlanByKey
@Nullable @Deprecated @Nullable Plan getPlanByKey(@NotNull @NotNull String planKey) throws IncorrectPlanTypeException Deprecated.since 4.2Returns aPlanby its planKey- Parameters:
planKey- of the plan to find- Returns:
- plan by the id if found, otherwise null
- Throws:
IncorrectPlanTypeException- if plan cannot be found with the correct type (should never happen)
-
getPlanByKey
@Nullable @Deprecated <T extends Plan> T getPlanByKey(@NotNull @NotNull String planKey, Class<T> planType) throws IncorrectPlanTypeException Deprecated.since 4.2- 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
-
getAllPlansMarkedForDeletionCount
Returns a count ofPlans that areImmutableDeletable.isMarkedForDeletion()for the given type- Returns:
- number of plans of a requested type scheduled for deletion
- Since:
- 10.0
-