Interface IdentifiersManager<INT>
-
- All Superinterfaces:
ExternalIdGenerator
- All Known Subinterfaces:
BuildTypeIdentifiersManager
,ProjectIdentifiersManager
,VcsRootIdentifiersManager
- All Known Implementing Classes:
BaseIdentifiersManager
,BaseValidatingIdentifiersManager
,BuildTypeIdentifiersManagerImpl
,ProjectIdentifiersManagerImpl
,TemporaryIdentifiersManager
,VcsRootIdentifiersManagerImpl
public interface IdentifiersManager<INT> extends ExternalIdGenerator
Manages external to internal identifiers mapping.Since 8.1 supports also previous external ids. As a result the call
findEntityIdByExternalId
can return the entity corresponding to the current (int id, ext id) pair.- Since:
- 8.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description INT
configIdToInternal(String configId)
Looks for the internal identifier by the given config id.void
consumeEntityIds(Consumer<EntityId<INT>> consumer)
Consumes entityIds in this managerINT
externalToInternal(String extId)
Looks for the internal identifier by the given external one.List<INT>
externalToInternal(List<String> extIds)
Looks for the internal identifiers by the given external onesEntityId<INT>
findEntityIdByConfigId(String configId)
Looks for a registered entity id by the given config id.EntityId<INT>
findEntityIdByExternalId(String extId)
Looks for a registered entity id by the given external id.EntityId<INT>
findEntityIdByInternalId(INT intId)
Looks for a registered entity id by the given internal id.EntityId<INT>
generateAndRegisterBrandNewExternalId(String parentExtId, String name)
Generates a unique external identifier by the given parent external identifier and a user string (usually name), and register the just generated identifier as a brand new one.Set<String>
getAllExternalIds()
Provides with all known external identifiers.Set<String>
getAllExternalIds(INT intId)
Returns all external ids that correspond to theintId
.Set<INT>
getAllInternalIds()
Provides with all known internal identifiers.String
internalToExternal(INT intId)
Looks for the external identifier by the given internal one.List<String>
internalToExternal(List<INT> intIds)
Looks for the external identifiers by the given internal ones.boolean
isExternalIdAlias(String externalId)
Check whether the external id is an alias (but not a primary external id).void
markRemoved(EntityId<INT> entityId, String originProjectIntId)
Marks specified entityId as removed and sets the origin project internal id to the given valuevoid
modifyConfigId(EntityId<INT> entityId, String newConfigId, CustomIdChangeApplier<String> configApplier)
Modifies the given config identifier to the given new one.void
modifyExternalId(EntityId<INT> entityId, String newExternalId, CustomIdChangeApplier<String> applier)
Modifies the given external identifier to the given new one.void
reassignInternalId(EntityId<INT> entityId, INT internalId, CustomIdChangeApplier<INT> applier)
Assigns the specified internalId to the given entity and runs provided applier after that.void
reassignInternalIdInMemory(EntityId<INT> entityId, INT internalId)
Reassigns internal id in memory only, does not change anything in database.EntityId<INT>
refreshFromDbIfNecessary(String extId, String configId)
Looks for a registered entity id by the given config id and ext id and refresh from db if necessary.EntityId<INT>
registerBrandNewExternalId(String extId)
Registers the given external identifier with a brand new internal one.EntityId<INT>
registerOrReuseExternalAndConfigId(String extId, String configId)
Registers the given external identifier and config id pair.boolean
removeExternalIdAlias(String externalIdAlias)
Removes the external id alias (but not a primary external id) from the model and database.void
resetRemoved(Collection<EntityId<INT>> entityIds)
Resets removed mark for the given entityIdvoid
validateExternalId(String externalId, EntityId<INT> curObjId)
Validates given external identifier-
Methods inherited from interface jetbrains.buildServer.serverSide.identifiers.ExternalIdGenerator
externalIdSatisfiesConvention, generateNewExternalId, generateNewExternalId, regenerateExternalId
-
-
-
-
Method Detail
-
registerBrandNewExternalId
@NotNull EntityId<INT> registerBrandNewExternalId(@NotNull String extId) throws InvalidIdentifierException
Registers the given external identifier with a brand new internal one. If such external identifier was already registered, the correspondent internal one is dropped (and is not reused).- Parameters:
extId
- the external identifier to register.- Returns:
- new associated internal identifier.
- Throws:
InvalidIdentifierException
- Since:
- 8.0
-
registerOrReuseExternalAndConfigId
@NotNull EntityId<INT> registerOrReuseExternalAndConfigId(@NotNull String extId, @Nullable String configId) throws InvalidIdentifierException
Registers the given external identifier and config id pair. If specified config id exists in database it's internal id will be used, otherwise new internal id will be generated.- Parameters:
extId
- the external identifier to register.configId
- the config identifier to register, if null new config id is generated.- Returns:
- associated internal identifier.
- Throws:
InvalidIdentifierException
- Since:
- 9.0
-
generateAndRegisterBrandNewExternalId
@NotNull EntityId<INT> generateAndRegisterBrandNewExternalId(@Nullable String parentExtId, @NotNull String name) throws InvalidIdentifierException
Generates a unique external identifier by the given parent external identifier and a user string (usually name), and register the just generated identifier as a brand new one.- Parameters:
parentExtId
- the parent's external identifier (optional).name
- the user string (name).- Returns:
- just created identifiers pair.
- Throws:
InvalidIdentifierException
- Since:
- 8.0
-
findEntityIdByInternalId
@Nullable EntityId<INT> findEntityIdByInternalId(@NotNull INT intId)
Looks for a registered entity id by the given internal id.- Parameters:
intId
- internal id.- Returns:
- found entity id or null when not found.
- Since:
- 8.0
-
findEntityIdByExternalId
@Nullable EntityId<INT> findEntityIdByExternalId(@NotNull String extId)
Looks for a registered entity id by the given external id.- Parameters:
intId
- external id, case insensitive.- Returns:
- found entity id or null when not found.
- Since:
- 8.0
-
findEntityIdByConfigId
@Nullable EntityId<INT> findEntityIdByConfigId(@NotNull String configId)
Looks for a registered entity id by the given config id.- Parameters:
configId
- config id, case insensitive.- Returns:
- found entity id or null when not found.
- Since:
- 9.0
-
refreshFromDbIfNecessary
@Nullable EntityId<INT> refreshFromDbIfNecessary(@NotNull String extId, @Nullable String configId)
Looks for a registered entity id by the given config id and ext id and refresh from db if necessary. Called by secondary nodes while loading new entities- Returns:
- found entity id or null when not found.
- Since:
- 2019.1
-
modifyExternalId
void modifyExternalId(@NotNull EntityId<INT> entityId, @NotNull String newExternalId, @Nullable CustomIdChangeApplier<String> applier) throws DuplicateExternalIdException, NoSuchExternalIdException
Modifies the given external identifier to the given new one.- Parameters:
entityId
- the entity id where to modify its external id.newExternalId
- the new external id.applier
- external procedure to make changes in files when successful.- Throws:
DuplicateExternalIdException
- thrown when such external identifier already exists.NoSuchExternalIdException
- Since:
- 8.0
-
modifyConfigId
void modifyConfigId(@NotNull EntityId<INT> entityId, @NotNull String newConfigId, @Nullable CustomIdChangeApplier<String> configApplier) throws DuplicateConfigIdException
Modifies the given config identifier to the given new one.- Parameters:
entityId
- the entity id where to modify its config id.newConfigId
- the new config id.configApplier
- external procedure to make changes in files when successful.- Throws:
DuplicateConfigIdException
- Since:
- 9.0
-
reassignInternalId
void reassignInternalId(@NotNull EntityId<INT> entityId, @NotNull INT internalId, @Nullable CustomIdChangeApplier<INT> applier)
Assigns the specified internalId to the given entity and runs provided applier after that. The internalId should come from an entityId present in DB and marked as removed, otherwise anIllegalArgumentException
is thrown. Makes the extId of the given internalId becomes an alias for the entityId. Also creates a new deleted entity with extId='{entityId.extId}_Detached', intId={entityId.intId}, cfgId={entityId.cfgId}, so that {entityId.intId} can then be specified as internalId to in this method.- Since:
- 2018.1
-
reassignInternalIdInMemory
void reassignInternalIdInMemory(@NotNull EntityId<INT> entityId, @NotNull INT internalId)
Reassigns internal id in memory only, does not change anything in database. Should be used in case of multi node event about internal id changes.- Parameters:
entityId
-internalId
-
-
removeExternalIdAlias
boolean removeExternalIdAlias(@NotNull String externalIdAlias) throws FailedToRemoveExternalIdAlias
Removes the external id alias (but not a primary external id) from the model and database. If no nether alias nor internal id found, just silently returns.- Parameters:
externalIdAlias
- the alias to remove.- Returns:
- whether the entry was really removed (from the database).
- Throws:
FailedToRemoveExternalIdAlias
- when could not remove.- Since:
- 9.0
-
isExternalIdAlias
boolean isExternalIdAlias(@NotNull String externalId)
Check whether the external id is an alias (but not a primary external id).- Parameters:
externalId
- the external id to check.- Returns:
- whether the externalId is an alias
- Since:
- 9.0
-
internalToExternal
@Nullable String internalToExternal(@Nullable INT intId)
Looks for the external identifier by the given internal one.- Parameters:
intId
- internal identifier (case sensitive).- Returns:
- the external identifier if found, or null if not found.
- Since:
- 8.0
-
internalToExternal
@NotNull List<String> internalToExternal(@NotNull List<INT> intIds)
Looks for the external identifiers by the given internal ones.- Parameters:
intIds
- list of internal IDs. Nulls are allowed.- Returns:
- List of external IDs. List size is always equal to initial one. For unknown IDs null will be returned
- Since:
- 9.1
-
externalToInternal
@Nullable INT externalToInternal(@Nullable String extId)
Looks for the internal identifier by the given external one.- Parameters:
extId
- external identifier (case insensitive).- Returns:
- the internal identifier if found, or null if not found.
- Since:
- 8.0
-
externalToInternal
@NotNull List<INT> externalToInternal(@NotNull List<String> extIds)
Looks for the internal identifiers by the given external ones- Parameters:
extIds
- list of external IDs. Nulls are allowed.- Returns:
- List of internal IDs. List size is always equal to initial one. For unknown IDs null will be returned
- Since:
- 9.1
-
configIdToInternal
@Nullable INT configIdToInternal(@Nullable String configId)
Looks for the internal identifier by the given config id.- Parameters:
configId
- config identifier (case insensitive).- Returns:
- the internal identifier if found, or null if not found.
- Since:
- 9.0
-
getAllInternalIds
@NotNull Set<INT> getAllInternalIds()
Provides with all known internal identifiers.- Returns:
- internal identifiers as a set of case-sensitive strings.
- Since:
- 8.0
-
getAllExternalIds
@NotNull Set<String> getAllExternalIds()
Provides with all known external identifiers.- Returns:
- external identifiers as a set of case-insensitive strings.
- Since:
- 8.0
-
getAllExternalIds
@NotNull Set<String> getAllExternalIds(@NotNull INT intId)
Returns all external ids that correspond to theintId
. There is a main one, or probably several aliases.If the
intId
is not found, empty set is returned.- Parameters:
intId
- internal identifier (case sensitive).- Returns:
- set of corresponding external ids
- Since:
- 8.1
-
validateExternalId
void validateExternalId(@NotNull String externalId, @Nullable EntityId<INT> curObjId) throws InvalidIdentifierException
Validates given external identifier- Parameters:
externalId
- identifier to validate- Throws:
InvalidIdentifierException
- Since:
- 8.0
-
markRemoved
void markRemoved(@NotNull EntityId<INT> entityId, @Nullable String originProjectIntId)
Marks specified entityId as removed and sets the origin project internal id to the given value
-
resetRemoved
void resetRemoved(@NotNull Collection<EntityId<INT>> entityIds)
Resets removed mark for the given entityId- Since:
- 2018.2.2
-
-