cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] git commit: CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Updated index.html to use AJAX for posting files.
Date Thu, 04 Sep 2014 16:08:50 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 08e47a272 -> 698cfd2ef


CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Updated
index.html to use AJAX for posting files.


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

Branch: refs/heads/master
Commit: 11243052a6e1656657776bc3a0c586cba962c49f
Parents: a50e622
Author: reta <drreta@gmail.com>
Authored: Thu Sep 4 12:08:23 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Thu Sep 4 12:08:23 2014 -0400

----------------------------------------------------------------------
 .../java/demo/jaxrs/search/server/Catalog.java  | 16 +++++++++-----
 .../src/main/resources/browser/index.html       | 22 ++++++++++++++++++++
 .../java/demo/jaxrs/server/CustomerService.java |  5 ++---
 3 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/11243052/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 b1404bc..99d5d62 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
@@ -84,6 +84,8 @@ import org.apache.tika.parser.pdf.PDFParser;
 
 @Path("/catalog")
 public class Catalog {
+    private static final String ACCESS_CONTROL_ALLOW_ORIGIN_HEADER = "Access-Control-Allow-Origin";
+    
     private final TikaLuceneContentExtractor extractor = new TikaLuceneContentExtractor(new
PDFParser());    
     private final Directory directory = new RAMDirectory();
     private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9);    
@@ -117,25 +119,29 @@ public class Catalog {
                         
                         try {
                             if (exists(source)) {
-                                response.resume(Response.status(Status.CONFLICT).build());
+                                response.resume(Response.status(Status.CONFLICT)
+                                        .header(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*").build());
                                 return;
                             }
 
                             final byte[] content = IOUtils.readBytesFromStream(handler.getInputStream());
                             storeAndIndex(metadata, content);
                         } catch (final Exception ex) {
-                            response.resume(Response.serverError().build());  
+                            response.resume(Response.serverError()
+                                    .header(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*").build());
 
                         } 
                         
                         if (response.isSuspended()) {
-                            response.resume(Response.created(uri.getRequestUriBuilder()
-                                .path(source).build()).build());
+                            response.resume(Response
+                                    .created(uri.getRequestUriBuilder().path(source).build())
+                                    .header(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*").build());
                         }
                     }                       
                 }              
                 
                 if (response.isSuspended()) {
-                    response.resume(Response.status(Status.BAD_REQUEST).build());
+                    response.resume(Response.status(Status.BAD_REQUEST)
+                            .header(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*").build());
                 }
             }
         });

http://git-wip-us.apache.org/repos/asf/cxf/blob/11243052/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 9d158c5..f628345 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
@@ -21,6 +21,28 @@
             </div>
         </form>
     </div> <!-- /container -->
+    
+    <script type="text/javascript">
+    	$( "#form" ).submit(function(e) {    		
+    		var formData = new FormData($(this)[0]);
+
+    		$.ajax({
+    			url:$(this).attr("action"),
+    			type: 'POST',
+    			data: formData,
+    			async: false,
+    			success: function (data) {
+    			    $('#file').fileinput('clear');
+    			},
+	    		cache: false,
+    			contentType: false,
+    			processData: false
+    		});
+    			        
+	        e.preventDefault();
+	        return false;
+	    });
+    </script>
 </body>
 
 </html>

http://git-wip-us.apache.org/repos/asf/cxf/blob/11243052/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
b/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
index 2927d24..967e978 100644
--- a/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
+++ b/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
@@ -21,10 +21,8 @@ package demo.jaxrs.server;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -126,7 +124,8 @@ public class CustomerService {
     @GET
     @Path("/monitor")
     @Produces("text/*")
-    public StreamingOutput monitorCustomers(@HeaderParam(WebSocketConstants.DEFAULT_REQUEST_ID_KEY)
String reqid) {
+    public StreamingOutput monitorCustomers(
+            @HeaderParam(WebSocketConstants.DEFAULT_REQUEST_ID_KEY) String reqid) {
         final String key = reqid == null ? "*" : reqid; 
         return new StreamingOutput() {
             public void write(final OutputStream out) throws IOException, WebApplicationException
{


Mime
View raw message