use of edu.harvard.iq.dataverse.export.ExportException 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;
}
use of edu.harvard.iq.dataverse.export.ExportException in project dataverse by IQSS.
the class Xrecord method writeToStream.
public void writeToStream(OutputStream outputStream) throws IOException {
outputStream.flush();
String headerString = itemHeaderToString(this.header);
if (headerString == null) {
throw new IOException("Xrecord: failed to stream item header.");
}
outputStream.write(headerString.getBytes());
if (!isExtendedDataverseMetadataMode(formatName)) {
outputStream.write(METADATA_START_ELEMENT.getBytes());
outputStream.flush();
if (dataset != null && formatName != null) {
InputStream inputStream = null;
try {
inputStream = ExportService.getInstance().getExport(dataset, formatName);
} catch (ExportException ex) {
inputStream = null;
}
if (inputStream == null) {
throw new IOException("Xrecord: failed to open metadata stream.");
}
writeMetadataStream(inputStream, outputStream);
}
outputStream.write(METADATA_END_ELEMENT.getBytes());
} else {
outputStream.write(customMetadataExtensionRef(this.dataset.getGlobalId()).getBytes());
}
outputStream.flush();
}
use of edu.harvard.iq.dataverse.export.ExportException in project dataverse by IQSS.
the class DeaccessionDatasetVersionCommand method execute.
@Override
public DatasetVersion execute(CommandContext ctxt) throws CommandException {
Dataset ds = theVersion.getDataset();
theVersion.setVersionState(DatasetVersion.VersionState.DEACCESSIONED);
/* We do not want to delete the identifier if the dataset is completely deaccessioned
logger.fine("deleteDOIIdentifier=" + deleteDOIIdentifier);
if (deleteDOIIdentifier) {
String nonNullDefaultIfKeyNotFound = "";
String protocol = ctxt.settings().getValueForKey(SettingsServiceBean.Key.Protocol, nonNullDefaultIfKeyNotFound);
ArrayList<String> currentProtocol = new ArrayList<>();
currentProtocol.add(protocol);
IdServiceBean idServiceBean = IdServiceBean.getBean(ctxt);
logger.fine("protocol=" + protocol);
try {
idServiceBean.deleteIdentifier(ds);
} catch (Exception e) {
if (e.toString().contains("Internal Server Error")) {
throw new CommandException(BundleUtil.getStringFromBundle("dataset.publish.error", idServiceBean.getProviderInformation()),this);
}
throw new CommandException(BundleUtil.getStringFromBundle("dataset.delete.error", currentProtocol),this);
}
}*/
DatasetVersion managed = ctxt.em().merge(theVersion);
boolean doNormalSolrDocCleanUp = true;
ctxt.index().indexDataset(managed.getDataset(), doNormalSolrDocCleanUp);
ExportService instance = ExportService.getInstance(ctxt.settings());
if (managed.getDataset().getReleasedVersion() != null) {
try {
instance.exportAllFormats(managed.getDataset());
} catch (ExportException ex) {
// Something went wrong!
// But we're not going to treat it as a fatal condition.
}
} else {
try {
// otherwise, we need to wipe clean the exports we may have cached:
instance.clearAllCachedFormats(managed.getDataset());
} catch (IOException ex) {
// Try catch required due to original method for clearing cached metadata (non fatal)
}
}
// And save the dataset, to get the "last exported" timestamp right:
Dataset managedDs = ctxt.em().merge(managed.getDataset());
return managed;
}
Aggregations