incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r587143 - /incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
Date Mon, 22 Oct 2007 16:23:15 GMT
Author: bdelacretaz
Date: Mon Oct 22 09:23:14 2007
New Revision: 587143

URL: http://svn.apache.org/viewvc?rev=587143&view=rev
Log:
bugfix: microsling DefaultSlingServlet created content under 'ull' instead of 'content'

Modified:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java?rev=587143&r1=587142&r2=587143&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
Mon Oct 22 09:23:14 2007
@@ -87,29 +87,20 @@
     protected void doPost(HttpServletRequest req, HttpServletResponse resp)
             throws ServletException, IOException {
         final SlingRequestContext ctx = SlingRequestContext.Accessor.getSlingRequestContext(req);
-
-        // Create or update node under current path
-        final String nodePath = ctx.getRequestPathInfo().getResourcePath();
         String redirectPath = req.getPathInfo();
         
         Session s = null;
         try {
             s = ctx.getSession();
-            Node current = null;
-            boolean createNewNode = false;
-            if (nodePath != null && s.itemExists(nodePath)) {
-                current = (Node) s.getItem(nodePath);
-                // TODO this is simplistic...if the node has children we assume
-                // it's a folder,
-                // so we create a new node under it instead of updating it
-                createNewNode = current.hasNodes();
-            } else {
-                createNewNode = true;
-            }
-
-            if (createNewNode) {
-                final String newNodePath = nodePath + "/"
-                    + System.currentTimeMillis();
+            Node current = (ctx.getResource() == null ? null : (Node)ctx.getResource().getItem());
+            
+            // Decide whether to create or update a node
+            // TODO: this is a simplistic way of deciding, for now: if we have
+            // no Resource or if the Node that it points to already has child nodes,
+            // we create a new node. Else we update the current node.
+            if(current == null || current.hasNodes()) {
+                final String parentPath = (current == null ? req.getPathInfo() : current.getPath());
+                final String newNodePath = parentPath + "/" + System.currentTimeMillis();
                 current = deepCreateNode(s, newNodePath);
             }
 
@@ -117,9 +108,11 @@
             setPropertiesFromRequest(current, req);
             s.save();
             redirectPath = current.getPath();
+            
         } catch (RepositoryException re) {
-            throw new ServletException("Failed modifying content: "
+            throw new ServletException("Failed to modify content: "
                 + re.getMessage(), re);
+            
         } finally {
             try {
                 if (s != null && s.hasPendingChanges()) {



Mime
View raw message