incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r644720 - in /incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl: NodeNameGenerator.java SlingPostServlet.java
Date Fri, 04 Apr 2008 14:17:04 GMT
Author: cziegeler
Date: Fri Apr  4 07:17:02 2008
New Revision: 644720

URL: http://svn.apache.org/viewvc?rev=644720&view=rev
Log:
SLING-354: Added sling:post:nodeName request parameter.

Modified:
    incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameGenerator.java
    incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java

Modified: incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameGenerator.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameGenerator.java?rev=644720&r1=644719&r2=644720&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameGenerator.java
(original)
+++ incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameGenerator.java
Fri Apr  4 07:17:02 2008
@@ -27,9 +27,23 @@
  *  See SLING-128.
  */
 public class NodeNameGenerator {
-    private List<String> parameterNames;
+
+    private static final List<String> DEFAULT_NAMES = new LinkedList<String>();
+    static {
+        DEFAULT_NAMES.add(SlingPostServlet.RP_NODE_NAME);
+        DEFAULT_NAMES.add("title");
+        DEFAULT_NAMES.add("jcr:title");
+        DEFAULT_NAMES.add("name");
+        DEFAULT_NAMES.add("description");
+        DEFAULT_NAMES.add("jcr:description");
+        DEFAULT_NAMES.add("abstract");
+    }
+
+    private final List<String> parameterNames;
     private final NodeNameFilter filter = new NodeNameFilter();
+
     public static final int DEFAULT_MAX_NAME_LENGTH = 20;
+
     private int maxLength = DEFAULT_MAX_NAME_LENGTH;
     private int counter;
 
@@ -38,14 +52,8 @@
     }
 
     public NodeNameGenerator(List<String> parameterNames) {
-        if(parameterNames == null) {
-            this.parameterNames = new LinkedList<String>();
-            this.parameterNames.add("title");
-            this.parameterNames.add("jcr:title");
-            this.parameterNames.add("name");
-            this.parameterNames.add("description");
-            this.parameterNames.add("jcr:description");
-            this.parameterNames.add("abstract");
+        if (parameterNames == null) {
+            this.parameterNames = DEFAULT_NAMES;
         } else {
             this.parameterNames = parameterNames;
         }
@@ -73,8 +81,12 @@
                 if(valueToUse != null) {
                     break;
                 }
-                final RequestParameter[] pp = parameters.get(prefix + param);
-                if(pp!=null) {
+                RequestParameter[] pp = parameters.get(prefix + param);
+                // check without prefix for exact match, like everything staring with sling:post:
+                if ( pp == null ) {
+                    pp = parameters.get(param);
+                }
+                if (pp!=null) {
                     for(RequestParameter p : pp) {
                         valueToUse = p.getString();
                         if(valueToUse != null && valueToUse.length() > 0) {

Modified: incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java?rev=644720&r1=644719&r2=644720&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
(original)
+++ incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
Fri Apr  4 07:17:02 2008
@@ -103,6 +103,11 @@
     public static final String MOVE_FLAG_REPLACE = "replace";
 
     /**
+     * Optional request paramter specifying the node name for a newly created now.
+     */
+    public static final String RP_NODE_NAME = RP_PREFIX + "nodeName";
+
+    /**
      * Optional request parameter: only request parameters starting with this prefix are
      * saved as Properties when creating a Node. Active only if at least one parameter
      * starts with this prefix, and defaults to {@link #DEFAULT_SAVE_PARAM_PREFIX}.
@@ -199,7 +204,6 @@
             throw new ServletException("No JCR Session available");
         }
 
-        // create the post context
         return new SlingPostProcessor(request, s, nodeNameGenerator, dateParser, this.getServletContext());
     }
 



Mime
View raw message