Search in sources :

Example 11 with MCRSwordCollectionProvider

use of org.mycore.sword.application.MCRSwordCollectionProvider in project mycore by MyCoRe-Org.

the class MCRSwordCollectionManager method createNew.

@Override
public DepositReceipt createNew(String editIRI, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
    LOGGER.info("createNew:{}", editIRI);
    String collection = MCRSwordUtil.ParseLinkUtil.CollectionIRI.getCollectionNameFromCollectionIRI(new IRI(editIRI));
    MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
    collectionProvider.getAuthHandler().authentication(authCredentials);
    return collectionProvider.getContainerHandler().addObject(deposit);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider)

Example 12 with MCRSwordCollectionProvider

use of org.mycore.sword.application.MCRSwordCollectionProvider 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 13 with MCRSwordCollectionProvider

use of org.mycore.sword.application.MCRSwordCollectionProvider 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)

Example 14 with MCRSwordCollectionProvider

use of org.mycore.sword.application.MCRSwordCollectionProvider in project mycore by MyCoRe-Org.

the class MCRSwordContainerHandler method addMetadata.

public DepositReceipt addMetadata(MCRObject object, Deposit deposit) throws SwordError, SwordServerException {
    final MCRSwordCollectionProvider collection = MCRSword.getCollection(this.lifecycleConfiguration.getCollection());
    collection.getIngester().updateMetadata(object, deposit, false);
    return collection.getMetadataProvider().provideMetadata(object);
}
Also used : MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider)

Example 15 with MCRSwordCollectionProvider

use of org.mycore.sword.application.MCRSwordCollectionProvider in project mycore by MyCoRe-Org.

the class MCRSwordContainerHandler method addResources.

public DepositReceipt addResources(MCRObject object, Deposit deposit) throws SwordError, SwordServerException {
    final MCRSwordCollectionProvider collection = MCRSword.getCollection(this.lifecycleConfiguration.getCollection());
    collection.getIngester().ingestResource(object, deposit);
    return collection.getMetadataProvider().provideMetadata(object);
}
Also used : MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider)

Aggregations

MCRSwordCollectionProvider (org.mycore.sword.application.MCRSwordCollectionProvider)15 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)7 IRI (org.apache.abdera.i18n.iri.IRI)6 MCRBase (org.mycore.datamodel.metadata.MCRBase)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 MCRObject (org.mycore.datamodel.metadata.MCRObject)2 SwordError (org.swordapp.server.SwordError)2 AbstractMap (java.util.AbstractMap)1 Collections (java.util.Collections)1 Hashtable (java.util.Hashtable)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Abdera (org.apache.abdera.Abdera)1 Feed (org.apache.abdera.model.Feed)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 MCRConfiguration (org.mycore.common.config.MCRConfiguration)1 MCRFrontendUtil (org.mycore.frontend.MCRFrontendUtil)1