com.atlassian.bamboo.plan.job
Class JobServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.plan.job.JobServiceImpl
All Implemented Interfaces:
JobService

public class JobServiceImpl
extends Object
implements JobService


Constructor Summary
JobServiceImpl(CachedPlanManager cachedPlanManager, PlanManager planManager, com.atlassian.struts.TextProvider textProvider, ChainBranchManager chainBranchManager, BambooPermissionManager bambooPermissionManager, ValidationService validationService, AuditLogService auditLogService, DeletionService deletionService, BuildExecutionManager buildExecutionManager, com.atlassian.event.api.EventPublisher eventPublisher, JobCreationService jobCreationService, BuildDefinitionConverter buildDefinitionConverter, ScopedExclusionService scopedExclusionService, ArtifactSubscriptionManager artifactSubscriptionManager)
           
 
Method Summary
 ImmutableJob addJob(PlanKey chainKey, long stageId, String jobKeyString, String name, String description, boolean suspended)
          Add a job to an existing stage in the plan
 ImmutableJob cloneJob(String sourceJobKeyString, PlanKey chainKey, long stageId, String newJobKeyString, String name, String description, boolean suspended)
          Copy the given job and give the copy the key, name, description and suspended state provided.
 void deleteJob(PlanKey jobKey, BambooClosures.Throwing1<ImmutableJob,WebValidationException>... runBefore)
          Remove a job.
 ImmutableJob getJob(PlanKey jobKey)
          Get an individual job
 List<ImmutableJob> getJobsForPlan(PlanKey planKey)
          Assumption is made that AbstractImmutableChain.getAllJobs() will return 2-level sorted list of jobs
 List<ImmutableJob> getJobsForStage(PlanKey planKey, long stageId)
          Get all jobs in a particular stage, ordered alphabetically
 ImmutableJob updateJob(PlanKey jobKey, String name, String description, boolean suspended, long stageId, BambooClosures.Throwing1<ImmutableJob,WebValidationException>... runBefore)
          Update the details of a job
 ErrorCollection validateJobForAdd(PlanKey planKey, long stageId, String jobKey, String name, String description, boolean suspended)
          Validates the parameters for adding a job.
 ErrorCollection validateJobForClone(String sourceJobKeyString, PlanKey chainKey, long stageId, String newJobKey, String name, String description, Boolean suspended)
          Validates the parameters for cloning a job.
 ErrorCollection validateJobForUpdate(PlanKey jobKey, String name, String description, boolean suspended, long stageId)
          Validate editing of a job
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobServiceImpl

public JobServiceImpl(@NotNull
                      CachedPlanManager cachedPlanManager,
                      @NotNull
                      PlanManager planManager,
                      @NotNull
                      com.atlassian.struts.TextProvider textProvider,
                      @NotNull
                      ChainBranchManager chainBranchManager,
                      @NotNull
                      BambooPermissionManager bambooPermissionManager,
                      @NotNull
                      ValidationService validationService,
                      @NotNull
                      AuditLogService auditLogService,
                      @NotNull
                      DeletionService deletionService,
                      @NotNull
                      BuildExecutionManager buildExecutionManager,
                      @NotNull
                      com.atlassian.event.api.EventPublisher eventPublisher,
                      @NotNull
                      JobCreationService jobCreationService,
                      @NotNull
                      BuildDefinitionConverter buildDefinitionConverter,
                      @NotNull
                      ScopedExclusionService scopedExclusionService,
                      @NotNull
                      ArtifactSubscriptionManager artifactSubscriptionManager)
Method Detail

getJobsForPlan

@NotNull
public List<ImmutableJob> getJobsForPlan(@NotNull
                                                 PlanKey planKey)
Assumption is made that AbstractImmutableChain.getAllJobs() will return 2-level sorted list of jobs

Specified by:
getJobsForPlan in interface JobService
Parameters:
planKey - of plan
Returns:
list of immutable jobs

getJobsForStage

@NotNull
public List<ImmutableJob> getJobsForStage(@NotNull
                                                  PlanKey planKey,
                                                  long stageId)
Description copied from interface: JobService
Get all jobs in a particular stage, ordered alphabetically

Specified by:
getJobsForStage in interface JobService
Parameters:
planKey - of plan
stageId - id of the stage
Returns:
list of immutable jobs

getJob

@NotNull
public ImmutableJob getJob(@NotNull
                                   PlanKey jobKey)
Description copied from interface: JobService
Get an individual job

Specified by:
getJob in interface JobService
Parameters:
jobKey - of the job to get
Returns:
the job

validateJobForAdd

public ErrorCollection validateJobForAdd(@NotNull
                                         PlanKey planKey,
                                         long stageId,
                                         @Nullable
                                         String jobKey,
                                         @Nullable
                                         String name,
                                         @Nullable
                                         String description,
                                         boolean suspended)
                                  throws WebValidationException
