Search in sources :

Example 1 with Exporter

use of edu.harvard.iq.dataverse.export.spi.Exporter 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 Exporter

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

the class ExportService method clearAllCachedFormats.

public void clearAllCachedFormats(Dataset dataset) throws IOException {
    try {
        Iterator<Exporter> exporters = loader.iterator();
        while (exporters.hasNext()) {
            Exporter e = exporters.next();
            String formatName = e.getProviderName();
            clearCachedExport(dataset, formatName);
        }
        dataset.setLastExportTime(null);
    } catch (IOException ex) {
    // not fatal
    }
}
Also used : IOException(java.io.IOException) Exporter(edu.harvard.iq.dataverse.export.spi.Exporter)

Example 3 with Exporter

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

the class ExportService method getExportersLabels.

public List<String[]> getExportersLabels() {
    List<String[]> retList = new ArrayList<>();
    Iterator<Exporter> exporters = ExportService.getInstance().loader.iterator();
    while (exporters.hasNext()) {
        Exporter e = exporters.next();
        String[] temp = new String[2];
        temp[0] = e.getDisplayName();
        temp[1] = e.getProviderName();
        retList.add(temp);
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) Exporter(edu.harvard.iq.dataverse.export.spi.Exporter)

Example 4 with Exporter

use of edu.harvard.iq.dataverse.export.spi.Exporter 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)

Example 5 with Exporter

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

the class OAIServlet method addSupportedMetadataFormats.

private void addSupportedMetadataFormats(Context context) {
    for (String[] provider : ExportService.getInstance(settingsService).getExportersLabels()) {
        String formatName = provider[1];
        Exporter exporter;
        try {
            exporter = ExportService.getInstance(settingsService).getExporter(formatName);
        } catch (ExportException ex) {
            exporter = null;
        }
        if (exporter != null && exporter.isXMLFormat() && exporter.isHarvestable()) {
            MetadataFormat metadataFormat;
            try {
                metadataFormat = MetadataFormat.metadataFormat(formatName);
                metadataFormat.withNamespace(exporter.getXMLNameSpace());
                metadataFormat.withSchemaLocation(exporter.getXMLSchemaLocation());
            } catch (ExportException ex) {
                metadataFormat = null;
            }
            if (metadataFormat != null) {
                context.withMetadataFormat(metadataFormat);
            }
        }
    }
// return context;
}
Also used : MetadataFormat(com.lyncode.xoai.dataprovider.model.MetadataFormat) Exporter(edu.harvard.iq.dataverse.export.spi.Exporter) ExportException(edu.harvard.iq.dataverse.export.ExportException)

Aggregations

Exporter (edu.harvard.iq.dataverse.export.spi.Exporter)7 ExportException (edu.harvard.iq.dataverse.export.ExportException)3 ArrayList (java.util.ArrayList)3 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)2 JsonPrinter (edu.harvard.iq.dataverse.util.json.JsonPrinter)2 IOException (java.io.IOException)2 ServiceConfigurationError (java.util.ServiceConfigurationError)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 MetadataFormat (com.lyncode.xoai.dataprovider.model.MetadataFormat)1 SchemaDotOrgExporter (edu.harvard.iq.dataverse.export.SchemaDotOrgExporter)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 JsonObject (javax.json.JsonObject)1