use of org.apache.jena.util.FileManager in project jena by apache.
the class Env method initFM.
private static void initFM() {
fileManager = new FileManager();
fileManager.addLocatorFile();
// sysBase = System.getenv(SDBROOT) ;
if (sysBase == null)
return;
File baseDir = new File(sysBase);
if (!baseDir.exists()) {
log.warn("Directory does not exist: " + baseDir);
return;
}
if (!baseDir.isDirectory()) {
log.warn("Not a directory (but does exist): " + baseDir);
return;
}
fileManager.addLocatorFile(sysBase);
}
use of org.apache.jena.util.FileManager 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.util.FileManager in project jena by apache.
the class TestFileManager method testFileManagerFileLocator.
@Test
public void testFileManagerFileLocator() {
FileManager fileManager = new FileManager();
fileManager.addLocatorFile();
InputStream in = fileManager.open(testingDir + "/" + filename);
assertNotNull(in);
closeInputStream(in);
}
use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testCache1.
@Test
public void testCache1() {
FileManager fileManager = new FileManager();
fileManager.addLocatorFile(testingDir);
Model m1 = fileManager.loadModel(fileModel);
Model m2 = fileManager.loadModel(fileModel);
assertNotSame(m1, m2);
}
use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testFileManagerLocatorClassLoaderNotFound.
@Test
public void testFileManagerLocatorClassLoaderNotFound() {
FileManager fileManager = new FileManager();
fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader());
try {
InputStream in = fileManager.open("not/java/lang/String.class");
closeInputStream(in);
assertNull("Found non-existant class", in);
} catch (NotFoundException ex) {
}
}
Aggregations