Package com.atlassian.bamboo.plan.branch
Class ChainBranchManagerImpl
- java.lang.Object
-
- com.atlassian.bamboo.plan.branch.ChainBranchManagerImpl
-
- All Implemented Interfaces:
ChainBranchManager
public class ChainBranchManagerImpl extends Object implements ChainBranchManager
-
-
Constructor Summary
Constructors Constructor Description ChainBranchManagerImpl(PlanDao planDao, com.atlassian.bandana.BandanaManager bandanaManager, VcsBranchManager vcsBranchManager, PlanManager planManager, com.atlassian.event.api.EventPublisher eventPublisher, CustomVariableContext customVariableContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearInvalidMetadataFlagInBranches(long masterId)
Clears 'invalid' flag in all branches of a chain.int
getBranchCount(@NotNull ImmutablePlan plan)
Returns the number of branches the given plan has@NotNull List<ChainBranch>
getBranchesForChain(@NotNull ImmutableChain chain)
Get all feature branches associated with the given chain@NotNull List<PlanKey>
getBranchesForChain(@NotNull PlanKey chainKey)
Get all feature branches associated with the chain identified by the given keyCollection<Job>
getBranchesForJob(Job job)
@NotNull List<ChainBranchIdentifier>
getBranchIdentifiersForChain(@NotNull PlanIdentifier chain)
Get all feature branches associated with the given chain, however on pulls up minimal details about each branch.ChainBranchIdentifier
getBranchWithName(ImmutableChain masterPlan, String branchName)
long
getNextBranchKeyNumber(ImmutablePlan chain)
Retrieving suggested number for next branch key in given chain.@NotNull Set<Long>
getPlansWithBranches()
Returns a list of plans that currently have branchesvoid
handleVcsBranchDeletedOfPlanBranch(@NotNull ImmutableChain chainBranch, @NotNull PlanRepositoryDefinition planRepositoryDefinition)
Handles deletion of a VCS branch from any of the plan branch's repositories.void
handleVcsBranchDeletedOfPlanBranch(ImmutableChain chainBranch)
Handles deletion of a VCS branch from plan branch's default repository.boolean
hasBranches(@NotNull Plan plan)
Returns whether or not the given plan has any branchesboolean
isPlanBranchNameConflicting(ImmutableChain masterPlan, long planIdToIgnore, String branchName)
Verifies whether aChainBranch
name is unique with a given masterChain
void
markMetadataInvalid(@NotNull PlanKey branchKey)
Marks the chain as 'invalid', which means metadata no longer match vcs data.void
updateNextBranchKeyNumber(ImmutablePlan chain, long number)
Set suggested number for next branch key in given chainvoid
updatePlanBranchMetadata(@NotNull PlanKey branchKey)
Update plan branch metadata to reflect the current state of chain.
-
-
-
Constructor Detail
-
ChainBranchManagerImpl
public ChainBranchManagerImpl(PlanDao planDao, com.atlassian.bandana.BandanaManager bandanaManager, VcsBranchManager vcsBranchManager, PlanManager planManager, com.atlassian.event.api.EventPublisher eventPublisher, CustomVariableContext customVariableContext)
-
-
Method Detail
-
getBranchesForChain
@NotNull public @NotNull List<ChainBranch> getBranchesForChain(@NotNull @NotNull ImmutableChain chain)
Description copied from interface:ChainBranchManager
Get all feature branches associated with the given chain- Specified by:
getBranchesForChain
in interfaceChainBranchManager
- Parameters:
chain
- - the master- Returns:
- List
ChainBranch
s associated with the given chain.
-
getBranchesForChain
@NotNull public @NotNull List<PlanKey> getBranchesForChain(@NotNull @NotNull PlanKey chainKey)
Description copied from interface:ChainBranchManager
Get all feature branches associated with the chain identified by the given key- Specified by:
getBranchesForChain
in interfaceChainBranchManager
- Parameters:
chainKey
- - the chain key- Returns:
- List
ChainBranch
s associated with the chain identified by the given key.
-
getBranchesForJob
public Collection<Job> getBranchesForJob(Job job)
- Specified by:
getBranchesForJob
in interfaceChainBranchManager
-
getBranchIdentifiersForChain
@NotNull public @NotNull List<ChainBranchIdentifier> getBranchIdentifiersForChain(@NotNull @NotNull PlanIdentifier chain)
Description copied from interface:ChainBranchManager
Get all feature branches associated with the given chain, however on pulls up minimal details about each branch.- Specified by:
getBranchIdentifiersForChain
in interfaceChainBranchManager
- Parameters:
chain
- - the master- Returns:
- List
ChainBranchIdentifier
for branches associated with the given Chain.
-
hasBranches
public boolean hasBranches(@NotNull @NotNull Plan plan)
Description copied from interface:ChainBranchManager
Returns whether or not the given plan has any branches- Specified by:
hasBranches
in interfaceChainBranchManager
- Parameters:
plan
- to check for branches for- Returns:
- true if branches exist of the plan
-
getBranchCount
public int getBranchCount(@NotNull @NotNull ImmutablePlan plan)
Description copied from interface:ChainBranchManager
Returns the number of branches the given plan has- Specified by:
getBranchCount
in interfaceChainBranchManager
- Parameters:
plan
- to check for branches for- Returns:
- number of branches for the plan
-
getPlansWithBranches
@NotNull public @NotNull Set<Long> getPlansWithBranches()
Description copied from interface:ChainBranchManager
Returns a list of plans that currently have branches- Specified by:
getPlansWithBranches
in interfaceChainBranchManager
- Returns:
- a list of plan ids of the plans with branches.
-
isPlanBranchNameConflicting
public boolean isPlanBranchNameConflicting(ImmutableChain masterPlan, long planIdToIgnore, String branchName)
Description copied from interface:ChainBranchManager
Verifies whether aChainBranch
name is unique with a given masterChain
- Specified by:
isPlanBranchNameConflicting
in interfaceChainBranchManager
- Parameters:
masterPlan
- the master chain within which the name has to be uniqueplanIdToIgnore
- the id of the ChainBranch that has to be ignored during lookup (when you're saving a ChainBranch, you should supply its id here)branchName
- displayed name of the ChainBranch inside the master's plan- Returns:
- true if the name is in conflict
-
getBranchWithName
public ChainBranchIdentifier getBranchWithName(ImmutableChain masterPlan, String branchName)
Description copied from interface:ChainBranchManager
- Specified by:
getBranchWithName
in interfaceChainBranchManager
- Returns:
ChainBranchIdentifier
or null if no such branch exists
-
handleVcsBranchDeletedOfPlanBranch
public void handleVcsBranchDeletedOfPlanBranch(ImmutableChain chainBranch)
Description copied from interface:ChainBranchManager
Handles deletion of a VCS branch from plan branch's default repository. If the passed in chain is a plan branch it will be disabled and it's default VCS branch will be marked as deleted.- Specified by:
handleVcsBranchDeletedOfPlanBranch
in interfaceChainBranchManager
- Parameters:
chainBranch
- the plan branch of which a default VCS branch was deleted
-
handleVcsBranchDeletedOfPlanBranch
public void handleVcsBranchDeletedOfPlanBranch(@NotNull @NotNull ImmutableChain chainBranch, @NotNull @NotNull PlanRepositoryDefinition planRepositoryDefinition)
Description copied from interface:ChainBranchManager
Handles deletion of a VCS branch from any of the plan branch's repositories. If the passed in chain is a plan branch it will be disabled. If the deleted branch is the default branch it will mark that VCS branch as deleted.- Specified by:
handleVcsBranchDeletedOfPlanBranch
in interfaceChainBranchManager
- Parameters:
chainBranch
- the plan branch of which a VCS branch was deletedplanRepositoryDefinition
- plan repository whose branch was deleted
-
getNextBranchKeyNumber
public long getNextBranchKeyNumber(ImmutablePlan chain)
Description copied from interface:ChainBranchManager
Retrieving suggested number for next branch key in given chain. If it's first branch it will return 0.- Specified by:
getNextBranchKeyNumber
in interfaceChainBranchManager
- Returns:
-
updateNextBranchKeyNumber
public void updateNextBranchKeyNumber(ImmutablePlan chain, long number)
Description copied from interface:ChainBranchManager
Set suggested number for next branch key in given chain- Specified by:
updateNextBranchKeyNumber
in interfaceChainBranchManager
-
clearInvalidMetadataFlagInBranches
public void clearInvalidMetadataFlagInBranches(long masterId)
Description copied from interface:ChainBranchManager
Clears 'invalid' flag in all branches of a chain.- Specified by:
clearInvalidMetadataFlagInBranches
in interfaceChainBranchManager
-
updatePlanBranchMetadata
public void updatePlanBranchMetadata(@NotNull @NotNull PlanKey branchKey)
Description copied from interface:ChainBranchManager
Update plan branch metadata to reflect the current state of chain.- Specified by:
updatePlanBranchMetadata
in interfaceChainBranchManager
-
markMetadataInvalid
public void markMetadataInvalid(@NotNull @NotNull PlanKey branchKey)
Description copied from interface:ChainBranchManager
Marks the chain as 'invalid', which means metadata no longer match vcs data.- Specified by:
markMetadataInvalid
in interfaceChainBranchManager
-
-