public class PlanManagerImpl extends Object implements PlanManager
Constructor and Description |
---|
PlanManagerImpl(PlanDao planDao,
BambooLicenseManager bambooLicenseManager,
com.atlassian.event.api.EventPublisher eventPublisher,
ProjectManager projectManager,
PlanScheduler planScheduler) |
Modifier and Type | Method and Description |
---|---|
boolean |
assertPlanPermission(PlanIdentifier plan)
Used to validate user permission for plan.
|
void |
createPlan(Plan plan)
Same as savePlan, but create permissions used instead of edit permissions.
|
void |
deletePlan(Plan plan)
Removes the plan object from the database.
|
Set<ImmutableChain> |
filterFavouritedPlans(Collection<? extends ImmutableChain> plans,
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 . |
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)
|
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 |
List<TopLevelPlan> |
getAllPlansUnrestricted()
Returns all
TopLevelPlan 's ignoring permissions |
Set<ImmutableChain> |
getFavouritePlans(com.atlassian.user.User user) |
Plan |
getPlanById(long id)
Returns a
Plan by its id |
<T extends Plan> |
getPlanById(long id,
Class<T> planType)
|
Plan |
getPlanByKey(PlanKey planKey)
|
<T extends Plan> |
getPlanByKey(PlanKey planKey,
Class<T> planType)
|
Plan |
getPlanByKey(String planKey)
Returns a
Plan by its planKey |
<T extends Plan> |
getPlanByKey(String planKey,
Class<T> planType)
|
<T extends Plan> |
getPlanByKeyIfOfType(PlanKey planKey,
Class<T> planType)
|
<T extends Plan> |
getPlanByOid(BambooEntityOid oid,
Class<T> planType)
|
<T extends Plan> |
getPlanByPartialKeyAndName(PlanKey partialPlanKey,
String planName,
Class<T> planType)
Used for Job validation.
|
Class<? extends Plan> |
getPlanClass(PlanKey planKey) |
int |
getPlanCount() |
<T extends Plan> |
getPlanCount(Class<T> planType)
How many plans filtered by
Class currently exist |
PlanIdentifier |
getPlanIdentifierForPermissionCheckingByKey(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(ProjectIdentifier project,
Class<T> planType,
boolean includeMarkedForDeletion)
Retrieve a list of plans for a given project.
|
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(String projectKey,
long planIdToIgnore,
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(PlanKey planKey)
Verifies whether a
Plan key is unique within whole Bamboo installation |
boolean |
isPlanKeyConflicting(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(PlanKey key,
Collection<Long> stageIds)
Remove the tages from the plan specified.
|
void |
savePlan(Plan plan)
Saves the
Plan |
void |
savePlanWithSchedulesStopped(Plan plan)
Saves the
Plan while polling jobs are stopped. |
void |
setPlanSuspendedState(PlanKey planKey,
boolean isSuspended) |
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 |
triggerConfigUpdatedEventsForPlansInProject(Project project)
Triggers updated events for every plan in a project regardless of permissions.
|
public PlanManagerImpl(@NotNull PlanDao planDao, @NotNull BambooLicenseManager bambooLicenseManager, @NotNull com.atlassian.event.api.EventPublisher eventPublisher, @NotNull ProjectManager projectManager, @NotNull PlanScheduler planScheduler)
@Nullable public 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 Plan getPlanByKey(@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 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 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 PlanKey planKey)
getPlanClass
in interface PlanManager
public <T extends Plan> T getPlanByKeyIfOfType(@NotNull PlanKey planKey, @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 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 PlanIdentifier plan)
PlanManager
assertPlanPermission
in interface PlanManager
plan
- to check the permissions ofpublic <T extends Plan> T getPlanByKey(@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 String projectKey, long planIdToIgnore, @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 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 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 PlanKey partialPlanKey, @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 List<TopLevelPlan> getAllPlans()
PlanManager
TopLevelPlan
'sgetAllPlans
in interface PlanManager
@NotNull public List<TopLevelPlan> getAllPlansUnrestricted()
PlanManager
TopLevelPlan
's ignoring permissionsgetAllPlansUnrestricted
in interface PlanManager
@NotNull public <T extends Plan> 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> List<PlanKey> getAllPlanKeys(Class<T> planType)
PlanManager
getAllPlanKeys
in interface PlanManager
planType
- - the type of the plan to retrieve@NotNull public <T extends Plan> 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 List<Chain> getAllChainsAndJobsUnrestricted()
PlanManager
ChainStage
and Job
of all Chain
s returned.getAllChainsAndJobsUnrestricted
in interface PlanManager
@NotNull public 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> 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> 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> List<PlanIdentifier> getPlanIdentifiersForProject(@NotNull ProjectIdentifier project, @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> 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 void savePlan(@NotNull Plan plan)
PlanManager
Plan
savePlan
in interface PlanManager
plan
- to be savedpublic void savePlanWithSchedulesStopped(@NotNull Plan plan)
PlanManager
Plan
while polling jobs are stopped.savePlanWithSchedulesStopped
in interface PlanManager
public void createPlan(@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 Project project)
PlanManager
triggerConfigUpdatedEventsForPlansInProject
in interface PlanManager
project
- to trigger event for.public void deletePlan(@NotNull Plan plan)
PlanManager
DeletionService
rather than using this method directlydeletePlan
in interface PlanManager
plan
- to delete.@NotNull public <T extends Plan> 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 removeStages(@NotNull PlanKey key, @NotNull Collection<Long> stageIds)
PlanManager
Chain
removeStages
in interface PlanManager
@NotNull public Set<ImmutableChain> filterFavouritedPlans(@NotNull Collection<? extends ImmutableChain> plans, @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 com.atlassian.user.User user)
getFavouritePlans
in interface PlanManager
Copyright © 2017 Atlassian Software Systems Pty Ltd. All rights reserved.