public class Range
extends java.lang.Object
Long.MAX_VALUE many UIDs.
This class is implemented as an intelligent wrapper for the castor class IdentifierRange
which itself gets generated from the schema "IdentifierRange.xsd".
For a better description, see the Archive/UidLibrary wiki page.
General remark on the length of UIDs: there is no limit on the length of the three "/x012af" parts of a UID, as was confirmed by awicenec to hsommer on 2007-04-20. It is therefore the Archive's responsibility to ensure that all code dealing with UIDs (which should all be under archive responsibility anyway) be updated accordingly whenever the actually generated UIDs exceed the "Long" limit.
| Constructor and Description |
|---|
Range(IdentifierRange identifierRange) |
| Modifier and Type | Method and Description |
|---|---|
void |
assignUniqueEntityId(EntityT entity)
Assigns a UID to the
EntityT castor object that should be a direct child of an Alma XML entity. |
void |
assignUniqueEntityRef(EntityRefT ref)
Assigns a UID from the range to a given entity reference.
|
static java.lang.String |
generateUID(java.lang.String _archiveID,
java.lang.String _rangeID,
long _localId)
This method is only exposed for testing purposes, when a UID has to be generated from its constituent parts.
|
long |
getLength() |
boolean |
hasNextID()
Checks whether another UID can be pulled from this range without causing an exception due to an overflow.
|
boolean |
isLocked()
A range can be either locked or unlocked.
|
java.net.URI |
next()
cryptic comment from Simon: TODO: this needs to be moved to protected soon, will require the ArchiveID web service to be moved to this namespace
|
java.net.URI |
rangeId()
Gets the UID of this range document itself.
|
java.lang.String |
rangeIdString()
Gets a String representation of the UID of this range document itself.
|
void |
replaceUniqueEntityId(EntityT entity)
Assigns a UID to the
EntityT castor object that should be a direct child of an Alma XML entity. |
public long getLength()
public boolean isLocked()
TODO: explain better the real meaning of this locking, and the forseen scenarios.
public void assignUniqueEntityId(EntityT entity)
throws AcsJUidAlreadyExistsEx,
AcsJRangeLockedEx,
AcsJRangeExhaustedEx
EntityT castor object that should be a direct child of an Alma XML entity.
As a means of protection, this call will fail if the entity already has a UID. If you actually need to
replace a UID in some rare cases, please use replaceUniqueEntityId(EntityT).
The same functionality is offered in ContainerServices#assignUniqueEntityId(EntityT) which actually delegates to here.
AcsJUidAlreadyExistsExAcsJRangeLockedExAcsJRangeExhaustedExpublic void replaceUniqueEntityId(EntityT entity)
throws AcsJUidAlreadyExistsEx,
AcsJRangeLockedEx,
AcsJRangeExhaustedEx
EntityT castor object that should be a direct child of an Alma XML entity.
Unlike #assignUniqueEntityID, this method will silently replace any existing UID,
which is possibly dangerous. Therefore it should only be used in rare cases where replacing an existing ID is
needed, for example when the ObsPrep tool might translate locally created documents into an archivable format.AcsJUidAlreadyExistsExAcsJRangeLockedExAcsJRangeExhaustedExpublic void assignUniqueEntityRef(EntityRefT ref)
throws AcsJRangeUnlockedEx,
AcsJRangeExhaustedEx
isLocked().ref - AcsJRangeUnlockedExAcsJRangeExhaustedExpublic static final java.lang.String generateUID(java.lang.String _archiveID,
java.lang.String _rangeID,
long _localId)
public boolean hasNextID()
Warning about thread safety: This method does not reserve a UID or anything like that,
thus a returned true value does not necessarily mean that a later call
to one of the assignXYZ etc methods will succeed.
public java.net.URI next()
throws AcsJIdentifierUnexpectedEx,
AcsJRangeExhaustedEx
AcsJIdentifierUnexpectedExAcsJRangeExhaustedExpublic java.net.URI rangeId()
throws AcsJIdentifierUnexpectedEx
AcsJIdentifierUnexpectedEx - if the string from rangeIdString() cannot be turned into a URIpublic final java.lang.String rangeIdString()