You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2018/08/15 15:30:29 UTC

[sling-whiteboard] branch master updated (e43f34a -> 9bd0f43)

This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git.


    from e43f34a  fix code block
     new adbe1cf  Use more flexible ResourceActions
     new 5f482ed  Factor out rendering logic
     new b535eea  Move demos schemas to a separate 'demo' bundle
     new c073205  Move demos schemas to a separate 'demo' bundle
     new 9bd0f43  Move demos schemas to a separate 'demo' bundle

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 resource-schemas/README.md                         |  28 ------
 resource-schemas/core/README.md                    |  16 ++++
 resource-schemas/{ => core}/pom.xml                |   2 +-
 .../resourceschemas/api/CreateChildAction.java}    |  21 ++++-
 .../sling/resourceschemas/api/RenderingLogic.java} |  10 +-
 .../sling/resourceschemas/api/ResourceAction.java  |   8 +-
 .../resourceschemas/api/ResourceProperty.java      |   0
 .../resourceschemas/api/ResourceRenderer.java      |  48 ++++++++++
 .../sling/resourceschemas/api/ResourceSchema.java  |  12 +--
 .../api/ResourceSchemaRegistry.java                |   0
 .../api/ResourceSchemasConstants.java              |   0
 .../impl/DefaultRenderingLogic.java                |  75 +++++++++++++++
 .../sling/resourceschemas/impl/RedirectFilter.java |   0
 .../servlets/DefaultHtmlServlet.java               |  34 ++-----
 .../servlets/HtmlResourceRenderer.java}            | 105 ++++++++++++---------
 resource-schemas/demo/README.md                    |  16 ++++
 resource-schemas/{ => demo}/pom.xml                |  11 +--
 .../schemas/DefaultResourceSchemaRegistry.java     |   0
 .../resourceschemas/demo/schemas/DemoSchemas.java  |  23 +++--
 19 files changed, 276 insertions(+), 133 deletions(-)
 delete mode 100644 resource-schemas/README.md
 create mode 100644 resource-schemas/core/README.md
 copy resource-schemas/{ => core}/pom.xml (98%)
 copy resource-schemas/{src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java => core/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java} (65%)
 copy resource-schemas/{src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java => core/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java} (77%)
 copy file-optim/src/main/java/org/apache/sling/fileoptim/package-info.java => resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java (85%)
 rename resource-schemas/{ => core}/src/main/java/org/apache/sling/resourceschemas/api/ResourceProperty.java (100%)
 create mode 100644 resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java
 rename resource-schemas/{ => core}/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java (88%)
 rename resource-schemas/{ => core}/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemaRegistry.java (100%)
 rename resource-schemas/{ => core}/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java (100%)
 create mode 100644 resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java
 rename resource-schemas/{ => core}/src/main/java/org/apache/sling/resourceschemas/impl/RedirectFilter.java (100%)
 rename resource-schemas/{ => core}/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java (72%)
 rename resource-schemas/{src/main/java/org/apache/sling/resourceschemas/impl/HtmlGenerator.java => core/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java} (68%)
 create mode 100644 resource-schemas/demo/README.md
 rename resource-schemas/{ => demo}/pom.xml (88%)
 rename resource-schemas/{ => demo}/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DefaultResourceSchemaRegistry.java (100%)
 rename resource-schemas/{ => demo}/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java (76%)


[sling-whiteboard] 03/05: Move demos schemas to a separate 'demo' bundle

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit b535eea25d3bf331e9576363dc448f42582ccd3f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 15 17:27:55 2018 +0200

    Move demos schemas to a separate 'demo' bundle
