Search in sources :

Example 1 with ExportException

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

the class FilePage method getExporters.

public List<String[]> getExporters() {
    List<String[]> retList = new ArrayList<>();
    String myHostURL = systemConfig.getDataverseSiteUrl();
    for (String[] provider : ExportService.getInstance(settingsService).getExportersLabels()) {
        String formatName = provider[1];
        String formatDisplayName = provider[0];
        Exporter exporter = null;
        try {
            exporter = ExportService.getInstance(settingsService).getExporter(formatName);
        } catch (ExportException ex) {
            exporter = null;
        }
        if (exporter != null && exporter.isAvailableToUsers()) {
            // Not all metadata exports should be presented to the web users!
            // Some are only for harvesting clients.
            String[] temp = new String[2];
            temp[0] = formatDisplayName;
            temp[1] = myHostURL + "/api/datasets/export?exporter=" + formatName + "&persistentId=" + fileMetadata.getDatasetVersion().getDataset().getGlobalId();
            retList.add(temp);
        }
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) Exporter(edu.harvard.iq.dataverse.export.spi.Exporter) ExportException(edu.harvard.iq.dataverse.export.ExportException)

Example 2 with ExportException

use of edu.harvard.iq.dataverse.export.ExportException 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 3 with ExportException

use of edu.harvard.iq.dataverse.export.ExportException 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 4 with ExportException

use of edu.harvard.iq.dataverse.export.ExportException 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 5 with ExportException

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

the class DatasetPage method getExporters.

public List<String[]> getExporters() {
    List<String[]> retList = new ArrayList<>();
    String myHostURL = getDataverseSiteUrl();
    for (String[] provider : ExportService.getInstance(settingsService).getExportersLabels()) {
        String formatName = provider[1];
        String formatDisplayName = provider[0];
        Exporter exporter = null;
        try {
            exporter = ExportService.getInstance(settingsService).getExporter(formatName);
        } catch (ExportException ex) {
            exporter = null;
        }
        if (exporter != null && exporter.isAvailableToUsers()) {
            // Not all metadata exports should be presented to the web users!
            // Some are only for harvesting clients.
            String[] temp = new String[2];
            temp[0] = formatDisplayName;
            temp[1] = myHostURL + "/api/datasets/export?exporter=" + formatName + "&persistentId=" + dataset.getGlobalId();
            retList.add(temp);
        }
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) SchemaDotOrgExporter(edu.harvard.iq.dataverse.export.SchemaDotOrgExporter) Exporter(edu.harvard.iq.dataverse.export.spi.Exporter) ExportException(edu.harvard.iq.dataverse.export.ExportException)

Aggregations

ExportException (edu.harvard.iq.dataverse.export.ExportException)8 ExportService (edu.harvard.iq.dataverse.export.ExportService)4 IOException (java.io.IOException)4 Exporter (edu.harvard.iq.dataverse.export.spi.Exporter)3 ArrayList (java.util.ArrayList)2 MetadataFormat (com.lyncode.xoai.dataprovider.model.MetadataFormat)1 Dataset (edu.harvard.iq.dataverse.Dataset)1 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)1 SchemaDotOrgExporter (edu.harvard.iq.dataverse.export.SchemaDotOrgExporter)1 InputStream (java.io.InputStream)1 TransactionAttribute (javax.ejb.TransactionAttribute)1