com.atlassian.bamboo.plan.branch
Class BranchDetectionServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.plan.branch.BranchDetectionServiceImpl
All Implemented Interfaces:
BranchDetectionService

public class BranchDetectionServiceImpl
extends Object
implements BranchDetectionService


Constructor Summary
BranchDetectionServiceImpl(PlanManager planManager, ChainBranchCreationService chainBranchCreationService, RepositoryManager repositoryManager, VcsBranchManager vcsBranchManager, RepositoryCachingFacade repositoryCachingFacade, ErrorHandler errorHandler, ScopedExclusionService scopedExclusionService, com.atlassian.event.api.EventPublisher eventPublisher, JiraBranchLinkingService jiraBranchLinkingService, VariableDefinitionManager variableDefinitionManager, CustomVariableContext customVariableContext, org.springframework.orm.hibernate3.HibernateTemplate hibernateTemplate, CachedPlanManager cachedPlanManager, com.atlassian.struts.TextProvider textProvider, ChainBranchManager chainBranchManager)
           
 
Method Summary
 PlanKey createChainBranch(ImmutableChain chain, String branchName, VcsBranch vcsBranch, BuildConfiguration buildConfiguration, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry)
          Given a branch name and (optionally) vcs branch name, create Plan Branches with overriding repository definitions.
 PlanKey createChainBranch(ImmutableChain chain, String branchName, VcsBranch vcsBranch, PlanCreationService.EnablePlan enablePlan, boolean enableExpiry)
          Given a branch name and (optionally) vcs branch name, create Plan Branches with overriding repository definitions.
