Make importers more robust to preview errors when someone selects the
wrong importer/parser
This commit is contained in:
parent
57ca70132c
commit
3003c1a709
@ -43,6 +43,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.poi.POIXMLException;
|
||||||
import org.apache.poi.common.usermodel.Hyperlink;
|
import org.apache.poi.common.usermodel.Hyperlink;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
@ -117,6 +118,8 @@ public class ExcelImporter extends TabularImportingParserBase {
|
|||||||
logger.error("Error generating parser UI initialization data for Excel file", e);
|
logger.error("Error generating parser UI initialization data for Excel file", e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.error("Error generating parser UI initialization data for Excel file (only Excel 97 & later supported)", e);
|
logger.error("Error generating parser UI initialization data for Excel file (only Excel 97 & later supported)", e);
|
||||||
|
} catch (POIXMLException e) {
|
||||||
|
logger.error("Error generating parser UI initialization data for Excel file - invalid XML", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
@ -162,6 +165,13 @@ public class ExcelImporter extends TabularImportingParserBase {
|
|||||||
e
|
e
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
|
} catch (POIXMLException e) {
|
||||||
|
exceptions.add(new ImportException(
|
||||||
|
"Attempted to parse as an Excel file but failed. " +
|
||||||
|
"Invalid XML.",
|
||||||
|
e
|
||||||
|
));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] sheets = JSONUtilities.getIntArray(options, "sheets");
|
int[] sheets = JSONUtilities.getIntArray(options, "sheets");
|
||||||
|
@ -86,18 +86,23 @@ public class RdfTripleImporter extends ImportingParserBase {
|
|||||||
JSONObject options, List<Exception> exceptions) {
|
JSONObject options, List<Exception> exceptions) {
|
||||||
|
|
||||||
Graph graph;
|
Graph graph;
|
||||||
switch (mode) {
|
try {
|
||||||
case NT:
|
switch (mode) {
|
||||||
graph = rdfReader.parseNTriples(input);
|
case NT:
|
||||||
break;
|
graph = rdfReader.parseNTriples(input);
|
||||||
case N3:
|
break;
|
||||||
graph = rdfReader.parseN3(input);
|
case N3:
|
||||||
break;
|
graph = rdfReader.parseN3(input);
|
||||||
case RDFXML:
|
break;
|
||||||
graph = rdfReader.parseRdfXml(input);
|
case RDFXML:
|
||||||
break;
|
graph = rdfReader.parseRdfXml(input);
|
||||||
default:
|
break;
|
||||||
throw new IllegalArgumentException("Unknown parsing mode");
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown parsing mode");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
exceptions.add(e);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClosableIterable<Triple> triples = graph.find(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
|
ClosableIterable<Triple> triples = graph.find(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
|
||||||
|
Loading…
Reference in New Issue
Block a user