Package com.atlassian.bamboo.plan.branch
Class LightweightBranchCreationServiceImpl
java.lang.Object
com.atlassian.bamboo.plan.branch.LightweightBranchCreationServiceImpl
- All Implemented Interfaces:
LightweightBranchCreationService
public class LightweightBranchCreationServiceImpl
extends Object
implements LightweightBranchCreationService
-
Constructor Summary
ConstructorDescriptionLightweightBranchCreationServiceImpl
(CachedPlanManager cachedPlanManager, ChainBranchCreationService chainBranchCreationService, CustomVariableContext customVariableContext, ErrorHandler errorHandler, JiraBranchLinkingService jiraBranchLinkingService, PlanManager planManager, RawRepositoryConfigurationXmlConverter rawRepositoryConfigurationXmlConverter, RepositoryDefinitionManager repositoryDefinitionManager, VcsBranchManager vcsBranchManager, VcsRepositoryManager vcsRepositoryManager, TriggerTypeManager triggerTypeManager, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescription@NotNull ChainBranchCreationResult
createChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull String branchName, @Nullable String branchDescription, @Nullable PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable VcsRepositoryModuleDescriptor moduleDescriptor, @Nullable VcsBranch newBranch, @NotNull BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch) Creates a new lightweight plan branch for give chain.@NotNull ChainBranchCreationResult
createChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull String branchName, @Nullable String branchDescription, @Nullable PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable VcsRepositoryModuleDescriptor moduleDescriptor, @Nullable VcsBranch newBranch, @NotNull BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch, Optional<VcsPullRequest> pullRequest) Creates a new lightweight plan branch for give chain.@NotNull Collection<ChainBranchCreationResult>
createChainBranches
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull Collection<VcsBranch> branches, @NotNull PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable ErrorCollection errorCollection, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull Consumer<PlanKey> consumer, boolean expectingDivergentBranch) Creates a new lightweight plan branch or enables existing one for each vcs branch in given collection under given chain.@NotNull ChainBranchCreationResult
createOrEnableChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @Nullable String branchName, @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @Nullable BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch) Given a branch name and (optionally) vcs branch name, check if branch already exists.@NotNull ChainBranchCreationResult
createOrEnableChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @Nullable String branchName, @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @Nullable BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch, Optional<VcsPullRequest> pullRequest) Given a branch name and (optionally) vcs branch name, check if branch already exists.@NotNull ChainBranchCreationResult
enableExistingChainBranch
(@NotNull ImmutableChain chain, @NotNull ImmutableChainBranch existingChainBranch, @NotNull VcsBranch vcsBranch, PlanCreationService.EnablePlan enablePlan, boolean expectingDivergentBranch) Enables existing chain branch.void
validateCreateChainBranch
(@NotNull ImmutableChain chain, @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull String branchName, @Nullable String branchDescription, @Nullable PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable VcsRepositoryModuleDescriptor moduleDescriptor, @Nullable VcsBranch newBranch, boolean enableExpiry, @NotNull com.atlassian.struts.ValidationAware validationAware) Validates configuration for creating chain branch
-
Constructor Details
-
LightweightBranchCreationServiceImpl
public LightweightBranchCreationServiceImpl(CachedPlanManager cachedPlanManager, ChainBranchCreationService chainBranchCreationService, CustomVariableContext customVariableContext, ErrorHandler errorHandler, JiraBranchLinkingService jiraBranchLinkingService, PlanManager planManager, RawRepositoryConfigurationXmlConverter rawRepositoryConfigurationXmlConverter, RepositoryDefinitionManager repositoryDefinitionManager, VcsBranchManager vcsBranchManager, VcsRepositoryManager vcsRepositoryManager, TriggerTypeManager triggerTypeManager, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Details
-
createChainBranches
@NotNull public @NotNull Collection<ChainBranchCreationResult> createChainBranches(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull Collection<VcsBranch> branches, @NotNull @NotNull PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable @Nullable ErrorCollection errorCollection, @NotNull PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull @NotNull Consumer<PlanKey> consumer, boolean expectingDivergentBranch) Description copied from interface:LightweightBranchCreationService
Creates a new lightweight plan branch or enables existing one for each vcs branch in given collection under given chain.- Specified by:
createChainBranches
in interfaceLightweightBranchCreationService
- Parameters:
chain
- to create branches underplanBranchWorkflow
- which workflow led to creation of these branchesbranches
- collection ov vcs branches for which plan branches should be createddefaultRepositoryDefinition
- default repository of the givenchain
errorCollection
- 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 creationenableExpiry
- defines whether created branch can be removed due to branch expiration detectionconsumer
- code should be executed before triggering events that new plan createdexpectingDivergentBranch
- RSS will attempt updating this branch; post creation events should be deferred- Returns:
- keys of created plan branches
-
createOrEnableChainBranch
@NotNull public @NotNull ChainBranchCreationResult createOrEnableChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @Nullable @Nullable String branchName, @NotNull @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @Nullable @Nullable BuildConfiguration buildConfiguration, @NotNull PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch, Optional<VcsPullRequest> pullRequest) throws PlanCreationDeniedExceptionDescription copied from interface:LightweightBranchCreationService
Given a branch name and (optionally) vcs branch name, check if branch already exists. If it does, enable it if it's disabled. Otherwise create a new lightweight plan branch. The overloaded method is aimed to deal with pull requests.- Specified by:
createOrEnableChainBranch
in interfaceLightweightBranchCreationService
- Parameters:
chain
- to create branch underplanBranchWorkflow
- which workflow led to creation of branchbranchName
- optional name for the plan branch. If null name of vcs branch will be usedvcsBranchProvider
- provides VcsBranch to use when overriding repository definitionbuildConfiguration
- optional default fragment of configuration to create the chain branch withenablePlan
- defines whether newly created branches should be enabled or disabled after creationenableExpiry
- defines whether created branch can be removed due to branch expiration detectionbranchPlanKeyConsumer
- code should be executed before triggering events that new plan createdexpectingDivergentBranch
- RSS will attempt updating this branch; post creation events should be deferredpullRequest
- optional pull requests object which contains potential source repository information- Returns:
- key of the created plan branch
- Throws:
PlanCreationDeniedException
-
createOrEnableChainBranch
@NotNull public @NotNull ChainBranchCreationResult createOrEnableChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @Nullable @Nullable String branchName, @NotNull @NotNull Function<VcsBranchConfigurator, VcsBranch> vcsBranchProvider, @Nullable @Nullable BuildConfiguration buildConfiguration, @NotNull PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch) throws PlanCreationDeniedExceptionDescription copied from interface:LightweightBranchCreationService
Given a branch name and (optionally) vcs branch name, check if branch already exists. If it does, enable it if it's disabled. Otherwise create a new lightweight plan branch.- Specified by:
createOrEnableChainBranch
in interfaceLightweightBranchCreationService
- Parameters:
chain
- to create branch underplanBranchWorkflow
- which workflow led to creation of branchbranchName
- optional name for the plan branch. If null name of vcs branch will be usedvcsBranchProvider
- provides VcsBranch to use when overriding repository definitionbuildConfiguration
- optional default fragment of configuration to create the chain branch withenablePlan
- defines whether newly created branches should be enabled or disabled after creationenableExpiry
- defines whether created branch can be removed due to branch expiration detectionbranchPlanKeyConsumer
- code should be executed before triggering events that new plan createdexpectingDivergentBranch
- RSS will attempt updating this branch; post creation events should be deferred- Returns:
- key of the created plan branch
- Throws:
PlanCreationDeniedException
-
enableExistingChainBranch
@NotNull public @NotNull ChainBranchCreationResult enableExistingChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull ImmutableChainBranch existingChainBranch, @NotNull @NotNull VcsBranch vcsBranch, @NotNull PlanCreationService.EnablePlan enablePlan, boolean expectingDivergentBranch) Description copied from interface:LightweightBranchCreationService
Enables existing chain branch.- Specified by:
enableExistingChainBranch
in interfaceLightweightBranchCreationService
-
createChainBranch
@NotNull public @NotNull ChainBranchCreationResult createChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull String branchName, @Nullable @Nullable String branchDescription, @Nullable @Nullable PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable @Nullable VcsRepositoryModuleDescriptor moduleDescriptor, @Nullable @Nullable VcsBranch newBranch, @NotNull @NotNull BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch, Optional<VcsPullRequest> pullRequest) throws PlanCreationDeniedException Description copied from interface:LightweightBranchCreationService
Creates a new lightweight plan branch for give chain. Does not check if plan branch for given VCS branch already exists. The overloaded method is aimed to deal with pull requests.- Specified by:
createChainBranch
in interfaceLightweightBranchCreationService
- Parameters:
chain
- to create branches underplanBranchWorkflow
- which workflow led to creation of branchbranchName
- optional plan branch namebranchDescription
- optional plan branch descriptiondefaultRepositoryDefinition
- optional default repository of the givenchain
moduleDescriptor
- module descriptor of the givendefaultRepositoryDefinition
newBranch
- VCS branch to usebuildConfiguration
- optional default fragment of configuration to create the chain branch withenablePlan
- defines whether newly created branches should be enabled or disabled after creationenableExpiry
- defines whether created branch can be removed due to branch expiration detectionbranchPlanKeyConsumer
- code should be executed before triggering events that new plan createdexpectingDivergentBranch
- RSS will attempt updating this branch; post creation events should be deferredpullRequest
- optional pull requests object which contains potential source repository information- Returns:
- key of the created plan branch
- Throws:
PlanCreationDeniedException
-
createChainBranch
@NotNull public @NotNull ChainBranchCreationResult createChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull String branchName, @Nullable @Nullable String branchDescription, @Nullable @Nullable PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable @Nullable VcsRepositoryModuleDescriptor moduleDescriptor, @Nullable @Nullable VcsBranch newBranch, @NotNull @NotNull BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry, @NotNull @NotNull Consumer<PlanKey> branchPlanKeyConsumer, boolean expectingDivergentBranch) throws PlanCreationDeniedException Description copied from interface:LightweightBranchCreationService
Creates a new lightweight plan branch for give chain. Does not check if plan branch for given VCS branch already exists.- Specified by:
createChainBranch
in interfaceLightweightBranchCreationService
- Parameters:
chain
- to create branches underplanBranchWorkflow
- which workflow led to creation of branchbranchName
- optional plan branch namebranchDescription
- optional plan branch descriptiondefaultRepositoryDefinition
- optional default repository of the givenchain
moduleDescriptor
- module descriptor of the givendefaultRepositoryDefinition
newBranch
- VCS branch to usebuildConfiguration
- optional default fragment of configuration to create the chain branch withenablePlan
- defines whether newly created branches should be enabled or disabled after creationenableExpiry
- defines whether created branch can be removed due to branch expiration detectionbranchPlanKeyConsumer
- code should be executed before triggering events that new plan createdexpectingDivergentBranch
- RSS will attempt updating this branch; post creation events should be deferred- Returns:
- key of the created plan branch
- Throws:
PlanCreationDeniedException
-
validateCreateChainBranch
public void validateCreateChainBranch(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull PlanBranchWorkflow planBranchWorkflow, @NotNull @NotNull String branchName, @Nullable @Nullable String branchDescription, @Nullable @Nullable PlanRepositoryDefinition defaultRepositoryDefinition, @Nullable @Nullable VcsRepositoryModuleDescriptor moduleDescriptor, @Nullable @Nullable VcsBranch newBranch, boolean enableExpiry, @NotNull @NotNull com.atlassian.struts.ValidationAware validationAware) Description copied from interface:LightweightBranchCreationService
Validates configuration for creating chain branch- Specified by:
validateCreateChainBranch
in interfaceLightweightBranchCreationService
- Parameters:
chain
- to create branches underplanBranchWorkflow
- which workflow led to creation of branchbranchName
- optional plan branch namebranchDescription
- optional plan branch descriptiondefaultRepositoryDefinition
- optional default repository of the givenchain
moduleDescriptor
- module descriptor of the givendefaultRepositoryDefinition
newBranch
- VCS branch to useenableExpiry
- defines whether created branch can be removed due to branch expiration * detectionvalidationAware
- to add errors to
-