Search in sources :

Example 1 with ExportService

use of edu.harvard.iq.dataverse.export.ExportService in project dataverse by IQSS.

the class OAIRecordServiceBean method exportAllFormats.

// TODO:
// Export functionality probably deserves its own EJB ServiceBean -
// so maybe create ExportServiceBean, and move these methods there?
// (why these need to be in an EJB bean at all, what's wrong with keeping
// them in the loadable ExportService? - since we need to modify the
// "last export" timestamp on the dataset, being able to do that in the
// @EJB context is convenient.
public void exportAllFormats(Dataset dataset) {
    try {
        ExportService exportServiceInstance = ExportService.getInstance();
        logger.fine("Attempting to run export on dataset " + dataset.getGlobalId());
        exportServiceInstance.exportAllFormats(dataset);
        datasetService.updateLastExportTimeStamp(dataset.getId());
    } catch (ExportException ee) {
        logger.fine("Caught export exception while trying to export. (ignoring)");
    } catch (Exception e) {
        logger.fine("Caught unknown exception while trying to export (ignoring)");
    }
}
Also used : ExportService(edu.harvard.iq.dataverse.export.ExportService) ExportException(edu.harvard.iq.dataverse.export.ExportException) IOException(java.io.IOException) ExportException(edu.harvard.iq.dataverse.export.ExportException)

Example 2 with ExportService

use of edu.harvard.iq.dataverse.export.ExportService in project dataverse by IQSS.

the class OAIRecordServiceBean method exportAllFormatsInNewTransaction.

@TransactionAttribute(REQUIRES_NEW)
public void exportAllFormatsInNewTransaction(Dataset dataset) throws ExportException {
    try {
        ExportService exportServiceInstance = ExportService.getInstance();
        exportServiceInstance.exportAllFormats(dataset);
        datasetService.updateLastExportTimeStamp(dataset.getId());
    } catch (Exception e) {
        logger.fine("Caught unknown exception while trying to export");
        throw new ExportException(e.getMessage());
    }
}
Also used : ExportService(edu.harvard.iq.dataverse.export.ExportService) ExportException(edu.harvard.iq.dataverse.export.ExportException) IOException(java.io.IOException) ExportException(edu.harvard.iq.dataverse.export.ExportException) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 3 with ExportService

use of edu.harvard.iq.dataverse.export.ExportService in project dataverse by IQSS.

the class FinalizeDatasetPublicationCommand method exportMetadata.

/**
 * Attempting to run metadata export, for all the formats for which we have
 * metadata Exporters.
 */
private void exportMetadata(SettingsServiceBean settingsServiceBean) {
    try {
        ExportService instance = ExportService.getInstance(settingsServiceBean);
        instance.exportAllFormats(theDataset);
    } catch (ExportException ex) {
        // Something went wrong!
        // Just like with indexing, a failure to export is not a fatal
        // condition. We'll just log the error as a warning and keep
        // going:
        logger.log(Level.WARNING, "Dataset publication finalization: exception while exporting:{0}", ex.getMessage());
    }
}
Also used : ExportService(edu.harvard.iq.dataverse.export.ExportService) ExportException(edu.harvard.iq.dataverse.export.ExportException)

Example 4 with ExportService

use of edu.harvard.iq.dataverse.export.ExportService in project dataverse by IQSS.

the class DatasetPage method getJsonLd.

public String getJsonLd() {
    if (isThisLatestReleasedVersion()) {
        ExportService instance = ExportService.getInstance(settingsService);
        String jsonLd = instance.getExportAsString(dataset, SchemaDotOrgExporter.NAME);
        if (jsonLd != null) {
            logger.fine("Returning cached schema.org JSON-LD.");
            return jsonLd;
        } else {
            logger.fine("No cached schema.org JSON-LD available. Going to the database.");
            return workingVersion.getJsonLd();
        }
    }
    return "";
}
Also used : ExportService(edu.harvard.iq.dataverse.export.ExportService)

Example 5 with ExportService

use of edu.harvard.iq.dataverse.export.ExportService in project dataverse by IQSS.

the class Datasets method exportDataset.

// TODO:
// This API call should, ideally, call findUserOrDie() and the GetDatasetCommand
// to obtain the dataset that we are trying to export - which would handle
// Auth in the process... For now, Auth isn't necessary - since export ONLY
// WORKS on published datasets, which are open to the world. -- L.A. 4.5
@GET
@Path("/export")
@Produces({ "application/xml", "application/json" })
public Response exportDataset(@QueryParam("persistentId") String persistentId, @QueryParam("exporter") String exporter) {
    try {
        Dataset dataset = datasetService.findByGlobalId(persistentId);
        if (dataset == null) {
            return error(Response.Status.NOT_FOUND, "A dataset with the persistentId " + persistentId + " could not be found.");
        }
        ExportService instance = ExportService.getInstance(settingsSvc);
        String xml = instance.getExportAsString(dataset, exporter);
        // I'm wondering if this going to become a performance problem
        // with really GIANT datasets,
        // the fact that we are passing these exports, blobs of JSON, and,
        // especially, DDI XML as complete strings. It would be nicer
        // if we could stream instead - and the export service already can
        // give it to as as a stream; then we could start sending the
        // output to the remote client as soon as we got the first bytes,
        // without waiting for the whole thing to be generated and buffered...
        // (the way Access API streams its output).
        // -- L.A., 4.5
        logger.fine("xml to return: " + xml);
        String mediaType = MediaType.TEXT_PLAIN;
        if (instance.isXMLFormat(exporter)) {
            mediaType = MediaType.APPLICATION_XML;
        }
        return allowCors(Response.ok().entity(xml).type(mediaType).build());
    } catch (Exception wr) {
        return error(Response.Status.FORBIDDEN, "Export Failed");
    }
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) ExportService(edu.harvard.iq.dataverse.export.ExportService) DataFileTagException(edu.harvard.iq.dataverse.datasetutility.DataFileTagException) JsonParseException(edu.harvard.iq.dataverse.util.json.JsonParseException) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) EJBException(javax.ejb.EJBException) DataCaptureModuleException(edu.harvard.iq.dataverse.datacapturemodule.DataCaptureModuleException) NoFilesException(edu.harvard.iq.dataverse.datasetutility.NoFilesException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ExportService (edu.harvard.iq.dataverse.export.ExportService)6 ExportException (edu.harvard.iq.dataverse.export.ExportException)4 IOException (java.io.IOException)3 Dataset (edu.harvard.iq.dataverse.Dataset)2 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)1 DataCaptureModuleException (edu.harvard.iq.dataverse.datacapturemodule.DataCaptureModuleException)1 DataFileTagException (edu.harvard.iq.dataverse.datasetutility.DataFileTagException)1 NoFilesException (edu.harvard.iq.dataverse.datasetutility.NoFilesException)1 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)1 JsonParseException (edu.harvard.iq.dataverse.util.json.JsonParseException)1 EJBException (javax.ejb.EJBException)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1