cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Refactored handling of static resources.
Date Tue, 23 Sep 2014 14:45:39 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 6fda6440b -> 64f232307


CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Refactored
handling of static resources.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/64f23230
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/64f23230
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/64f23230

Branch: refs/heads/master
Commit: 64f232307444269286b7f14fc3838b07187d4c03
Parents: 6fda644
Author: reta <drreta@gmail.com>
Authored: Tue Sep 23 10:45:24 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Tue Sep 23 10:45:24 2014 -0400

----------------------------------------------------------------------
 .../release/samples/jax_rs/search/README.txt    | 18 ++++++-------
 .../java/demo/jaxrs/search/client/Client.java   |  2 +-
 .../java/demo/jaxrs/search/server/Server.java   | 28 +++++++++-----------
 .../src/main/resources/browser/index.html       |  4 +--
 4 files changed, 24 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/64f23230/distribution/src/main/release/samples/jax_rs/search/README.txt
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/README.txt b/distribution/src/main/release/samples/jax_rs/search/README.txt
index 863071b..1eaf01e 100644
--- a/distribution/src/main/release/samples/jax_rs/search/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/search/README.txt
@@ -4,10 +4,10 @@ JAX-RS Search Demo
 The demo shows a basic usage of search extension with REST based Web Services using 
 JAX-RS 2.0 (JSR-339). The REST server provides the following services: 
 
-A RESTful catalog service is provided on URL http://localhost:9000/jaxrs/catalog 
-A web browser demo is available at: http://localhost:9000/catalog
+A RESTful catalog service is provided on URL http://localhost:9000/catalog 
+A web browser demo is available at: http://localhost:9000/
 
-A HTTP GET request to URL http://localhost:9000/jaxrs/catalog
+A HTTP GET request to URL http://localhost:9000/catalog
 returns all the documents currently stored and managed (in JSON format):
 
 [
@@ -15,29 +15,29 @@ returns all the documents currently stored and managed (in JSON format):
     "JavaWebSocketAPI_1.0_Final.pdf"
 ]
 
-A HTTP POST request to URL http://localhost:9000/jaxrs/catalog
+A HTTP POST request to URL http://localhost:9000/catalog
 uploads document and stores it.
 
-A HTTP GET request to URL http://localhost:9000/jaxrs/catalog/search?$filter=<query>
+A HTTP GET request to URL http://localhost:9000/catalog/search?$filter=<query>
 searches the relevant documents which match the query and returns them (in JSON format):
 
 [
     {
         "source":"JavaWebSocketAPI_1.0_Final.pdf",
         "score":0.07321092486381531,
-        "url":"http://localhost:9000/jaxrs/catalog/JavaWebSocketAPI_1.0_Final.pdf"
+        "url":"http://localhost:9000/catalog/JavaWebSocketAPI_1.0_Final.pdf"
     },
     {
         "source":"jsr339-jaxrs-2.0-final-spec.pdf",
         "score":0.03448590263724327,
-        "url":"http://localhost:9000/jaxrs/catalog/jsr339-jaxrs-2.0-final-spec.pdf"
+        "url":"http://localhost:9000/catalog/jsr339-jaxrs-2.0-final-spec.pdf"
     }
 ]
 
-A HTTP GET request to URL http://localhost:9000/jaxrs/catalog/<document> returns the
+A HTTP GET request to URL http://localhost:9000/catalog/<document> returns the
 original document content (in  binary form).
 
-A HTTP DELETE request to URL http://localhost:9000/jaxrs/catalog removes all documents
+A HTTP DELETE request to URL http://localhost:9000/catalog removes all documents
 from the catalog.
 
 Building and running the demo using Maven

