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; ...@@ -6,6 +6,7 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
import javax.xml.bind.JAXB; import javax.xml.bind.JAXB;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
...@@ -28,7 +29,7 @@ import de.sekmi.histream.etl.ScriptProcessingQueue; ...@@ -28,7 +29,7 @@ import de.sekmi.histream.etl.ScriptProcessingQueue;
* the location of the data source description. * the location of the data source description.
* *
* @see JAXB#unmarshal(java.io.File, Class) * @see JAXB#unmarshal(java.io.File, Class)
* @author Raphael * @author R.W.Majeed
* *
*/ */
@XmlRootElement(name="datasource") @XmlRootElement(name="datasource")
...@@ -89,14 +90,22 @@ public class DataSource { ...@@ -89,14 +90,22 @@ public class DataSource {
return Arrays.asList(); 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(); URLConnection conn = configuration.openConnection();
conn.connect(); conn.connect();
DataSource ds; DataSource ds;
try( InputStream in = conn.getInputStream() ){ try( InputStream in = conn.getInputStream() ){
ds = JAXB.unmarshal(configuration, DataSource.class); 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().setLastModified(conn.getLastModified());
ds.getMeta().setLocation(configuration); ds.getMeta().setLocation(configuration);
return ds; return ds;
......
...@@ -32,6 +32,8 @@ public class DecimalColumn extends Column<BigDecimal>{ ...@@ -32,6 +32,8 @@ public class DecimalColumn extends Column<BigDecimal>{
@Override @Override
public BigDecimal valueFromString(String input) throws ParseException { 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 ){ if( locale == null ){
// parse according to BigDecimal(String) // parse according to BigDecimal(String)
try{ try{
...@@ -48,7 +50,7 @@ public class DecimalColumn extends Column<BigDecimal>{ ...@@ -48,7 +50,7 @@ public class DecimalColumn extends Column<BigDecimal>{
try { try {
return (BigDecimal)decimalFormat.parse(input); return (BigDecimal)decimalFormat.parse(input);
} catch (java.text.ParseException e) { } 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> { ...@@ -20,6 +20,7 @@ public class IntegerColumn extends Column<Long> {
@Override @Override
public Long valueFromString(String input) throws ParseException { public Long valueFromString(String input) throws ParseException {
input = input.trim(); // TODO warning for user feedback if spaces were removed
return Long.parseLong(input); return Long.parseLong(input);
} }
......
...@@ -37,6 +37,7 @@ import de.sekmi.histream.ontology.OntologyException; ...@@ -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.ConditionType;
import de.sekmi.histream.ontology.skos.transform.Rule; import de.sekmi.histream.ontology.skos.transform.Rule;
import de.sekmi.histream.ontology.skos.transform.TransformationRules; import de.sekmi.histream.ontology.skos.transform.TransformationRules;
import de.sekmi.histream.xml.NamespaceResolver;
public class Store implements Ontology, Plugin { public class Store implements Ontology, Plugin {
private static final Logger log = Logger.getLogger(Store.class.getName()); private static final Logger log = Logger.getLogger(Store.class.getName());
...@@ -47,7 +48,7 @@ public class Store implements Ontology, Plugin { ...@@ -47,7 +48,7 @@ public class Store implements Ontology, Plugin {
private Resource inferredContext; private Resource inferredContext;
// SKOS scheme to enforce unique notations // SKOS scheme to enforce unique notations
private Resource scheme; private Resource scheme;
/// XXX namespace resolver
/** /**
* Plugin constructor which accepts configuration parameters. * 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