use of org.mycore.sword.application.MCRSwordCollectionProvider in project mycore by MyCoRe-Org.
the class MCRSwordContainerHandler method replaceMetadata.
/**
* Replaces the metadata of an existing object.
* @param object The object with the metadata to replace
* @param deposit the deposit with the new metadata
* @return a new {@link DepositReceipt} with the new metadata
*/
public DepositReceipt replaceMetadata(MCRObject object, Deposit deposit) throws SwordError, SwordServerException {
final MCRSwordCollectionProvider collection = MCRSword.getCollection(this.lifecycleConfiguration.getCollection());
collection.getIngester().updateMetadata(object, deposit, true);
return collection.getMetadataProvider().provideMetadata(object);
}
use of org.mycore.sword.application.MCRSwordCollectionProvider 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);
}
use of org.mycore.sword.application.MCRSwordCollectionProvider in project mycore by MyCoRe-Org.
the class MCRSwordContainerHandler method replaceMetadataAndResources.
public DepositReceipt replaceMetadataAndResources(MCRObject object, Deposit deposit) throws SwordError, SwordServerException {
final MCRSwordCollectionProvider collection = MCRSword.getCollection(this.lifecycleConfiguration.getCollection());
collection.getIngester().updateMetadataResources(object, deposit);
return collection.getMetadataProvider().provideMetadata(object);
}
use of org.mycore.sword.application.MCRSwordCollectionProvider 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);
}
use of org.mycore.sword.application.MCRSwordCollectionProvider in project mycore by MyCoRe-Org.
the class MCRSwordCollectionManager method listCollectionContents.
@Override
public Feed listCollectionContents(IRI collectionIRI, AuthCredentials authCredentials, SwordConfiguration config) throws SwordServerException, SwordAuthException, SwordError {
String collection = MCRSwordUtil.ParseLinkUtil.CollectionIRI.getCollectionNameFromCollectionIRI(collectionIRI);
String path = collectionIRI.getPath();
LOGGER.info(MessageFormat.format("List Collection: {0}", collection));
Feed feed = new Abdera().newFeed();
if (MCRSword.getCollectionNames().contains(collection)) {
MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
collectionProvider.getAuthHandler().authentication(authCredentials);
if (collectionProvider.isVisible()) {
Integer paginationFromIRI = MCRSwordUtil.ParseLinkUtil.CollectionIRI.getPaginationFromCollectionIRI(collectionIRI);
final int start = (paginationFromIRI - 1) * MCRSwordConstants.MAX_ENTRYS_PER_PAGE;
collectionProvider.getIDSupplier().get(start, MCRSwordConstants.MAX_ENTRYS_PER_PAGE).stream().map(id -> {
try {
return collectionProvider.getMetadataProvider().provideListMetadata(id);
} catch (SwordError swordError) {
LOGGER.warn("Error while creating feed for [{}]! (Will be removed from List)", id);
return null;
}
}).filter(Objects::nonNull).forEach(feed::addEntry);
MCRSwordUtil.BuildLinkUtil.addPaginationLinks(collectionIRI, collection, feed, collectionProvider);
}
} else {
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, HttpServletResponse.SC_NOT_FOUND, "The collection '" + collection + "' does not exist!");
}
return feed;
}
Aggregations