Package com.atlassian.bamboo.plan.branch
Class BranchCreationFacadeImpl
java.lang.Object
com.atlassian.bamboo.plan.branch.BranchCreationFacadeImpl
- All Implemented Interfaces:
BranchCreationFacade
-
Constructor Summary
ConstructorDescriptionBranchCreationFacadeImpl
(BranchDetectionService branchDetectionService, CachedRepositoryDefinitionManager cachedRepositoryDefinitionManager, CustomVariableContext customVariableContext, ErrorHandler errorHandler, LightweightBranchCreationService branchCreationService, com.atlassian.struts.TextProvider textProvider, VcsRepositoryManager vcsRepositoryManager) -
Method Summary
Modifier and TypeMethodDescription@NotNull ChainBranchCreationResult
createChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull String branchName, @Nullable String branchDescription, @Nullable VcsBranch vcsBranch, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry) Given a branch name and (optionally) vcs branch name, creates a plan branch, overriding repository definition.@Nullable ChainBranchCreationResult
createChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull String branchName, @Nullable String branchDescription, @Nullable VcsBranch vcsBranch, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull com.atlassian.struts.ValidationAware validationAware) Given a branch name and (optionally) vcs branch name, creates a plan branch, overriding repository definition.@NotNull List<ChainBranchCreationResult>
createManualBranches
(@NotNull ImmutableChain chain, @NotNull Collection<VcsBranch> branches, @Nullable ErrorCollection errorCollection, PlanCreationService.EnablePlan enablePlan) Given a list of branches names, create plan branches for them under give chain.void
createOrEnableChainsBranches
(@NotNull List<ImmutableChain> chains, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @NotNull Function<ImmutableChain, BuildConfiguration> buildConfigurationProvider, @NotNull Consumer<PlanKey> planBranchConsumer) Given a list of plans and a vcs branch creates plan branches for those chains, queuing RSS execution if required.void
createOrEnableChainsBranches
(@NotNull List<ImmutableChain> chains, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @NotNull Function<ImmutableChain, BuildConfiguration> buildConfigurationProvider, @NotNull Consumer<PlanKey> planBranchConsumer, Optional<VcsPullRequest> pullRequest) Given a list of plans and a vcs branch creates plan branches for those chains, queuing RSS execution if required.void
enableExistingChainBranch
(@NotNull ImmutableChain chain, @NotNull ImmutableChainBranch existingChainBranch) Enables existing chain branch, queuing RSS execution if required.void
enableExistingChainBranch
(@NotNull ImmutableChain chain, @NotNull ImmutableChainBranch existingChainBranch, Optional<VcsPullRequest> pullRequest) Enables existing chain branch, queuing RSS execution if required.getOpenBranches
(@NotNull ImmutableChain chain, @Nullable ErrorCollection errorCollection) Returns a list of currently open branches for the chain's default repository List ordering determined by underlying repository (preference is for native ordering e.g.getOpenBranches
(@NotNull ImmutableChain chain, @Nullable ErrorCollection errorCollection, @NotNull Optional<String> searchTerm) Returns a list of currently open branches for the chain's default repository List filtered by optional case-insensitive searchTerm.boolean
scheduleBranchListInitialisation
(@NotNull Chain chain) Schedules initialisation of existing vcs branch list.
-
Constructor Details
-
BranchCreationFacadeImpl
public BranchCreationFacadeImpl(BranchDetectionService branchDetectionService, CachedRepositoryDefinitionManager cachedRepositoryDefinitionManager, CustomVariableContext customVariableContext, ErrorHandler errorHandler, LightweightBranchCreationService branchCreationService, com.atlassian.struts.TextProvider textProvider, VcsRepositoryManager vcsRepositoryManager)
-
-
Method Details
-
createOrEnableChainsBranches
public void createOrEnableChainsBranches(@NotNull @NotNull List<ImmutableChain> chains, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @NotNull @NotNull Function<ImmutableChain, BuildConfiguration> buildConfigurationProvider, @NotNull @NotNull Consumer<PlanKey> planBranchConsumer, Optional<VcsPullRequest> pullRequest) Description copied from interface:BranchCreationFacade
Given a list of plans and a vcs branch creates plan branches for those chains, queuing RSS execution if required. The overloaded method is aimed to deal with pull requests. If branch name conflicts with an existing plan branch, the name will be automatically generated.- Specified by:
createOrEnableChainsBranches
in interfaceBranchCreationFacade
- Parameters:
chains
- list of plans for which plan branches should be createdplanBranchWorkflow
- workflow which led to creation of these branchesvcsBranchProvider
- provides VcsBranch to use when overriding repository definitionbuildConfigurationProvider
- provides a default fragment of configuration to create the chain branch withplanBranchConsumer
- code should be executed before triggering events that new plan createdpullRequest
- optional pull requests object which contains potential source repository information
-
createOrEnableChainsBranches
public void createOrEnableChainsBranches(@NotNull @NotNull List<ImmutableChain> chains, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @NotNull @NotNull Function<ImmutableChain, BuildConfiguration> buildConfigurationProvider, @NotNull @NotNull Consumer<PlanKey> planBranchConsumer) Description copied from interface:BranchCreationFacade
Given a list of plans and a vcs branch creates plan branches for those chains, queuing RSS execution if required. If branch name conflicts with an existing plan branch, the name will be automatically generated.- Specified by:
createOrEnableChainsBranches
in interfaceBranchCreationFacade
- Parameters:
chains
- list of plans for which plan branches should be createdplanBranchWorkflow
- workflow which led to creation of these branchesvcsBranchProvider
- provides VcsBranch to use when overriding repository definitionbuildConfigurationProvider
- provides a default fragment of configuration to create the chain branch withplanBranchConsumer
- code should be executed before triggering events that new plan created
-
enableExistingChainBranch
public void enableExistingChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull ImmutableChainBranch existingChainBranch) Description copied from interface:BranchCreationFacade
Enables existing chain branch, queuing RSS execution if required. Does nothing if chain branch doesn't exist.- Specified by:
enableExistingChainBranch
in interfaceBranchCreationFacade
-
enableExistingChainBranch
public void enableExistingChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull ImmutableChainBranch existingChainBranch, Optional<VcsPullRequest> pullRequest) Description copied from interface:BranchCreationFacade
Enables existing chain branch, queuing RSS execution if required. Does nothing if chain branch doesn't exist. The decision about queuing RSS execution may depend on the pull request state.- Specified by:
enableExistingChainBranch
in interfaceBranchCreationFacade
-
createManualBranches
@NotNull public @NotNull List<ChainBranchCreationResult> createManualBranches(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull Collection<VcsBranch> branches, @Nullable @Nullable ErrorCollection errorCollection, @NotNull PlanCreationService.EnablePlan enablePlan) Description copied from interface:BranchCreationFacade
Given a list of branches names, create plan branches for them under give chain. Enqueues RSS execution if required. Branches created using this method are excluded from expiration by default. Branches are considered to be "manual branches"- Specified by:
createManualBranches
in interfaceBranchCreationFacade
- Parameters:
chain
- chain for which plan branches should be createdbranches
- branches to createerrorCollection
- to add errors to, if you don't supply an error collection, they will just get loggedenablePlan
- defines whether newly created branches should be enabled or disabled after creation- Returns:
- collection of branch keys (for created lightweight branches) and RSS executions futures (for enqueued divergent branches)
-
createChainBranch
@NotNull public @NotNull ChainBranchCreationResult createChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull String branchName, @Nullable @Nullable String branchDescription, @Nullable @Nullable VcsBranch vcsBranch, @NotNull PlanCreationService.EnablePlan enablePlan, boolean enableExpiry) throws PlanCreationDeniedException, WebValidationException Description copied from interface:BranchCreationFacade
Given a branch name and (optionally) vcs branch name, creates a plan branch, overriding repository definition. Returns either plan branch key if lightweight branch was created or future reference if divergent branch creation has been queued.- Specified by:
createChainBranch
in interfaceBranchCreationFacade
- Parameters:
chain
- chain for which plan branches should be createdplanBranchWorkflow
- workflow which led to creation of this chain branchbranchName
- name of plan branch to createbranchDescription
- optional description of the new branchvcsBranch
- VCS branch to use when overriding repository definitionenablePlan
- defines whether newly created branches should be enabled or disabled after creationenableExpiry
- defines whether created branch can be removed due to branch expiration detection- Returns:
- Throws:
PlanCreationDeniedException
- if chain branch creation was denied for any reasonWebValidationException
- if there were validation errors
-
createChainBranch
@Nullable public @Nullable ChainBranchCreationResult createChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull String branchName, @Nullable @Nullable String branchDescription, @Nullable @Nullable VcsBranch vcsBranch, @NotNull PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull @NotNull com.atlassian.struts.ValidationAware validationAware) throws PlanCreationDeniedException Description copied from interface:BranchCreationFacade
Given a branch name and (optionally) vcs branch name, creates a plan branch, overriding repository definition. Returns either plan branch key if lightweight branch was created or future reference if divergent branch creation has been queued.- Specified by:
createChainBranch
in interfaceBranchCreationFacade
- Parameters:
chain
- chain to create branches underplanBranchWorkflow
- which workflow led to creation of this chain branchbranchName
- name of plan branch to createbranchDescription
- optional description of the new branchvcsBranch
- VCS branch to use when overriding repository definitionenablePlan
- defines whether newly created branches should be enabled or disabled after creationenableExpiry
- defines whether created branch can be removed due to branch expiration detectionvalidationAware
- to add errors to- Returns:
- Null if there were validation errors. Otherwise either key of newly created lightweight plan branch or RSS execution future for enqueued divergent branch
- Throws:
PlanCreationDeniedException
- if chain branch creation was denied for any reason
-
scheduleBranchListInitialisation
Description copied from interface:BranchCreationFacade
Schedules initialisation of existing vcs branch list. The next branch detection for the chain will only seek for existing branches but will not create any ChainBranches.- Specified by:
scheduleBranchListInitialisation
in interfaceBranchCreationFacade
- Parameters:
chain
- chain which vcs branches list should be initialized- Returns:
- false if another detection for this chain is already in progress or in queue
-
getOpenBranches
@Nullable public @Nullable List<VcsBranch> getOpenBranches(@NotNull @NotNull ImmutableChain chain, @Nullable @Nullable ErrorCollection errorCollection) Description copied from interface:BranchCreationFacade
Returns a list of currently open branches for the chain's default repository List ordering determined by underlying repository (preference is for native ordering e.g. last updated first for hg)- Specified by:
getOpenBranches
in interfaceBranchCreationFacade
- Parameters:
chain
- to find branches forerrorCollection
- to add errors to- Returns:
- a list of currently open branches for the chain's default repository or null if there were errors fetching branches list
-
getOpenBranches
@Nullable public @Nullable List<VcsBranch> getOpenBranches(@NotNull @NotNull ImmutableChain chain, @Nullable @Nullable ErrorCollection errorCollection, @NotNull @NotNull Optional<String> searchTerm) Description copied from interface:BranchCreationFacade
Returns a list of currently open branches for the chain's default repository List filtered by optional case-insensitive searchTerm. Ordering determined by underlying repository (preference is for native ordering e.g. last updated first for hg)- Specified by:
getOpenBranches
in interfaceBranchCreationFacade
- Parameters:
chain
- to find branches forerrorCollection
- to add errors tosearchTerm
- optional search term that has to appear inside branch name- Returns:
- a list of currently open branches for the chain's default repository or null if there were errors fetching branches list
-