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