Package jetbrains.buildServer.vcs.impl
Class SVcsRootImpl
- java.lang.Object
-
- jetbrains.buildServer.vcs.impl.VcsRootImpl
-
- jetbrains.buildServer.vcs.impl.SVcsRootImpl
-
- All Implemented Interfaces:
Comparable<SVcsRoot>
,Loggable
,SPersistentEntity
,LVcsRoot
,SVcsRoot
,SVcsRootAccess
,SVcsRootEx
,SVcsRootUpdate
,SVcsRootUsages
,VcsRoot
- Direct Known Subclasses:
MockSVcsRoot
,SecuredVcsRoot
public class SVcsRootImpl extends VcsRootImpl implements SVcsRootEx, Loggable
-
-
Field Summary
Fields Modifier and Type Field Description protected VcsRootContext
myContext
-
Fields inherited from class jetbrains.buildServer.vcs.impl.VcsRootImpl
BRANCH_SPEC_PROP, CHECKOUT_ROOT, UNKNOWN_ROOT_NAME, VCS_NAME_PROP, VCS_ROOT_NAME_PROP
-
Fields inherited from interface jetbrains.buildServer.vcs.VcsRoot
SECURE_PROPERTY_PREFIX
-
-
Constructor Summary
Constructors Constructor Description SVcsRootImpl(EntityId<Long> rootId, String name, String vcsName, Map<String,String> parameters, ProjectEx ownerProject, VcsRootContext context, boolean emptyUuid)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
checkAccessibleFrom(SBuildType buildType)
Checks that VCS root can be attached to specified configuration.void
checkAccessibleFrom(SProject project)
Checks that VCS root can be attached to configurations of specified project.protected void
checkModificationAllowed()
int
compareTo(SVcsRoot o)
int
compareTo(SVcsRootEx rootEx)
ConfigAction
createConfigAction(SUser user, String description)
Creates a config action instance associated with this entity and having the specified description.String
describe(boolean verbose)
Set<SProject>
getAccessibleProjects()
Returns projects where this VCS root can be attached to a configurationBranchSpec
getBranchSpec(ValueResolver valueResolver)
Returns branch specification if it is defined in VCS root and can be fully resolved.File
getConfigDirectory()
String
getConfigId()
Returns the entity's config identifier.File
getConfigurationFile()
Returns the configuration file where this entity instance is persisted (or will be persisted to).File
getConfigurationFile(File projectsDir)
Returns the configuration file where this entity is persisted in custom projects directoryString
getDescription()
EntityId<Long>
getEntityId()
String
getExternalId()
Returns the external identifier.AuditLogAction
getLastConfigModificationAction()
int
getModificationCheckInterval()
returns modification check interval in secondsint
getNumberOfUsagesInProjects()
SPersistentEntity
getParent()
The parent entity.ProjectEx
getProject()
ReadOnlyReason
getReadOnlyReason()
static String
getResolvedBranchSpec(String spec, ValueResolver valueResolver)
VcsRootScope
getScope()
Returns scope of this VCS rootString
getSimpleName()
Deprecated.since 8.0, usegetExternalId()
insteadMap<SBuildType,CheckoutRules>
getUsages()
List<SBuildType>
getUsagesInConfigurations()
Collection<SProject>
getUsagesInProjects()
String
getVcsDisplayName()
Returns VCS plugin display namePersistentEntityVersion
getVersion()
Returns version of this entity which can be used to check if the entity was edited or persisted.void
init(int modificationCheckInterval)
boolean
isAccessibleFrom(SBuildType buildType)
Returns true if VCS root can be attached to specified configuration.boolean
isAccessibleFrom(SProject project)
Returns true if VCS root can be attached to configurations of specified project.boolean
isAliasExternalId(String extId)
boolean
isBranchSpecDefined(ValueResolver valueResolver)
Returns true if after the properties resolution this VCS root has not empty branch specificationboolean
isEmptyUuid()
boolean
isReadOnly()
boolean
isUseDefaultModificationCheckInterval()
Returns if 'use default modification check interval' mode is enabled for the root.boolean
isUsedInProjects()
void
markPersisted(long expectedEditId)
Marks entity as persistedvoid
markUnedited()
void
moveToProject(ConfigAction cause, SProject target)
Moves this VCS root to specified target project.void
moveToProject(SProject target)
Moves this VCS root to specified target project.void
persist()
Persists this VCS root on diskvoid
persist(ConfigAction cause)
Persists this entity on disk.void
remove()
Removes this VCS root from it's project.void
restoreDefaultModificationCheckInterval()
Switched to 'use default modification check interval' mode.PersistTask
schedulePersisting(String reason)
Schedules background persisting of this entity settings.BackgroundPersistTask
schedulePersisting(ConfigAction cause)
Schedules background persisting of this project settings.void
schedulePersisting(BackgroundPersistTask task)
PersistTask
scheduleRemove(ConfigAction cause)
Schedules remove of this persistent entity.void
sendExtIdChangedEvents(ConfigAction cause, String oldExtId, String newExtId)
Sends external id changed event.void
setExternalId(String externalId)
Changes external id of this VCS root and persists this VCS root configuration to diskvoid
setExternalId(ConfigAction cause, String externalId)
Changes external id of this VCS root and persists this VCS root configuration to diskvoid
setExternalId(ConfigAction cause, String externalId, boolean sendEvents)
Same as {SVcsRootUpdate.setExternalId(ConfigAction, String)
} but provides control over events processing.void
setModificationCheckInterval(int value)
Changes modification check interval for the root.void
setName(String name)
Changes connection name.void
setProperties(Map<String,String> map)
Adds number of properties.void
setVcsName(String vcsName)
Sets new version control name (name of version control plugin)String
toString()
void
unregister()
Removes VCS root from project model but does not removes any configuration files from disk-
Methods inherited from class jetbrains.buildServer.vcs.impl.VcsRootImpl
addProperty, equals, getId, getName, getProperties, getProperty, getProperty, getVcsName, hashCode, isEquivalentRoots
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.serverSide.SPersistentEntity
getName, isVirtual
-
Methods inherited from interface jetbrains.buildServer.vcs.VcsRoot
getId, getName, getProperties, getProperty, getProperty, getVcsName
-
-
-
-
Field Detail
-
myContext
@NotNull protected final VcsRootContext myContext
-
-
Method Detail
-
init
public void init(int modificationCheckInterval)
-
getEntityId
@NotNull public EntityId<Long> getEntityId()
- Specified by:
getEntityId
in interfaceSVcsRootEx
-
getConfigId
@NotNull public String getConfigId()
Description copied from interface:SPersistentEntity
Returns the entity's config identifier. Config identifier uniquely identifies the entity across different TeamCity servers and can't be modified in contrast to external identifier.- Specified by:
getConfigId
in interfaceSPersistentEntity
-
getExternalId
@NotNull public String getExternalId()
Description copied from interface:SPersistentEntity
Returns the external identifier.- Specified by:
getExternalId
in interfaceSPersistentEntity
- Specified by:
getExternalId
in interfaceVcsRoot
- Overrides:
getExternalId
in classVcsRootImpl
- Returns:
- externalID for this VCS Root, if it was set.
-
getScope
@NotNull public VcsRootScope getScope()
Description copied from interface:SVcsRootUsages
Returns scope of this VCS root- Specified by:
getScope
in interfaceSVcsRootUsages
- Returns:
- scope of this VCS root
-
getProject
@NotNull public ProjectEx getProject()
- Specified by:
getProject
in interfaceSVcsRootEx
- Specified by:
getProject
in interfaceSVcsRootUsages
- Returns:
- project this VCS root belongs to
-
getParent
@Nullable public SPersistentEntity getParent()
Description copied from interface:SPersistentEntity
The parent entity.- Specified by:
getParent
in interfaceSPersistentEntity
- Returns:
- see above.
-
getModificationCheckInterval
public int getModificationCheckInterval()
Description copied from interface:SVcsRoot
returns modification check interval in seconds- Specified by:
getModificationCheckInterval
in interfaceSVcsRoot
- Returns:
- modification check interval configured for the root.
-
getDescription
@NotNull public String getDescription()
- Specified by:
getDescription
in interfaceLVcsRoot
- Returns:
- short human readable description of the root. Composed by underlying VCS support.
-
getVcsDisplayName
@NotNull public String getVcsDisplayName()
Description copied from interface:LVcsRoot
Returns VCS plugin display name- Specified by:
getVcsDisplayName
in interfaceLVcsRoot
- Returns:
- see above, returns null if VCS plugin corresponding to VCS root does not exist
-
isUseDefaultModificationCheckInterval
public boolean isUseDefaultModificationCheckInterval()
Description copied from interface:SVcsRoot
Returns if 'use default modification check interval' mode is enabled for the root.- Specified by:
isUseDefaultModificationCheckInterval
in interfaceSVcsRoot
- Returns:
- if 'use default modification check interval' mode is enabled for the root.
-
isAccessibleFrom
public boolean isAccessibleFrom(@NotNull SBuildType buildType)
Description copied from interface:SVcsRootAccess
Returns true if VCS root can be attached to specified configuration.- Specified by:
isAccessibleFrom
in interfaceSVcsRootAccess
- Parameters:
buildType
- build configuration- Returns:
- true if VCS roots with this scope are accessible from the specified build configuration.
-
isAccessibleFrom
public boolean isAccessibleFrom(@NotNull SProject project)
Description copied from interface:SVcsRootAccess
Returns true if VCS root can be attached to configurations of specified project.- Specified by:
isAccessibleFrom
in interfaceSVcsRootAccess
- Parameters:
project
- project- Returns:
- true if VCS roots with this scope are accessible from the specified project
-
getAccessibleProjects
@NotNull public Set<SProject> getAccessibleProjects()
Description copied from interface:SVcsRootAccess
Returns projects where this VCS root can be attached to a configuration- Specified by:
getAccessibleProjects
in interfaceSVcsRootAccess
- Returns:
- see above
-
checkAccessibleFrom
public void checkAccessibleFrom(@NotNull SBuildType buildType) throws InvalidVcsRootScopeException
Description copied from interface:SVcsRootAccess
Checks that VCS root can be attached to specified configuration.- Specified by:
checkAccessibleFrom
in interfaceSVcsRootAccess
- Parameters:
buildType
- build configuration- Throws:
InvalidVcsRootScopeException
- if VCS root is inaccessible
-
checkAccessibleFrom
public void checkAccessibleFrom(@NotNull SProject project) throws InvalidVcsRootScopeException
Description copied from interface:SVcsRootAccess
Checks that VCS root can be attached to configurations of specified project.- Specified by:
checkAccessibleFrom
in interfaceSVcsRootAccess
- Parameters:
project
- project- Throws:
InvalidVcsRootScopeException
- if VCS root is not accessible
-
getConfigDirectory
@NotNull public File getConfigDirectory()
-
getConfigurationFile
@NotNull public File getConfigurationFile()
Description copied from interface:SPersistentEntity
Returns the configuration file where this entity instance is persisted (or will be persisted to).- Specified by:
getConfigurationFile
in interfaceSPersistentEntity
- Returns:
- see above.
-
getConfigurationFile
@NotNull public File getConfigurationFile(@NotNull File projectsDir)
Description copied from interface:SPersistentEntity
Returns the configuration file where this entity is persisted in custom projects directory- Specified by:
getConfigurationFile
in interfaceSPersistentEntity
- Parameters:
projectsDir
- path to teamcity projects directory- Returns:
- see above
-
persist
public void persist()
Description copied from interface:SVcsRootUpdate
Persists this VCS root on disk- Specified by:
persist
in interfaceSPersistentEntity
- Specified by:
persist
in interfaceSVcsRootUpdate
-
persist
public void persist(@NotNull ConfigAction cause) throws PersistFailedException
Description copied from interface:SPersistentEntity
Persists this entity on disk.- Specified by:
persist
in interfaceSPersistentEntity
- Parameters:
cause
- an action which caused persisting- Throws:
PersistFailedException
- if persisting failed
-
schedulePersisting
@NotNull public BackgroundPersistTask schedulePersisting(@NotNull ConfigAction cause) throws PersistFailedException
Description copied from interface:SPersistentEntity
Schedules background persisting of this project settings.- Specified by:
schedulePersisting
in interfaceSPersistentEntity
- Parameters:
cause
- an action which caused persisting- Returns:
- a task which can be used to track the operation progress or wait for the operation to complete
- Throws:
PersistFailedException
- if failed to schedule the operation- See Also:
SPersistentEntity.schedulePersisting(String)
-
schedulePersisting
@NotNull public PersistTask schedulePersisting(@NotNull String reason) throws PersistFailedException
Description copied from interface:SPersistentEntity
Schedules background persisting of this entity settings.- Specified by:
schedulePersisting
in interfaceSPersistentEntity
- Parameters:
reason
- provides a reason why persist operation was called- Returns:
- a task which can be used to track the operation progress or wait for the operation to complete
- Throws:
PersistFailedException
- if failed to schedule the operation- See Also:
SPersistentEntity.schedulePersisting(ConfigAction)
-
schedulePersisting
public void schedulePersisting(@NotNull BackgroundPersistTask task)
-
remove
public void remove()
Description copied from interface:SVcsRootUpdate
Removes this VCS root from it's project.- Specified by:
remove
in interfaceSPersistentEntity
- Specified by:
remove
in interfaceSVcsRootUpdate
-
scheduleRemove
@NotNull public PersistTask scheduleRemove(@NotNull ConfigAction cause) throws PersistFailedException
Description copied from interface:SPersistentEntity
Schedules remove of this persistent entity. Returns task which can be used to wait for the operation to complete.- Specified by:
scheduleRemove
in interfaceSPersistentEntity
- Parameters:
cause
- reason of the remove- Returns:
- a task which can be used to track the operation progress or wait for the operation to complete
- Throws:
PersistFailedException
- if failed to schedule the operation
-
unregister
public void unregister()
Description copied from interface:SVcsRootEx
Removes VCS root from project model but does not removes any configuration files from disk- Specified by:
unregister
in interfaceSVcsRootEx
-
getLastConfigModificationAction
@Nullable public AuditLogAction getLastConfigModificationAction()
- Specified by:
getLastConfigModificationAction
in interfaceSVcsRootEx
-
getSimpleName
@Deprecated public String getSimpleName()
Deprecated.since 8.0, usegetExternalId()
insteadReturns name of this VCS root with all non alpha numeric characters replaced with '_'.- Returns:
- name of this VCS root with all non alpha numeric characters replaced with '_'.
-
toString
public String toString()
- Overrides:
toString
in classVcsRootImpl
-
describe
@NotNull public String describe(boolean verbose)
- Specified by:
describe
in interfaceLoggable
- Overrides:
describe
in classVcsRootImpl
- Parameters:
verbose
- verbosity of object description- Returns:
- description of this object. If verbose is true, description should have mode details.
-
compareTo
public int compareTo(SVcsRootEx rootEx)
-
getUsagesInConfigurations
@NotNull public List<SBuildType> getUsagesInConfigurations()
- Specified by:
getUsagesInConfigurations
in interfaceSVcsRootUsages
- Returns:
- All configurations where this VCS Root is used (excluding VCS settings usages). Works faster than
SVcsRootUsages.getUsages()
-
getUsages
@NotNull public Map<SBuildType,CheckoutRules> getUsages()
- Specified by:
getUsages
in interfaceSVcsRootUsages
- Returns:
- This method returns all usages of this VCS root in various build configurations + its checkout rules
-
getNumberOfUsagesInProjects
public int getNumberOfUsagesInProjects()
- Specified by:
getNumberOfUsagesInProjects
in interfaceSVcsRootUsages
- Returns:
- number of projects using this VCS root in their templates or configurations.
-
isUsedInProjects
public boolean isUsedInProjects()
- Specified by:
isUsedInProjects
in interfaceSVcsRootUsages
- Returns:
- true if
SVcsRootUsages.getNumberOfUsagesInProjects()
is positive, but works faster because it does not count all of the usages
-
getUsagesInProjects
@NotNull public Collection<SProject> getUsagesInProjects()
- Specified by:
getUsagesInProjects
in interfaceSVcsRootUsages
- Returns:
- projects using this VCS root in their templates or configurations.
-
setName
public void setName(@NotNull String name)
Changes connection name.- Specified by:
setName
in interfaceSVcsRootUpdate
- Overrides:
setName
in classVcsRootImpl
- Parameters:
name
- new connection name.
-
setExternalId
public void setExternalId(@NotNull String externalId) throws DuplicateExternalIdException
Description copied from interface:SVcsRootUpdate
Changes external id of this VCS root and persists this VCS root configuration to disk- Specified by:
setExternalId
in interfaceSVcsRootUpdate
- Overrides:
setExternalId
in classVcsRootImpl
- Parameters:
externalId
- External ID for this VCS Root- Throws:
DuplicateExternalIdException
- if newly specified external id already exists
-
setExternalId
public void setExternalId(@NotNull ConfigAction cause, @NotNull String externalId) throws DuplicateExternalIdException, InvalidIdentifierException
Description copied from interface:SVcsRootUpdate
Changes external id of this VCS root and persists this VCS root configuration to disk- Specified by:
setExternalId
in interfaceSVcsRootUpdate
- Parameters:
cause
- config action caused the changeexternalId
- new external id- Throws:
DuplicateExternalIdException
- if newly specified external id already existsInvalidIdentifierException
-
setExternalId
public void setExternalId(@NotNull ConfigAction cause, @NotNull String externalId, boolean sendEvents) throws DuplicateExternalIdException, InvalidIdentifierException, ObsoleteEntityException, ReadOnlyEntityException
Description copied from interface:SVcsRootEx
Same as {SVcsRootUpdate.setExternalId(ConfigAction, String)
} but provides control over events processing. If parameter sendEvents is false, then no events about changing of the external id will be sent. This mode can be useful if the events will be sent later, for instance, in case of bulk edit ids operation.- Specified by:
setExternalId
in interfaceSVcsRootEx
- Throws:
DuplicateExternalIdException
InvalidIdentifierException
ObsoleteEntityException
ReadOnlyEntityException
-
sendExtIdChangedEvents
public void sendExtIdChangedEvents(@NotNull ConfigAction cause, @NotNull String oldExtId, @NotNull String newExtId)
Description copied from interface:SVcsRootEx
Sends external id changed event.- Specified by:
sendExtIdChangedEvents
in interfaceSVcsRootEx
-
checkModificationAllowed
protected void checkModificationAllowed()
-
moveToProject
public void moveToProject(@NotNull SProject target) throws ScopeCannotBeChangedException, VcsRootNotFoundException
Description copied from interface:SVcsRootUpdate
Moves this VCS root to specified target project. Upon successful completion affected configuration settings will be persisted.- Specified by:
moveToProject
in interfaceSVcsRootUpdate
- Parameters:
target
- target project- Throws:
ScopeCannotBeChangedException
- if move is impossible because of VCS root usagesVcsRootNotFoundException
-
moveToProject
public void moveToProject(@NotNull ConfigAction cause, @NotNull SProject target) throws ScopeCannotBeChangedException, DuplicateVcsRootNameException
Description copied from interface:SVcsRootUpdate
Moves this VCS root to specified target project. Upon successful completion affected configuration settings will be persisted.- Specified by:
moveToProject
in interfaceSVcsRootUpdate
- Parameters:
cause
- config action caused the changetarget
- target project- Throws:
ScopeCannotBeChangedException
- if move is impossible because of VCS root usagesDuplicateVcsRootNameException
-
setVcsName
public void setVcsName(@NotNull String vcsName)
Description copied from class:VcsRootImpl
Sets new version control name (name of version control plugin)- Specified by:
setVcsName
in interfaceSVcsRootUpdate
- Overrides:
setVcsName
in classVcsRootImpl
- Parameters:
vcsName
- new version control name
-
setProperties
public void setProperties(@NotNull Map<String,String> map)
Description copied from class:VcsRootImpl
Adds number of properties.- Specified by:
setProperties
in interfaceSVcsRootUpdate
- Overrides:
setProperties
in classVcsRootImpl
- Parameters:
map
- properties map.
-
setModificationCheckInterval
public void setModificationCheckInterval(int value)
Description copied from interface:SVcsRootUpdate
Changes modification check interval for the root.- Specified by:
setModificationCheckInterval
in interfaceSVcsRootUpdate
- Parameters:
value
- seconds.
-
restoreDefaultModificationCheckInterval
public void restoreDefaultModificationCheckInterval()
Description copied from interface:SVcsRootUpdate
Switched to 'use default modification check interval' mode.- Specified by:
restoreDefaultModificationCheckInterval
in interfaceSVcsRootUpdate
-
compareTo
public int compareTo(@NotNull SVcsRoot o)
- Specified by:
compareTo
in interfaceComparable<SVcsRoot>
-
getBranchSpec
@Nullable public BranchSpec getBranchSpec(@NotNull ValueResolver valueResolver)
Description copied from interface:SVcsRootEx
Returns branch specification if it is defined in VCS root and can be fully resolved. If branch spec is not defined or cannot be fully resolved returns null.- Specified by:
getBranchSpec
in interfaceSVcsRootEx
- Parameters:
valueResolver
- value resolver to use- Returns:
- see above
-
isBranchSpecDefined
public boolean isBranchSpecDefined(@NotNull ValueResolver valueResolver)
Description copied from interface:SVcsRootEx
Returns true if after the properties resolution this VCS root has not empty branch specification- Specified by:
isBranchSpecDefined
in interfaceSVcsRootEx
- Returns:
-
getResolvedBranchSpec
@Nullable public static String getResolvedBranchSpec(@Nullable String spec, @NotNull ValueResolver valueResolver)
-
markUnedited
public void markUnedited()
-
getVersion
@NotNull public PersistentEntityVersion getVersion()
Description copied from interface:SPersistentEntity
Returns version of this entity which can be used to check if the entity was edited or persisted.- Specified by:
getVersion
in interfaceSPersistentEntity
- Returns:
- see above
-
markPersisted
public void markPersisted(long expectedEditId)
Description copied from interface:SPersistentEntity
Marks entity as persisted- Specified by:
markPersisted
in interfaceSPersistentEntity
- Parameters:
expectedEditId
- expected editId in the end of persist. The entity will be marked as unedited if expected editId is the same as actual, ie. the entity wasn't edited while persist was running
-
createConfigAction
@NotNull public ConfigAction createConfigAction(@Nullable SUser user, @NotNull String description)
Description copied from interface:SPersistentEntity
Creates a config action instance associated with this entity and having the specified description. The config action object can be used inSPersistentEntity.schedulePersisting(ConfigAction)
orSPersistentEntity.scheduleRemove(ConfigAction)
methods to describe the performed action.- Specified by:
createConfigAction
in interfaceSPersistentEntity
- Parameters:
user
- user who performs operation, or null if operation is performed by the systemdescription
- description to set to the config action object- Returns:
- new config action
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceSPersistentEntity
- Returns:
- true if this entity settings are in read only mode
-
getReadOnlyReason
@Nullable public ReadOnlyReason getReadOnlyReason()
- Specified by:
getReadOnlyReason
in interfaceSPersistentEntity
- Returns:
- reason why this entity settings are in read only state or null if they are not read only
-
isEmptyUuid
public boolean isEmptyUuid()
- Specified by:
isEmptyUuid
in interfaceSVcsRootEx
- Returns:
- true if this root has an empty uuid in its config on disk
-
isAliasExternalId
public boolean isAliasExternalId(@NotNull String extId)
- Specified by:
isAliasExternalId
in interfaceSVcsRootEx
- Returns:
- true if the provided external id is an alias for the current external id of this VCS root
-
-