Search in sources :

Example 11 with FusekiException

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 */
        }
    }
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) FusekiException(org.apache.jena.fuseki.FusekiException) GZIPOutputStream(java.util.zip.GZIPOutputStream)

Example 12 with FusekiException

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;
}
Also used : Credential(org.eclipse.jetty.util.security.Credential) FusekiException(org.apache.jena.fuseki.FusekiException) HttpException(org.apache.jena.atlas.web.HttpException) FusekiException(org.apache.jena.fuseki.FusekiException) Password(org.eclipse.jetty.util.security.Password)

Example 13 with FusekiException

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();
}
Also used : FusekiException(org.apache.jena.fuseki.FusekiException) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) FusekiException(org.apache.jena.fuseki.FusekiException)

Example 14 with FusekiException

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 + "'");
    }
}
Also used : Server(org.eclipse.jetty.server.Server) FusekiException(org.apache.jena.fuseki.FusekiException) XmlConfiguration(org.eclipse.jetty.xml.XmlConfiguration) FileInputStream(java.io.FileInputStream) FusekiException(org.apache.jena.fuseki.FusekiException)

Aggregations

FusekiException (org.apache.jena.fuseki.FusekiException)14 FileInputStream (java.io.FileInputStream)2 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 Server (org.eclipse.jetty.server.Server)2 XmlConfiguration (org.eclipse.jetty.xml.XmlConfiguration)2 HttpServlet (javax.servlet.http.HttpServlet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HttpException (org.apache.jena.atlas.web.HttpException)1 MediaType (org.apache.jena.atlas.web.MediaType)1 IRI (org.apache.jena.iri.IRI)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 Credential (org.eclipse.jetty.util.security.Credential)1 Password (org.eclipse.jetty.util.security.Password)1 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)1 Test (org.junit.Test)1