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,6 +86,7 @@ public class RdfTripleImporter extends ImportingParserBase {
|
|||||||
JSONObject options, List<Exception> exceptions) {
|
JSONObject options, List<Exception> exceptions) {
|
||||||
|
|
||||||
Graph graph;
|
Graph graph;
|
||||||
|
try {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case NT:
|
case NT:
|
||||||
graph = rdfReader.parseNTriples(input);
|
graph = rdfReader.parseNTriples(input);
|
||||||
@ -99,6 +100,10 @@ public class RdfTripleImporter extends ImportingParserBase {
|
|||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown parsing mode");
|
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);
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user