Search in sources :

Example 1 with AcsJRangeUnavailableEx

use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.

the class UIDLibrary method assignUniqueEntityRef.

/**
	 * Assigns a UID to an entity reference. 
	 * This method should only be used in very special cases, 
	 * see <a href="http://almasw.hq.eso.org/almasw/bin/view/Archive/UidLibrary">Archive/UidLibrary wiki page</a>!
	 * Note that this operation is only permitted with a locked range.
	 * @param ref  the schema-generated entity reference
	 * @param uri
	 * @throws UniqueIdException
	 */
public void assignUniqueEntityRef(EntityRefT ref, URI uri) throws AcsJRangeUnavailableEx, AcsJRangeExhaustedEx, AcsJRangeUnlockedEx {
    if (refRanges.containsKey(uri)) {
        logger.finest("UIDLibrary: Assigning ID Ref to entity from: " + uri.toASCIIString());
        Range r = refRanges.get(uri);
        r.assignUniqueEntityRef(ref);
    } else {
        AcsJRangeUnavailableEx ex = new AcsJRangeUnavailableEx();
        ex.setRange(uri.toASCIIString());
        throw ex;
    }
}
Also used : AcsJRangeUnavailableEx(alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx) IdentifierRange(alma.archive.range.IdentifierRange)

Example 2 with AcsJRangeUnavailableEx

use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.

the class UIDLibrary method getNewRestrictedRange.

/**
	 * Fetches a new restricted range. 
	 * This will return a URI allowing access to the new Range. 
	 * The range is automatically stored in the archive. 
	 * This method should only be used in very special cases, 
	 * see <a href="http://almasw.hq.eso.org/almasw/bin/view/Archive/UidLibrary">Archive/UidLibrary wiki page</a>!
	 * @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>.
	 * @param printLogs Emit logs, iff set to true.
	 * @return the UID of the range, which can be used for example as an argument in {@link #assignUniqueEntityId(EntityT, URI)}.
	 * @throws UniqueIdException  if the range cannot be obtained from the archive. 
	 */
public URI getNewRestrictedRange(int size, String user, IdentifierJ identifier, boolean printLogs) throws AcsJRangeUnavailableEx, AcsJIdentifierUnexpectedEx {
    Range range = null;
    try {
        if (printLogs)
            logger.finest("UIDLibrary: Fetching a restricted range");
        IdentifierRange idRange = identifier.getNewRestrictedRange(size, user);
        range = new Range(idRange);
    } catch (NotAvailable e) {
        throw new AcsJRangeUnavailableEx(e);
    }
    URI uri = range.rangeId();
    if (idRanges.containsKey(uri)) {
        AcsJIdentifierUnexpectedEx ex = new AcsJIdentifierUnexpectedEx();
        ex.setContextInfo("Cannot store new range. URI occupied. This should never have happened by design!!");
        throw ex;
    }
    if (printLogs)
        logger.finest("UIDLibrary: Storing Range under: " + uri.toASCIIString());
    idRanges.put(uri, range);
    return uri;
}
Also used : NotAvailable(alma.xmlstore.IdentifierPackage.NotAvailable) AcsJRangeUnavailableEx(alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx) AcsJIdentifierUnexpectedEx(alma.ArchiveIdentifierError.wrappers.AcsJIdentifierUnexpectedEx) IdentifierRange(alma.archive.range.IdentifierRange) IdentifierRange(alma.archive.range.IdentifierRange) URI(java.net.URI)

Example 3 with AcsJRangeUnavailableEx

use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.

the class UIDLibrary method fetchRange.

/**
	 * Fetch an existing range from the archive and deserialise, only certain
	 * operations will be permitted.
	 * This method should only be used in very special cases, 
	 * see <a href="http://almasw.hq.eso.org/almasw/bin/view/Archive/UidLibrary">Archive/UidLibrary wiki page</a>!
	 * @param uri
	 * @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>.
	 * 
	 * @throws AcsJRangeUnavailableEx
	 */
