Search in sources :

Example 81 with MCRObjectID

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

the class MCRSwordContainerManager method replaceMetadataAndMediaResource.

@Override
public DepositReceipt replaceMetadataAndMediaResource(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 and resource 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);
    return collectionProvider.getContainerHandler().replaceMetadataAndResources((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 82 with MCRObjectID

use of org.mycore.datamodel.metadata.MCRObjectID 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 83 with MCRObjectID

use of org.mycore.datamodel.metadata.MCRObjectID 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 84 with MCRObjectID

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

the class MCRSwordContainerHandler method addObject.

public DepositReceipt addObject(Deposit deposit) throws SwordError, SwordServerException {
    final MCRSwordCollectionProvider collection = MCRSword.getCollection(this.lifecycleConfiguration.getCollection());
    final MCRObjectID idOfIngested = collection.getIngester().ingestMetadata(deposit);
    final MCRObject createdObject = (MCRObject) MCRMetadataManager.retrieve(idOfIngested);
    return collection.getMetadataProvider().provideMetadata(createdObject);
}
Also used : MCRObject(org.mycore.datamodel.metadata.MCRObject) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID)

Example 85 with MCRObjectID

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

the class MCRSwordContainerHandler method addObjectWithDerivate.

public DepositReceipt addObjectWithDerivate(String objectIdString, Deposit deposit) throws SwordError, SwordServerException {
    final MCRSwordCollectionProvider collection = MCRSword.getCollection(this.lifecycleConfiguration.getCollection());
    final MCRObjectID idOfIngested = collection.getIngester().ingestMetadataResources(deposit);
    final MCRObject createdObject = (MCRObject) MCRMetadataManager.retrieve(idOfIngested);
    return collection.getMetadataProvider().provideMetadata(createdObject);
}
Also used : MCRObject(org.mycore.datamodel.metadata.MCRObject) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID)

Aggregations

MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)144 IOException (java.io.IOException)37 MCRObject (org.mycore.datamodel.metadata.MCRObject)32 MCRException (org.mycore.common.MCRException)30 MCRCommand (org.mycore.frontend.cli.annotation.MCRCommand)30 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)29 MCRPath (org.mycore.datamodel.niofs.MCRPath)25 MCRAccessException (org.mycore.access.MCRAccessException)22 Document (org.jdom2.Document)20 MCRPersistenceException (org.mycore.common.MCRPersistenceException)18 MCRMetaLinkID (org.mycore.datamodel.metadata.MCRMetaLinkID)16 JDOMException (org.jdom2.JDOMException)15 MCRBase (org.mycore.datamodel.metadata.MCRBase)15 SAXException (org.xml.sax.SAXException)15 Date (java.util.Date)14 MCRActiveLinkException (org.mycore.datamodel.common.MCRActiveLinkException)13 MCRSession (org.mycore.common.MCRSession)11 MCRContent (org.mycore.common.content.MCRContent)11 MCRPersistentIdentifierException (org.mycore.pi.exceptions.MCRPersistentIdentifierException)11 URISyntaxException (java.net.URISyntaxException)10