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) {
}
}
}
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);
}
}
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());
}
}
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;
}
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);
}
}
Aggregations