public void fetchRange(URI uri, String user, IdentifierJ identifier) throws AcsJRangeUnavailableEx {
    IdentifierRange idRange = null;
    try {
        logger.finest("UIDLibrary: Fetching range: " + uri.toASCIIString());
        idRange = identifier.getExistingRange(uri.toASCIIString(), user);
    } catch (NotFound e) {
        throw new AcsJRangeUnavailableEx(e);
    }
    Range r = new Range(idRange);
    if (!refRanges.containsKey(uri)) {
        refRanges.put(uri, r);
    } else {
        AcsJRangeUnavailableEx ex = new AcsJRangeUnavailableEx();
        ex.setRange(uri.toASCIIString());
        throw ex;
    }
}
Also used : AcsJRangeUnavailableEx(alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx) IdentifierRange(alma.archive.range.IdentifierRange) IdentifierRange(alma.archive.range.IdentifierRange) NotFound(alma.xmlstore.IdentifierPackage.NotFound)

Example 4 with AcsJRangeUnavailableEx

use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.

the class UIDLibrary method assignUniqueEntityId.

/**
	 * Assigns a uid to the EntityT from the specified range.
	 * This is not permitted with a locked Range object.
	 * This method should only be used in very special cases, 
	 * see <a href="http://almasw.hq.eso.org/almasw/bin/view/Archive/UidLibrary">Archive/UidLibrary wiki page</a>!
	 * <p>
	 * 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.
	 * 
	 * @param entity  
	 * @param uri  the UID of the Range object
	 * @param printLogs set to true, iff logs should be printed
	 */
public void assignUniqueEntityId(EntityT entity, URI uri, boolean printLogs) throws AcsJRangeUnavailableEx, AcsJUidAlreadyExistsEx, AcsJRangeLockedEx, AcsJRangeExhaustedEx {
    if (idRanges.containsKey(uri)) {
        if (printLogs && logger.isLoggable(Level.FINEST)) {
            logger.finest("UIDLibrary: Assigning ID to entity from range " + uri.toASCIIString());
        }
        Range r = idRanges.get(uri);
        r.assignUniqueEntityId(entity);
    } else {
        AcsJRangeUnavailableEx ex = new AcsJRangeUnavailableEx();
        ex.setRange(uri.toASCIIString());
        throw ex;
    }
}
Also used : AcsJRangeUnavailableEx(alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx) IdentifierRange(alma.archive.range.IdentifierRange)

Example 5 with AcsJRangeUnavailableEx

use of alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx in project ACS by ACS-Community.

the class UIDLibrary method checkDefaultRange.

/**
	 * 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).
	 * @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>.
	 */
protected synchronized void checkDefaultRange(IdentifierJ identifier) throws AcsJRangeUnavailableEx, AcsJIdentifierUnavailableEx {
    if (identifier == null) {
        AcsJIdentifierUnavailableEx ex = new AcsJIdentifierUnavailableEx();
        ex.setContextInfo("Provided identifier reference is null.");
        throw ex;
    }
    try {
        if (defaultRange == null || !defaultRange.hasNextID()) {
            defaultRange = new Range(identifier.getNewRange());
        }
    } catch (NotAvailable e) {
        AcsJRangeUnavailableEx ex = new AcsJRangeUnavailableEx();
        ex.setRange("default");
        throw ex;
    }
}
Also used : NotAvailable(alma.xmlstore.IdentifierPackage.NotAvailable) AcsJRangeUnavailableEx(alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx) IdentifierRange(alma.archive.range.IdentifierRange) AcsJIdentifierUnavailableEx(alma.ArchiveIdentifierError.wrappers.AcsJIdentifierUnavailableEx)

Aggregations

AcsJRangeUnavailableEx (alma.ArchiveIdentifierError.wrappers.AcsJRangeUnavailableEx)7 IdentifierRange (alma.archive.range.IdentifierRange)5 AcsJIdentifierUnavailableEx (alma.ArchiveIdentifierError.wrappers.AcsJIdentifierUnavailableEx)3 AcsJIdentifierUnexpectedEx (alma.ArchiveIdentifierError.wrappers.AcsJIdentifierUnexpectedEx)3 NotAvailable (alma.xmlstore.IdentifierPackage.NotAvailable)2 AcsJUidAlreadyExistsEx (alma.ArchiveIdentifierError.wrappers.AcsJUidAlreadyExistsEx)1 NotFound (alma.xmlstore.IdentifierPackage.NotFound)1 URI (java.net.URI)1