Search in sources :

Example 26 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class HttpQuery method exec.

/**
     * Execute the operation
     * 
     * @return Model The resulting model
     * @throws QueryExceptionHTTP
     */
public InputStream exec() throws QueryExceptionHTTP {
    // Select the appropriate HttpClient to use
    HttpClientContext hcc = HttpClientContext.adapt(getContext());
    RequestConfig.Builder builder = RequestConfig.copy(hcc.getRequestConfig());
    contextualizeCompressionSettings(builder);
    contextualizeTimeoutSettings(builder);
    hcc.setRequestConfig(builder.build());
    try {
        if (usesPOST())
            return execPost();
        return execGet();
    } catch (QueryExceptionHTTP httpEx) {
        log.trace("Exception in exec", httpEx);
        throw httpEx;
    } catch (JenaException jEx) {
        log.trace("JenaException in exec", jEx);
        throw jEx;
    }
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) JenaException(org.apache.jena.shared.JenaException) HttpClientContext(org.apache.http.client.protocol.HttpClientContext)

Example 27 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class DOM2Model method load.

/**
     * Parse a DOM Node with the RDF/XML parser, loading the triples into the
     * associated Model. Known not to work with Java 1.4.1.
     * 
     * @param document
     */
public void load(Node document) {
    Source input = new DOMSource(document);
    // Make a SAXResult object using this handler
    SAXResult output = new SAXResult(this);
    output.setLexicalHandler(this);
    // Run transform
    TransformerFactory xformFactory = TransformerFactory.newInstance();
    try {
        Transformer idTransform = xformFactory.newTransformer();
        idTransform.transform(input, output);
    } catch (FatalParsingErrorException e) {
        // Old code ignored this,
        // given difficult bug report, don't be silent.
        logger.error("Unexpected exception in DOM2Model", e);
    } catch (RuntimeException rte) {
        throw rte;
    } catch (Exception nrte) {
        throw new JenaException(nrte);
    } finally {
        close();
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) DOMSource(javax.xml.transform.dom.DOMSource) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) SAXResult(javax.xml.transform.sax.SAXResult) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) SAXParseException(org.xml.sax.SAXParseException) JenaException(org.apache.jena.shared.JenaException)

Example 28 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class JenaHandler method statement.

@Override
public void statement(AResource subj, AResource pred, ALiteral lit) {
    try {
        Triple t = JenaReader.convert(subj, pred, lit);
        graph.add(t);
    } catch (JenaException e) {
        errorHandler.error(e);
    }
}
Also used : Triple(org.apache.jena.graph.Triple) JenaException(org.apache.jena.shared.JenaException)

Example 29 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class JenaReader method read.

private synchronized void read(final Graph g, InputSource inputS, String xmlBase, Model m) {
    try {
        g.getEventManager().notifyEvent(g, GraphEvents.startRead);
        inputS.setSystemId(xmlBase);
        handler = new JenaHandler(g, m, errorHandler);
        handler.useWith(arpf.getHandlers());
        arpf.parse(inputS, xmlBase);
    } catch (IOException e) {
        throw new WrappedIOException(e);
    } catch (SAXException e) {
        throw new JenaException(e);
    } finally {
        g.getEventManager().notifyEvent(g, GraphEvents.finishRead);
        handler = null;
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) WrappedIOException(org.apache.jena.shared.WrappedIOException) WrappedIOException(org.apache.jena.shared.WrappedIOException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 30 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class Unparser method error.

/*
     * Unexpected error.
     */
private void error(String msg) {
    JenaException e = new BrokenException("Internal error in Unparser: " + msg);
    this.prettyWriter.fatalError(e);
    // Just in case.
    throw e;
}
Also used : JenaException(org.apache.jena.shared.JenaException) BrokenException(org.apache.jena.shared.BrokenException)

Aggregations

JenaException (org.apache.jena.shared.JenaException)70 Model (org.apache.jena.rdf.model.Model)12 RDFReader (org.apache.jena.rdf.model.RDFReader)8 IOException (java.io.IOException)7 QueryException (org.apache.jena.query.QueryException)5 QueryParseException (org.apache.jena.query.QueryParseException)5 java.io (java.io)4 InputStream (java.io.InputStream)4 Reader (java.io.Reader)4 StringReader (java.io.StringReader)4 Graph (org.apache.jena.graph.Graph)4 ServletOutputStream (javax.servlet.ServletOutputStream)3 CmdException (jena.cmd.CmdException)3 AmbiguousSpecificTypeException (org.apache.jena.assembler.exceptions.AmbiguousSpecificTypeException)3 MediaType (org.apache.jena.atlas.web.MediaType)3 Triple (org.apache.jena.graph.Triple)3 BadDescriptionMultipleRootsException (org.apache.jena.shared.BadDescriptionMultipleRootsException)3 BadDescriptionNoRootException (org.apache.jena.shared.BadDescriptionNoRootException)3 ARQParser (org.apache.jena.sparql.lang.arq.ARQParser)3 FileNotFoundException (java.io.FileNotFoundException)2