better error messages if remote SPARQL endpoint is unavailable
This commit is contained in:
parent
fab1555cdb
commit
dcfc32803c
2 changed files with 18 additions and 0 deletions
|
@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpException;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -77,6 +78,20 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
|
||||||
this.updateEndpointURI = updateEndpointURI;
|
this.updateEndpointURI = updateEndpointURI;
|
||||||
this.readRepository = new HTTPRepository(readEndpointURI);
|
this.readRepository = new HTTPRepository(readEndpointURI);
|
||||||
this.updateRepository = new HTTPRepository(updateEndpointURI);
|
this.updateRepository = new HTTPRepository(updateEndpointURI);
|
||||||
|
|
||||||
|
testConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testConnection() {
|
||||||
|
try {
|
||||||
|
this.sparqlSelectQuery(
|
||||||
|
"SELECT ?s WHERE { ?s a " +
|
||||||
|
"<http://vitro.mannlib.cornell.edu/ns/vitro/nonsense/> }",
|
||||||
|
RDFService.ResultFormat.JSON);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Unable to connect to endpoint at " +
|
||||||
|
readEndpointURI, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -133,6 +133,7 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase
|
||||||
baseOms.setTBoxModel(tboxAssertions);
|
baseOms.setTBoxModel(tboxAssertions);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Unable to load tbox assertion cache from DB", e);
|
log.error("Unable to load tbox assertion cache from DB", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TBox inferences
|
// TBox inferences
|
||||||
|
@ -155,6 +156,7 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase
|
||||||
inferenceOms.setTBoxModel(tboxInferences);
|
inferenceOms.setTBoxModel(tboxInferences);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Unable to load tbox inference cache from DB", e);
|
log.error("Unable to load tbox inference cache from DB", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// union ABox
|
// union ABox
|
||||||
|
@ -204,6 +206,7 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Unable to load application metadata model cache from DB"
|
log.error("Unable to load application metadata model cache from DB"
|
||||||
, e);
|
, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForNamespaceMismatch( baseOms.getApplicationMetadataModel(), ctx );
|
checkForNamespaceMismatch( baseOms.getApplicationMetadataModel(), ctx );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue