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