Search in sources :

Example 16 with IRI

use of org.apache.abdera.i18n.iri.IRI in project dataverse by IQSS.

the class ReceiptGenerator method createDatasetReceipt.

DepositReceipt createDatasetReceipt(String baseUrl, Dataset dataset) {
    logger.fine("baseUrl was: " + baseUrl);
    DepositReceipt depositReceipt = new DepositReceipt();
    String globalId = dataset.getGlobalIdString();
    String editIri = baseUrl + "/edit/study/" + globalId;
    depositReceipt.setEditIRI(new IRI(editIri));
    /**
     * @todo: should setLocation depend on if an atom entry or a zip file
     * was deposited? (This @todo has been carried over from the DVN 3.x
     * version.)
     */
    depositReceipt.setLocation(new IRI(editIri));
    depositReceipt.setEditMediaIRI(new IRI(baseUrl + "/edit-media/study/" + globalId));
    depositReceipt.setStatementURI("application/atom+xml;type=feed", baseUrl + "/statement/study/" + globalId);
    depositReceipt.addDublinCore("bibliographicCitation", dataset.getLatestVersion().getCitation());
    depositReceipt.setSplashUri(dataset.getPersistentURL());
    return depositReceipt;
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) DepositReceipt(org.swordapp.server.DepositReceipt)

Example 17 with IRI

use of org.apache.abdera.i18n.iri.IRI 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);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRSwordCollectionProvider(org.mycore.sword.application.MCRSwordCollectionProvider)

Example 18 with IRI

use of org.apache.abdera.i18n.iri.IRI 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("REQUEST: Get entry {} 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);
    final Optional<Map<String, String>> accept = Optional.of(map);
    return collectionProvider.getContainerHandler().getMetadata(collection, (MCRObject) retrievedMCRBase, accept);
}
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) Map(java.util.Map)

Example 19 with IRI

use of org.apache.abdera.i18n.iri.IRI 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("REQUEST: Delete {} from {}", 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);
}
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 20 with IRI

use of org.apache.abdera.i18n.iri.IRI in project mycore by MyCoRe-Org.

the class MCRSwordMediaManager method addResource.

public DepositReceipt addResource(String editMediaIRI, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
    LOGGER.info("addResource: {}", editMediaIRI);
    final IRI mediaEditIRI = new IRI(editMediaIRI);
    final String requestDerivateID = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getDerivateFromMediaEditIRI(mediaEditIRI);
    String requestFilePath = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getFilePathFromMediaEditIRI(mediaEditIRI);
    final String collection = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getCollectionFromMediaEditIRI(mediaEditIRI);
    doAuthentication(authCredentials, collection);
    checkObject(requestDerivateID);
    if (requestFilePath == null) {
        requestFilePath = "/";
    }
    getMediaProvider(collection).addResource(requestDerivateID, requestFilePath, deposit);
    final MCRObject mcrObject = MCRSwordUtil.getMcrObjectForDerivateID(requestDerivateID);
    return MCRSword.getCollection(collection).getMetadataProvider().provideMetadata(mcrObject);
}
Also used : IRI(org.apache.abdera.i18n.iri.IRI) MCRObject(org.mycore.datamodel.metadata.MCRObject)

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