Search in sources :

Example 21 with IOProviderConfigurationException

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;
}
Also used : SLDTransformer(org.geotools.styling.SLDTransformer) OutputStream(java.io.OutputStream) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) IOException(java.io.IOException)

Example 22 with IOProviderConfigurationException

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;
}
Also used : InputStream(java.io.InputStream) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) URI(java.net.URI) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) IOException(java.io.IOException)

Example 23 with IOProviderConfigurationException

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;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) InputStream(java.io.InputStream) Document(org.w3c.dom.Document) URI(java.net.URI) ClientProtocolException(org.apache.http.client.ClientProtocolException) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) HttpResponseException(org.apache.http.client.HttpResponseException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) InputSupplier(eu.esdihumboldt.util.io.InputSupplier)

Example 24 with IOProviderConfigurationException

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;
}
Also used : InputStream(java.io.InputStream) URI(java.net.URI) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) IOException(java.io.IOException)

Example 25 with IOProviderConfigurationException

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;
}
Also used : InputStream(java.io.InputStream) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) EntityResolver(eu.esdihumboldt.hale.common.align.io.EntityResolver) IOProviderConfigurationException(eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException) IOException(java.io.IOException)

Aggregations

IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)44 IOException (java.io.IOException)38 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)27 InputStream (java.io.InputStream)14 URI (java.net.URI)13 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)7 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)6 InstanceCollection (eu.esdihumboldt.hale.common.instance.model.InstanceCollection)6 DefaultSchema (eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchema)6 File (java.io.File)6 OutputStream (java.io.OutputStream)6 ArrayList (java.util.ArrayList)6 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)5 QName (javax.xml.namespace.QName)5 IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)4 DefaultPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition)4 InputStreamReader (java.io.InputStreamReader)4 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 PathUpdate (eu.esdihumboldt.hale.common.core.io.PathUpdate)3