use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.
the class UIDLibrary method replaceUniqueEntityId.
/**
* Similar to {@link #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!
* @param identifier the identifier archive from which a new <code>Range</code> can be obtained if necessary. Use <br>
* <code>ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class);</code> <br>
* to create the required XML binding class aware interface from the plain-Corba <code>Identifier</code> object
* (<code>identRaw</code>) that is obtained, for example, by <br>
* <code>IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0"))</code>.
* @see #assignUniqueEntityId(EntityT, IdentifierJ)
*/
public synchronized void replaceUniqueEntityId(EntityT entity, IdentifierJ identifier) throws AcsJRangeUnavailableEx, AcsJIdentifierUnavailableEx, AcsJIdentifierUnexpectedEx {
if (entity == null) {
throw new NullPointerException("argument 'entity' must not be null.");
}
try {
String oldUid = entity.getEntityId();
checkDefaultRange(identifier);
defaultRange.replaceUniqueEntityId(entity);
logger.info("Replaced old UID '" + oldUid + "' with new UID '" + entity.getEntityId() + "' on an entity of type " + entity.getEntityTypeName());
} catch (AcsJRangeUnavailableEx e) {
throw e;
} catch (AcsJIdentifierUnavailableEx e) {
throw e;
} catch (Throwable e) {
// AcsJRangeLockedEx and AcsJRangeExhaustedEx should not occur for default range, thanks to method checkDefaultRange
throw new AcsJIdentifierUnexpectedEx(e);
}
}
use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.
the class UIDLibrary method assignUniqueEntityId.
/**
* Assigns a UID from the default range to the <code>EntityT</code> castor class
* of an XML-based entity such as a SchedBlock.
* <p>
* 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 <code>identifier</code> 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 <code>defaultRange.hasNextId</code> 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.
*
* @param identifier the identifier archive from which a new <code>Range</code> can be obtained if necessary. Use <br>
* <code>ContainerServices#getTransparentXmlComponent(IdentifierJ.class, identRaw, IdentifierOperations.class);</code> <br>
* to create the required XML binding class aware interface from the plain-Corba <code>Identifier</code> object
* (<code>identRaw</code>) that is obtained, for example, by <br>
* <code>IdentifierHelper.narrow(getDefaultComponent("IDL:alma/xmlstore/Identifier:1.0"))</code>.
* @see ContainerServices#assignUniqueEntityId(EntityT)
*/
public synchronized void assignUniqueEntityId(EntityT entity, IdentifierJ identifier) throws AcsJUidAlreadyExistsEx, AcsJIdentifierUnavailableEx, AcsJRangeUnavailableEx, AcsJIdentifierUnexpectedEx {
try {
checkDefaultRange(identifier);
defaultRange.assignUniqueEntityId(entity);
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Assigned UID '" + entity.getEntityId() + "' to entity of type " + entity.getEntityTypeName());
}
} catch (AcsJUidAlreadyExistsEx e) {
throw e;
} catch (AcsJRangeUnavailableEx e) {
throw e;
} catch (AcsJIdentifierUnavailableEx e) {
throw e;
} catch (Throwable e) {
// AcsJRangeLockedEx and AcsJRangeExhaustedEx should not occur for default range, thanks to method checkDefaultRange
throw new AcsJIdentifierUnexpectedEx(e);
}
}
Aggregations