Search in sources :

Example 46 with JenaException

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

the class RDFInput method buildRows.

private void buildRows(Resource root) {
    // Now the results themselves
    int count = 0;
    StmtIterator solnIter = root.listProperties(ResultSetGraphVocab.solution);
    for (; solnIter.hasNext(); ) {
        Resource soln = solnIter.nextStatement().getResource();
        count++;
        Binding rb = buildBinding(soln);
        rows.add(rb);
    }
    solnIter.close();
    if (root.hasProperty(ResultSetGraphVocab.size)) {
        try {
            int size = root.getRequiredProperty(ResultSetGraphVocab.size).getInt();
            if (size != count)
                Log.warn(this, "Warning: Declared size = " + size + " : Count = " + count);
        } catch (JenaException rdfEx) {
        }
    }
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) JenaException(org.apache.jena.shared.JenaException)

Example 47 with JenaException

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

the class Metadata method read.

private static void read(Properties properties, String resource) {
    ClassLoader classLoader = SystemUtils.chooseClassLoader();
    if (classLoader == null)
        classLoader = Metadata.class.getClassLoader();
    if (classLoader == null) {
        log.error("No classloader");
        return;
    }
    InputStream in = classLoader.getResourceAsStream(resource);
    if (in == null)
        // In development, there is no properties file.
        return;
    try {
        properties.loadFromXML(in);
    } catch (InvalidPropertiesFormatException ex) {
        throw new JenaException("Invalid properties file", ex);
    } catch (IOException ex) {
        throw new JenaException("Metadata ==> IOException", ex);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 48 with JenaException

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

the class LocationMapper method initFromPath.

private void initFromPath(String configPath, boolean configMustExist) {
    if (configPath == null || configPath.length() == 0) {
        log.warn("Null configuration");
        return;
    }
    // Make a file manager to look for the location mapping file
    FileManager fm = new FileManager();
    fm.addLocatorFile();
    fm.addLocatorClassLoader(fm.getClass().getClassLoader());
    try {
        String uriConfig = null;
        InputStream in = null;
        StringTokenizer pathElems = new StringTokenizer(configPath, FileManager.PATH_DELIMITER);
        while (pathElems.hasMoreTokens()) {
            String uri = pathElems.nextToken();
            if (uri == null || uri.length() == 0)
                break;
            in = fm.openNoMap(uri);
            if (in != null) {
                uriConfig = uri;
                break;
            }
        }
        if (in == null) {
            if (!configMustExist)
                log.debug("Failed to find configuration: " + configPath);
            return;
        }
        String syntax = FileUtils.guessLang(uriConfig);
        Model model = ModelFactory.createDefaultModel();
        model.read(in, uriConfig, syntax);
        processConfig(model);
    } catch (JenaException ex) {
        LoggerFactory.getLogger(LocationMapper.class).warn("Error in configuration file: " + ex.getMessage());
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) InputStream(java.io.InputStream)

Example 49 with JenaException

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

the class OntDocumentManager method findMetadata.

/**
     * <p>
     * Search the given path for a resolvable URI, from which we load a model
     * (assuming RDF/XML).
     * </p>
     *
     * @param configPath The path to search
     * @return A model loaded by resolving an entry on the path, or null if
     * no path entries succeed.
     */
protected Model findMetadata(String configPath) {
    if (configPath == null) {
        return null;
    }
    // Make a temporary file manager to look for the metadata file
    FileManager fm = new FileManager();
    fm.addLocatorFile();
    fm.addLocatorURL();
    fm.addLocatorClassLoader(fm.getClass().getClassLoader());
    try {
        String uri = null;
        InputStream in = null;
        StringTokenizer pathElems = new StringTokenizer(configPath, FileManager.PATH_DELIMITER);
        while (in == null && pathElems.hasMoreTokens()) {
            uri = pathElems.nextToken();
            in = fm.openNoMap(uri);
        }
        if (in != null) {
            String syntax = FileUtils.guessLang(uri);
            Model model = ModelFactory.createDefaultModel();
            model.read(in, uri, syntax);
            m_policyURL = uri;
            return model;
        }
    } catch (JenaException e) {
        log.warn("Exception while reading configuration: " + e.getMessage(), e);
    }
    return null;
}
Also used : JenaException(org.apache.jena.shared.JenaException) InputStream(java.io.InputStream) FileManager(org.apache.jena.util.FileManager)

Example 50 with JenaException

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

the class N3IndentedWriter method println.

public void println() {
    try {
        writer.write(lineSeparator);
        writer.flush();
        column = 0;
        row++;
        padTo();
    } catch (java.io.IOException ex) {
        throw new JenaException(ex);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) java.io(java.io)

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