Description copied from interface: JobService
Validates the parameters for adding a job.

Specified by:
validateJobForAdd in interface JobService
Parameters:
planKey - of the plan to add job to.
stageId - of the stage to add the job to.
jobKey - key of the job to add. May be full or partial job key.
name - name of the job to add.
description - description of the job.
suspended - sets the job's suspended status.
Returns:
error collection containing any validation errors that may have occurred against job data.
Throws:
WebValidationException

addJob

@NotNull
public ImmutableJob addJob(@NotNull
                                   PlanKey chainKey,
                                   long stageId,
                                   @Nullable
                                   String jobKeyString,
                                   @Nullable
                                   String name,
                                   @Nullable
                                   String description,
                                   boolean suspended)
                    throws WebValidationException
Description copied from interface: JobService
Add a job to an existing stage in the plan

Specified by:
addJob in interface JobService
Parameters:
chainKey - of the plan to add the job
stageId - of the stage to add the job
jobKeyString - of the job to add. May be full or partial job key.
name - name of the job
description - description of the job
suspended - sets the job suspended status
Returns:
added job
Throws:
WebValidationException

validateJobForClone

public ErrorCollection validateJobForClone(@Nullable
                                           String sourceJobKeyString,
                                           @NotNull
                                           PlanKey chainKey,
                                           long stageId,
                                           @Nullable
                                           String newJobKey,
                                           @Nullable
                                           String name,
                                           @Nullable
                                           String description,
                                           @Nullable
                                           Boolean suspended)
                                    throws WebValidationException
Description copied from interface: JobService
Validates the parameters for cloning a job.

Specified by:
validateJobForClone in interface JobService
Parameters:
sourceJobKeyString - key of the job to clone. Must be full job key.
chainKey - key of the plan to add the new job to.
stageId - id of the stage to add the new job to.
newJobKey - key of the new job. May be full or partial job key.
name - name of the new job.
description - description of the new job.
suspended - suspended state of the new job.
Returns:
error collection containing any validation errors that may have occurred against job data.
Throws:
WebValidationException

cloneJob

public ImmutableJob cloneJob(@NotNull
                             String sourceJobKeyString,
                             @NotNull
                             PlanKey chainKey,
                             long stageId,
                             @NotNull
                             String newJobKeyString,
                             @NotNull
                             String name,
                             @Nullable
                             String description,
                             boolean suspended)
                      throws WebValidationException
Description copied from interface: JobService
Copy the given job and give the copy the key, name, description and suspended state provided.

Specified by:
cloneJob in interface JobService
Parameters:
sourceJobKeyString - key of the source job to copy. Must be full job key.
chainKey - of the plan to add the new job.
stageId - of the stage to add the new job.
newJobKeyString - key to give to the new job. May be full or partial job key.
name - The name of the cloned job.
description - The description of the cloned job.
suspended - The suspended state of the cloned job.
Returns:
the result of the copy.
Throws:
WebValidationException

deleteJob

public void deleteJob(@NotNull
                      PlanKey jobKey,
                      @NotNull
                      BambooClosures.Throwing1<ImmutableJob,WebValidationException>... runBefore)
               throws WebValidationException
Description copied from interface: JobService
Remove a job.

Specified by:
deleteJob in interface JobService
Parameters:
jobKey - of job
runBefore - code to execute after security and validation has passed but before the deletion occurs.
Throws:
WebValidationException

validateJobForUpdate

@NotNull
public ErrorCollection validateJobForUpdate(@NotNull
                                                    PlanKey jobKey,
                                                    @NotNull
                                                    String name,
                                                    @Nullable
                                                    String description,
                                                    boolean suspended,
                                                    long stageId)
Description copied from interface: JobService
Validate editing of a job

Specified by:
validateJobForUpdate in interface JobService
Parameters:
jobKey - of the job to update
name - new name of the job
description - new description of the job
suspended - sets the job suspended status
Returns:
error collection containing any validation errors that may have occurred against job data.

updateJob

@NotNull
public ImmutableJob updateJob(@NotNull
                                      PlanKey jobKey,
                                      @NotNull
                                      String name,
                                      @Nullable
                                      String description,
                                      boolean suspended,
                                      long stageId,
                                      @NotNull
                                      BambooClosures.Throwing1<ImmutableJob,WebValidationException>... runBefore)
                       throws WebValidationException
Description copied from interface: JobService
Update the details of a job

Specified by:
updateJob in interface JobService
Parameters:
jobKey - of the job to update
name - new name of the job
description - new description of the job
suspended - sets the job suspended status
stageId - new stage for the job
runBefore - code to execute after security and validation has passed but before the update occurs.
Returns:
updated job
Throws:
WebValidationException


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.