Search in sources :

Example 11 with MCRBase

use of org.mycore.datamodel.metadata.MCRBase in project mycore by MyCoRe-Org.

the class MCRSwordContainerManager method addResources.

@Override
public DepositReceipt addResources(String editIRI, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
    IRI iri = new IRI(editIRI);
    String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
    String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
    final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
    LOGGER.info(MessageFormat.format("REQUEST: add resources {0} from {1} !", objectIdString, collection));
    collectionProvider.getAuthHandler().authentication(authCredentials);
    MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
    if (!MCRMetadataManager.exists(objectId)) {
        throwObjectDoesNotExist(objectIdString);
    }
    MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
    return collectionProvider.getContainerHandler().addResources((MCRObject) retrievedMCRBase, deposit);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider) MCRBase(org.mycore.datamodel.metadata.MCRBase) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID)

Example 12 with MCRBase

use of org.mycore.datamodel.metadata.MCRBase in project mycore by MyCoRe-Org.

the class MCRSwordContainerManager method replaceMetadata.

@Override
public DepositReceipt replaceMetadata(String editIRI, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
    IRI iri = new IRI(editIRI);
    String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
    String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
    final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
    LOGGER.info(MessageFormat.format("REQUEST: Replace metadata of {0} from {1} !", objectIdString, collection));
    collectionProvider.getAuthHandler().authentication(authCredentials);
    MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
    if (!MCRMetadataManager.exists(objectId)) {
        throwObjectDoesNotExist(objectIdString);
    }
    MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
    checkIsObject(retrievedMCRBase);
    return collectionProvider.getContainerHandler().replaceMetadata((MCRObject) retrievedMCRBase, deposit);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider) MCRBase(org.mycore.datamodel.metadata.MCRBase) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID)

Example 13 with MCRBase

use of org.mycore.datamodel.metadata.MCRBase in project mycore by MyCoRe-Org.

the class MCRObjectCommands method repairMetadataSearchForID.

/**
 * The method start the repair of the metadata search for a given MCRObjectID as String.
 *
 * @param id
 *            the MCRObjectID as String
 */
@MCRCommand(syntax = "repair metadata search of ID {0}", help = "Retrieves the MCRObject with the MCRObjectID {0} and restores it in the search store.", order = 180)
public static void repairMetadataSearchForID(String id) {
    LOGGER.info("Start the repair for the ID {}", id);
    if (!MCRObjectID.isValid(id)) {
        LOGGER.error("The String {} is not a MCRObjectID.", id);
        return;
    }
    MCRObjectID mid = MCRObjectID.getInstance(id);
    MCRBase obj = MCRMetadataManager.retrieve(mid);
    MCRMetadataManager.fireRepairEvent(obj);
    LOGGER.info("Repaired {}", mid);
}
Also used : MCRBase(org.mycore.datamodel.metadata.MCRBase) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Example 14 with MCRBase

use of org.mycore.datamodel.metadata.MCRBase in project mycore by MyCoRe-Org.

the class MCRSwordContainerManager method deleteContainer.

@Override
public void deleteContainer(String editIRI, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
    IRI iri = new IRI(editIRI);
    String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
    String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
    final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
    LOGGER.info(MessageFormat.format("REQUEST: Delete {0} from {1}", objectIdString, collection));
    collectionProvider.getAuthHandler().authentication(authCredentials);
    MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
    if (!MCRMetadataManager.exists(objectId)) {
        throwObjectDoesNotExist(objectIdString);
    }
    final MCRBase object = MCRMetadataManager.retrieve(objectId);
    checkIsObject(object);
    collectionProvider.getContainerHandler().deleteObject((MCRObject) object);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider) MCRBase(org.mycore.datamodel.metadata.MCRBase) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID)

Example 15 with MCRBase

use of org.mycore.datamodel.metadata.MCRBase in project mycore by MyCoRe-Org.

the class MCRSwordContainerManager method getEntry.

@Override
public DepositReceipt getEntry(String editIRI, Map<String, String> map, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordServerException, SwordError, SwordAuthException {
    IRI iri = new IRI(editIRI);
    String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
    String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
    final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
    LOGGER.info(MessageFormat.format("REQUEST: Get entry {0} from {1} !", objectIdString, collection));
    collectionProvider.getAuthHandler().authentication(authCredentials);
    MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
    if (!MCRMetadataManager.exists(objectId)) {
        throwObjectDoesNotExist(objectIdString);
    }
    MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
    checkIsObject(retrievedMCRBase);
    final Optional<Map<String, String>> accept = Optional.of(map);
    return collectionProvider.getContainerHandler().getMetadata(collection, (MCRObject) retrievedMCRBase, accept);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider) MCRBase(org.mycore.datamodel.metadata.MCRBase) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID) Map(java.util.Map)

Aggregations

MCRBase (org.mycore.datamodel.metadata.MCRBase)18 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)13 MCRPersistentIdentifierException (org.mycore.pi.exceptions.MCRPersistentIdentifierException)9 IRI (org.apache.abdera.i18n.iri.IRI)5 MCRException (org.mycore.common.MCRException)5 MCRCommand (org.mycore.frontend.cli.annotation.MCRCommand)5 MCRSwordCollectionProvider (org.mycore.sword.application.MCRSwordCollectionProvider)5 MCRAccessException (org.mycore.access.MCRAccessException)4 MCRActiveLinkException (org.mycore.datamodel.common.MCRActiveLinkException)4 MCRPersistentIdentifier (org.mycore.pi.MCRPersistentIdentifier)4 MCRPI (org.mycore.pi.backend.MCRPI)4 MCRMetadataManager (org.mycore.datamodel.metadata.MCRMetadataManager)3 IOException (java.io.IOException)2 Date (java.util.Date)2 List (java.util.List)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 Document (org.jdom2.Document)2 Element (org.jdom2.Element)2 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)2