incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r612120 - in /incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling: ujax/UjaxPostServlet.java ujax/UjaxPropertyValueSetter.java usling/servlets/UslingDefaultServlet.java
Date Tue, 15 Jan 2008 14:09:19 GMT
Author: bdelacretaz
Date: Tue Jan 15 06:09:15 2008
New Revision: 612120

URL: http://svn.apache.org/viewvc?rev=612120&view=rev
Log:
SLING-149 - merge usling into Sling - default rendering is plain text, and fix wrong class
names

Modified:
    incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
    incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPropertyValueSetter.java
    incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/usling/servlets/UslingDefaultServlet.java

Modified: incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java?rev=612120&r1=612119&r2=612120&view=diff
==============================================================================
--- incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
(original)
+++ incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
Tue Jan 15 06:09:15 2008
@@ -46,7 +46,7 @@
     private static final long serialVersionUID = 1837674988291697074L;
 
     private static final Logger log = LoggerFactory.getLogger(UjaxPostServlet.class);
-    private final MicrojaxPropertyValueSetter propertyValueSetter = new MicrojaxPropertyValueSetter();
+    private final UjaxPropertyValueSetter propertyValueSetter = new UjaxPropertyValueSetter();
     private final NodeNameGenerator nodeNameGenerator = new NodeNameGenerator();
 
     /** Prefix for parameter names which control this POST

Modified: incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPropertyValueSetter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPropertyValueSetter.java?rev=612120&r1=612119&r2=612120&view=diff
==============================================================================
--- incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPropertyValueSetter.java
(original)
+++ incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/ujax/UjaxPropertyValueSetter.java
Tue Jan 15 06:09:15 2008
@@ -31,7 +31,7 @@
  * value. For example, "lastModified" with an empty value is stored as the
  * current Date.
  */
-class MicrojaxPropertyValueSetter {
+class UjaxPropertyValueSetter {
     public static final String CREATED_FIELD = "created";
     public static final String CREATED_BY_FIELD = "createdBy";
     public static final String LAST_MODIFIED_FIELD = "lastModified";

Modified: incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/usling/servlets/UslingDefaultServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/usling/servlets/UslingDefaultServlet.java?rev=612120&r1=612119&r2=612120&view=diff
==============================================================================
--- incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/usling/servlets/UslingDefaultServlet.java
(original)
+++ incubator/sling/trunk/usling/usling-servlets/src/main/java/org/apache/sling/usling/servlets/UslingDefaultServlet.java
Tue Jan 15 06:09:15 2008
@@ -79,12 +79,12 @@
         postServlet = new UjaxPostServlet();
         postServlet.init(config);
         
-        defaultGetServlet = new DefaultHtmlRendererServlet("text/html");
+        defaultGetServlet = new PlainTextRendererServlet("text/plain");
         
         getServlets = new HashMap<String, Servlet>();
-        getServlets.put("html", defaultGetServlet);
+        getServlets.put("html", new DefaultHtmlRendererServlet("text/html"));
         getServlets.put("json", new JsonRendererServlet("application/json"));
-        getServlets.put("txt", new PlainTextRendererServlet("text/plain"));
+        getServlets.put("txt", defaultGetServlet);
     }
 
     protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws IOException, ServletException {
@@ -96,11 +96,22 @@
             return;
         }
         
-        Servlet s = getServlets.get(request.getRequestPathInfo().getExtension());
+        // use default renderer servlet if no extension, else lookup our getServlets 
+        Servlet s = defaultGetServlet;
+        final String ext = request.getRequestPathInfo().getExtension();
+        if(ext!=null && ext.length() > 0) {
+            s = getServlets.get(ext);
+        }
+
+        // render using s, or fail
         if(s==null) {
-            s = defaultGetServlet;
+            response.sendError(
+                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+                    "No default renderer found for extension='" + ext + "'"
+            );
+        } else {
+            s.service(request, response);
         }
-        s.service(request, response);
     }
 
 



Mime
View raw message