Search in sources :

Example 6 with IRI

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);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI)

Example 7 with IRI

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);
}
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 8 with IRI

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);
}
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 9 with IRI

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);
}
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 10 with IRI

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;
}
Also used : MetadataValue(org.dspace.content.MetadataValue) IRI(org.apache.abdera.i18n.iri.IRI) Community(org.dspace.content.Community) SwordCollection(org.swordapp.server.SwordCollection)

Aggregations

IRI (org.apache.abdera.i18n.iri.IRI)26 MCRSwordCollectionProvider (org.mycore.sword.application.MCRSwordCollectionProvider)6 MCRBase (org.mycore.datamodel.metadata.MCRBase)5 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)5 Abdera (org.apache.abdera.Abdera)4 Entry (org.apache.abdera.model.Entry)4 Feed (org.apache.abdera.model.Feed)4 Date (java.util.Date)3 DepositReceipt (org.swordapp.server.DepositReceipt)3 SwordCollection (org.swordapp.server.SwordCollection)3 Dataset (edu.harvard.iq.dataverse.Dataset)2 Dataverse (edu.harvard.iq.dataverse.Dataverse)2 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)2 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)2 Map (java.util.Map)2 QName (javax.xml.namespace.QName)2 MetadataValue (org.dspace.content.MetadataValue)2 Test (org.junit.Test)2 AuthCredentials (org.swordapp.server.AuthCredentials)2 SwordError (org.swordapp.server.SwordError)2