---
 resource-schemas/README.md                         | 28 ----------------------
 resource-schemas/core/README.md                    | 16 +++++++++++++
 resource-schemas/{ => core}/pom.xml                |  2 +-
 .../resourceschemas/api/CreateChildAction.java     |  0
 .../sling/resourceschemas/api/RenderingLogic.java  |  0
 .../sling/resourceschemas/api/ResourceAction.java  |  0
 .../resourceschemas/api/ResourceProperty.java      |  0
 .../resourceschemas/api/ResourceRenderer.java      |  0
 .../sling/resourceschemas/api/ResourceSchema.java  |  0
 .../api/ResourceSchemaRegistry.java                |  0
 .../api/ResourceSchemasConstants.java              |  0
 .../impl/DefaultRenderingLogic.java                |  0
 .../sling/resourceschemas/impl/RedirectFilter.java |  0
 .../servlets/DefaultHtmlServlet.java               |  0
 .../servlets/HtmlResourceRenderer.java             |  0
 resource-schemas/{ => demo}/pom.xml                | 11 ++++-----
 .../schemas/DefaultResourceSchemaRegistry.java     |  0
 .../resourceschemas/demo/schemas/DemoSchemas.java  |  0
 18 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/resource-schemas/README.md b/resource-schemas/README.md
deleted file mode 100644
index 64ba9c5..0000000
--- a/resource-schemas/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-Apache Sling Resource Schemas prototype
-=======================================
-
-For now this is just a *rough* proof of concept...
-
-The Sling Resource Schemas extensions generate generic hypermedia user interfaces to manage content,
-based on resource schemas that define the various types of resources and how they can
-be nested.
-
-To test the demo schemas, which allow for managing a very basic blog with folders and posts, install 
-this bundle on Sling, create a resource with the `srs/demo/root`
-resource type and navigate to it with the `.srs.html` selector and extension:
-
-  $ curl -u admin:admin -F sling:resourceType=srs/demo/root http://localhost:8080/test
-  $ curl -u admin:admin http://localhost:8080/test.srs.html
-  
-  <html><body><div class='srs-page'>
-  <h1>Sling Resource Schemas: generated edit forms<br/>for /test</h1><hr/>
-  ....
-
-This module generates a basic HTML UI that allows you to navigate, create and edit resources
-based on the Resource Schemas.
-
-That interface is meant to be usable by machine clients as well, but that hasn't been tested so far.
-Using standard hypermedia formats like Siren or HAL might be an option.
-
-For now, the Resource Schemas are hardcoded in the `DemoSchemas` class. They should later be read from
-structured text files provided as OSGi bundle resources or in the Sling content repository.
\ No newline at end of file
diff --git a/resource-schemas/core/README.md b/resource-schemas/core/README.md
new file mode 100644
index 0000000..b346c03
--- /dev/null
+++ b/resource-schemas/core/README.md
@@ -0,0 +1,16 @@
+Apache Sling Resource Schemas prototype - core
+==============================================
+
+For now this is just a *rough* proof of concept...
+
+The Sling Resource Schemas extensions generate generic hypermedia user interfaces to manage content,
+based on resource schemas that define the various types of resources and how they can
+be nested.
+
+This module generates a basic HTML UI that allows you to navigate, create and edit resources
+based on the Resource Schemas.
+
+That interface is meant to be usable by machine clients as well, but that hasn't been tested so far.
+Using standard hypermedia formats like Siren or HAL might be an option.
+
+The sibling "demo" bundle provides demo schemas, see its README for testing instructions.
\ No newline at end of file
diff --git a/resource-schemas/pom.xml b/resource-schemas/core/pom.xml
similarity index 98%
copy from resource-schemas/pom.xml
copy to resource-schemas/core/pom.xml
index 7f7047a..c7db87f 100644
--- a/resource-schemas/pom.xml
+++ b/resource-schemas/core/pom.xml
@@ -22,7 +22,7 @@
   <artifactId>org.apache.sling.resourceschemas.core</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>bundle</packaging>
-  <name>Apache Sling Resource Schemas</name>
+  <name>Apache Sling Resource Schemas Core</name>
   <description>
         Prototype using Schemas for Sling Resources, to 
         create discoverable HTTP APIs
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceProperty.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceProperty.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceProperty.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceProperty.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemaRegistry.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemaRegistry.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemaRegistry.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemaRegistry.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchemasConstants.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/RedirectFilter.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/impl/RedirectFilter.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/RedirectFilter.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/impl/RedirectFilter.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java b/resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java
rename to resource-schemas/core/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java
diff --git a/resource-schemas/pom.xml b/resource-schemas/demo/pom.xml
similarity index 88%
rename from resource-schemas/pom.xml
rename to resource-schemas/demo/pom.xml
index 7f7047a..07ffb27 100644
--- a/resource-schemas/pom.xml
+++ b/resource-schemas/demo/pom.xml
@@ -19,13 +19,12 @@
     <version>32</version>
     <relativePath/>
   </parent>
