use of org.apache.abdera.i18n.iri.IRI in project mycore by MyCoRe-Org.
the class MCRSwordMediaManager method deleteMediaResource.
public void deleteMediaResource(String editMediaIRI, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
LOGGER.info("deleteMediaResource: {}", editMediaIRI);
final IRI mediaEditIRI = new IRI(editMediaIRI);
final String requestObjectID = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getDerivateFromMediaEditIRI(mediaEditIRI);
final String requestFilePath = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getFilePathFromMediaEditIRI(mediaEditIRI);
final String collection = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getCollectionFromMediaEditIRI(mediaEditIRI);
doAuthentication(authCredentials, collection);
getMediaProvider(collection).deleteMediaResource(requestObjectID, requestFilePath);
}
use of org.apache.abdera.i18n.iri.IRI 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("REQUEST: add resources {} from {}!", 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.apache.abdera.i18n.iri.IRI 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("REQUEST: Replace metadata and resource of {} from {}!", 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);
}
use of org.apache.abdera.i18n.iri.IRI 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("REQUEST: Replace metadata of {} from {}!", 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.apache.abdera.i18n.iri.IRI in project DSpace by DSpace.
the class CommunityCollectionGenerator method buildCollection.
public SwordCollection buildCollection(Context context, DSpaceObject dso, SwordConfigurationDSpace swordConfig) throws DSpaceSwordException {
if (!(dso instanceof Community)) {
log.error("buildCollection passed something other than a Community object");
throw new DSpaceSwordException("Incorrect ATOMCollectionGenerator instantiated");
}
// get the things we need out of the service
SwordUrlManager urlManager = swordConfig.getUrlManager(context, swordConfig);
Community com = (Community) dso;
SwordCollection scol = new SwordCollection();
// prepare the parameters to be put in the sword collection
String location = urlManager.getDepositLocation(com);
if (location == null) {
location = handleService.getCanonicalForm(com.getHandle());
}
scol.setLocation(location);
// collection title is just the community name
String title = communityService.getName(com);
if (StringUtils.isNotBlank(title)) {
scol.setTitle(title);
}
// FIXME: the community has no obvious licence
// the collection policy is the licence to which the collection adheres
// String collectionPolicy = col.getLicense();
// abstract is the short description of the collection
List<MetadataValue> abstracts = communityService.getMetadataByMetadataString(com, "short_description");
if (abstracts != null && !abstracts.isEmpty()) {
String firstValue = abstracts.get(0).getValue();
if (StringUtils.isNotBlank(firstValue)) {
scol.setAbstract(firstValue);
}
}
// do we support mediated deposit
scol.setMediation(swordConfig.isMediated());
// NOTE: for communities, there are no MIME types that it accepts.
// the list of mime types that we accept
// offer up the collections from this item as deposit targets
String subService = urlManager.constructSubServiceUrl(com);
scol.addSubService(new IRI(subService));
log.debug("Created ATOM Collection for DSpace Community");
return scol;
}
Aggregations