public class PlanManagerImpl extends Object implements PlanManager
Constructor and Description |
---|
PlanManagerImpl(@NotNull PlanDao planDao,
@NotNull BambooLicenseManager bambooLicenseManager,
@NotNull com.atlassian.event.api.EventPublisher eventPublisher,
@NotNull ProjectManager projectManager,
@NotNull PlanScheduler planScheduler) |
Modifier and Type | Method and Description |
---|---|
boolean |
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 of
Plan s that are a subset of the given TopLevelPlan s
collection that are favourited by the User . |
@NotNull List<Chain> |
getAllChainsAndJobsUnrestricted()
WARNING this is probably a bad idea from a performance perspective, only do this if you're going to
traverse through all the
ChainStage and Job of all Chain s returned. |
<T extends Plan> |
getAllPlanKeys(Class<T> planType)
|
@NotNull List<TopLevelPlan> |
getAllPlans()
Returns all
TopLevelPlan 's |
<T extends Plan> |
getAllPlans(Class<T> planType)
|
<T extends Plan> |
getAllPlans(Class<T> planType,
int firstResult,
int maxResults)
|
<T extends Plan> |
getAllPlansByProject(Project project,
Class<T> planType)
|
<T extends Plan> |
getAllPlansMarkedForDeletion(Class<T> planType)
Returns a list of
Plan s that are ImmutableDeletable.isMarkedForDeletion()
for the given type |
@NotNull List<TopLevelPlan> |
getAllPlansUnrestricted()
Returns all
TopLevelPlan 's ignoring permissions |
Set<ImmutableChain> |
getFavouritePlans(@NotNull com.atlassian.user.User user) |
@NotNull Set<Long> |
getFavouritePlansIds(@NotNull com.atlassian.user.User user)
Return a collection of Favourite plan ids.
|
@Nullable Plan |
getPlanById(long id)
Returns a
Plan by its id |
<T extends Plan> |
getPlanById(long id,
Class<T> planType)
|
Plan |
getPlanByKey(@NotNull PlanKey planKey)
|
<T extends Plan> |
getPlanByKey(@NotNull PlanKey planKey,
Class<T> planType)
|
@Nullable Plan |
getPlanByKey(@NotNull String planKey)
Returns a
Plan by its planKey |
<T extends Plan> |
getPlanByKey(@NotNull String planKey,
Class<T> planType)
|
<T extends Plan> |
getPlanByKeyIfOfType(@NotNull PlanKey planKey,
@NotNull Class<T> planType)
|
<T extends Plan> |
getPlanByOid(BambooEntityOid oid,
Class<T> planType)
|
<T extends Plan> |
getPlanByPartialKeyAndName(@NotNull PlanKey partialPlanKey,
@NotNull String planName,
Class<T> planType)
Used for Job validation.
|
Class<? extends Plan> |
getPlanClass(@NotNull PlanKey planKey) |
int |
getPlanCount() |
<T extends Plan> |
getPlanCount(Class<T> planType)
How many plans filtered by
Class currently exist |
int |
getPlanCount(@NotNull ProjectIdentifier projectIdentifier)
How many plans currently exist in a
project . |
PlanIdentifier |
getPlanIdentifierForPermissionCheckingByKey(@NotNull String planKey)
Returns a
Plan 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> |
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 all
TopLevelPlan 's filtered by Project
Result of this method is filtered by Acegi. |
<T extends Plan> |
getPlansByProject(Project project,
Class<T> planType)
|
<T extends Plan> |
getProjectPlanMap(Class<T> planType,
boolean includeEmptyProjects)
|
boolean |
isChainNameConflicting(@NotNull String projectKey,
long planIdToIgnore,
@NotNull String planName)
Verifies whether a
Chain name is unique with the given project |
boolean |
isPlanCreationAllowed()
Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!!!
|
boolean |
isPlanKeyConflicting(@NotNull PlanKey planKey)
Verifies whether a
Plan key is unique within whole Bamboo installation |
boolean |
isPlanKeyConflicting(@NotNull PlanKey planKey,
long planIdToIgnore)
Verifies whether a
Plan key is unique within whole Bamboo installation |
void |
markPlansForDeletion(PlanKey planKey)
Efficiently marks a plan to be deleted
|
void |
removeStages(@NotNull PlanKey key,
@NotNull Collection<Long> stageIds)
Remove the tages from the plan specified.
|
void |
savePlan(@NotNull Plan plan)
Saves the
Plan |
void |
savePlanWithSchedulesStopped(@NotNull Plan plan)
Saves the
Plan while polling jobs are stopped. |
void |
setPlanSuspendedState(PlanKey planKey,
boolean isSuspended) |
void |
syncDeletionStatusOfChainBranches()
Performs a cleanup task to mark
ChainBranch objects that have a master Plan that is marked
to be deleted, but is not marked as deleted. |
void |
syncDeletionStatusOfJobs()
Performs a cleanup task to mark
Job objects that have a Plan or ChainStage that is marked
to be deleted, but it itself was not marked as deleted. |
void |
syncDeletionStatusOfPlans()
|
void |
triggerConfigUpdatedEventsForPlansInProject(@NotNull Project project)
Triggers updated events for every plan in a project regardless of permissions.
|
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)
@Nullable public @Nullable Plan getPlanById(long id) throws IncorrectPlanTypeException
PlanManager
Plan
by its idgetPlanById
in interface PlanManager
id
- of the planIncorrectPlanTypeException
- if plan cannot be found@Nullable public <T extends Plan> T getPlanById(long id, Class<T> planType) throws IncorrectPlanTypeException
PlanManager
getPlanById
in interface PlanManager
id
- of the planplanType
- - the type of the plan to retrieveIncorrectPlanTypeException
- if plan cannot be found with the correct type@Nullable public <T extends Plan> T getPlanByOid(BambooEntityOid oid, Class<T> planType) throws IncorrectPlanTypeException
PlanManager
getPlanByOid
in interface PlanManager
oid
- of the planplanType
- - the type of the plan to retrieveIncorrectPlanTypeException
- if plan cannot be found with the correct type@Nullable public @Nullable Plan getPlanByKey(@NotNull @NotNull String planKey) throws IncorrectPlanTypeException
PlanManager
Plan
by its planKeygetPlanByKey
in interface PlanManager
planKey
- of the plan to findIncorrectPlanTypeException
- if plan cannot be found with the correct type (should never happen)@Nullable public <T extends Plan> T getPlanByKey(@NotNull @NotNull String planKey, Class<T> planType) throws IncorrectPlanTypeException
PlanManager
getPlanByKey
in interface PlanManager
planKey
- to search forplanType
- - the type of the plan to retrieveIncorrectPlanTypeException
- if plan cannot be found with the correct typepublic PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull @NotNull String planKey)
PlanManager
Plan
skeleton skeleton providing ONLY id and key, that matches the given key This method should
be used only for permission checking using Acegi
If Job
key is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are
defined only for TopLevelPlan
s
getPlanIdentifierForPermissionCheckingByKey
in interface PlanManager
planKey
- of the plan to findpublic Class<? extends Plan> getPlanClass(@NotNull @NotNull PlanKey planKey)
getPlanClass
in interface PlanManager
public <T extends Plan> T getPlanByKeyIfOfType(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Class<T> planType)
PlanManager
Plan
by its planKey and if it's of the type Class
. Does not throw IncorrectPlanTypeException
. Should only be used when the type of the plan can not be known.getPlanByKeyIfOfType
in interface PlanManager
planKey
- to search forplanType
- the type of the plan to retrievepublic Plan getPlanByKey(@NotNull @NotNull PlanKey planKey) throws IncorrectPlanTypeException
PlanManager
getPlanByKey
in interface PlanManager
planKey
- to search forIncorrectPlanTypeException
- if plan cannot be found with the correct type (should never happen)public boolean assertPlanPermission(@NotNull @NotNull PlanIdentifier plan)
PlanManager
assertPlanPermission
in interface PlanManager
plan
- to check the permissions ofpublic <T extends Plan> T getPlanByKey(@NotNull @NotNull PlanKey planKey, Class<T> planType) throws IncorrectPlanTypeException
PlanManager
getPlanByKey
in interface PlanManager
planKey
- to search forplanType
- - the type of the plan to retrieveIncorrectPlanTypeException
- if plan cannot be found with the correct typepublic boolean isChainNameConflicting(@NotNull @NotNull String projectKey, long planIdToIgnore, @NotNull @NotNull String planName)
PlanManager
Chain
name is unique with the given project
isChainNameConflicting
in interface PlanManager
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)public boolean isPlanKeyConflicting(@NotNull @NotNull PlanKey planKey)
PlanManager
Plan
key is unique within whole Bamboo installationisPlanKeyConflicting
in interface PlanManager
planKey
- key of the plan to be searched for in the databasepublic boolean isPlanKeyConflicting(@NotNull @NotNull PlanKey planKey, long planIdToIgnore)
PlanManager
Plan
key is unique within whole Bamboo installationisPlanKeyConflicting
in interface PlanManager
planIdToIgnore
- id of plan which we want to set key for, if the key is used by that plan, it's not really conflicting@Nullable public <T extends Plan> T getPlanByPartialKeyAndName(@NotNull @NotNull PlanKey partialPlanKey, @NotNull @NotNull String planName, Class<T> planType) throws IncorrectPlanTypeException
PlanManager
getPlanByPartialKeyAndName
in interface PlanManager
IncorrectPlanTypeException
- if plan cannot be found with the correct type@NotNull public @NotNull List<TopLevelPlan> getAllPlans()
PlanManager
TopLevelPlan
'sgetAllPlans
in interface PlanManager
@NotNull public @NotNull List<TopLevelPlan> getAllPlansUnrestricted()
PlanManager
TopLevelPlan
's ignoring permissionsgetAllPlansUnrestricted
in interface PlanManager
@NotNull public <T extends Plan> @NotNull List<T> getAllPlans(Class<T> planType)
PlanManager
getAllPlans
in interface PlanManager
planType
- - the type of the plan to retrieveDescriptionProvider.getName()
@NotNull public <T extends Plan> @NotNull List<PlanKey> getAllPlanKeys(Class<T> planType)
PlanManager
getAllPlanKeys
in interface PlanManager
planType
- - the type of the plan to retrieve@NotNull public <T extends Plan> @NotNull List<T> getAllPlans(Class<T> planType, int firstResult, int maxResults)
PlanManager
getAllPlans
in interface PlanManager
planType
- - the type of the plan to retrievefirstResult
- firstResult for a paginated resultsmaxResults
- maximum number of results to returnDescriptionProvider.getName()
@NotNull public @NotNull List<Chain> getAllChainsAndJobsUnrestricted()
PlanManager
ChainStage
and Job
of all Chain
s returned.getAllChainsAndJobsUnrestricted
in interface PlanManager
@NotNull public @NotNull List<TopLevelPlan> getPlansByProject(Project project)
PlanManager
TopLevelPlan
's filtered by Project
Result of this method is filtered by Acegi.getPlansByProject
in interface PlanManager
project
- - that the plans will belong toTopLevelPlan
plans contained within the given project@NotNull public <T extends Plan> @NotNull List<T> getPlansByProject(Project project, Class<T> planType)
PlanManager
getPlansByProject
in interface PlanManager
project
- - that the plans will belong toplanType
- - the type of the plan to retrieve@NotNull public <T extends Plan> @NotNull List<T> getAllPlansByProject(Project project, Class<T> planType)
PlanManager
getAllPlansByProject
in interface PlanManager
project
- - that the plans will belong toplanType
- - the type of the plan to retrieve@NotNull public <T extends Plan> @NotNull List<PlanIdentifier> getPlanIdentifiersForProject(@NotNull @NotNull ProjectIdentifier project, @NotNull @NotNull Class<T> planType, boolean includeMarkedForDeletion)
PlanManager
getPlanIdentifiersForProject
in interface PlanManager
project
- to get plans forplanType
- to filter plans byincludeMarkedForDeletion
- set to true if you want to return plans marked for deletion@NotNull public <T extends Plan> @NotNull Map<Project,Collection<T>> getProjectPlanMap(Class<T> planType, boolean includeEmptyProjects)
PlanManager
getProjectPlanMap
in interface PlanManager
planType
- type of plan to be selected from DBincludeEmptyProjects
- should empty projects be included in resultProject
to Plan
of given typepublic int getPlanCount()
getPlanCount
in interface PlanManager
Buildable
's existspublic <T extends Plan> int getPlanCount(Class<T> planType)
PlanManager
Class
currently existgetPlanCount
in interface PlanManager
planType
- - the type of the plan to retrievepublic int getPlanCount(@NotNull @NotNull ProjectIdentifier projectIdentifier)
PlanManager
project
.getPlanCount
in interface PlanManager
projectIdentifier
- identifier of the projectpublic void savePlan(@NotNull @NotNull Plan plan)
PlanManager
Plan
savePlan
in interface PlanManager
plan
- to be savedpublic void savePlanWithSchedulesStopped(@NotNull @NotNull Plan plan)
PlanManager
Plan
while polling jobs are stopped.savePlanWithSchedulesStopped
in interface PlanManager
public void createPlan(@NotNull @NotNull Plan plan)
PlanManager
createPlan
in interface PlanManager
public void setPlanSuspendedState(PlanKey planKey, boolean isSuspended)
setPlanSuspendedState
in interface PlanManager
public boolean isPlanCreationAllowed()
isPlanCreationAllowed
in interface PlanManager
public void triggerConfigUpdatedEventsForPlansInProject(@NotNull @NotNull Project project)
PlanManager
triggerConfigUpdatedEventsForPlansInProject
in interface PlanManager
project
- to trigger event for.public void deletePlan(@NotNull @NotNull Plan plan)
PlanManager
DeletionService
rather than using this method directlydeletePlan
in interface PlanManager
plan
- to delete.@NotNull public <T extends Plan> @NotNull Collection<T> getAllPlansMarkedForDeletion(Class<T> planType)
PlanManager
Plan
s that are ImmutableDeletable.isMarkedForDeletion()
for the given typegetAllPlansMarkedForDeletion
in interface PlanManager
public void markPlansForDeletion(PlanKey planKey)
PlanManager
markPlansForDeletion
in interface PlanManager
public void syncDeletionStatusOfJobs()
PlanManager
Job
objects that have a Plan
or ChainStage
that is marked
to be deleted, but it itself was not marked as deleted.syncDeletionStatusOfJobs
in interface PlanManager
public void syncDeletionStatusOfPlans()
PlanManager
Plan
objects that have a Project
that is marked
to be deleted, but is not marked as deleted.syncDeletionStatusOfPlans
in interface PlanManager
public void syncDeletionStatusOfChainBranches()
PlanManager
ChainBranch
objects that have a master Plan
that is marked
to be deleted, but is not marked as deleted.syncDeletionStatusOfChainBranches
in interface PlanManager
public void removeStages(@NotNull @NotNull PlanKey key, @NotNull @NotNull Collection<Long> stageIds)
PlanManager
Chain
removeStages
in interface PlanManager
@NotNull public @NotNull Set<ImmutableChain> filterFavouritedPlans(@NotNull @NotNull Collection<? extends ImmutableChain> plans, @NotNull @NotNull com.atlassian.user.User user)
PlanManager
Plan
s that are a subset of the given TopLevelPlan
s
collection that are favourited by the User
. Plans are not filtered by read permission.filterFavouritedPlans
in interface PlanManager
plans
- to filteruser
- to return the favourites ofChain
s that are a subset of the given TopLevelPlan
s collection that are favourited by the User
public Set<ImmutableChain> getFavouritePlans(@NotNull @NotNull com.atlassian.user.User user)
getFavouritePlans
in interface PlanManager
@NotNull public @NotNull Set<Long> getFavouritePlansIds(@NotNull @NotNull com.atlassian.user.User user)
PlanManager
getFavouritePlansIds
in interface PlanManager
Copyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.