public class UIDLibrary
extends java.lang.Object
assignUniqueEntityId(EntityT, IdentifierJ) could be used for this, although it is recommended
to instead use the convenience method ContainerServices#assignUniqueEntityId(EntityT) from the ContainerServices.
Here the caller is not expected to care about to which range of UIDs the new UID belongs, as long as it is a valid and unique ID.
replaceUniqueEntityId(EntityT, IdentifierJ).
Range objects by only referring to them through their UIDs
in methods assignUniqueEntityId(EntityT, URI), assignUniqueEntityRef(EntityRefT, URI) etc., but it is not clear how useful this is.| Constructor and Description |
|---|
UIDLibrary(java.util.logging.Logger logger)
Creates the UIDLibrary without making any calls.
|
| Modifier and Type | Method and Description |
|---|---|
void |
assignUniqueEntityId(EntityT entity,
IdentifierJ identifier)
Assigns a UID from the default range to the
EntityT castor class
of an XML-based entity such as a SchedBlock. |
void |
assignUniqueEntityId(EntityT entity,
java.net.URI uri)
convenience method for the above, printLogs is set to true
|
void |
assignUniqueEntityId(EntityT entity,
java.net.URI uri,
boolean printLogs)
Assigns a uid to the EntityT from the specified range.
|
void |
assignUniqueEntityRef(EntityRefT ref,
java.net.URI uri)
Assigns a UID to an entity reference.
|
protected void |
checkDefaultRange(IdentifierJ identifier)
Creates a default range on demand, or sets a new default range if the old range has no more UID
(which happens after pulling Long.MAX UIDs, or sooner if a limit was set).
|
void |
fetchRange(java.net.URI uri,
java.lang.String user,
IdentifierJ identifier)
Fetch an existing range from the archive and deserialise, only certain
operations will be permitted.
|
java.net.URI |
getNewRestrictedRange(int size,
java.lang.String user,
IdentifierJ identifier)
convenience method for the above, printLogs is set to true
|
java.net.URI |
getNewRestrictedRange(int size,
java.lang.String user,
IdentifierJ identifier,
boolean printLogs)
Fetches a new restricted range.
|
void |
replaceUniqueEntityId(EntityT entity,
IdentifierJ identifier)
Similar to
assignUniqueEntityId(EntityT, IdentifierJ), but allows replacing an existing ID. |
public UIDLibrary(java.util.logging.Logger logger)
logger - Logger used by this object.public void assignUniqueEntityId(EntityT entity,
IdentifierJ identifier)
throws AcsJUidAlreadyExistsEx,
AcsJIdentifierUnavailableEx,
AcsJRangeUnavailableEx,
AcsJIdentifierUnexpectedEx
EntityT castor class
of an XML-based entity such as a SchedBlock.
Implementation note: the default range of UIDs is retrieved from the archive at the first call and is then shared among instances
in order to be frugal on UIDs and to minimize archive access.
This means that often the passed in identifier will not be used at all but still must be provided,
because the calling component can not know whether another component or the container has
called this method before.
This method is synchronized to avoid the very unlikely situation that defaultRange.hasNextId succeeds for one thread but then later
assigning the UID still fails because of another thread having stolen the last free UID in the meantime.
identifier - the identifier archive from which a new Range can be obtained if necessary. Use ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class); Identifier object
(identRaw) that is obtained, for example, by IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0")).AcsJUidAlreadyExistsExAcsJIdentifierUnavailableExAcsJRangeUnavailableExAcsJIdentifierUnexpectedExContainerServices#assignUniqueEntityId(EntityT)public void replaceUniqueEntityId(EntityT entity,
IdentifierJ identifier)
throws AcsJRangeUnavailableEx,
AcsJIdentifierUnavailableEx,
AcsJIdentifierUnexpectedEx
assignUniqueEntityId(EntityT, IdentifierJ), but allows replacing an existing ID.
Only in very special cases such as ObsPrep replacing locally-generated IDs with archive-generated UIDs
should this method be used. Replacing UIDs can easily corrupt the archive because existing links would no longer hold!identifier - the identifier archive from which a new Range can be obtained if necessary. Use ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class); Identifier object
(identRaw) that is obtained, for example, by IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0")).AcsJRangeUnavailableExAcsJIdentifierUnavailableExAcsJIdentifierUnexpectedExassignUniqueEntityId(EntityT, IdentifierJ)protected void checkDefaultRange(IdentifierJ identifier)
throws AcsJRangeUnavailableEx,
AcsJIdentifierUnavailableEx
identifier - the identifier archive from which a new Range can be obtained if necessary. Use ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class); Identifier object
(identRaw) that is obtained, for example, by IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0")).AcsJRangeUnavailableExAcsJIdentifierUnavailableExpublic java.net.URI getNewRestrictedRange(int size,
java.lang.String user,
IdentifierJ identifier,
boolean printLogs)
throws AcsJRangeUnavailableEx,
AcsJIdentifierUnexpectedEx
identifier - the identifier archive from which a new Range can be obtained if necessary. Use ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class); Identifier object
(identRaw) that is obtained, for example, by IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0")).printLogs - Emit logs, iff set to true.assignUniqueEntityId(EntityT, URI).UniqueIdException - if the range cannot be obtained from the archive.AcsJRangeUnavailableExAcsJIdentifierUnexpectedExpublic java.net.URI getNewRestrictedRange(int size,
java.lang.String user,
IdentifierJ identifier)
throws AcsJRangeUnavailableEx,
AcsJIdentifierUnexpectedEx
AcsJRangeUnavailableExAcsJIdentifierUnexpectedExpublic void assignUniqueEntityId(EntityT entity,
java.net.URI uri,
boolean printLogs)
throws AcsJRangeUnavailableEx,
AcsJUidAlreadyExistsEx,
AcsJRangeLockedEx,
AcsJRangeExhaustedEx
TODO: figure out if this is meant to work only if the Range referenced by uri has been loaded previously by this instance. If so, put a comment that fetchRange must be called first. Otherwise the fetch method could be called automatically.
entity - uri - the UID of the Range objectprintLogs - set to true, iff logs should be printedAcsJRangeUnavailableExAcsJUidAlreadyExistsExAcsJRangeLockedExAcsJRangeExhaustedExpublic void assignUniqueEntityId(EntityT entity,
java.net.URI uri)
throws AcsJRangeUnavailableEx,
AcsJUidAlreadyExistsEx,
AcsJRangeLockedEx,
AcsJRangeExhaustedEx
AcsJRangeUnavailableExAcsJUidAlreadyExistsExAcsJRangeLockedExAcsJRangeExhaustedExpublic void fetchRange(java.net.URI uri,
java.lang.String user,
IdentifierJ identifier)
throws AcsJRangeUnavailableEx
uri - identifier - the identifier archive from which a new Range can be obtained if necessary. Use ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class); Identifier object
(identRaw) that is obtained, for example, by IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0")).AcsJRangeUnavailableExpublic void assignUniqueEntityRef(EntityRefT ref,
java.net.URI uri)
throws AcsJRangeUnavailableEx,
AcsJRangeExhaustedEx,
AcsJRangeUnlockedEx
ref - the schema-generated entity referenceuri - UniqueIdExceptionAcsJRangeUnavailableExAcsJRangeExhaustedExAcsJRangeUnlockedEx