|
From: <tho...@us...> - 2014-03-10 21:15:10
|
Revision: 7921
http://sourceforge.net/p/bigdata/code/7921
Author: thompsonbry
Date: 2014-03-10 21:15:00 +0000 (Mon, 10 Mar 2014)
Log Message:
-----------
- The jetty.xml file has been moved to be outside of the WEB-INF
directory. All static content has been pushed down into an "html/"
directory of the webapp. I've added several tests to verify the
basic structure of the webapp.
- BigdataStatics.getContextPath() consolidates references to the
"/bigdata" context path for the web application. It should be
possible to override this using an environment variable when
deploying the redpoint skin.
- RemoteServiceCallImpl now uses a standard policy to follow
redirects. Not sure if this is strictly necessary, but you can
otherwise have a failure to resolve a URL such as
http://localhost:8080/ when you are being redirected to
http://localhost:8080/bigdata.
- Increased sanity in NanoSparqlServer.java.
- Added some unit tests to
com.bigdata.rdf.sail.webapp.TestNanoSparqlClient to verify correct
resolution of various bits of the web application as deployed under
test suite control.
- It looks like some environment variables were not being propagated
to the ServiceStarter in startHAServices (GROUPS, LOCATORS,
ZK_SERVERS).
{{{
# Laptop setup.
cd /Users/bryan/Documents/workspace/RDR_NEW_SVN
#svn update
ant clean stage
export wd=/Users/bryan/Documents/workspace/RDR_NEW_SVN
export FEDNAME=benchmark3
export LOGICAL_SERVICE_ID=HAJournal-1
export FED_DIR=$wd
export LOCATORS="jini://localhost"
export ZK_SERVERS="localhost:2081"
export JETTY_XML=${wd}/dist/bigdata/var/jetty/jetty.xml
export JETTY_WEB_XML=${wd}/dist/bigdata/var/jetty/WEB-INF/web.xml
export JETTY_PORT=8090
dist/bigdata/bin/startHAServices
tail -f HAJournalServer.log | egrep '(ERROR|WARN|FATAL)'
}}}
See #730 (Jetty.xml configuration)
Modified Paths:
--------------
branches/RDR/bigdata/src/java/com/bigdata/BigdataStatics.java
branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example1.java
branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example2.java
branches/RDR/bigdata-gom/src/test/com/bigdata/gom/Example1.java
branches/RDR/bigdata-gom/src/test/com/bigdata/gom/LocalGOMTestCase.java
branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java
branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java
branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java
branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java
branches/RDR/bigdata-perf/chem2bio2rdf/src/test/com/bigdata/perf/chem2bio2rdf/TestQuery.java
branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java
branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/remote/BigdataSailRemoteRepository.java
branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java
branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java
branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java
branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNanoSparqlServerTestCase.java
branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractProtocolTest.java
branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java
branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestFederatedQuery.java
branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlClient.java
branches/RDR/bigdata-war/src/WEB-INF/web.xml
branches/RDR/bigdata-war/src/html/index.html
branches/RDR/bigdata-war/src/html/new.html
branches/RDR/build.xml
branches/RDR/src/resources/bin/startHAServices
Added Paths:
-----------
branches/RDR/bigdata-war/src/html/favicon.ico
Removed Paths:
-------------
branches/RDR/bigdata-war/src/html/favicon.ico
Modified: branches/RDR/bigdata/src/java/com/bigdata/BigdataStatics.java
===================================================================
--- branches/RDR/bigdata/src/java/com/bigdata/BigdataStatics.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata/src/java/com/bigdata/BigdataStatics.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -80,5 +80,19 @@
*/
public static final boolean runKnownBadTests = Boolean
.getBoolean("com.bigdata.runKnownBadTests");
+
+ /**
+ * Return the web application context path for the default deployment of the
+ * bigdata web application.
+ *
+ * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/730" >
+ * Allow configuration of embedded NSS jetty server using jetty-web.xml
+ * </a>
+ */
+ public static final String getContextPath() {
+
+ return "/bigdata";
+
+ }
}
Modified: branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example1.java
===================================================================
--- branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example1.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example1.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -11,6 +11,7 @@
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
+import com.bigdata.BigdataStatics;
import com.bigdata.gom.gpo.IGPO;
import com.bigdata.gom.om.IObjectManager;
import com.bigdata.gom.om.NanoSparqlObjectManager;
@@ -82,7 +83,8 @@
/**
* The top-level SPARQL end point for a NanoSparqlServer instance.
*/
- final String sparqlEndpointURL = "http://localhost:8080/sparql/";
+ final String sparqlEndpointURL = "http://localhost:8080"
+ + BigdataStatics.getContextPath() + "/sparql/";
/**
* The namespace of the KB instance that you want to connect to on that
Modified: branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example2.java
===================================================================
--- branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example2.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-gom/src/samples/com/bigdata/gom/samples/Example2.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -18,6 +18,7 @@
import org.openrdf.model.vocabulary.RDFS;
import org.openrdf.query.BindingSet;
+import com.bigdata.BigdataStatics;
import com.bigdata.gom.gpo.IGPO;
import com.bigdata.gom.gpo.ILinkSet;
import com.bigdata.gom.om.IObjectManager;
@@ -288,7 +289,8 @@
/**
* The top-level SPARQL end point for a NanoSparqlServer instance.
*/
- final String sparqlEndpointURL = "http://localhost:8080/sparql/";
+ final String sparqlEndpointURL = "http://localhost:8080/"
+ + BigdataStatics.getContextPath() + "/sparql/";
/**
* The namespace of the KB instance that you want to connect to on that
Modified: branches/RDR/bigdata-gom/src/test/com/bigdata/gom/Example1.java
===================================================================
--- branches/RDR/bigdata-gom/src/test/com/bigdata/gom/Example1.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-gom/src/test/com/bigdata/gom/Example1.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -11,6 +11,7 @@
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
+import com.bigdata.BigdataStatics;
import com.bigdata.gom.gpo.IGPO;
import com.bigdata.gom.om.IObjectManager;
import com.bigdata.gom.om.NanoSparqlObjectManager;
@@ -82,7 +83,8 @@
/**
* The top-level SPARQL end point for a NanoSparqlServer instance.
*/
- final String sparqlEndpointURL = "http://localhost:8080/sparql/";
+ final String sparqlEndpointURL = "http://localhost:8080/"
+ + BigdataStatics.getContextPath() + "/sparql/";
/**
* The namespace of the KB instance that you want to connect to on that
Modified: branches/RDR/bigdata-gom/src/test/com/bigdata/gom/LocalGOMTestCase.java
===================================================================
--- branches/RDR/bigdata-gom/src/test/com/bigdata/gom/LocalGOMTestCase.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-gom/src/test/com/bigdata/gom/LocalGOMTestCase.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -29,7 +29,6 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
-import java.util.Iterator;
import java.util.Properties;
import junit.extensions.proxy.ProxyTestSuite;
@@ -37,26 +36,20 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
-import org.openrdf.model.Value;
import org.openrdf.model.ValueFactory;
-import org.openrdf.model.vocabulary.RDFS;
import org.openrdf.repository.RepositoryException;
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFParseException;
-import com.bigdata.bop.fed.QueryEngineFactory;
-import com.bigdata.gom.gpo.IGPO;
-import com.bigdata.gom.gpo.ILinkSet;
+import com.bigdata.BigdataStatics;
import com.bigdata.gom.om.IObjectManager;
import com.bigdata.gom.om.ObjectManager;
import com.bigdata.journal.BufferMode;
-import com.bigdata.journal.Journal;
import com.bigdata.journal.Journal.Options;
import com.bigdata.rdf.sail.BigdataSail;
import com.bigdata.rdf.sail.BigdataSailRepository;
import com.bigdata.rdf.sail.BigdataSailRepositoryConnection;
import com.bigdata.rdf.store.AbstractTripleStore;
-import com.bigdata.rwstore.TestRWJournal;
public class LocalGOMTestCase extends TestCase implements IGOMProxy {
@@ -67,7 +60,6 @@
protected ValueFactory m_vf;
protected IObjectManager om;
-
public LocalGOMTestCase() {
}
@@ -130,8 +122,9 @@
m_repo.initialize();
m_vf = m_sail.getValueFactory();
// Note: This uses a mock endpoint URL.
- om = new ObjectManager("http://localhost/sparql", m_repo);
-
+ om = new ObjectManager("http://localhost"
+ + BigdataStatics.getContextPath() + "/sparql", m_repo);
+
}
protected void tearDown() throws Exception {
Modified: branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java
===================================================================
--- branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -54,6 +54,7 @@
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFParseException;
+import com.bigdata.BigdataStatics;
import com.bigdata.gom.gpo.IGPO;
import com.bigdata.gom.gpo.ILinkSet;
import com.bigdata.gom.om.IObjectManager;
@@ -203,7 +204,8 @@
}
- m_serviceURL = new URL("http", hostAddr, port, "/sparql"/* file */)
+ m_serviceURL = new URL("http", hostAddr, port,
+ BigdataStatics.getContextPath() + "/sparql"/* file */)
.toExternalForm();
// final HttpClient httpClient = new DefaultHttpClient();
Modified: branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java
===================================================================
--- branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -52,6 +52,7 @@
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFParseException;
+import com.bigdata.BigdataStatics;
import com.bigdata.gom.gpo.IGPO;
import com.bigdata.gom.gpo.ILinkSet;
import com.bigdata.gom.om.IObjectManager;
@@ -173,7 +174,8 @@
}
- m_serviceURL = new URL("http", hostAddr, port, "/sparql"/* file */)
+ m_serviceURL = new URL("http", hostAddr, port,
+ BigdataStatics.getContextPath() + "/sparql"/* file */)
.toExternalForm();
// final HttpClient httpClient = new DefaultHttpClient();
Modified: branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java
===================================================================
--- branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -457,7 +457,7 @@
* deploying outside of that context, the value needs to be set
* explicitly.
*/
- String DEFAULT_JETTY_XML = "WEB-INF/jetty.xml";
+ String DEFAULT_JETTY_XML = "jetty.xml";
}
Modified: branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java
===================================================================
--- branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -61,6 +61,7 @@
import org.openrdf.query.BindingSet;
import org.openrdf.query.TupleQueryResult;
+import com.bigdata.BigdataStatics;
import com.bigdata.btree.BytesUtil;
import com.bigdata.ha.HAGlue;
import com.bigdata.ha.HAStatusEnum;
@@ -524,7 +525,8 @@
protected String getNanoSparqlServerURL(final HAGlue haGlue)
throws IOException {
- return "http://localhost:" + haGlue.getNSSPort();
+ return "http://localhost:" + haGlue.getNSSPort()
+ + BigdataStatics.getContextPath();
}
Modified: branches/RDR/bigdata-perf/chem2bio2rdf/src/test/com/bigdata/perf/chem2bio2rdf/TestQuery.java
===================================================================
--- branches/RDR/bigdata-perf/chem2bio2rdf/src/test/com/bigdata/perf/chem2bio2rdf/TestQuery.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-perf/chem2bio2rdf/src/test/com/bigdata/perf/chem2bio2rdf/TestQuery.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -8,6 +8,7 @@
import org.openrdf.query.GraphQueryResult;
import org.openrdf.query.TupleQueryResult;
+import com.bigdata.BigdataStatics;
import com.bigdata.rdf.sail.webapp.client.DefaultClientConnectionManagerFactory;
import com.bigdata.rdf.sail.webapp.client.IPreparedGraphQuery;
import com.bigdata.rdf.sail.webapp.client.IPreparedTupleQuery;
@@ -60,8 +61,9 @@
*/
public static void main(String[] args) throws Exception {
- final String serviceURL = "http://localhost:8080/sparql";
-
+ final String serviceURL = "http://localhost:8080"
+ + BigdataStatics.getContextPath() + "/sparql";
+
final HttpClient httpClient =
new DefaultHttpClient(DefaultClientConnectionManagerFactory.getInstance().newInstance());
Modified: branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java
===================================================================
--- branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -31,6 +31,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.openrdf.query.BindingSet;
import org.openrdf.query.QueryEvaluationException;
import org.openrdf.query.TupleQueryResult;
@@ -142,8 +143,14 @@
o.addRequestParam("queryId", queryId.toString());
- final RemoteRepository repo = new RemoteRepository(uriStr,
- new DefaultHttpClient(params.getClientConnectionManager()),
+ final DefaultHttpClient httpClient = new DefaultHttpClient(
+ params.getClientConnectionManager());
+
+ // Setup a standard strategy for following redirects.
+ httpClient.setRedirectStrategy(new DefaultRedirectStrategy());
+
+ final RemoteRepository repo = new RemoteRepository(uriStr,//
+ httpClient,//
params.getTripleStore().getExecutorService()
);
Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/remote/BigdataSailRemoteRepository.java
===================================================================
--- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/remote/BigdataSailRemoteRepository.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/remote/BigdataSailRemoteRepository.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -28,9 +28,9 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.openrdf.model.ValueFactory;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
@@ -76,8 +76,15 @@
this.ccm = DefaultClientConnectionManagerFactory.getInstance()
.newInstance();
- final HttpClient httpClient = new DefaultHttpClient(ccm);
+ final DefaultHttpClient httpClient = new DefaultHttpClient(ccm);
+ /*
+ * Enable a standard http redirect policy. This allows references to
+ * http://localhost:8080 to be redirected to
+ * http://localhost:8080/bigdata.
+ */
+ httpClient.setRedirectStrategy(new DefaultRedirectStrategy());
+
this.nss = new RemoteRepository(
sparqlEndpointURL, httpClient, executor);
Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java
===================================================================
--- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -72,6 +72,7 @@
import org.openrdf.rio.RDFWriterRegistry;
import org.openrdf.sail.SailException;
+import com.bigdata.BigdataStatics;
import com.bigdata.bop.BufferAnnotations;
import com.bigdata.bop.IPredicate;
import com.bigdata.bop.engine.IRunningQuery;
@@ -171,7 +172,8 @@
*
* @see #XSL_STYLESHEET
*/
- protected static final String DEFAULT_XSL_STYLESHEET = "/bigdata/html/result-to-html.xsl";
+ protected static final String DEFAULT_XSL_STYLESHEET = BigdataStatics
+ .getContextPath() + "/html/result-to-html.xsl";
/**
* URL Query parameter used to request an incremental XHTML representation
Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java
===================================================================
--- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -38,6 +38,7 @@
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
+import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource;
@@ -45,6 +46,7 @@
import org.eclipse.jetty.xml.XmlConfiguration;
import com.bigdata.Banner;
+import com.bigdata.BigdataStatics;
import com.bigdata.journal.IIndexManager;
import com.bigdata.journal.ITx;
import com.bigdata.journal.Journal;
@@ -76,6 +78,32 @@
* @todo Remote command to advance the read-behind point. This will let people
* bulk load a bunch of stuff before advancing queries to read from the
* new consistent commit point.
+ *
+ * @todo Note: There appear to be plenty of ways to setup JSP support for
+ * embedded jetty, and plenty of ways to get it wrong. I wound up adding
+ * to the classpath the following jars for jetty 7.2.2 to get this
+ * running:
+ *
+ * <pre>
+ * com.sun.el_1.0.0.v201004190952.jar
+ * ecj-3.6.jar
+ * javax.el_2.1.0.v201004190952.jar
+ * javax.servlet.jsp.jstl_1.2.0.v201004190952.jar
+ * javax.servlet.jsp_2.1.0.v201004190952.jar
+ * jetty-jsp-2.1-7.2.2.v20101205.jar
+ * org.apache.jasper.glassfish_2.1.0.v201007080150.jar
+ * org.apache.taglibs.standard.glassfish_1.2.0.v201004190952.jar
+ * </pre>
+ *
+ * Note: JSP pages for the servlet 2.5 specification add the following
+ * dependencies:
+ *
+ * <pre>
+ * ant-1.6.5.jar
+ * core-3.1.1.jar
+ * jsp-2.1.jar
+ * jsp-api-2.1.jar
+ * </pre>
*/
public class NanoSparqlServer {
@@ -349,16 +377,16 @@
final Server server = new Server(port);
- final ServletContextHandler context = getContextHandler(//server,
- initParams);
+ final ServletContextHandler context = getContextHandler(initParams);
- // Force the use of the caller's IIndexManager.
- context.setAttribute(IIndexManager.class.getName(), indexManager);
-
final ResourceHandler resourceHandler = new ResourceHandler();
setupStaticResources(NanoSparqlServer.class.getClassLoader(),
resourceHandler);
+
+ // same resource base.
+ context.setResourceBase(resourceHandler.getResourceBase());
+ context.setWelcomeFiles(resourceHandler.getWelcomeFiles());
final HandlerList handlers = new HandlerList();
@@ -369,11 +397,62 @@
});
server.setHandler(handlers);
-
+
+ // Force the use of the caller's IIndexManager.
+ context.setAttribute(IIndexManager.class.getName(), indexManager);
+
return server;
}
+
+ /**
+ * Variant used when the life cycle of the {@link IIndexManager} will be
+ * managed by the server - this form is used by {@link #main(String[])}.
+ * <p>
+ * Note: This is mostly a convenience for scripts that do not need to take
+ * over the detailed control of the jetty container and the bigdata webapp.
+ *
+ * @param port
+ * The port on which the service will run -OR- ZERO (0) for any
+ * open port.
+ * @param propertyFile
+ * The <code>.properties</code> file (for a standalone database
+ * instance) or the <code>.config</code> file (for a federation).
+ * @param initParams
+ * Initialization parameters for the web application as specified
+ * by {@link ConfigParams}.
+ *
+ * @return The server instance.
+ */
+ static public Server newInstance(final int port, final String propertyFileIsNotUsed,
+ final Map<String, String> initParams) throws Exception {
+ final Server server = new Server(port);
+
+ final ServletContextHandler context = getContextHandler(initParams);
+
+ final ResourceHandler resourceHandler = new ResourceHandler();
+
+ setupStaticResources(NanoSparqlServer.class.getClassLoader(),
+ resourceHandler);
+
+ // same resource base.
+ context.setResourceBase(resourceHandler.getResourceBase());
+ context.setWelcomeFiles(resourceHandler.getWelcomeFiles());
+
+ final HandlerList handlers = new HandlerList();
+
+ handlers.setHandlers(new Handler[] {//
+ context,// maps servlets
+ resourceHandler,// maps welcome files.
+ new DefaultHandler() // responsible for anything not explicitly served.
+ });
+
+ server.setHandler(handlers);
+
+ return server;
+ }
+
/**
* Variant used when you already have the {@link IIndexManager} on hand and
* want to use <code>web.xml</code> to configure the {@link WebAppContext}
@@ -404,11 +483,14 @@
final URL jettyXmlUrl;
if (new File(jettyXml).exists()) {
+ // Check the file system.
jettyXmlUrl = new URL("file://" + jettyXml);
} else {
- jettyXmlUrl = getStaticResourceURL(classLoader, jettyXml);
+ // Check the classpath.
+ jettyXmlUrl = classLoader.getResource(jettyXml);
+// jettyXmlUrl = classLoader.getResource("bigdata-war/src/jetty.xml");
}
@@ -500,74 +582,6 @@
}
/**
- * Variant used when the life cycle of the {@link IIndexManager} will be
- * managed by the server - this form is used by {@link #main(String[])}.
- * <p>
- * Note: This is mostly a convenience for scripts that do not need to take
- * over the detailed control of the jetty container and the bigdata webapp.
- *
- * @param port
- * The port on which the service will run -OR- ZERO (0) for any
- * open port.
- * @param propertyFile
- * The <code>.properties</code> file (for a standalone database
- * instance) or the <code>.config</code> file (for a federation).
- * @param initParams
- * Initialization parameters for the web application as specified
- * by {@link ConfigParams}.
- *
- * @return The server instance.
- */
- static public Server newInstance(final int port, final String propertyFile,
- final Map<String, String> initParams) throws Exception {
-
- final Server server = new Server(port);
-
- final ServletContextHandler context = getContextHandler(//server,
- initParams);
-
- final ResourceHandler resourceHandler = new ResourceHandler();
-
- setupStaticResources(NanoSparqlServer.class.getClassLoader(),
- resourceHandler);
-
- /**
- * Note: There appear to be plenty of ways to setup JSP support for
- * embedded jetty, and plenty of ways to get it wrong. I wound up adding
- * to the classpath the following jars for jetty 7.2.2 to get this
- * running:
- *
- * <pre>
- * com.sun.el_1.0.0.v201004190952.jar
- * ecj-3.6.jar
- * javax.el_2.1.0.v201004190952.jar
- * javax.servlet.jsp.jstl_1.2.0.v201004190952.jar
- * javax.servlet.jsp_2.1.0.v201004190952.jar
- * jetty-jsp-2.1-7.2.2.v20101205.jar
- * org.apache.jasper.glassfish_2.1.0.v201007080150.jar
- * org.apache.taglibs.standard.glassfish_1.2.0.v201004190952.jar
- * </pre>
- *
- * With those jars on the class path, the following code will run
- * JSP pages.
- *
- * Note: In order for this to work, it must also be supported in the
- * alternative newInstance() method above.
- */
- final HandlerList handlers = new HandlerList();
-
- handlers.setHandlers(new Handler[] {//
- context,// maps servlets
- resourceHandler,// maps welcome files.
- new DefaultHandler() // responsible for anything not explicitly served.
- });
-
- server.setHandler(handlers);
-
- return server;
- }
-
- /**
* Construct a {@link ServletContextHandler}.
* <p>
* Note: The {@link ContextHandler} uses the longest prefix of the request
@@ -580,7 +594,6 @@
* The init parameters, per the web.xml definition.
*/
static private ServletContextHandler getContextHandler(
-// final Server server,
final Map<String, String> initParams) throws Exception {
if (initParams == null)
@@ -592,13 +605,8 @@
);
// Path to the webapp.
- context.setContextPath("/bigdata");
-
-// /*
-// * Setup resolution for the static web app resources (index.html).
-// */
-// setupStaticResources(server, context);
-
+ context.setContextPath(BigdataStatics.getContextPath());
+
/*
* Register a listener which will handle the life cycle events for the
* ServletContext.
@@ -638,6 +646,14 @@
}
+ // html directory.
+ context.addServlet(new ServletHolder(new DefaultServlet()),
+ "/html/*");
+
+ // Appears necessary for http://localhost:8080/bigdata to bring up index.html.
+ context.addServlet(new ServletHolder(new DefaultServlet()),
+ "/");
+
// Performance counters.
context.addServlet(new ServletHolder(new CountersServlet()),
"/counters");
@@ -651,25 +667,11 @@
// Multi-Tenancy API.
context.addServlet(new ServletHolder(new MultiTenancyServlet()),
"/namespace/*");
-
+
// Incremental truth maintenance
context.addServlet(new ServletHolder(new InferenceServlet()),
"/inference");
- /**
- * Note: JSP pages for the servlet 2.5 specification add the following
- * dependencies:
- *
- * <pre>
- * ant-1.6.5.jar
- * core-3.1.1.jar
- * jsp-2.1.jar
- * jsp-api-2.1.jar
- * </pre>
- *
- * @see http://docs.codehaus.org/display/JETTY/Embedding+Jetty
- */
-
// context.setResourceBase("bigdata-war/src/html");
//
// context.setWelcomeFiles(new String[]{"index.html"});
@@ -716,21 +718,45 @@
context.setDirectoriesListed(false); // Nope!
- final String file = "index.html";
+ final String file = "html/index.html";
- final URL url = getStaticResourceURL(classLoader, file);
+ final URL url;
+ {
- if (url == null)
- throw new RuntimeException("Could not locate file: " + file);
+ URL tmp = null;
+
+ if (tmp == null) {
+// // project local file system path.
+// classLoader.getResource("bigdata-war/src/html/" + file);
+
+ }
+
+ if (tmp == null) {
+
+ // Check the classpath.
+ tmp = classLoader.getResource(file);
+
+ }
+
+ url = tmp;
+
+ if (url == null) {
+
+ throw new RuntimeException("Could not locate index.html");
+
+ }
+
+ }
+
/*
* We have located the resource. Set it as the resource base from which
* static content will be served.
*/
- final String indexHtml = url.toExternalForm();
+ final String indexHtmlUrl = url.toExternalForm();
- final String webDir = indexHtml.substring(0,
- indexHtml.length() - file.length());
+ final String webDir = indexHtmlUrl.substring(0, indexHtmlUrl.length()
+ - file.length());
// Path to the content in the local file system or JAR.
context.setResourceBase(webDir);
@@ -739,65 +765,69 @@
* Note: replace with "new.html" for the new UX. Also change in
* web.xml.
*/
- context.setWelcomeFiles(new String[]{"index.html"});
+ context.setWelcomeFiles(new String[]{"html/index.html"});
+ if (log.isInfoEnabled())
+ log.info("\nindex.html: =" + indexHtmlUrl + "\nresourceBase="
+ + webDir);
+
}
- /**
- * Return the URL for the static web app resources (for example,
- * <code>index.html</code>).
- *
- * @param classLoader
- * The {@link ClassLoader} that will be used to locate the
- * resource (required).
- * @param path
- * The path for the resource (required)
- *
- * @return The URL for the web app resource directory -or- <code>null</code>
- * if it could not be found on the class path.
- *
- * @see https://sourceforge.net/apps/trac/bigdata/ticket/330
- */
- private static URL getStaticResourceURL(final ClassLoader classLoader,
- final String path) {
+// /**
+// * Return the URL for the static web app resources (for example,
+// * <code>index.html</code>).
+// *
+// * @param classLoader
+// * The {@link ClassLoader} that will be used to locate the
+// * resource (required).
+// * @param path
+// * The path for the resource (required)
+// *
+// * @return The URL for the web app resource directory -or- <code>null</code>
+// * if it could not be found on the class path.
+// *
+// * @see https://sourceforge.net/apps/trac/bigdata/ticket/330
+// */
+// private static URL getStaticResourceURL(final ClassLoader classLoader,
+// final String path) {
+//
+// if (classLoader == null)
+// throw new IllegalArgumentException();
+//
+// if (path == null)
+// throw new IllegalArgumentException();
+//
+// /*
+// * This is the resource path in the JAR.
+// */
+// final String WEB_DIR_JAR = "bigdata-war/src/html"
+// + (path == null ? "" : "/" + path);
+//
+// /*
+// * This is the resource path in the IDE when NOT using the JAR.
+// *
+// * Note: You MUST have "bigdata-war/src" on the build path for the IDE.
+// */
+// final String WEB_DIR_IDE = "html/" + path; // "html";
+//
+// URL url = classLoader.getResource(WEB_DIR_JAR);
+//
+// if (url == null && path != null) {
+//
+// url = classLoader.getResource(WEB_DIR_IDE);// "html");
+//
+// }
+//
+// if (url == null) {
+//
+// log.error("Could not locate: " + WEB_DIR_JAR + ", " + WEB_DIR_IDE
+// + ", -or- " + path);
+// }
+//
+// return url;
+//
+// }
- if (classLoader == null)
- throw new IllegalArgumentException();
-
- if (path == null)
- throw new IllegalArgumentException();
-
- /*
- * This is the resource path in the JAR.
- */
- final String WEB_DIR_JAR = "bigdata-war/src/html"
- + (path == null ? "" : "/" + path);
-
- /*
- * This is the resource path in the IDE when NOT using the JAR.
- *
- * Note: You MUST have "bigdata-war/src" on the build path for the IDE.
- */
- final String WEB_DIR_IDE = "html/" + path; // "html";
-
- URL url = classLoader.getResource(WEB_DIR_JAR);
-
- if (url == null && path != null) {
-
- url = classLoader.getResource(WEB_DIR_IDE);// "html");
-
- }
-
- if (url == null) {
-
- log.error("Could not locate: " + WEB_DIR_JAR + ", " + WEB_DIR_IDE
- + ", -or- " + path);
- }
-
- return url;
-
- }
-
/**
* Print the optional message on stderr, print the usage information on
* stderr, and then force the program to exit with the given status code.
Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java
===================================================================
--- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -1497,7 +1497,7 @@
}
- static protected HttpUriRequest newRequest(final String uri,
+ static public HttpUriRequest newRequest(final String uri,
final String method) {
if (method.equals("GET")) {
return new HttpGet(uri);
@@ -1547,6 +1547,7 @@
}
+ // TODO EntityUtils.toString(response.getEntity())?
protected static String getResponseBody(final HttpResponse response)
throws IOException {
Modified: branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNanoSparqlServerTestCase.java
===================================================================
--- branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNanoSparqlServerTestCase.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNanoSparqlServerTestCase.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -78,7 +78,8 @@
protected String m_serviceURL;
/**
- * The request path for the REST API under test.
+ * The request path for the REST API under test (does not include the
+ * ContextPath).
*/
protected static final String requestPath = "/sparql";
Modified: branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractProtocolTest.java
===================================================================
--- branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractProtocolTest.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractProtocolTest.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -42,6 +42,7 @@
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
+import com.bigdata.BigdataStatics;
import com.bigdata.journal.IIndexManager;
import com.bigdata.rdf.sail.webapp.client.ConnectOptions;
import com.bigdata.rdf.sail.webapp.client.DefaultClientConnectionManagerFactory;
@@ -91,11 +92,15 @@
private String accept = null;
private boolean permit400s = false;
+ private final String getSparqlURL(final String serviceURL) {
+ return serviceURL + "/sparql";
+ }
+
private final RequestFactory GET = new RequestFactory(){
@Override
public HttpUriRequest createRequest(String... params) {
- final StringBuffer url = new StringBuffer(m_serviceURL);
- url.append("/sparql");
+ final StringBuffer url = new StringBuffer();
+ url.append(getSparqlURL(m_serviceURL));
char sep = '?';
for (int i=0;i<params.length;i+=2) {
url.append(sep);
@@ -184,7 +189,7 @@
* @return the data returned by the server.
* @throws IOException
*/
- protected String serviceRequest(String ... paramValues) throws IOException {
+ protected String serviceRequest(final String ... paramValues) throws IOException {
HttpUriRequest req;
responseContentType = null;
try {
@@ -244,7 +249,7 @@
requestFactory = new RequestFactory(){
@Override
public HttpUriRequest createRequest(String... params) {
- final HttpPost rslt = new HttpPost(m_serviceURL+"/sparql");
+ final HttpPost rslt = new HttpPost(getSparqlURL(m_serviceURL));
try {
rslt.setEntity(ConnectOptions.getFormEntity(pairs2map(params)));
} catch (final Exception e) {
@@ -272,8 +277,8 @@
@Override
public HttpUriRequest createRequest(String... params) {
- final StringBuffer url = new StringBuffer(m_serviceURL);
- url.append("/sparql");
+ final StringBuffer url = new StringBuffer();
+ url.append(getSparqlURL(m_serviceURL));
char sep = '?';
for (int i=0;i<params.length;i+=2) {
url.append(sep);
Modified: branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java
===================================================================
--- branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -41,6 +41,7 @@
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.eclipse.jetty.server.Server;
import org.openrdf.model.Graph;
import org.openrdf.model.Literal;
@@ -71,6 +72,7 @@
import org.openrdf.rio.helpers.StatementCollector;
import org.openrdf.sail.SailException;
+import com.bigdata.BigdataStatics;
import com.bigdata.journal.IIndexManager;
import com.bigdata.journal.ITx;
import com.bigdata.journal.Journal;
@@ -123,16 +125,33 @@
*/
private ClientConnectionManager m_cm;
+ /**
+ * Exposed to tests that do direct HTTP GET/POST operations.
+ */
+ protected HttpClient m_httpClient = null;
+
/**
* The client-API wrapper to the NSS.
*/
protected RemoteRepositoryManager m_repo;
/**
- * The effective {@link NanoSparqlServer} http end point.
- */
+ * The effective {@link NanoSparqlServer} http end point (including the
+ * ContextPath).
+ */
protected String m_serviceURL;
+ /**
+ * The URL of the root of the web application server. This does NOT include
+ * the ContextPath for the webapp.
+ *
+ * <pre>
+ * http://localhost:8080 -- root URL
+ * http://localhost:8080/bigdata -- webapp URL (includes "/bigdata" context path.
+ * </pre>
+ */
+ protected String m_rootURL;
+
// /**
// * The request path for the REST API under test.
// */
@@ -275,14 +294,16 @@
}
- m_serviceURL = new URL("http", hostAddr, port, //
- "" // file
-// "/sparql/"// file
+ m_rootURL = new URL("http", hostAddr, port, ""/* contextPath */
).toExternalForm();
+ m_serviceURL = new URL("http", hostAddr, port,
+ BigdataStatics.getContextPath()).toExternalForm();
+
if (log.isInfoEnabled())
- log.info("Setup done: name=" + getName() + ", namespace="
- + namespace + ", serviceURL=" + m_serviceURL);
+ log.info("Setup done: \nname=" + getName() + "\nnamespace="
+ + namespace + "\nrootURL=" + m_rootURL + "\nserviceURL="
+ + m_serviceURL);
// final HttpClient httpClient = new DefaultHttpClient();
@@ -291,8 +312,20 @@
m_cm = DefaultClientConnectionManagerFactory.getInstance()
.newInstance();
+ final DefaultHttpClient httpClient = new DefaultHttpClient(m_cm);
+ m_httpClient = httpClient;
+
+ /*
+ * Ensure that the client follows redirects using a standard policy.
+ *
+ * Note: This is necessary for tests of the webapp structure since the
+ * container may respond with a redirect (302) to the location of the
+ * webapp when the client requests the root URL.
+ */
+ httpClient.setRedirectStrategy(new DefaultRedirectStrategy());
+
m_repo = new RemoteRepositoryManager(m_serviceURL,
- new DefaultHttpClient(m_cm),
+ m_httpClient,
m_indexManager.getExecutorService());
}
@@ -333,12 +366,18 @@
}
- m_repo = null;
-
- log.info("tear down done");
-
- super.tearDown();
+ m_httpClient = null;
+
+ m_repo = null;
+ m_serviceURL = null;
+
+ m_rootURL = null;
+
+ log.info("tear down done");
+
+ super.tearDown();
+
}
/**
Modified: branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestFederatedQuery.java
===================================================================
--- branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestFederatedQuery.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestFederatedQuery.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -106,6 +106,7 @@
import org.openrdf.rio.helpers.StatementCollector;
import org.openrdf.sail.SailException;
+import com.bigdata.BigdataStatics;
import com.bigdata.journal.IIndexManager;
import com.bigdata.rdf.sail.BigdataSail;
import com.bigdata.rdf.sail.BigdataSailRepository;
@@ -214,8 +215,9 @@
protected String getRepositoryUrlBase() {
- return m_serviceURL + requestPath + "/namespace/" + namespace + "_";
-
+ return m_serviceURL + BigdataStatics.getContextPath() + requestPath
+ + "/namespace/" + namespace + "_";
+
}
/**
Modified: branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlClient.java
===================================================================
--- branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlClient.java 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlClient.java 2014-03-10 21:15:00 UTC (rev 7921)
@@ -26,10 +26,17 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Map;
import junit.framework.Test;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.util.EntityUtils;
import org.openrdf.model.Graph;
import org.openrdf.model.Literal;
import org.openrdf.model.Resource;
@@ -50,6 +57,8 @@
import org.openrdf.rio.RDFWriterRegistry;
import com.bigdata.journal.IIndexManager;
+import com.bigdata.rdf.sail.webapp.client.ConnectOptions;
+import com.bigdata.rdf.sail.webapp.client.HttpException;
import com.bigdata.rdf.sail.webapp.client.IPreparedBooleanQuery;
import com.bigdata.rdf.sail.webapp.client.IPreparedGraphQuery;
import com.bigdata.rdf.sail.webapp.client.IPreparedTupleQuery;
@@ -77,15 +86,381 @@
}
public static Test suite() {
- return ProxySuiteHelper.suiteWhenStandalone(TestNanoSparqlClient.class, "test.*DELETE.*", TestMode.quads,TestMode.sids,TestMode.triples);
+
+ return ProxySuiteHelper.suiteWhenStandalone(TestNanoSparqlClient.class,
+ "test.*DELETE.*", TestMode.quads, TestMode.sids,
+ TestMode.triples);
+
}
+
public void test_startup() throws Exception {
assertTrue("open", m_fixture.isRunning());
}
-
+
+ /*
+ * Verify the correct structure of the webapp.
+ *
+ * TODO There should be tests here to verify that we do not allow listing of
+ * the directory contents in the web application. This appears to be allowed
+ * by default and we do not test to ensure that this option is disabled. E.g.
+ *
+ * http://172.16.0.185:8090/bigdata/html/
+ *
+ * might list the directory contents.
+ */
+
/**
+ * A marker placed into index.html so we can recognize when that page is
+ * served.
+ */
+ private static final String JUNIT_TEST_MARKER_INDEX_HTML = "junit test marker: index.html";
+
+ /**
+ * bare URL of the server
+ *
+ * <pre>
+ * http://localhost:8080
+ * </pre>
+ *
+ * The response is should be <code>index.html</code> since we want the
+ * bigdata webapp to respond for the top-level context.
+ *
+ * <p>
+ * Note: You must ensure that the client follows redirects using a standard
+ * policy. This is necessary for tests of the webapp structure since the
+ * container may respond with a redirect (302) to the location of the webapp
+ * when the client requests the root URL.
+ */
+ public void test_webapp_structure_rootURL() throws Exception {
+
+ final String content = doGET(m_rootURL);
+
+ assertTrue(content.contains(JUNIT_TEST_MARKER_INDEX_HTML));
+
+ }
+
+ /**
+ * URL with correct context path
+ *
+ * <pre>
+ * http://localhost:8080/bigdata
+ * </pre>
+ *
+ * The response is should be <code>index.html</code>, which is specified
+ * through the welcome files list.
+ */
+ public void test_webapp_structure_contextPath() throws Exception {
+
+ final String content = doGET(m_serviceURL);
+
+ assertTrue(content.contains(JUNIT_TEST_MARKER_INDEX_HTML));
+ }
+
+ /**
+ * URL with context path and index.html reference
+ *
+ * <pre>
+ * http://localhost:8080/bigdata/index.html
+ * </pre>
+ *
+ * This URL does NOT get mapped to anything (404).
+ */
+ public void test_webapp_structure_contextPath_indexHtml() throws Exception {
+
+ try {
+
+ doGET(m_serviceURL + "/index.html");
+
+ } catch (HttpException ex) {
+
+ assertEquals(404, ex.getStatusCode());
+
+ }
+
+ }
+
+ /**
+ * The <code>favicon.ico</code> file.
+ *
+ * @see <a href="http://www.w3.org/2005/10/howto-favicon"> How to add a
+ * favicon </a>
+ */
+ public void test_webapp_structure_favicon() throws Exception {
+
+ doGET(m_serviceURL + "/html/favicon.ico");
+
+ }
+
+ /**
+ * The <code>/status</code> servlet responds.
+ */
+ public void test_webapp_structure_status() throws Exception {
+
+ doGET(m_serviceURL + "/status");
+
+ }
+
+ /**
+ * The <code>/counters</code> servlet responds.
+ */
+ public void test_webapp_structure_counters() throws Exception {
+
+ doGET(m_serviceURL + "/counters");
+
+ }
+
+// /**
+// * The <code>/namespace/</code> servlet responds (multi-tenancy API).
+// */
+// public void test_webapp_structure_namespace() throws Exception {
+//
+// doGET(m_serviceURL + "/namespace/");
+//
+// }
+
+ /**
+ * The fully qualified URL for <code>index.html</code>
+ *
+ * <pre>
+ * http://localhost:8080/bigdata/html/index.html
+ * </pre>
+ *
+ * The response is should be <code>index.html</code>, which is specified
+ * through the welcome files list.
+ */
+ public void test_webapp_structure_contextPath_html_indexHtml() throws Exception {
+
+ doGET(m_serviceURL + "/html/index.html");
+ }
+
+ private String doGET(final String url) throws Exception {
+
+ HttpResponse response = null;
+ HttpEntity entity = null;
+
+ try {
+
+ final ConnectOptions opts = new ConnectOptions(url);
+ opts.method = "GET";
+
+ response = doConnect(opts);
+
+ checkResponseCode(url, response);
+
+ entity = response.getEntity();
+
+ final String content = EntityUtils.toString(response.getEntity());
+
+ return content;
+
+ } finally {
+
+ try {
+ EntityUtils.consume(entity);
+ } catch (IOException ex) {
+ }
+
+ }
+
+ }
+
+ /**
+ * Throw an exception if the status code does not indicate success.
+ *
+ * @param response
+ * The response.
+ *
+ * @return The response.
+ *
+ * @throws IOException
+ */
+ private static HttpResponse checkResponseCode(final String url,
+ final HttpResponse response) throws IOException {
+
+ final int rc = response.getStatusLine().getStatusCode();
+
+ if (rc < 200 || rc >= 300) {
+ throw new HttpException(rc, "StatusCode=" + rc + ", StatusLine="
+ + response.getStatusLine() + ", headers="
+ + Arrays.toString(response.getAllHeaders())
+ + ", ResponseBody="
+ + EntityUtils.toString(response.getEntity()));
+
+ }
+
+ if (log.isDebugEnabled()) {
+ /*
+ * write out the status list, headers, etc.
+ */
+ log.debug("*** Response ***");
+ log.debug("Status Line: " + response.getStatusLine());
+ }
+
+ return response;
+
+ }
+
+ /**
+ * Connect to a SPARQL end point (GET or POST query only).
+ *
+ * @param opts
+ * The connection options.
+ *
+ * @return The connection.
+ *
+ * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/619">
+ * RemoteRepository class should use application/x-www-form-urlencoded
+ * for large POST requests </a>
+ */
+ private HttpResponse doConnect(final ConnectOptions opts) throws Exception {
+
+ /*
+ * Generate the fully formed and encoded URL.
+ */
+
+ final StringBuilder urlString = new StringBuilder(opts.serviceURL);
+
+ ConnectOptions.addQueryParams(urlString, opts.requestParams);
+
+ final boolean isLongRequestURL = urlString.length() > 1024;
+
+ if (isLongRequestURL && opts.method.equals("POST")
+ && opts.entity == null) {
+
+ /*
+ * URL is too long. Reset the URL to just the service endpoint and
+ * use application/x-www-form-urlencoded entity instead. Only in
+ * cases where there is not already a request entity (SPARQL query
+ * and SPARQL update).
+ */
+
+ urlString.setLength(0);
+ urlString.append(opts.serviceURL);
+
+ opts.entity = ConnectOptions.getFormEntity(opts.requestParams);
+
+ } else if (isLongRequestURL && opts.method.equals("GET")
+ && opts.entity == null) {
+
+ /*
+ * Convert automatically to a POST if the request URL is too long.
+ *
+ * Note: [opts.entity == null] should always be true for a GET so
+ * this bit is a paranoia check.
+ */
+
+ opts.method = "POST";
+
+ urlString.setLength(0);
+ urlString.append(opts.serviceURL);
+
+ opts.entity = ConnectOptions.getFormEntity(opts.requestParams);
+
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("*** Request ***");
+ log.debug(opts.serviceURL);
+ log.debug(opts.method);
+ log.debug("query=" + opts.getRequestParam("query"));
+ log.debug(urlString.toString());
+ }
+
+ HttpUriRequest request = null;
+ try {
+
+ request = RemoteRepository.newRequest(urlString.toString(), opts.method);
+
+ if (opts.requestHeaders != null) {
+
+ for (Map.Entry<String, String> e : opts.requestHeaders
+ .entrySet()) {
+
+ request.addHeader(e.getKey(), e.getValue());
+
+ if (log.isDebugEnabled())
+ log.debug(e.getKey() + ": " + e.getValue());
+
+ }
+
+ }
+
+// // conn = doConnect(urlString.toString(), opts.method);
+// final URL url = new URL(urlString.toString());
+// conn = (HttpURLConnection) url.openConnection();
+// conn.setRequestMethod(opts.method);
+// conn.setDoOutput(true);
+// conn.setDoInput(true);
+// conn.setUseCaches(false);
+// conn.setReadTimeout(opts.timeout);
+// conn.setRequestProperty("Accept", opts.acceptHeader);
+// if (log.isDebugEnabled())
+// log.debug("Accept: " + opts.acceptHeader);
+
+ if (opts.entity != null) {
+
+// if (opts.data == null)
+// throw new AssertionError();
+
+// final String contentLength = Integer.toString(opts.data.length);
+
+// conn.setRequestProperty("Content-Type", opts.contentType);
+// conn.setRequestProperty("Content-Length", contentLength);
+
+// if (log.isDebugEnabled()) {
+// log.debug("Content-Type: " + opts.contentType);
+// log.debug("Content-Length: " + contentLength);
+// }
+
+// final ByteArrayEntity entity = new ByteArrayEntity(opts.data);
+// entity.setContentType(opts.contentType);
+
+ ((HttpEntityEnclosingRequestBase) request).setEntity(opts.entity);
+
+// final OutputStream os = conn.getOutputStream();
+// try {
+// os.write(opts.data);
+// os.flush();
+// } finally {
+// os.close();
+// }
+
+ }
+
+ final HttpResponse response = m_httpClient.execute(request);
+
+ return response;
+
+// // connect.
+// conn.connect();
+//
+// return conn;
+
+ } catch (Throwable t) {
+ /*
+ * If something goes wrong, then close the http connection.
+ * Otherwise, the connection will be closed by the caller.
+ */
+ try {
+
+ if (request != null)
+ request.abort();
+
+// // clean up the connection resources
+// if (conn != null)
+// conn.disconnect();
+
+ } catch (Throwable t2) {
+ // ignored.
+ }
+ throw new RuntimeException(opts.serviceURL + " : " + t, t);
+ }
+
+ }
+
+ /**
* Request the SPARQL SERVICE DESCRIPTION for the end point.
*/
public void test_SERVICE_DESCRIPTION() throws Exception {
Modified: branches/RDR/bigdata-war/src/WEB-INF/web.xml
===================================================================
--- branches/RDR/bigdata-war/src/WEB-INF/web.xml 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-war/src/WEB-INF/web.xml 2014-03-10 21:15:00 UTC (rev 7921)
@@ -89,8 +89,8 @@
</welcome-file-list>
<!-- Serve anything under /html/* as a simple file. -->
<servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>/html/*</url-pattern>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/html/*</url-pattern>
</servlet-mapping>
<!-- Mapping for the default KB namespace (as configured above). -->
<servlet-mapping>
Deleted: branches/RDR/bigdata-war/src/html/favicon.ico
===================================================================
(Binary files differ)
Added: branches/RDR/bigdata-war/src/html/favicon.ico
===================================================================
--- branches/RDR/bigdata-war/src/html/favicon.ico (rev 0)
+++ branches/RDR/bigdata-war/src/html/favicon.ico 2014-03-10 21:15:00 UTC (rev 7921)
@@ -0,0 +1,3 @@
++UX dB&3$.Ae\ No newline at end of file
Modified: branches/RDR/bigdata-war/src/html/index.html
===================================================================
--- branches/RDR/bigdata-war/src/html/index.html 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-war/src/html/index.html 2014-03-10 21:15:00 UTC (rev 7921)
@@ -1,10 +1,14 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
-<head>
+<head profile="http://www.w3.org/2005/10/profile">
+<link rel="icon"
+ type="image/png"
+ href="/bigdata/html/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>bigdata® NanoSparqlServer</title>
<!-- $Id$ -->
+<!-- junit test marker: index.html -->
</head>
<body>
Modified: branches/RDR/bigdata-war/src/html/new.html
===================================================================
--- branches/RDR/bigdata-war/src/html/new.html 2014-03-08 16:03:33 UTC (rev 7920)
+++ branches/RDR/bigdata-war/src/html/new.html 2014-03-10 21:15:00 UTC (rev 7921)
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8">
+ <head profile="http://www.w3.org/2005/10/profile">
+ <link rel="icon"
+ type="image/png"
+ href="/bigdata/html/favicon.ico" />
+ <!-- meta charset="utf-8" -->
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>Bigdata Workbench</title>
<link re...
[truncated message content] |