You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2007/10/26 02:22:29 UTC

svn commit: r588438 - /incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java

Author: jmsnell
Date: Thu Oct 25 17:22:28 2007
New Revision: 588438

URL: http://svn.apache.org/viewvc?rev=588438&view=rev
Log:
This servlet will take any input xml document and output it as json using the json writer

Modified:
    incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java

Modified: incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java?rev=588438&r1=588437&r2=588438&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java (original)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONServlet.java Thu Oct 25 17:22:28 2007
@@ -30,6 +30,7 @@
 import org.apache.abdera.model.Document;
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
 import org.apache.abdera.writer.Writer;
 
 @SuppressWarnings("unchecked") 
@@ -58,16 +59,27 @@
       throws ServletException, IOException {
     
     String url = request.getPathInfo();
-    if (url != null) url = URLDecoder.decode(url, "UTF-8");
+    if (url != null && url.length() > 1) url = URLDecoder.decode(url, "UTF-8");
     else {
       response.sendError(400); 
       return;
     }
+    url = url.substring(1);
 
     Abdera abdera = getAbdera();
     AbderaClient client = new AbderaClient(abdera);
     
     Writer json = abdera.getWriterFactory().getWriter("json");
+
+    RequestOptions options = client.getDefaultRequestOptions();
+    if (request.getHeader("If-Match") != null)
+      options.setIfMatch(request.getHeader("If-Match"));
+    if (request.getHeader("If-None-Match") != null)
+      options.setIfNoneMatch(request.getHeader("If-None-Match"));
+    if (request.getHeader("If-Modified-Since") != null)
+      options.setIfNoneMatch(request.getHeader("If-Modified-Since"));
+    if (request.getHeader("If-Unmodified-Since") != null)
+      options.setIfNoneMatch(request.getHeader("If-Unmodified-Since"));
     
     ClientResponse resp = client.get(url);
     switch(resp.getType()) {