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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations