use of org.apache.jena.fuseki.FusekiException in project jena by apache.
the class ActionBackup method backup.
public static void backup(DatasetGraph dsg, String backupfile) {
if (!backupfile.endsWith(".nq"))
backupfile = backupfile + ".nq";
OutputStream out = null;
try {
if (true) {
// This seems to achive about the same as "gzip -6"
// It's not too expensive in elapsed time but it's not zero cost.
// GZip, large buffer.
out = new FileOutputStream(backupfile + ".gz");
out = new GZIPOutputStream(out, 8 * 1024);
out = new BufferedOutputStream(out);
} else {
out = new FileOutputStream(backupfile);
out = new BufferedOutputStream(out);
}
RDFDataMgr.write(out, dsg, Lang.NQUADS);
out.close();
out = null;
} catch (FileNotFoundException e) {
Log.warn(ActionBackup.class, "File not found: " + backupfile);
throw new FusekiException("File not found: " + backupfile);
} catch (IOException e) {
IO.exception(e);
} finally {
try {
if (out != null)
out.close();
} catch (IOException e) {
/* ignore */
}
}
}
use of org.apache.jena.fuseki.FusekiException in project jena by apache.
the class FusekiTestAuth method makeUserStore.
/** Very simple! */
private static UserStore makeUserStore(String user, String password, String role) {
Credential cred = new Password(password);
PropertyUserStore propertyUserStore = new PropertyUserStore();
String[] roles = role == null ? null : new String[] { role };
propertyUserStore.addUser(user, cred, roles);
try {
propertyUserStore.start();
} catch (Exception ex) {
throw new FusekiException("UserStore", ex);
}
return propertyUserStore;
}
use of org.apache.jena.fuseki.FusekiException in project jena by apache.
the class SPARQLServer method start.
/**
* Initialize the {@link SPARQLServer} instance.
*/
public void start() {
String now = DateTimeUtils.nowAsString();
serverLog.info(format("%s %s %s", Fuseki.NAME, Fuseki.VERSION, Fuseki.BUILD_DATE));
// This does not get set usefully for Jetty as we use it.
// String jettyVersion = org.eclipse.jetty.server.Server.getVersion() ;
// serverLog.info(format("Jetty %s",jettyVersion)) ;
String host = server.getConnectors()[0].getHost();
if (host != null)
serverLog.info("Incoming connections limited to " + host);
serverLog.info(format("Started %s on port %d", now, server.getConnectors()[0].getPort()));
try {
server.start();
} catch (java.net.BindException ex) {
serverLog.error("SPARQLServer: Failed to start server: " + ex.getMessage());
throw new FusekiException("BindException: port=" + server.getConnectors()[0].getPort() + ": Failed to start server: " + ex.getMessage(), ex);
} catch (Exception ex) {
serverLog.error("SPARQLServer: Failed to start server: " + ex.getMessage(), ex);
throw new FusekiException("Failed to start server: " + ex.getMessage(), ex);
}
ServletContextHandler context = (ServletContextHandler) server.getHandler();
}
use of org.apache.jena.fuseki.FusekiException in project jena by apache.
the class SPARQLServer method configServer.
private static Server configServer(String jettyConfig) {
try {
serverLog.info("Jetty server config file = " + jettyConfig);
Server server = new Server();
XmlConfiguration configuration = new XmlConfiguration(new FileInputStream(jettyConfig));
configuration.configure(server);
return server;
} catch (Exception ex) {
serverLog.error("SPARQLServer: Failed to configure server: " + ex.getMessage(), ex);
throw new FusekiException("Failed to configure a server using configuration file '" + jettyConfig + "'");
}
}
Aggregations