Commit 9a4a938e authored by R.W.Majeed's avatar R.W.Majeed

more verbose error messages

parent 437801bb
......@@ -6,6 +6,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.JAXB;
import javax.xml.bind.annotation.XmlAccessType;
......@@ -28,7 +29,7 @@ import de.sekmi.histream.etl.ScriptProcessingQueue;
* the location of the data source description.
*
* @see JAXB#unmarshal(java.io.File, Class)
* @author Raphael
* @author R.W.Majeed
*
*/
@XmlRootElement(name="datasource")
......@@ -89,14 +90,22 @@ public class DataSource {
return Arrays.asList();
}
}
public static DataSource load(URL configuration) throws IOException{
/**
* Load the datasource configuration from the given URL.
* @param configuration configuration URL
* @return data source object
* @throws IOException IO error
* @throws NullPointerException /datasource or /datasource/meta missing
*/
public static DataSource load(URL configuration) throws IOException, NullPointerException{
URLConnection conn = configuration.openConnection();
conn.connect();
DataSource ds;
try( InputStream in = conn.getInputStream() ){
ds = JAXB.unmarshal(configuration, DataSource.class);
}
Objects.requireNonNull(ds, "JAXB unmarshall returned null for URL "+configuration);
Objects.requireNonNull(ds.getMeta(), "/datasource/meta element missing");
ds.getMeta().setLastModified(conn.getLastModified());
ds.getMeta().setLocation(configuration);
return ds;
......
......@@ -32,6 +32,8 @@ public class DecimalColumn extends Column<BigDecimal>{
@Override
public BigDecimal valueFromString(String input) throws ParseException {
// remove leading/trailing spaces
input = input.trim(); // TODO warning for user feedback if spaces were removed
if( locale == null ){
// parse according to BigDecimal(String)
try{
......@@ -48,7 +50,7 @@ public class DecimalColumn extends Column<BigDecimal>{
try {
return (BigDecimal)decimalFormat.parse(input);
} catch (java.text.ParseException e) {
throw new ParseException("Unable to parse number '"+input+"'", e);
throw new ParseException("Unable to parse number '"+input+"' with locale "+locale, e);
}
}
}
......
......@@ -20,6 +20,7 @@ public class IntegerColumn extends Column<Long> {
@Override
public Long valueFromString(String input) throws ParseException {
input = input.trim(); // TODO warning for user feedback if spaces were removed
return Long.parseLong(input);
}
......
......@@ -37,6 +37,7 @@ import de.sekmi.histream.ontology.OntologyException;
import de.sekmi.histream.ontology.skos.transform.ConditionType;
import de.sekmi.histream.ontology.skos.transform.Rule;
import de.sekmi.histream.ontology.skos.transform.TransformationRules;
import de.sekmi.histream.xml.NamespaceResolver;
public class Store implements Ontology, Plugin {
private static final Logger log = Logger.getLogger(Store.class.getName());
......@@ -47,7 +48,7 @@ public class Store implements Ontology, Plugin {
private Resource inferredContext;
// SKOS scheme to enforce unique notations
private Resource scheme;
/// XXX namespace resolver
/**
* Plugin constructor which accepts configuration parameters.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment