Class VcsRepositoryConfigurationServiceImpl
- java.lang.Object
-
- com.atlassian.bamboo.vcs.configuration.service.VcsRepositoryConfigurationServiceImpl
-
- All Implemented Interfaces:
VcsRepositoryConfigurationService
public class VcsRepositoryConfigurationServiceImpl extends Object implements VcsRepositoryConfigurationService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.vcs.configuration.service.VcsRepositoryConfigurationService
VcsRepositoryConfigurationService.LinkedRepositoryAccess, VcsRepositoryConfigurationService.RepositoryAccess
-
-
Field Summary
-
Fields inherited from interface com.atlassian.bamboo.vcs.configuration.service.VcsRepositoryConfigurationService
LEGACY_VCS_PLUGINS_USED_BANDANA_KEY
-
-
Constructor Summary
Constructors Constructor Description VcsRepositoryConfigurationServiceImpl(RepositoryDefinitionManager repositoryDefinitionManager, AuditLogService auditLogService, HibernateMutableAclService aclService, RawRepositoryConfigurationXmlConverter rawRepositoryConfigurationXmlConverter, ScopedExclusionService scopedExclusionService, TriggerConfigurationService triggerConfigurationService, TaskConfigurationService taskConfigurationService, ChainBranchManager chainBranchManager, EnvironmentTaskService environmentTaskService, BuildDefinitionManager buildDefinitionManager, com.atlassian.event.api.EventPublisher eventPublisher, BranchCreationFacade branchCreationFacade, VcsRepositoryManager vcsRepositoryManager, TransactionAndHibernateTemplate hibernateTemplate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull ErrorCollectionconfigureRssDetection(long repositoryId, PartialVcsRepositoryData vcsRepositoryData, boolean isEnabled)Sets detection of Bamboo Specs for repository and saves new config.PartialVcsRepositoryDataconvertToNewRepositoryConfiguration(@NotNull PartialVcsRepositoryData vcsRepositoryData)If repository data represents a repository implemented in the old system and appropriate new plugin exists, the data is converted to the new plugin.@NotNull PartialVcsRepositoryDatacreateLinkedRepository(@NotNull PartialVcsRepositoryData newVcsConfiguration, @NotNull com.atlassian.user.User user, @NotNull VcsRepositoryConfigurationService.RepositoryAccess accessOption)Creates new linked repositoryorg.acegisecurity.acls.MutableAclcreateNewSharedRepositoryDefaultAcl(@Nullable com.atlassian.user.User user, long repositoryId, VcsRepositoryConfigurationService.RepositoryAccess accessOption)Creates a defualt Acl for a specific repository which has: - READ permissions for the creator (if applicable) - READ permission to logged in users if ALL_USERS option is specified@NotNull PartialVcsRepositoryDatacreatePlanRepository(@NotNull Plan plan, @NotNull PartialVcsRepositoryData newVcsConfiguration)Creates "plan local" repository and adds it to a plan.@NotNull PartialVcsRepositoryDatacreateProjectRepository(@NotNull PartialVcsRepositoryData newVcsConfiguration, @Nullable com.atlassian.user.User user, @NotNull VcsRepositoryConfigurationService.RepositoryAccess accessOption)Creates new project repositoryvoiddeleteLinkedRepository(long repositoryId)Removes linked repository.voiddeleteProjectRepository(long repositoryId)Removes project repository.voiddeleteRepository(@NotNull Plan plan, long repositoryId, Long replacementRepositoryId)Removes repository definition from a plan@NotNull PartialVcsRepositoryDataeditLinkedRepository(long repositoryId, @NotNull PartialVcsRepositoryData newVcsConfiguration)Edits existing linked repository@NotNull PartialVcsRepositoryDataeditProjectRepository(long repositoryId, @NotNull PartialVcsRepositoryData newVcsConfiguration)Edits existing project repository@NotNull PartialVcsRepositoryDataeditRepository(@NotNull Plan plan, long repositoryId, @NotNull PartialVcsRepositoryData newVcsConfiguration)Edits existing "plan local" repository.protected @NotNull List<PlanRepositoryLink>getNewRepositoryList(@NotNull List<PlanRepositoryLink> originalRepositories, @NotNull PlanRepositoryLink toMove, long beforeId, long afterId)Map<ImmutableJob,List<TaskDefinition>>getRelevantJobsForRepositoryIdChange(@NotNull ImmutablePlan plan, long repositoryId)Gets list of jobs using a repository.@org.jetbrains.annotations.NotNull booleanhasProjectSharedCredentialsForRepository(PartialVcsRepositoryData vcsRepositoryData)@NotNull PartialVcsRepositoryDatalinkRepositoryToPlan(@NotNull Plan plan, long selectedRepositoryId)Connects a linked repository to a plan by creating a new repository that inherits all the data from the linked repository and adding it to the plan.PartialVcsRepositoryDatamergeLinkedRepository(@NotNull PartialVcsRepositoryData vcsRepositoryData)Merges the state of the given linked repository into the database.voidmergePlanRepositories(@NotNull Plan plan, @NotNull List<PartialVcsRepositoryData> vcsRepositoryDataList)Merges the state of the given plan repositories into the database.PartialVcsRepositoryDatamergeProjectRepository(@NotNull PartialVcsRepositoryData vcsRepositoryData)Merges the state of the given project repository into the database.voidmoveRepository(@NotNull Plan plan, long repositoryId, long beforePosition, long afterPosition)Changes position of repository in the repository list.PartialVcsRepositoryDatareplaceRepositoryInPlan(@NotNull Plan plan, @NotNull VcsRepositoryData parentRepository, @NotNull PartialVcsRepositoryData oldRepository, @NotNull PartialVcsRepositoryData newRepository)Replaces uses of a repository with another one.voidsetParentOfPlanRepository(@NotNull ImmutablePlan plan, long repositoryId, long parentRepositoryId)Creates or changes parent-child relationship for a plan repository.voidshareRepository(@NotNull Plan plan, @NotNull PartialVcsRepositoryData repositoryData, @NotNull String repositoryName, @Nullable String userDescription, @NotNull com.atlassian.user.User user)Converts existing Plan repository to Linked repository.booleanvalidateContinuableStatus(@NotNull ResultsSummary resultSummary)Checks that result is continuable and repositories referenced by a result still exists in Bamboo db.voidvalidateLinkedRepository(@NotNull PartialVcsRepositoryData vcsRepositoryData)Validate linked repository before saving it in database.booleanvalidateLinkedRepositoryName(@NotNull String repositoryName, @Nullable BambooIdProvider vcsRepositoryData)Checks if name of a linked repository is unique.voidvalidatePlanRepositoriesNamesAndOids(@NotNull Plan plan, @NotNull List<PartialVcsRepositoryData> repositoryDataList)Validate repository names checking if there are no duplicates.voidvalidatePlanRepository(@NotNull Plan plan, @NotNull PartialVcsRepositoryData vcsRepositoryData)Validate plan repository before saving it in database.voidvalidateProjectRepository(@NotNull PartialVcsRepositoryData vcsRepositoryData)Validate project repository before saving it in database.booleanvalidateProjectRepositoryName(@NotNull String repositoryName, @NotNull Long projectId, @Nullable BambooIdProvider vcsRepositoryData)Checks if name of a project repository is unique in the project.booleanvalidateRepositoryName(@NotNull ImmutablePlan immutablePlan, @NotNull String repositoryName, @Nullable BambooIdProvider repositoryDefinition)Checks if provided name for repository is unique in the PlanbooleanvalidateRestartableStatus(@NotNull ResultsSummary resultSummary)Checks that result is restartable and repositories referenced by a result still exists in Bamboo db.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.vcs.configuration.service.VcsRepositoryConfigurationService
createLinkedRepository
-
-
-
-
Constructor Detail
-
VcsRepositoryConfigurationServiceImpl
public VcsRepositoryConfigurationServiceImpl(RepositoryDefinitionManager repositoryDefinitionManager, AuditLogService auditLogService, HibernateMutableAclService aclService, RawRepositoryConfigurationXmlConverter rawRepositoryConfigurationXmlConverter, ScopedExclusionService scopedExclusionService, TriggerConfigurationService triggerConfigurationService, TaskConfigurationService taskConfigurationService, ChainBranchManager chainBranchManager, EnvironmentTaskService environmentTaskService, BuildDefinitionManager buildDefinitionManager, com.atlassian.event.api.EventPublisher eventPublisher, BranchCreationFacade branchCreationFacade, VcsRepositoryManager vcsRepositoryManager, TransactionAndHibernateTemplate hibernateTemplate)
-
-
Method Detail
-
createPlanRepository
@NotNull public @NotNull PartialVcsRepositoryData createPlanRepository(@NotNull @NotNull Plan plan, @NotNull @NotNull PartialVcsRepositoryData newVcsConfiguration)
Description copied from interface:VcsRepositoryConfigurationServiceCreates "plan local" repository and adds it to a plan.- Specified by:
createPlanRepositoryin interfaceVcsRepositoryConfigurationService- Returns:
-
editRepository
@NotNull public @NotNull PartialVcsRepositoryData editRepository(@NotNull @NotNull Plan plan, long repositoryId, @NotNull @NotNull PartialVcsRepositoryData newVcsConfiguration)
Description copied from interface:VcsRepositoryConfigurationServiceEdits existing "plan local" repository.- Specified by:
editRepositoryin interfaceVcsRepositoryConfigurationService- Returns:
-
setParentOfPlanRepository
public void setParentOfPlanRepository(@NotNull @NotNull ImmutablePlan plan, long repositoryId, long parentRepositoryId)Description copied from interface:VcsRepositoryConfigurationServiceCreates or changes parent-child relationship for a plan repository.- Specified by:
setParentOfPlanRepositoryin interfaceVcsRepositoryConfigurationService
-
replaceRepositoryInPlan
public PartialVcsRepositoryData replaceRepositoryInPlan(@NotNull @NotNull Plan plan, @NotNull @NotNull VcsRepositoryData parentRepository, @NotNull @NotNull PartialVcsRepositoryData oldRepository, @NotNull @NotNull PartialVcsRepositoryData newRepository)
Description copied from interface:VcsRepositoryConfigurationServiceReplaces uses of a repository with another one.- Specified by:
replaceRepositoryInPlanin interfaceVcsRepositoryConfigurationService- Returns:
-
linkRepositoryToPlan
@NotNull public @NotNull PartialVcsRepositoryData linkRepositoryToPlan(@NotNull @NotNull Plan plan, long selectedRepositoryId)
Description copied from interface:VcsRepositoryConfigurationServiceConnects a linked repository to a plan by creating a new repository that inherits all the data from the linked repository and adding it to the plan.- Specified by:
linkRepositoryToPlanin interfaceVcsRepositoryConfigurationService- Returns:
-
createLinkedRepository
@NotNull public @NotNull PartialVcsRepositoryData createLinkedRepository(@NotNull @NotNull PartialVcsRepositoryData newVcsConfiguration, @NotNull @NotNull com.atlassian.user.User user, @NotNull @NotNull VcsRepositoryConfigurationService.RepositoryAccess accessOption)
Description copied from interface:VcsRepositoryConfigurationServiceCreates new linked repository- Specified by:
createLinkedRepositoryin interfaceVcsRepositoryConfigurationService- Returns:
-
createProjectRepository
@NotNull public @NotNull PartialVcsRepositoryData createProjectRepository(@NotNull @NotNull PartialVcsRepositoryData newVcsConfiguration, @Nullable @Nullable com.atlassian.user.User user, @NotNull @NotNull VcsRepositoryConfigurationService.RepositoryAccess accessOption)
Description copied from interface:VcsRepositoryConfigurationServiceCreates new project repository- Specified by:
createProjectRepositoryin interfaceVcsRepositoryConfigurationService- Returns:
-
editLinkedRepository
@NotNull public @NotNull PartialVcsRepositoryData editLinkedRepository(long repositoryId, @NotNull @NotNull PartialVcsRepositoryData newVcsConfiguration)
Description copied from interface:VcsRepositoryConfigurationServiceEdits existing linked repository- Specified by:
editLinkedRepositoryin interfaceVcsRepositoryConfigurationService- Returns:
-
editProjectRepository
@NotNull public @NotNull PartialVcsRepositoryData editProjectRepository(long repositoryId, @NotNull @NotNull PartialVcsRepositoryData newVcsConfiguration)
Description copied from interface:VcsRepositoryConfigurationServiceEdits existing project repository- Specified by:
editProjectRepositoryin interfaceVcsRepositoryConfigurationService- Returns:
-
deleteLinkedRepository
public void deleteLinkedRepository(long repositoryId)
Description copied from interface:VcsRepositoryConfigurationServiceRemoves linked repository.- Specified by:
deleteLinkedRepositoryin interfaceVcsRepositoryConfigurationService
-
deleteProjectRepository
public void deleteProjectRepository(long repositoryId)
Description copied from interface:VcsRepositoryConfigurationServiceRemoves project repository.- Specified by:
deleteProjectRepositoryin interfaceVcsRepositoryConfigurationService
-
validateLinkedRepositoryName
public boolean validateLinkedRepositoryName(@NotNull @NotNull String repositoryName, @Nullable @Nullable BambooIdProvider vcsRepositoryData)Description copied from interface:VcsRepositoryConfigurationServiceChecks if name of a linked repository is unique.- Specified by:
validateLinkedRepositoryNamein interfaceVcsRepositoryConfigurationService- Returns:
-
validateProjectRepositoryName
public boolean validateProjectRepositoryName(@NotNull @NotNull String repositoryName, @NotNull @NotNull Long projectId, @Nullable @Nullable BambooIdProvider vcsRepositoryData)Description copied from interface:VcsRepositoryConfigurationServiceChecks if name of a project repository is unique in the project.- Specified by:
validateProjectRepositoryNamein interfaceVcsRepositoryConfigurationService- Returns:
-
validateRepositoryName
public boolean validateRepositoryName(@NotNull @NotNull ImmutablePlan immutablePlan, @NotNull @NotNull String repositoryName, @Nullable @Nullable BambooIdProvider repositoryDefinition)Description copied from interface:VcsRepositoryConfigurationServiceChecks if provided name for repository is unique in the Plan- Specified by:
validateRepositoryNamein interfaceVcsRepositoryConfigurationService
-
createNewSharedRepositoryDefaultAcl
public org.acegisecurity.acls.MutableAcl createNewSharedRepositoryDefaultAcl(@Nullable @Nullable com.atlassian.user.User user, long repositoryId, VcsRepositoryConfigurationService.RepositoryAccess accessOption)Creates a defualt Acl for a specific repository which has: - READ permissions for the creator (if applicable) - READ permission to logged in users if ALL_USERS option is specified- Parameters:
user- to create acl foraccessOption-- Returns:
MutableAclrepresenting a default permission set
-
deleteRepository
public void deleteRepository(@NotNull @NotNull Plan plan, long repositoryId, Long replacementRepositoryId)Description copied from interface:VcsRepositoryConfigurationServiceRemoves repository definition from a plan- Specified by:
deleteRepositoryin interfaceVcsRepositoryConfigurationServicereplacementRepositoryId- repository id to replace removed one in tasks depending on it
-
moveRepository
public void moveRepository(@NotNull @NotNull Plan plan, long repositoryId, long beforePosition, long afterPosition) throws IllegalArgumentException, IllegalStateExceptionDescription copied from interface:VcsRepositoryConfigurationServiceChanges position of repository in the repository list. Important for setting default repository- Specified by:
moveRepositoryin interfaceVcsRepositoryConfigurationServicerepositoryId- the RepositoryDefinition to movebeforePosition- position of the RepositoryDefinition that will be before the moving Repository, -1 if the beginning of the listafterPosition- position of the RepositoryDefinition that will be after the moving Repository, -1 if the end of the list- Throws:
IllegalArgumentExceptionIllegalStateException
-
getNewRepositoryList
@NotNull protected @NotNull List<PlanRepositoryLink> getNewRepositoryList(@NotNull @NotNull List<PlanRepositoryLink> originalRepositories, @NotNull @NotNull PlanRepositoryLink toMove, long beforeId, long afterId)
-
shareRepository
public void shareRepository(@NotNull @NotNull Plan plan, @NotNull @NotNull PartialVcsRepositoryData repositoryData, @NotNull @NotNull String repositoryName, @Nullable @Nullable String userDescription, @NotNull @NotNull com.atlassian.user.User user)Description copied from interface:VcsRepositoryConfigurationServiceConverts existing Plan repository to Linked repository.- Specified by:
shareRepositoryin interfaceVcsRepositoryConfigurationService- Parameters:
plan- plan that owns the repositoryrepositoryData- repository to sharerepositoryName- new name of the repositoryuserDescription- of the repository
-
validateRestartableStatus
public boolean validateRestartableStatus(@NotNull @NotNull ResultsSummary resultSummary)Description copied from interface:VcsRepositoryConfigurationServiceChecks that result is restartable and repositories referenced by a result still exists in Bamboo db.- Specified by:
validateRestartableStatusin interfaceVcsRepositoryConfigurationService
-
validateContinuableStatus
public boolean validateContinuableStatus(@NotNull @NotNull ResultsSummary resultSummary)Description copied from interface:VcsRepositoryConfigurationServiceChecks that result is continuable and repositories referenced by a result still exists in Bamboo db.- Specified by:
validateContinuableStatusin interfaceVcsRepositoryConfigurationService
-
getRelevantJobsForRepositoryIdChange
public Map<ImmutableJob,List<TaskDefinition>> getRelevantJobsForRepositoryIdChange(@NotNull @NotNull ImmutablePlan plan, long repositoryId)
Description copied from interface:VcsRepositoryConfigurationServiceGets list of jobs using a repository.- Specified by:
getRelevantJobsForRepositoryIdChangein interfaceVcsRepositoryConfigurationService
-
convertToNewRepositoryConfiguration
public PartialVcsRepositoryData convertToNewRepositoryConfiguration(@NotNull @NotNull PartialVcsRepositoryData vcsRepositoryData)
Description copied from interface:VcsRepositoryConfigurationServiceIf repository data represents a repository implemented in the old system and appropriate new plugin exists, the data is converted to the new plugin. Otherwise, original data is returned.- Specified by:
convertToNewRepositoryConfigurationin interfaceVcsRepositoryConfigurationService- Returns:
-
validateProjectRepository
public void validateProjectRepository(@NotNull @NotNull PartialVcsRepositoryData vcsRepositoryData) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationExceptionDescription copied from interface:VcsRepositoryConfigurationServiceValidate project repository before saving it in database.- Specified by:
validateProjectRepositoryin interfaceVcsRepositoryConfigurationService- Parameters:
vcsRepositoryData- imported project repository- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
validateLinkedRepository
public void validateLinkedRepository(@NotNull @NotNull PartialVcsRepositoryData vcsRepositoryData) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationExceptionDescription copied from interface:VcsRepositoryConfigurationServiceValidate linked repository before saving it in database.- Specified by:
validateLinkedRepositoryin interfaceVcsRepositoryConfigurationService- Parameters:
vcsRepositoryData- imported linked repository- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
mergeLinkedRepository
public PartialVcsRepositoryData mergeLinkedRepository(@NotNull @NotNull PartialVcsRepositoryData vcsRepositoryData) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
Description copied from interface:VcsRepositoryConfigurationServiceMerges the state of the given linked repository into the database.This service will attempt to merge the entity based on
ImmutableEntityWithOid.getOid(), and if there's no match, based onDescriptionProvider.getName(). If an existing entity is found, then it will be updated. Otherwise, a new database entity will be created.It's assumed that this method is used in specs import only as it's sending analytic event.
- Specified by:
mergeLinkedRepositoryin interfaceVcsRepositoryConfigurationService- Parameters:
vcsRepositoryData- imported linked repository- Returns:
- an object after persisting to the database - either the newly created or updated database object
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
mergeProjectRepository
public PartialVcsRepositoryData mergeProjectRepository(@NotNull @NotNull PartialVcsRepositoryData vcsRepositoryData) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
Description copied from interface:VcsRepositoryConfigurationServiceMerges the state of the given project repository into the database.This service will attempt to merge the entity based on
ImmutableEntityWithOid.getOid(), and if there's no match, based onDescriptionProvider.getName(). If an existing entity is found, then it will be updated. Otherwise, a new database entity will be created. It's assumed that this method is used in specs import only as it's sending analytic event.- Specified by:
mergeProjectRepositoryin interfaceVcsRepositoryConfigurationService- Parameters:
vcsRepositoryData- imported project repository- Returns:
- an object after persisting to the database - either the newly created or updated database object
- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
validatePlanRepository
public void validatePlanRepository(@NotNull @NotNull Plan plan, @NotNull @NotNull PartialVcsRepositoryData vcsRepositoryData) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationExceptionDescription copied from interface:VcsRepositoryConfigurationServiceValidate plan repository before saving it in database.- Specified by:
validatePlanRepositoryin interfaceVcsRepositoryConfigurationServicevcsRepositoryData- imported plan repository- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
validatePlanRepositoriesNamesAndOids
public void validatePlanRepositoriesNamesAndOids(@NotNull @NotNull Plan plan, @NotNull @NotNull List<PartialVcsRepositoryData> repositoryDataList) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationExceptionDescription copied from interface:VcsRepositoryConfigurationServiceValidate repository names checking if there are no duplicates.- Specified by:
validatePlanRepositoriesNamesAndOidsin interfaceVcsRepositoryConfigurationService- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
mergePlanRepositories
public void mergePlanRepositories(@NotNull @NotNull Plan plan, @NotNull @NotNull List<PartialVcsRepositoryData> vcsRepositoryDataList) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationExceptionDescription copied from interface:VcsRepositoryConfigurationServiceMerges the state of the given plan repositories into the database. Note that it is up to the caller to validate if the resulting changes of repository configurations are actually legal.This service will attempt to merge the entities based on
BambooIdProvider.getId(), and if there's no match, a new database entity will be created. All other repositories in plan will be removed.- Specified by:
mergePlanRepositoriesin interfaceVcsRepositoryConfigurationServicevcsRepositoryDataList- list of imported plan repositories- Throws:
com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
-
configureRssDetection
@NotNull public @NotNull ErrorCollection configureRssDetection(long repositoryId, PartialVcsRepositoryData vcsRepositoryData, boolean isEnabled)
Description copied from interface:VcsRepositoryConfigurationServiceSets detection of Bamboo Specs for repository and saves new config. Validates if repository supports RSS.- Specified by:
configureRssDetectionin interfaceVcsRepositoryConfigurationService- Parameters:
repositoryId- id of repositoryvcsRepositoryData- repository configuration, remains unchangedisEnabled- true if Specs detection should be enabled, false otherwise- Returns:
- a list of errors.
-
hasProjectSharedCredentialsForRepository
@NotNull public @org.jetbrains.annotations.NotNull boolean hasProjectSharedCredentialsForRepository(PartialVcsRepositoryData vcsRepositoryData)
- Specified by:
hasProjectSharedCredentialsForRepositoryin interfaceVcsRepositoryConfigurationService- Parameters:
vcsRepositoryData- repository configuration- Returns:
- true if has project shared credentials
-
-