Ignore markdown files in RDF directories.
People want to document the RDF directories (such as rdf/abox/filegraph) by adding README.md files Such files produce either a warning or an exception, depending on the directory and who is reading. Modify to ignore any file with a .md extension.
This commit is contained in:
parent
ed0b7f0f0d
commit
abea644f46
3 changed files with 18 additions and 8 deletions
|
@ -40,8 +40,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
|||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ModelSerializationFormat;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
// This ContextListener must run after the JenaDataSourceSetup ContextListener
|
||||
|
@ -164,6 +164,8 @@ public class FileGraphSetup implements ServletContextListener {
|
|||
model.read( fis, null, "N3" );
|
||||
} else if ( fn.endsWith(".owl") || fn.endsWith(".rdf") || fn.endsWith(".xml") ) {
|
||||
model.read( fis, null, "RDF/XML" );
|
||||
} else if ( fn.endsWith(".md") ) {
|
||||
// Ignore markdown files - documentation.
|
||||
} else {
|
||||
log.warn("Ignoring " + type + " file graph " + p + " because the file extension is unrecognized.");
|
||||
}
|
||||
|
|
|
@ -34,7 +34,10 @@ public class RDFFilesLoader {
|
|||
private static final String FIRST_TIME = "firsttime";
|
||||
private static final String EVERY_TIME = "everytime";
|
||||
|
||||
/** Path filter that ignores sub-directories and hidden files. */
|
||||
/**
|
||||
* Path filter that ignores sub-directories, hidden files, and markdown
|
||||
* files.
|
||||
*/
|
||||
private static final DirectoryStream.Filter<Path> RDF_FILE_FILTER = new DirectoryStream.Filter<Path>() {
|
||||
@Override
|
||||
public boolean accept(Path p) throws IOException {
|
||||
|
@ -46,6 +49,9 @@ public class RDFFilesLoader {
|
|||
+ p + "' ignored.");
|
||||
return false;
|
||||
}
|
||||
if (p.toString().endsWith(".md")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -61,8 +67,8 @@ public class RDFFilesLoader {
|
|||
public static void loadFirstTimeFiles(String modelPath, Model model,
|
||||
boolean firstTime) {
|
||||
if (firstTime) {
|
||||
Set<Path> paths = getPaths(locateHomeDirectory(), RDF,
|
||||
modelPath, FIRST_TIME);
|
||||
Set<Path> paths = getPaths(locateHomeDirectory(), RDF, modelPath,
|
||||
FIRST_TIME);
|
||||
for (Path p : paths) {
|
||||
readOntologyFileIntoModel(p, model);
|
||||
}
|
||||
|
@ -128,8 +134,8 @@ public class RDFFilesLoader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Find the paths to RDF files in this directory. Sub-directories and hidden
|
||||
* files are ignored.
|
||||
* Find the paths to RDF files in this directory. Sub-directories, hidden
|
||||
* files, and markdown files are ignored.
|
||||
*/
|
||||
private static Set<Path> getPaths(String parentDir, String... strings) {
|
||||
Path dir = Paths.get(parentDir, strings);
|
||||
|
|
|
@ -532,7 +532,9 @@ public class UpdateKnowledgeBase {
|
|||
try {
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
try {
|
||||
if (f.getName().endsWith(".n3")) {
|
||||
if (f.getName().endsWith(".md")) {
|
||||
// Markdown files are documentation - skip.
|
||||
} else if (f.getName().endsWith(".n3")) {
|
||||
om.read(fis, null, "N3");
|
||||
} else {
|
||||
om.read(fis, null, "RDF/XML");
|
||||
|
|
Loading…
Add table
Reference in a new issue