use of eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException in project hale by halestudio.
the class SLDStyleWriter method execute.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Save styles to SLD", ProgressIndicator.UNKNOWN);
SLDTransformer trans = new SLDTransformer();
trans.setIndentation(2);
OutputStream out = getTarget().getOutput();
try {
trans.transform(getStyle(), out);
reporter.setSuccess(true);
} catch (Exception e) {
reporter.error(new IOMessageImpl("Saving the style as SLD failed.", e));
reporter.setSuccess(false);
} finally {
out.close();
progress.end();
}
return reporter;
}
use of eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException in project hale by halestudio.
the class SkosCodeListReader method execute.
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Loading SKOS code list", ProgressIndicator.UNKNOWN);
try {
this.language = getLangauge();
URI loc = getSource().getLocation();
InputStream in = getSource().getInput();
codelist = new SkosCodeList(in, loc, this.language);
progress.setCurrentTask("Code list loaded.");
reporter.setSuccess(true);
} catch (Exception ex) {
reporter.error(new IOMessageImpl("Error in loading skos code list", ex));
reporter.setSuccess(false);
}
return reporter;
}
use of eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException in project hale by halestudio.
the class INSPIRECodeListReader method execute.
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Loading code list.", ProgressIndicator.UNKNOWN);
try {
Document doc;
URI loc = getSource().getLocation();
if (loc != null && (loc.getScheme().equals("http") || loc.getScheme().equals("https"))) {
// and provide headers to retrieve correct format and language
try {
doc = loadXmlDocument(loc);
} catch (Exception e) {
// try local resources as fall-back
InputSupplier<? extends InputStream> localInput = Resources.tryResolve(loc, Resources.RESOURCE_TYPE_XML_CODELIST);
if (localInput != null) {
try (InputStream is = localInput.getInput()) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(is);
}
} else
throw e;
}
} else {
// just access stream
try (InputStream is = getSource().getInput()) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(is);
}
}
reporter.setSuccess(parse(doc, loc, reporter));
} catch (Exception e) {
throw new RuntimeException(e);
}
progress.setCurrentTask("Code list loaded.");
return reporter;
}
use of eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException in project hale by halestudio.
the class XmlCodeListReader method execute.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Loading code list.", ProgressIndicator.UNKNOWN);
try {
InputStream in = getSource().getInput();
URI loc = getSource().getLocation();
codelist = new XmlCodeList(in, loc);
progress.setCurrentTask("Code list loaded.");
} catch (Exception e) {
throw new RuntimeException(e);
}
reporter.setSuccess(true);
return reporter;
}
use of eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException in project hale by halestudio.
the class JaxbAlignmentReader method loadAlignment.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected MutableAlignment loadAlignment(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Load hale alignment", ProgressIndicator.UNKNOWN);
InputStream in = getSource().getInput();
MutableAlignment alignment = null;
try {
EntityResolver entityResolver = null;
if (getServiceProvider() != null) {
entityResolver = getServiceProvider().getService(EntityResolver.class);
}
alignment = JaxbAlignmentIO.load(in, reporter, getSourceSchema(), getTargetSchema(), getPathUpdater(), entityResolver, getServiceProvider());
} catch (Exception e) {
reporter.error(new IOMessageImpl(e.getMessage(), e));
reporter.setSuccess(false);
return alignment;
} finally {
in.close();
}
progress.end();
reporter.setSuccess(true);
return alignment;
}
Aggregations