Package com.atlassian.bamboo.plan
Class PlanManagerImpl
java.lang.Object
com.atlassian.bamboo.plan.PlanManagerImpl
- All Implemented Interfaces:
PlanManager
-
Constructor Summary
ConstructorDescriptionPlanManagerImpl
(@NotNull PlanDao planDao, @NotNull BambooLicenseManager bambooLicenseManager, @NotNull com.atlassian.event.api.EventPublisher eventPublisher, @NotNull ProjectManager projectManager, @NotNull PlanScheduler planScheduler) -
Method Summary
Modifier and TypeMethodDescriptionboolean
assertPlanPermission
(@NotNull PlanIdentifier plan) Used to validate user permission for plan.void
createPlan
(@NotNull Plan plan) Same as savePlan, but create permissions used instead of edit permissions.void
deletePlan
(@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 ofPlan
s that are a subset of the givenTopLevelPlan
s 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 theChainStage
andJob
of allChain
s 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 ofPlan
s that areImmutableDeletable.isMarkedForDeletion()
for the given type@NotNull List<TopLevelPlan>
Returns 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 Plan
getPlanById
(long id) Returns aPlan
by its id<T extends Plan>
TgetPlanById
(long id, Class<T> planType) getPlanByKey
(@NotNull PlanKey planKey) <T extends Plan>
TgetPlanByKey
(@NotNull PlanKey planKey, Class<T> planType) @Nullable Plan
getPlanByKey
(@NotNull String planKey) Returns aPlan
by its planKey<T extends Plan>
TgetPlanByKey
(@NotNull String planKey, Class<T> planType) <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) Used for Job validation.getPlanClass
(@NotNull PlanKey planKey) int
int
getPlanCount
(@NotNull ProjectIdentifier projectIdentifier) How many plans currently exist in aproject
.<T extends Plan>
intgetPlanCount
(Class<T> planType) How many plans filtered byClass
currently existgetPlanIdentifierForPermissionCheckingByKey
(@NotNull String planKey) Returns aPlan
skeleton 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 byProject
Result 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) boolean
isChainNameConflicting
(@NotNull String projectKey, long planIdToIgnore, @NotNull String planName) Verifies whether aChain
name is unique with the given projectboolean
Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!!!boolean
isPlanKeyConflicting
(@NotNull PlanKey planKey) Verifies whether aPlan
key is unique within whole Bamboo installationboolean
isPlanKeyConflicting
(@NotNull PlanKey planKey, long planIdToIgnore) Verifies whether aPlan
key is unique within whole Bamboo installationvoid
markPlansForDeletion
(PlanKey planKey) Efficiently marks a plan to be deletedvoid
removeStages
(@NotNull PlanKey key, @NotNull Collection<Long> stageIds) Remove the tages from the plan specified.void
Saves thePlan
void
savePlanWithSchedulesStopped
(@NotNull Plan plan) Saves thePlan
while polling jobs are stopped.void
setPlanSuspendedState
(PlanKey planKey, boolean isSuspended) void
triggerConfigUpdatedEventsForPlansInProject
(@NotNull Project project) Triggers updated events for every plan in a project regardless of permissions.
-
Constructor Details
-
PlanManagerImpl
public PlanManagerImpl(@NotNull @NotNull PlanDao planDao, @NotNull @NotNull BambooLicenseManager bambooLicenseManager, @NotNull @NotNull com.atlassian.event.api.EventPublisher eventPublisher, @NotNull @NotNull ProjectManager projectManager, @NotNull @NotNull PlanScheduler planScheduler)
-
-
Method Details
-
getPlanById
Description copied from interface:PlanManager
Returns aPlan
by its id- Specified by:
getPlanById
in interfacePlanManager
- 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 public <T extends Plan> T getPlanById(long id, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:PlanManager
- Specified by:
getPlanById
in interfacePlanManager
- 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 public <T extends Plan> T getPlanByOid(BambooEntityOid oid, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:PlanManager
- Specified by:
getPlanByOid
in interfacePlanManager
- 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 public @Nullable Plan getPlanByKey(@NotNull @NotNull String planKey) throws IncorrectPlanTypeException Description copied from interface:PlanManager
Returns aPlan
by its planKey- Specified by:
getPlanByKey
in interfacePlanManager
- 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 public <T extends Plan> T getPlanByKey(@NotNull @NotNull String planKey, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:PlanManager
- Specified by:
getPlanByKey
in interfacePlanManager
- 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
-
getPlanIdentifierForPermissionCheckingByKey
Description copied from interface:PlanManager
Returns aPlan
skeleton skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using AcegiIf
Job
key is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only forTopLevelPlan
s- Specified by:
getPlanIdentifierForPermissionCheckingByKey
in interfacePlanManager
- Parameters:
planKey
- of the plan to find- Returns:
- plan by the id if found, otherwise null
-
getPlanClass
- Specified by:
getPlanClass
in interfacePlanManager
-
getPlanByKeyIfOfType
public <T extends Plan> T getPlanByKeyIfOfType(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Class<T> planType) Description copied from interface:PlanManager
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.- Specified by:
getPlanByKeyIfOfType
in interfacePlanManager
- 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
-
getPlanByKey
Description copied from interface:PlanManager
- Specified by:
getPlanByKey
in interfacePlanManager
- Parameters:
planKey
- to search for- Returns:
- plan
- Throws:
IncorrectPlanTypeException
- if plan cannot be found with the correct type (should never happen)
-
assertPlanPermission
Description copied from interface:PlanManager
Used to validate user permission for plan.- Specified by:
assertPlanPermission
in interfacePlanManager
- Parameters:
plan
- to check the permissions of- Returns:
- true if the current user has read(?) permissions on the plan
-
getPlanByKey
public <T extends Plan> T getPlanByKey(@NotNull @NotNull PlanKey planKey, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:PlanManager
- Specified by:
getPlanByKey
in interfacePlanManager
- 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
-
isChainNameConflicting
public boolean isChainNameConflicting(@NotNull @NotNull String projectKey, long planIdToIgnore, @NotNull @NotNull String planName) Description copied from interface:PlanManager
Verifies whether aChain
name is unique with the given project- Specified by:
isChainNameConflicting
in interfacePlanManager
- 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
-
isPlanKeyConflicting
Description copied from interface:PlanManager
Verifies whether aPlan
key is unique within whole Bamboo installation- Specified by:
isPlanKeyConflicting
in interfacePlanManager
- Parameters:
planKey
- key of the plan to be searched for in the database- Returns:
- true if plan key is conflicting
-
isPlanKeyConflicting
Description copied from interface:PlanManager
Verifies whether aPlan
key is unique within whole Bamboo installation- Specified by:
isPlanKeyConflicting
in interfacePlanManager
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
-
getPlanByPartialKeyAndName
@Nullable public <T extends Plan> T getPlanByPartialKeyAndName(@NotNull @NotNull PlanKey partialPlanKey, @NotNull @NotNull String planName, Class<T> planType) throws IncorrectPlanTypeException Description copied from interface:PlanManager
Used for Job validation. Should update to be a specialised method- Specified by:
getPlanByPartialKeyAndName
in interfacePlanManager
- Throws:
IncorrectPlanTypeException
- if plan cannot be found with the correct type
-
getAllPlansUnrestricted
Description copied from interface:PlanManager
Returns allTopLevelPlan
's ignoring permissions- Specified by:
getAllPlansUnrestricted
in interfacePlanManager
- Returns:
-
getAllPlans
Description copied from interface:PlanManager
- Specified by:
getAllPlans
in interfacePlanManager
- Parameters:
planType
- - the type of the plan to retrieve- Returns:
- plans sorted by
DescriptionProvider.getName()
-
getAllPlans
@NotNull public <T extends Plan> @NotNull List<T> getAllPlans(Class<T> planType, int firstResult, int maxResults) Description copied from interface:PlanManager
- Specified by:
getAllPlans
in interfacePlanManager
- 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
Description copied from interface:PlanManager
WARNING this is probably a bad idea from a performance perspective, only do this if you're going to traverse through all theChainStage
andJob
of allChain
s returned.- Specified by:
getAllChainsAndJobsUnrestricted
in interfacePlanManager
- Returns:
-
getPlansByProject
Description copied from interface:PlanManager
Returns allTopLevelPlan
's filtered byProject
Result of this method is filtered by Acegi.- Specified by:
getPlansByProject
in interfacePlanManager
- Parameters:
project
- - that the plans will belong to- Returns:
TopLevelPlan
plans contained within the given project
-
getPlansByProject
@NotNull public <T extends Plan> @NotNull List<T> getPlansByProject(Project project, Class<T> planType) Description copied from interface:PlanManager
- Specified by:
getPlansByProject
in interfacePlanManager
- 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
@NotNull public <T extends Plan> @NotNull List<T> getAllPlansByProject(Project project, Class<T> planType) Description copied from interface:PlanManager
- Specified by:
getAllPlansByProject
in interfacePlanManager
- 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
-
getPlanIdentifiersForProject
@NotNull public <T extends Plan> @NotNull List<PlanIdentifier> getPlanIdentifiersForProject(@NotNull @NotNull ProjectIdentifier project, @NotNull @NotNull Class<T> planType, boolean includeMarkedForDeletion) Description copied from interface:PlanManager
Retrieve a list of plans for a given project. Only minimal data about the plans is returned.- Specified by:
getPlanIdentifiersForProject
in interfacePlanManager
- 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.
-
getProjectPlanMap
@NotNull public <T extends Plan> @NotNull Map<Project,Collection<T>> getProjectPlanMap(Class<T> planType, boolean includeEmptyProjects) Description copied from interface:PlanManager
- Specified by:
getProjectPlanMap
in interfacePlanManager
- Parameters:
planType
- type of plan to be selected from DBincludeEmptyProjects
- should empty projects be included in result- Returns:
- mapping of
Project
toPlan
of given type
-
getPlanCount
public int getPlanCount()- Specified by:
getPlanCount
in interfacePlanManager
- Returns:
- How many
Buildable
's exists
-
getPlanCount
Description copied from interface:PlanManager
How many plans filtered byClass
currently exist- Specified by:
getPlanCount
in interfacePlanManager
- Parameters:
planType
- - the type of the plan to retrieve- Returns:
- how many plans exist in the datbase
-
getPlanCount
Description copied from interface:PlanManager
How many plans currently exist in aproject
.- Specified by:
getPlanCount
in interfacePlanManager
- Parameters:
projectIdentifier
- identifier of the project- Returns:
- number of plans in the project, excluding ones marked for deletion
-
savePlan
Description copied from interface:PlanManager
Saves thePlan
- Specified by:
savePlan
in interfacePlanManager
- Parameters:
plan
- to be saved
-
savePlanWithSchedulesStopped
Description copied from interface:PlanManager
Saves thePlan
while polling jobs are stopped.- Specified by:
savePlanWithSchedulesStopped
in interfacePlanManager
-
createPlan
Description copied from interface:PlanManager
Same as savePlan, but create permissions used instead of edit permissions.- Specified by:
createPlan
in interfacePlanManager
-
setPlanSuspendedState
- Specified by:
setPlanSuspendedState
in interfacePlanManager
-
isPlanCreationAllowed
public boolean isPlanCreationAllowed()Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!!!- Specified by:
isPlanCreationAllowed
in interfacePlanManager
- Returns:
- true if a plan can be created otherwise false;
-
triggerConfigUpdatedEventsForPlansInProject
Description copied from interface:PlanManager
Triggers updated events for every plan in a project regardless of permissions.- Specified by:
triggerConfigUpdatedEventsForPlansInProject
in interfacePlanManager
- Parameters:
project
- to trigger event for.
-
deletePlan
Description copied from interface:PlanManager
Removes the plan object from the database. Does not do any other clean up work at all Please use theDeletionService
rather than using this method directly- Specified by:
deletePlan
in interfacePlanManager
- Parameters:
plan
- to delete.
-
markPlansForDeletion
Description copied from interface:PlanManager
Efficiently marks a plan to be deleted- Specified by:
markPlansForDeletion
in interfacePlanManager
-
removeStages
public void removeStages(@NotNull @NotNull PlanKey key, @NotNull @NotNull Collection<Long> stageIds) Description copied from interface:PlanManager
Remove the tages from the plan specified. key must be for aChain
- Specified by:
removeStages
in interfacePlanManager
-
filterFavouritedPlans
@NotNull public @NotNull Set<ImmutableChain> filterFavouritedPlans(@NotNull @NotNull Collection<? extends ImmutableChain> plans, @NotNull @NotNull com.atlassian.user.User user) Description copied from interface:PlanManager
Return a set ofPlan
s that are a subset of the givenTopLevelPlan
s collection that are favourited by theUser
. Plans are not filtered by read permission.- Specified by:
filterFavouritedPlans
in interfacePlanManager
- Parameters:
plans
- to filteruser
- to return the favourites of- Returns:
- a set of
Chain
s that are a subset of the givenTopLevelPlan
s collection that are favourited by theUser
-
getFavouritePlans
- Specified by:
getFavouritePlans
in interfacePlanManager
-
getFavouritePlansIds
@NotNull public @NotNull Set<Long> getFavouritePlansIds(@NotNull @NotNull com.atlassian.user.User user) Description copied from interface:PlanManager
Return a collection of Favourite plan ids.- Specified by:
getFavouritePlansIds
in interfacePlanManager
- Returns:
- favouritePlansIds
-
getAllPlansMarkedForDeletionCount
Description copied from interface:PlanManager
Returns a count ofPlan
s that areImmutableDeletable.isMarkedForDeletion()
for the given type- Specified by:
getAllPlansMarkedForDeletionCount
in interfacePlanManager
- Returns:
- number of plans of a requested type scheduled for deletion
-