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. Updated index.html to support search.
Date Mon, 08 Sep 2014 12:30:23 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 76461079c -> 384ad7543


CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Updated
index.html to support search.


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

Branch: refs/heads/master
Commit: 384ad75433037358ea1607c4ddcb0cd978fae10c
Parents: 7646107
Author: reta <drreta@gmail.com>
Authored: Mon Sep 8 08:30:04 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Mon Sep 8 08:30:04 2014 -0400

----------------------------------------------------------------------
 .../java/demo/jaxrs/search/server/Catalog.java  |  4 +-
 .../src/main/resources/browser/index.html       | 60 ++++++++++++++++++++
 2 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/384ad754/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
index 99d5d62..ead0cd0 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
@@ -177,7 +177,7 @@ public class Catalog {
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     @Path("/search")
-    public JsonArray findBook(@Context SearchContext searchContext, 
+    public Response findBook(@Context SearchContext searchContext, 
             @Context final UriInfo uri) throws IOException {
         
         final IndexReader reader = DirectoryReader.open(directory);
@@ -209,7 +209,7 @@ public class Catalog {
                 }
             }
             
-            return builder.build();
+            return Response.ok(builder.build()).header(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER,
"*").build();
         } finally {
             reader.close();
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/384ad754/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 f628345..7ab4fd4 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
@@ -20,6 +20,19 @@
                 <input id="file" name="file" type="file" multiple=true class="file"></button>
             </div>
         </form>
+        
+        <form id="from-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">
	    
+			    <div class="input-group-btn">
+			    	<button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
+			    </div>
+		    </div>
+		</form>
+		
+		<div class="fluent-container" id="results">
+		</div>
     </div> <!-- /container -->
     
     <script type="text/javascript">
@@ -42,6 +55,53 @@
 	        e.preventDefault();
 	        return false;
 	    });
+    	
+    	$( "#from-search" ).submit(function(e) {    		
+    		var query = $( "#search-query" ).val();
+    		$( "#results" ).html("");
+    		
+    		if( query !== "" ) {
+	    		$.ajax({
+	    			url: $(this).attr("action") + "?$filter=ct=="  + encodeURIComponent( query ),
+	    			type: 'GET',
+	    			async: false,
+	    			success: function (data) {
+	    				var table = "\
+	    				<table class=\"table table-striped\">\
+	    			    <thead>\
+	    			        <tr>\
+	    			            <th>File</th>\
+	    			            <th>Score</th>\
+	    			            <th>Action</th>\
+	    			        </tr>\
+	    			    </thead>\
+	    			    <tbody>";	    			    
+	    				
+	    				$.each(data, function (index, value) {
+	    					table += "\
+	    					<tr>\
+	    		               <td>" + value.source + "</td>\
+	    		                <td>" + value.score + "</td>\
+	    		                <td><a href='" + value.url + "'>Open</a></td>\
+	    		            </tr>";
+	    				});
+
+	    				table += "\
+	    	    	    </tbody>\
+	    	    		</table>";
+	    	    		
+	    				$( "#results" ).html(table);
+	    		
+	    			},
+		    		cache: false,
+	    			contentType: false,
+	    			processData: false
+	    		});
+    	    }
+    			        
+	        e.preventDefault();
+	        return false;
+	    });
     </script>
 </body>
 


Mime
View raw message