http://git-wip-us.apache.org/repos/asf/cxf/blob/64f23230/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/client/Client.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/client/Client.java
b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/client/Client.java
index fb689a6..e277132 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/client/Client.java
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/client/Client.java
@@ -37,7 +37,7 @@ public final class Client {
     }
 
     public static void main(String args[]) throws Exception {               
-        final String url = "http://localhost:9000/jaxrs/catalog";
+        final String url = "http://localhost:9000/catalog";
         final HttpClient httpClient = new HttpClient();
                         
         uploadToCatalog(url, httpClient, "jsr339-jaxrs-2.0-final-spec.pdf");

http://git-wip-us.apache.org/repos/asf/cxf/blob/64f23230/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Server.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Server.java
b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Server.java
index 0e2cf35..f0ce84e 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Server.java
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Server.java
@@ -26,7 +26,6 @@ import org.apache.cxf.jaxrs.provider.MultipartProvider;
 import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
 import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter;
-import org.eclipse.jetty.server.handler.HandlerList;
 import org.eclipse.jetty.servlet.DefaultServlet;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -35,13 +34,21 @@ public class Server {
 
     protected Server() throws Exception {
         org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000);
-        
+
+        // Configuring all static web resource
+        final ServletHolder staticHolder = new ServletHolder(new DefaultServlet());
         // Register and map the dispatcher servlet
         final ServletHolder servletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
         final ServletContextHandler context = new ServletContextHandler();      
         context.setContextPath("/");
-        context.addServlet(servletHolder, "/jaxrs/*");     
+        context.addServlet(staticHolder, "/static/*");
+        context.addServlet(servletHolder, "/*");  
+        context.setResourceBase(getClass().getResource("/browser").toURI().toString());
         
+        servletHolder.setInitParameter("redirects-list", 
+            "/ /index.html /js/fileinput.min.js /css/fileinput.min.css");
+        servletHolder.setInitParameter("redirect-servlet-name", staticHolder.getName());
+        servletHolder.setInitParameter("redirect-attributes", "javax.servlet.include.request_uri");
         servletHolder.setInitParameter("jaxrs.serviceClasses", Catalog.class.getName());
         servletHolder.setInitParameter("jaxrs.properties", StringUtils.join(
             new String[] {
@@ -57,19 +64,8 @@ public class Server {
                 CrossOriginResourceSharingFilter.class.getName()
             }, ",") 
         );                
-        
-        // Configuring all static web resource
-        final ServletHolder staticHolder = new ServletHolder(new DefaultServlet());
-        final ServletContextHandler htmls = new ServletContextHandler();
-        htmls.setContextPath("/catalog");
-        htmls.addServlet(staticHolder, "/*");
-        htmls.setResourceBase(getClass().getResource("/browser").toURI().toString());
-
-        final HandlerList handlers = new HandlerList();
-        handlers.addHandler(htmls);
-        handlers.addHandler(context);        
-        
-        server.setHandler(handlers);
+                
+        server.setHandler(context);
         server.start();
         server.join();
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/64f23230/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
b/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
index b7520ee..3537747 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
@@ -18,14 +18,14 @@
 			<div class="alert alert-danger hide" role="alert" id="error-message"></div>
    	
 	    </div>
 	
-	    <form id="form" class="form-upload" role="form" enctype="multipart/form-data" method="post"
action="http://localhost:9000/jaxrs/catalog">
+	    <form id="form" class="form-upload" role="form" enctype="multipart/form-data" method="post"
action="http://localhost:9000/catalog">
             <h2 class="form-upload-heading">Please select a PDF file</h2>
             <div class="form-group">
                 <input id="file" name="file" type="file" multiple="true" class="file"></input>
             </div>
         </form>
         
-        <form id="form-search" role="search" method="get" action="http://localhost:9000/jaxrs/catalog/search">
+        <form id="form-search" role="search" method="get" action="http://localhost:9000/catalog/search">
             <h2 class="form-upload-heading">Query the Catalog</h2>
 		    <div class="input-group add-on">
 		        <input id="search-query" type="text" class="form-control" placeholder="Search">
	    


Mime
View raw message