Class PlanCreationTemplate

java.lang.Object
com.atlassian.bamboo.build.creation.PlanCreationTemplate
All Implemented Interfaces:
PlanCreationService
Direct Known Subclasses:
ChainBranchCreationServiceImpl, ChainCreationServiceImpl, JobCreationServiceImpl

public abstract class PlanCreationTemplate extends Object implements PlanCreationService
  • Field Details

  • Constructor Details

  • Method Details

    • performCloneIfRequired

      protected abstract boolean performCloneIfRequired(@NotNull @NotNull BuildConfiguration buildConfiguration, @NotNull @NotNull PlanCreationBean planCreationBean, @NotNull @NotNull ActionParametersMap params) throws PlanCreationException, PlanCreationDeniedException
      Using the action parameters determine if cloning is required and if so, perform the clone. Cloned details are put in the PlanCreationBean.
      Parameters:
      buildConfiguration - for any extra configuration to override when cloning
      planCreationBean - containing the plan and acls (currently does not contain buildConfiguration)
      params - containing any properties provided from the UI
      Returns:
      true if cloning has been completed
      Throws:
      PlanCreationException - if cloning is required but fails.
      PlanCreationDeniedException - if cloning required but can't be completed due to licensing restrictions
    • getDefaultPermissionsForPlan

      @Nullable protected abstract @Nullable org.acegisecurity.acls.MutableAcl getDefaultPermissionsForPlan(boolean accessForAllUsers)
      Generate the permissions to be stored against the plan on creation.
      Parameters:
      accessForAllUsers - anyone that can access Bamboo instance (logged-in users and depending on configuration anonymous) will be able to view this plan.
      Returns:
      the permissions to be stored against the plan on creation
    • prepareBuildConfiguration

      protected abstract void prepareBuildConfiguration(@NotNull @NotNull BuildConfiguration buildConfiguration, @NotNull @NotNull Plan plan, @NotNull @NotNull PlanCreationBean planCreationBean)
      Prepare build configuration for saving. Only occurs if cloning did NOT occur.
      Parameters:
      buildConfiguration - the current build configuration.
      plan - the current plan (will already have details populated)
    • cleanBuildConfiguration

      protected abstract void cleanBuildConfiguration(@NotNull @NotNull BuildConfiguration buildConfiguration, @NotNull @NotNull Plan plan)
      Clean build configuration for saving. Build Config may have been cloned.
      Parameters:
      buildConfiguration - the current build configuration.
      plan - the current plan (will already have details populated)
    • saveAndUpdateParents

      @Deprecated protected void saveAndUpdateParents(@NotNull @NotNull Plan plan)
      Deprecated.
      Perform any necessary database operations required before saving the plan. E.g. creation of new projects.
      Parameters:
      plan - - complete plan (except for full key) to be saved
    • saveAndUpdateParents

      protected abstract void saveAndUpdateParents(@NotNull @NotNull PlanCreationBean planCreationBean)
      Perform any necessary database operations required before saving the plan. E.g. creation of new projects.
      Parameters:
      planCreationBean - plan creation bean
    • setFullPlanKey

      protected abstract void setFullPlanKey(@NotNull @NotNull Plan plan)
      Set the full key for this plan
      Parameters:
      plan - - complete plan to be saved
    • performPostCreateAction

      protected abstract void performPostCreateAction(@NotNull @NotNull Plan plan)
      Perform plan specific actions that need to be run immediately after plan creation.
      Parameters:
      plan - created plan
    • triggerCreationCompleteEvents

      public abstract void triggerCreationCompleteEvents(PlanKey planKey)
      Trigger the appropriate events after the plan has been saved successfully Calling this method is responsibility of class using this template.
      Specified by:
      triggerCreationCompleteEvents in interface PlanCreationService
    • createPlan

      protected String createPlan(@NotNull @NotNull BuildConfiguration buildConfiguration, @NotNull @NotNull ActionParametersMap actionParametersMap, @NotNull @NotNull PlanCreationService.EnablePlan enabled, @NotNull @NotNull BiConsumer<Plan,ActionParametersMap> preparePlanDetails) throws PlanCreationDeniedException, PlanCreationException
      Creates and saves a plan
      Parameters:
      buildConfiguration - configuration of the plan
      actionParametersMap - any other params that are not in the buildConfiguration
      enabled - whether the plan should start enabled or disabled
      preparePlanDetails - prepares the plan object for saving.
      Returns:
      the full key of the created plan
      Throws:
      PlanCreationDeniedException
      PlanCreationException
    • savePlan

      public String savePlan(@NotNull @NotNull PlanCreationBean planCreationBean) throws PlanCreationDeniedException, PlanCreationException
      Description copied from interface: PlanCreationService
      Saves a already created plan to the database
      Specified by:
      savePlan in interface PlanCreationService
      Parameters:
      planCreationBean - containing the required components for saving
      Returns:
      The full key of the build just created
      Throws:
      PlanCreationDeniedException - if plan creation fails because you already have too many plans.
      PlanCreationException - if plan creation fails for any other reason
    • cleanBuildConfiguration

      public static void cleanBuildConfiguration(BuildConfiguration buildConfiguration)
      Performs general cleanup of the buildConfiguration, cleaning up properties we don't want to save mostly these are properties that get used for UI display.
      Parameters:
      buildConfiguration - to clean
    • clonePlanPermissionsToSession

      protected void clonePlanPermissionsToSession(Plan buildToClone, PlanCreationBean planCreationBean, String planOwner)
    • logBuildConfiguration

      protected void logBuildConfiguration(BuildConfiguration buildConfiguration)
    • validateThrowingPlanCreationException

      @Contract("false,_ -> fail") protected void validateThrowingPlanCreationException(boolean condition, String message)