-  <artifactId>org.apache.sling.resourceschemas.core</artifactId>
+  <artifactId>org.apache.sling.resourceschemas.demo</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>bundle</packaging>
-  <name>Apache Sling Resource Schemas</name>
+  <name>Apache Sling Resource Schemas Demo</name>
   <description>
-        Prototype using Schemas for Sling Resources, to 
-        create discoverable HTTP APIs
+        Demo Schemas for the Sling Resource Schemas module
     </description>
   <properties>
     <sling.java.version>8</sling.java.version>
@@ -59,8 +58,8 @@
     </dependency>
     <dependency>
         <groupId>org.apache.sling</groupId>
-        <artifactId>org.apache.sling.api</artifactId>
-        <version>2.1.0</version>
+        <artifactId>org.apache.sling.resourceschemas.core</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
         <scope>provided</scope>
     </dependency>
   </dependencies>
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DefaultResourceSchemaRegistry.java b/resource-schemas/demo/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DefaultResourceSchemaRegistry.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DefaultResourceSchemaRegistry.java
rename to resource-schemas/demo/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DefaultResourceSchemaRegistry.java
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java b/resource-schemas/demo/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java
similarity index 100%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java
rename to resource-schemas/demo/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java


[sling-whiteboard] 01/05: Use more flexible ResourceActions

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit adbe1cfe94f1a9a234203cc469bf160be33b19de
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 15 16:31:13 2018 +0200

    Use more flexible ResourceActions
---
 .../resourceschemas/api/CreateChildAction.java     | 36 ++++++++++++++++++++++
 .../sling/resourceschemas/api/ResourceAction.java  | 22 +++++++++++++
 .../sling/resourceschemas/api/ResourceSchema.java  | 12 ++++----
 .../resourceschemas/demo/schemas/DemoSchemas.java  | 23 ++++++++------
 .../servlets/DefaultHtmlServlet.java               | 23 ++++++++------
 5 files changed, 92 insertions(+), 24 deletions(-)

diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java
new file mode 100644
index 0000000..35cef4d
--- /dev/null
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/CreateChildAction.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sling.resourceschemas.api;
+
+/** Base interface for Actions on Resources */
+public class CreateChildAction implements ResourceAction {
+    private final String resourceType;
+    
+    public CreateChildAction(String resourceType) {
+        this.resourceType = resourceType;
+    }
+    
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + "(" + resourceType + ")";
+    }
+    
+    public String getResourceType() {
+        return resourceType;
+    }
+}
\ No newline at end of file
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java
new file mode 100644
index 0000000..7e34746
--- /dev/null
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceAction.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sling.resourceschemas.api;
+
+/** Base interface for Actions on Resources */
+public interface ResourceAction {    
+}
\ No newline at end of file
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java
index d28be11..5a81ee8 100644
--- a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceSchema.java
@@ -34,7 +34,7 @@ public class ResourceSchema {
         
         String name;
         String description;
-        List<String> postHereResourceTypes = new ArrayList<>();
+        List<ResourceAction> actions  = new ArrayList<>();
         List<ResourceProperty> properties = new ArrayList<>(); 
         
         public Builder withName(String n) {
@@ -47,8 +47,8 @@ public class ResourceSchema {
             return this;
         }
         
-        public Builder withPostHereResourceType(String p) {
-            postHereResourceTypes.add(p);
+        public Builder withAction(ResourceAction a) {
+            actions.add(a);
             return this;
         }
         
@@ -76,7 +76,7 @@ public class ResourceSchema {
        sb.append(getClass().getSimpleName()).append(":");
        sb.append(b.name).append(":").append(b.description);
        sb.append("\nproperties=").append(b.properties);
-       sb.append("\npost-here=").append(b.postHereResourceTypes);
+       sb.append("\npactions=").append(b.actions);
        return sb.toString();
     }
     
@@ -93,8 +93,8 @@ public class ResourceSchema {
     /** @return an Iterator over resource types that
      *  can be POSTed to this Resource.
      */
-    public Collection<String> getPostHereResourceTypes() {
-        return Collections.unmodifiableCollection(b.postHereResourceTypes);
+    public Collection<ResourceAction> getActions() {
+        return Collections.unmodifiableCollection(b.actions);
     }
     
     /** @return an Iterator over the Resource Properties of this schema */
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java
index c777218..764f8c5 100644
--- a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/demo/schemas/DemoSchemas.java
@@ -29,36 +29,41 @@ import org.apache.sling.resourceschemas.api.*;
  */
 class DemoSchemas {
 
+    static String RT_ROOT = "srs/demo/root";
+    static String RT_BLOG_HOME = "srs/demo/blog/home";
+    static String RT_BLOG_FOLDER = "srs/demo/blog/folder";
+    static String RT_BLOG_POST = "srs/blog/post";
+    
     static Collection<ResourceSchema> getSchemas() {
         final List<ResourceSchema> list = new ArrayList<>();
         
         list.add(ResourceSchema.BUILDER()
-                .withName("srs/demo/root")
+                .withName(RT_ROOT)
                 .withDescription("SRS Demo Root")
-                .withPostHereResourceType("srs/demo/blog/home")
+                .withAction(new CreateChildAction(RT_BLOG_HOME))
                 .build()
         );
         
         list.add(ResourceSchema.BUILDER()
-                .withName("srs/demo/blog/home")
+                .withName(RT_BLOG_HOME)
                 .withDescription("Homepage of a Blog")
-                .withPostHereResourceType("srs/demo/blog/post")
-                .withPostHereResourceType("srs/demo/blog/folder")
+                .withAction(new CreateChildAction(RT_BLOG_POST))
+                .withAction(new CreateChildAction(RT_BLOG_FOLDER))
                 .withProperty(new ResourceProperty("title", "Title", true, "srs:string"))
                 .build()
         );
         
         list.add(ResourceSchema.BUILDER()
-                .withName("srs/demo/blog/folder")
+                .withName(RT_BLOG_FOLDER)
                 .withDescription("Folder for Blog Posts")
-                .withPostHereResourceType("srs/demo/blog/post")
-                .withPostHereResourceType("srs/demo/blog/folder")
+                .withAction(new CreateChildAction(RT_BLOG_POST))
+                .withAction(new CreateChildAction(RT_BLOG_FOLDER))
                 .withProperty(new ResourceProperty("title", "Title", true, "srs:string"))
                 .build()
         );
         
         list.add(ResourceSchema.BUILDER()
-                .withName("srs/demo/blog/post")
+                .withName(RT_BLOG_POST)
                 .withDescription("Blog Post")
                 .withProperty(new ResourceProperty("title", "Title", true, "srs:string"))
                 .withProperty(new ResourceProperty("text", "Text", true, "srs:richtext"))
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
index 227f8f0..1de08af 100644
--- a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
@@ -26,6 +26,8 @@ import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+import org.apache.sling.resourceschemas.api.CreateChildAction;
+import org.apache.sling.resourceschemas.api.ResourceAction;
 import org.apache.sling.resourceschemas.api.ResourceSchema;
 import org.apache.sling.resourceschemas.impl.HtmlGenerator;
 import org.osgi.service.component.annotations.Component;
@@ -74,17 +76,20 @@ public class DefaultHtmlServlet extends SlingSafeMethodsServlet {
         h.generateEditForm(r, m);
         w.println();
 
-        if(!m.getPostHereResourceTypes().isEmpty()) {
-            w.println("<h2>Create Child Resources</h2>");
+        if(!m.getActions().isEmpty()) {
+            w.println("<h2>Actions</h2>");
         }
-        for(String rt : m.getPostHereResourceTypes()) {
-            final ResourceSchema em = registry.getSchema(rt);
-            if(em == null) {
-                w.println("<p>WARNING: ResourceSchema not found for resource type " + rt + "</p>");
-            } else {
-                h.generateCreateForm(r.getPath(), em);
+        for(ResourceAction a : m.getActions()) {
+            if(a instanceof CreateChildAction) {
+                final CreateChildAction cca = (CreateChildAction)a;
+                final ResourceSchema em = registry.getSchema(cca.getResourceType());
+                if(em == null) {
+                    w.println("<p>WARNING: ResourceSchema not found for resource type " + cca.getResourceType() + "</p>");
+                } else {
+                    h.generateCreateForm(r.getPath(), em);
+                }
+                w.println();
             }
-            w.println();
         }
         
         w.println("\n</div></body></html>\n");


[sling-whiteboard] 04/05: Move demos schemas to a separate 'demo' bundle

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit c073205643475ffe90a81d36fd470670488caffb
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 15 17:28:07 2018 +0200

    Move demos schemas to a separate 'demo' bundle
---
 resource-schemas/demo/README.md | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/resource-schemas/demo/README.md b/resource-schemas/demo/README.md
new file mode 100644
index 0000000..1ec6958
--- /dev/null
+++ b/resource-schemas/demo/README.md
@@ -0,0 +1,16 @@
+Apache Sling Resource Schemas prototype - demo schemas
+======================================================
+
+To test the demo schemas, which allow for managing a very basic blog with folders and posts, install 
+both the sibling core bundle and this one, create a resource with the `srs/demo/root`
+resource type and navigate to it with the `.srs.html` selector and extension:
+
+  $ curl -u admin:admin -F sling:resourceType=srs/demo/root http://localhost:8080/test
+  $ curl -u admin:admin http://localhost:8080/test.srs.html
+  
+  <html><body><div class='srs-page'>
+  <h1>Sling Resource Schemas: generated edit forms<br/>for /test</h1><hr/>
+  ....
+
+For now, the Resource Schemas are hardcoded in the `DemoSchemas` class. They should later be read from
+structured text files provided as OSGi bundle resources or in the Sling content repository.
\ No newline at end of file


[sling-whiteboard] 05/05: Move demos schemas to a separate 'demo' bundle

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 9bd0f43f0cd8dae9119e885dcd90442e53633a8f
Merge: c073205 e43f34a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 15 17:30:17 2018 +0200

    Move demos schemas to a separate 'demo' bundle

 resource-schemas/demo/README.md | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --cc resource-schemas/demo/README.md
index 1ec6958,0000000..e849935
mode 100644,000000..100644
--- a/resource-schemas/demo/README.md
+++ b/resource-schemas/demo/README.md
@@@ -1,16 -1,0 +1,16 @@@
 +Apache Sling Resource Schemas prototype - demo schemas
 +======================================================
 +
 +To test the demo schemas, which allow for managing a very basic blog with folders and posts, install 
 +both the sibling core bundle and this one, create a resource with the `srs/demo/root`
 +resource type and navigate to it with the `.srs.html` selector and extension:
 +
-   $ curl -u admin:admin -F sling:resourceType=srs/demo/root http://localhost:8080/test
-   $ curl -u admin:admin http://localhost:8080/test.srs.html
++    $ curl -u admin:admin -F sling:resourceType=srs/demo/root http://localhost:8080/test
++    $ curl -u admin:admin http://localhost:8080/test.srs.html
 +  
-   <html><body><div class='srs-page'>
-   <h1>Sling Resource Schemas: generated edit forms<br/>for /test</h1><hr/>
-   ....
++    <html><body><div class='srs-page'>
++    <h1>Sling Resource Schemas: generated edit forms<br/>for /test</h1><hr/>
++    ....
 +
 +For now, the Resource Schemas are hardcoded in the `DemoSchemas` class. They should later be read from
- structured text files provided as OSGi bundle resources or in the Sling content repository.
++structured text files provided as OSGi bundle resources or in the Sling content repository.


[sling-whiteboard] 02/05: Factor out rendering logic

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 5f482edc494ab713468d2e9873ff9368599004a2
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Aug 15 17:20:41 2018 +0200

    Factor out rendering logic
---
 .../sling/resourceschemas/api/RenderingLogic.java  |  25 +++++
 .../resourceschemas/api/ResourceRenderer.java      |  48 ++++++++++
 .../impl/DefaultRenderingLogic.java                |  75 +++++++++++++++
 .../servlets/DefaultHtmlServlet.java               |  39 ++------
 .../HtmlResourceRenderer.java}                     | 105 ++++++++++++---------
 5 files changed, 216 insertions(+), 76 deletions(-)

diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java
new file mode 100644
index 0000000..cc6f09e
--- /dev/null
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/RenderingLogic.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sling.resourceschemas.api;
+
+import java.io.IOException;
+import org.apache.sling.api.resource.Resource;
+
+public interface RenderingLogic {
+    public void render(Resource r, ResourceSchema s, ResourceRenderer rr) throws IOException;
+}
\ No newline at end of file
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java
new file mode 100644
index 0000000..3974771
--- /dev/null
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/api/ResourceRenderer.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sling.resourceschemas.api;
+
+import java.io.IOException;
+import org.apache.sling.api.resource.Resource;
+
+public interface ResourceRenderer {
+    
+    enum NavigationType {
+        PARENT,
+        CHILD,
+        SELF
+    }
+    
+    class NavigationItem {
+        public final NavigationType type;
+        public final Resource resource;
+        public final ResourceSchema schema;
+        
+        public NavigationItem(NavigationType t, Resource r, ResourceSchema s) {
+            type = t;
+            resource = r;
+            schema = s;
+        }
+    }
+    
+    public void renderPrefix(Resource r, ResourceSchema s) throws IOException;
+    public void renderSuffix(Resource r, ResourceSchema s) throws IOException;
+    public void renderContent(Resource r, ResourceSchema s) throws IOException;
+    public void renderNavigationItems(Resource r, NavigationItem ... item) throws IOException;
+    public void renderActions(Resource r, ResourceAction ... action) throws IOException;
+}
\ No newline at end of file
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java
new file mode 100644
index 0000000..db7d465
--- /dev/null
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/DefaultRenderingLogic.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sling.resourceschemas.impl;
+
+import org.apache.sling.resourceschemas.api.*;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.resourceschemas.api.ResourceRenderer.NavigationItem;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(service = RenderingLogic.class,
+    property = {
+            "service.description=Sling Resource Schemas - Default Rendering Logic",
+            "service.vendor=The Apache Software Foundation"
+    })
+public class DefaultRenderingLogic implements RenderingLogic {
+
+    private static NavigationItem [] NI_ARRAY = {};
+    private static ResourceAction [] ACT_ARRAY = {};
+    
+    // TODO: pagination would be better...
+    public static final int MAX_NAV_CHILDREN = 20;
+    
+    @Reference
+    private ResourceSchemaRegistry registry;
+    
+    @Override
+    public void render(Resource r, ResourceSchema s, ResourceRenderer rr) throws IOException {
+        
+        rr.renderPrefix(r, s);
+        
+        final List<NavigationItem> nav = new ArrayList<>();
+        
+        // Navigation
+        if(r.getParent() != null) {
+            final Resource parent = r.getParent();
+            nav.add(new NavigationItem(ResourceRenderer.NavigationType.PARENT, parent, registry.getSchema(parent.getResourceType())));
+        }
+        
+        int availableLinks = MAX_NAV_CHILDREN;
+        final Iterator<Resource> it = r.getResourceResolver().listChildren(r);
+        while(it.hasNext()) {
+            if(availableLinks-- <= 0) {
+                // TODO do something about it
+                break;
+            }
+            final Resource child = it.next();
+            nav.add(new NavigationItem(ResourceRenderer.NavigationType.CHILD, child, registry.getSchema(child.getResourceType())));
+        }
+        
+        rr.renderNavigationItems(r, nav.toArray(NI_ARRAY));
+        rr.renderContent(r, s);
+        rr.renderActions(r, s.getActions().toArray(ACT_ARRAY));
+        rr.renderSuffix(r, s);
+    }
+}
\ No newline at end of file
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
index 1de08af..a78e46f 100644
--- a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/DefaultHtmlServlet.java
@@ -18,7 +18,6 @@
 package org.apache.sling.resourceschemas.servlets;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
@@ -26,13 +25,11 @@ import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
-import org.apache.sling.resourceschemas.api.CreateChildAction;
-import org.apache.sling.resourceschemas.api.ResourceAction;
+import org.apache.sling.resourceschemas.api.RenderingLogic;
 import org.apache.sling.resourceschemas.api.ResourceSchema;
-import org.apache.sling.resourceschemas.impl.HtmlGenerator;
+import org.apache.sling.resourceschemas.api.ResourceSchemaRegistry;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
-import org.apache.sling.resourceschemas.api.ResourceSchemaRegistry;
 
 /** SlingServlet that generates the default HTML representations
  *  to allow CRUD operations on resources backed by Sling Resource Schemas
@@ -51,6 +48,9 @@ public class DefaultHtmlServlet extends SlingSafeMethodsServlet {
     @Reference
     private ResourceSchemaRegistry registry;
     
+    @Reference
+    private RenderingLogic renderingLogic;
+    
     @Override
     protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
 
@@ -66,33 +66,8 @@ public class DefaultHtmlServlet extends SlingSafeMethodsServlet {
         
         response.setCharacterEncoding("UTF-8");
         response.setContentType("text/html");
-        
-        final PrintWriter w = response.getWriter();
-        w.println("<html><body><div class='srs-page'>");
-        w.println("<h1>Sling Resource Schemas: generated edit forms<br/>for " + r.getPath() + "</h1><hr/>\n");
-        
-        final HtmlGenerator h = new HtmlGenerator(request, w);
-        h.generateNavigation(r);
-        h.generateEditForm(r, m);
-        w.println();
 
-        if(!m.getActions().isEmpty()) {
-            w.println("<h2>Actions</h2>");
-        }
-        for(ResourceAction a : m.getActions()) {
-            if(a instanceof CreateChildAction) {
-                final CreateChildAction cca = (CreateChildAction)a;
-                final ResourceSchema em = registry.getSchema(cca.getResourceType());
-                if(em == null) {
-                    w.println("<p>WARNING: ResourceSchema not found for resource type " + cca.getResourceType() + "</p>");
-                } else {
-                    h.generateCreateForm(r.getPath(), em);
-                }
-                w.println();
-            }
-        }
-        
-        w.println("\n</div></body></html>\n");
-        w.flush();
+        renderingLogic.render(r, m, new HtmlResourceRenderer(registry, request, response.getWriter()));
+        response.getWriter().flush();
     }
 }
diff --git a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/HtmlGenerator.java b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java
similarity index 68%
rename from resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/HtmlGenerator.java
rename to resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java
index e95e391..4c000e8 100644
--- a/resource-schemas/src/main/java/org/apache/sling/resourceschemas/impl/HtmlGenerator.java
+++ b/resource-schemas/src/main/java/org/apache/sling/resourceschemas/servlets/HtmlResourceRenderer.java
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.sling.resourceschemas.impl;
+package org.apache.sling.resourceschemas.servlets;
 
+import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.Iterator;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
@@ -27,68 +27,85 @@ import org.apache.sling.api.request.ResponseUtil;
 
 
 /** Define a Property of a Resource: name, type, required etc */
-public class HtmlGenerator {
+class HtmlResourceRenderer implements ResourceRenderer {
 
-    private final PrintWriter w;
     private final SlingHttpServletRequest request;
+    private final PrintWriter w;
+    private final ResourceSchemaRegistry registry;
     
-    // TODO: pagination would be better...
-    public static final int MAX_NAV_CHILDREN = 20;
-    
-    public HtmlGenerator(SlingHttpServletRequest request, PrintWriter pw) {
+    HtmlResourceRenderer(ResourceSchemaRegistry rsr, SlingHttpServletRequest request, PrintWriter writer) {
         this.request = request;
-        this.w = pw;
+        this.w = writer;
+        this.registry = rsr;
+    }
+ 
+    @Override
+    public void renderPrefix(Resource r, ResourceSchema s) throws IOException {
+        w.println("<html><body><div class='srs-page'>");
+        w.println("<h1>Sling Resource Schemas: generated edit forms<br/>for " + r.getPath() + "</h1><hr/>\n");
     }
     
-    public String addSelectorsAndExtension(SlingHttpServletRequest request, String path) {
-        final StringBuilder sb = new StringBuilder(path);
-        for(String selector : request.getRequestPathInfo().getSelectors()) {
-            sb.append(".").append(selector);
-        }
-        final String ext = request.getRequestPathInfo().getExtension();
-        if(ext != null && ext.length() > 0) {
-            sb.append(".").append(ext);
+    @Override
+    public void renderSuffix(Resource r, ResourceSchema s) throws IOException {
+        w.println("\n</div></body></html>\n");
+    }
+    
+    public void renderContent(Resource r, ResourceSchema s) throws IOException {
+        if(s.getProperties().isEmpty()) {
+            return;
         }
-        return sb.toString();
+        form(
+            s, 
+            r.adaptTo(ValueMap.class), 
+            "Edit the current Resource",
+            r.getPath() + " (" + s.getDescription() + ")",
+            "srs-edit-form",
+            "", 
+            addSelectorsAndExtension(request, r.getPath()),
+            null);
     }
     
-    public void generateNavigation(Resource r) {
+    public void renderNavigationItems(Resource r, NavigationItem ... items) throws IOException {
         w.println("<div class='srs-navigation'><h2>Navigation</h2>");
         w.println("<ul>");
         
-        if(r.getParent() != null) {
-            link("li", ".. (parent Resource)", addSelectorsAndExtension(request, r.getParent().getPath()));
+        for(NavigationItem i : items) {
+            final String prefix = i.type == NavigationType.PARENT ? "^" : "-";
+            link("ul", prefix + " " + i.resource.getName(), addSelectorsAndExtension(request, i.resource.getPath()));
+        }
+        
+        w.println("</ul></div>");
+    }
+    
+    public void renderActions(Resource r, ResourceAction ... actions) throws IOException {
+        
+        if(actions.length == 0) {
+            w.println("<h2>No Actions available here</h2>");
+        } else {
+            w.println("<h2>Actions</h2>");
         }
         
-        int availableLinks = MAX_NAV_CHILDREN;
-        final Iterator<Resource> it = r.getResourceResolver().listChildren(r);
-        while(it.hasNext()) {
-            if(availableLinks-- <= 0) {
-                w.println("<li><em>Stopping at " + MAX_NAV_CHILDREN + " links</em></li>");
-                break;
+        for(ResourceAction act : actions) {
+            if(act instanceof CreateChildAction) {
+                final CreateChildAction cca = (CreateChildAction)act;
+                generateCreateForm(r.getPath(), registry.getSchema(cca.getResourceType()));
             }
-            final Resource child = it.next();
-            link("li", child.getName(), addSelectorsAndExtension(request, child.getPath()));
         }
-        w.println("</ul></div>");
     }
     
-    public void generateEditForm(Resource r, ResourceSchema m) {
-        if(m.getProperties().isEmpty()) {
-            return;
+    private String addSelectorsAndExtension(SlingHttpServletRequest request, String path) {
+        final StringBuilder sb = new StringBuilder(path);
+        for(String selector : request.getRequestPathInfo().getSelectors()) {
+            sb.append(".").append(selector);
         }
-        form(
-            m, 
-            r.adaptTo(ValueMap.class), 
-            "Edit the current Resource",
-            r.getPath() + " (" + m.getDescription() + ")",
-            "srs-edit-form",
-            "", 
-            addSelectorsAndExtension(request, r.getPath()),
-            null);
+        final String ext = request.getRequestPathInfo().getExtension();
+        if(ext != null && ext.length() > 0) {
+            sb.append(".").append(ext);
+        }
+        return sb.toString();
     }
     
-    public void generateCreateForm(String parentPath, ResourceSchema m) {
+    private void generateCreateForm(String parentPath, ResourceSchema m) {
         form(
             m, 
             null,
@@ -100,7 +117,7 @@ public class HtmlGenerator {
             ResourceSchemasConstants.SRS_FORM_MARKER_PARAMETER);
     }
     
-     public void form(ResourceSchema m, ValueMap vm, String title, String subtitle, String cssClass, String actionPath, String redirectPath, String formMarkerFieldName) {
+    private void form(ResourceSchema m, ValueMap vm, String title, String subtitle, String cssClass, String actionPath, String redirectPath, String formMarkerFieldName) {
         // TODO should use templates
         // TODO escape values
         w.println("<br/>");