protected  void createNewBranchesForChainNoLock(ImmutableChain chain, RepositoryDefinition defaultRepositoryDefinition)
           
 Collection<PlanKey> createPlanBranches(ImmutableChain chain, Collection<VcsBranch> branches, ErrorCollection errorCollection)
          Given a list of branch names, create Plan Branches for these, with overriding repository definitions.
 Collection<PlanKey> createPlanBranches(ImmutableChain chain, Collection<VcsBranch> branches, ErrorCollection errorCollection, PlanCreationService.EnablePlan enablePlan)
          Given a list of branch names, create Plan Branches for these, with overriding repository definitions.
 void deleteBambooVcsBranch(Iterable<ImmutableChain> chains, String branchName)
          Deletes vcs branch from table
 void detectBranchesForChain(ImmutableChain chain)
          Immediately executes the detection for a given Chain and creates new plan branches if new branches found in the plan's default repository.
 void disableChainBranch(Iterable<ImmutableChain> chains)
          Disables bamboo branches from given chain branches (or chains if it's default branch).
 List<VcsBranch> getOpenBranches(ImmutableChain chain, 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.
 boolean scheduleBranchDetectionForChain(ImmutableChain chain)
          Registers branch detection request for a given Chain.
 boolean scheduleBranchListInitialisation(Chain chain)
          Schedules initialisation of existing vcs branch list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BranchDetectionServiceImpl

public BranchDetectionServiceImpl(PlanManager planManager,
                                  ChainBranchCreationService chainBranchCreationService,
                                  RepositoryManager repositoryManager,
                                  VcsBranchManager vcsBranchManager,
                                  RepositoryCachingFacade repositoryCachingFacade,
                                  ErrorHandler errorHandler,
                                  ScopedExclusionService scopedExclusionService,
                                  com.atlassian.event.api.EventPublisher eventPublisher,
                                  JiraBranchLinkingService jiraBranchLinkingService,
                                  VariableDefinitionManager variableDefinitionManager,
                                  CustomVariableContext customVariableContext,
                                  org.springframework.orm.hibernate3.HibernateTemplate hibernateTemplate,
                                  CachedPlanManager cachedPlanManager,
                                  com.atlassian.struts.TextProvider textProvider,
                                  ChainBranchManager chainBranchManager)
Method Detail

scheduleBranchListInitialisation

public boolean scheduleBranchListInitialisation(@NotNull
                                                Chain chain)
Description copied from interface: BranchDetectionService
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 interface BranchDetectionService
Returns:
false if another detection for this chain is already in progress or in queue

scheduleBranchDetectionForChain

public boolean scheduleBranchDetectionForChain(@NotNull
                                               ImmutableChain chain)
Description copied from interface: BranchDetectionService
Registers branch detection request for a given Chain. The BranchDetectionService will try to flatten the real branch detection execution density over time.

Specified by:
scheduleBranchDetectionForChain in interface BranchDetectionService
Returns:
false if another detection for this chain is already in progress or in queue

detectBranchesForChain

public void detectBranchesForChain(@NotNull
                                   ImmutableChain chain)
Description copied from interface: BranchDetectionService
Immediately executes the detection for a given Chain and creates new plan branches if new branches found in the plan's default repository. This method blocks until the detection is finished.

Specified by:
detectBranchesForChain in interface BranchDetectionService

createNewBranchesForChainNoLock

protected void createNewBranchesForChainNoLock(@NotNull
                                               ImmutableChain chain,
                                               @NotNull
                                               RepositoryDefinition defaultRepositoryDefinition)

createPlanBranches

@NotNull
public Collection<PlanKey> createPlanBranches(@NotNull
                                                      ImmutableChain chain,
                                                      @NotNull
                                                      Collection<VcsBranch> branches,
                                                      @Nullable
                                                      ErrorCollection errorCollection)
Description copied from interface: BranchDetectionService
Given a list of branch names, create Plan Branches for these, with overriding repository definitions. Branches created using this method are excluded from expiration by default.

Specified by:
createPlanBranches in interface BranchDetectionService
Parameters:
chain - to create branches under
branches - to create.
errorCollection - - to add errors to, if you don't supply an error collection, they will just get logged.
Returns:
collection of keys of created plans

createPlanBranches

@NotNull
public Collection<PlanKey> createPlanBranches(@NotNull
                                                      ImmutableChain chain,
                                                      @NotNull
                                                      Collection<VcsBranch> branches,
                                                      @Nullable
                                                      ErrorCollection errorCollection,
                                                      PlanCreationService.EnablePlan enablePlan)
Description copied from interface: BranchDetectionService
Given a list of branch names, create Plan Branches for these, with overriding repository definitions. Branches created using this method are excluded from expiration by default.

Specified by:
createPlanBranches in interface BranchDetectionService
Parameters:
chain - to create branches under
branches - to create.
errorCollection - - to add errors to, if you don't supply an error collection, they will just get logged.
enablePlan - - defines whether newly created branches should be enabled or disabled after creation
Returns:
collection of keys of created plans

getOpenBranches

@Nullable
public List<VcsBranch> getOpenBranches(@NotNull
                                                ImmutableChain chain,
                                                ErrorCollection errorCollection)
Description copied from interface: BranchDetectionService
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 interface BranchDetectionService
Parameters:
chain - to find branches for.
errorCollection - to add any errors to during detection
Returns:
a list of currently open branches for the chain's default repository

createChainBranch

public PlanKey createChainBranch(@NotNull
                                 ImmutableChain chain,
                                 @NotNull
                                 String branchName,
                                 @Nullable
                                 VcsBranch vcsBranch,
                                 PlanCreationService.EnablePlan enablePlan,
                                 boolean enableExpiry)
                          throws PlanCreationDeniedException
Description copied from interface: BranchDetectionService
Given a branch name and (optionally) vcs branch name, create Plan Branches with overriding repository definitions.

Specified by:
createChainBranch in interface BranchDetectionService
Parameters:
chain - to create branches under
branchName - to create.
vcsBranch - to use when overriding repository definition.
enablePlan - - defines whether newly created branches should be enabled or disabled after creation
enableExpiry - - defines whether created branch can be removed due to branch expiration detection
Returns:
collection of keys of created plans
Throws:
PlanCreationDeniedException

createChainBranch

public PlanKey createChainBranch(@NotNull
                                 ImmutableChain chain,
                                 @NotNull
                                 String branchName,
                                 @Nullable
                                 VcsBranch vcsBranch,
                                 @Nullable
                                 BuildConfiguration buildConfiguration,
                                 PlanCreationService.EnablePlan enablePlan,
                                 boolean enableExpiry)
                          throws PlanCreationDeniedException
Description copied from interface: BranchDetectionService
Given a branch name and (optionally) vcs branch name, create Plan Branches with overriding repository definitions.

Specified by:
createChainBranch in interface BranchDetectionService
Parameters:
chain - to create branches under
branchName - to create.
vcsBranch - to use when overriding repository definition.
buildConfiguration - - a default fragment of configuration to create the chain branch with
enablePlan - - defines whether newly created branches should be enabled or disabled after creation
enableExpiry - - defines whether created branch can be removed due to branch expiration detection
Returns:
collection of keys of created plans
Throws:
PlanCreationDeniedException

deleteBambooVcsBranch

public void deleteBambooVcsBranch(@NotNull
                                  Iterable<ImmutableChain> chains,
                                  @NotNull
                                  String branchName)
Description copied from interface: BranchDetectionService
Deletes vcs branch from table

Specified by:
deleteBambooVcsBranch in interface BranchDetectionService
Parameters:
chains - collection of chains/chain branches to search through
branchName - vcs branch name that was removed

disableChainBranch

public void disableChainBranch(@NotNull
                               Iterable<ImmutableChain> chains)
Description copied from interface: BranchDetectionService
Disables bamboo branches from given chain branches (or chains if it's default branch). Doesn't disable branch if branch is already disabled, marked for deletion or has cleanup disabled. Also doesn't disable branch if SystemProperty.DISABLE_CLOSED_BRANCH_DETECTION property is enabled.

Specified by:
disableChainBranch in interface BranchDetectionService
Parameters:
chains - collection of chains/chain branches that should be disabled


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