Author: bdelacretaz
Date: Wed Sep  6 13:24:23 2017
New Revision: 1807480

URL: http://svn.apache.org/viewvc?rev=1807480&view=rev
Log:
Feeling nostalgic...restore microsling here from incubator revision 666561, 
right before it was deleted

Added:
    sling/whiteboard/microsling/
    sling/whiteboard/microsling/README.txt
    sling/whiteboard/microsling/pom.xml
    sling/whiteboard/microsling/src/
    sling/whiteboard/microsling/src/main/
    sling/whiteboard/microsling/src/main/java/
    sling/whiteboard/microsling/src/main/java/org/
    sling/whiteboard/microsling/src/main/java/org/apache/
    sling/whiteboard/microsling/src/main/java/org/apache/sling/
    sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/
    sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/Resource.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceMetadata.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceResolver.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ServiceLocator.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestPathInfo.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/HttpStatusCodeException.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/SlingException.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/helpers/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/helpers/AbstractFilter.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameter.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameterMap.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/constants/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/constants/HttpConstants.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/exceptions/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/exceptions/MissingRequestAttributeException.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/SlingAllMethodsServlet.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/SlingSafeMethodsServlet.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/MicroslingRequestContext.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/helpers/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/helpers/MicroslingRequestPathInfo.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/helpers/SlingRequestParameterMap.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourcePathIterator.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/ScriptEngine.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/freemarker/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/freemarker/FreemarkerScriptEngine.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/rhino/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/rhino/RhinoJavasSriptEngine.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/rhino/ScriptableNode.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/rhino/ScriptableResource.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/velocity/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/engines/velocity/VelocityTemplatesScriptEngine.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/helpers/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/helpers/EspReader.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/helpers/FileNodeRequestAttribute.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilder.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/helpers/ScriptHelper.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/services/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/services/MicroslingServiceLocator.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingFilterHelper.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroslingMainServlet.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
    
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/StreamServlet.java
    sling/whiteboard/microsling/src/main/webapp/
    sling/whiteboard/microsling/src/main/webapp/WEB-INF/
    sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.dtd
    sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.xml
    sling/whiteboard/microsling/src/main/webapp/WEB-INF/web.xml
    
sling/whiteboard/microsling/src/main/webapp/WEB-INF/webdav-resource-config.xml
    sling/whiteboard/microsling/src/main/webapp/content-creation-forms.html
    sling/whiteboard/microsling/src/main/webapp/freemarker-scripts.html
    sling/whiteboard/microsling/src/main/webapp/index.html
    sling/whiteboard/microsling/src/main/webapp/microsling.css
    sling/whiteboard/microsling/src/main/webapp/server-side-javascript.html
    sling/whiteboard/microsling/src/main/webapp/velocity-scripts.html
    sling/whiteboard/microsling/src/test/
    sling/whiteboard/microsling/src/test/java/
    sling/whiteboard/microsling/src/test/java/org/
    sling/whiteboard/microsling/src/test/java/org/apache/
    sling/whiteboard/microsling/src/test/java/org/apache/sling/
    sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/CreateNodeTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/FileUploadTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/MicroslingHttpTestBase.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/MkdirTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/NodetypeRenderingTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/RenderingTestBase.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/SlingResourceTypeRenderingTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/StreamServletTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/helpers/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/helpers/HttpAnyMethod.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/helpers/MicroslingIntegrationTestClient.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/request/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/request/helpers/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/request/helpers/MicroslingRequestPathInfoTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/resource/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/resource/ResourcePathIteratorTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/scripting/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/scripting/helpers/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/scripting/helpers/EspReaderTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/scripting/helpers/ScriptFilenameBuilderTest.java
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/services/
    
sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/services/MicroslingServiceLocatorTest.java
    sling/whiteboard/microsling/src/test/resources/
    sling/whiteboard/microsling/src/test/resources/integration-test/
    
sling/whiteboard/microsling/src/test/resources/integration-test/rendering-test.esp
    
sling/whiteboard/microsling/src/test/resources/integration-test/rendering-test.ftl
    
sling/whiteboard/microsling/src/test/resources/integration-test/rendering-test.js
    
sling/whiteboard/microsling/src/test/resources/integration-test/rendering-test.vlt
    
sling/whiteboard/microsling/src/test/resources/integration-test/testfile.html
    sling/whiteboard/microsling/src/test/resources/integration-test/testfile.txt

Added: sling/whiteboard/microsling/README.txt
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/README.txt?rev=1807480&view=auto
==============================================================================
--- sling/whiteboard/microsling/README.txt (added)
+++ sling/whiteboard/microsling/README.txt Wed Sep  6 13:24:23 2017
@@ -0,0 +1,39 @@
+------------------------------------------------------------
+Microsling: the Sling request processing, reduced to the max
+  **** 
+  THIS IS OBSOLETE - see the microsling-core module in
+  the main sling code repository
+  ****
+------------------------------------------------------------
+
+The goal of this prototype is to demonstrate the Sling HTTP
+request processing in the simplest possible way, to help the
+community converge on the goals and architecture of this 
+module.
+
+How to build and run this
+------------------------
+Currently this depends on the Jackrabbit 1.4-SNAPSHOT, mostly
+because I had a project skeleton around that takes advantage of
+JCR-955 to reuse some Jackrabbit servlets.
+
+To build and run:
+
+1) Install a JDK 1.5 and Maven 2.0.7.
+
+2) Get and build the Jackrabbit trunk from
+
+  http://svn.apache.org/repos/asf/jackrabbit/trunk
+
+I'm currently using revision 583722 for my tests.
+
+3) Build and run this webapp:
+
+  mvn clean package jetty:run
+  
+Which should say "Started SelectChannelConnector@0.0.0.0:8080" once
+the build is done.  
+  
+4) Connect to http://localhost:8080/ which should return a page
+saying "Microsling homepage". That page contains instructions for
+playing with Microsling.   

Added: sling/whiteboard/microsling/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/pom.xml?rev=1807480&view=auto
==============================================================================
--- sling/whiteboard/microsling/pom.xml (added)
+++ sling/whiteboard/microsling/pom.xml Wed Sep  6 13:24:23 2017
@@ -0,0 +1,297 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.sling</groupId>
+  <artifactId>microsling</artifactId>
+  <packaging>war</packaging>
+  <name>microsling</name>
+  <!--
+    WARNING: if changing this, change microsling.http.server.url below as well 
+   -->
+  <version>1.0-SNAPSHOT</version>
+  
+  <url>http://incubator.apache.org/sling</url>
+
+  <properties>
+    <!-- 
+      Use the Jackrabbit trunk, mostly because JCR-955
+      makes it easier to reuse the servlets from the
+      jackrabbit-webapp module.
+    -->
+    <jackrabbit.version>1.4-SNAPSHOT</jackrabbit.version>
+    
+    <!-- 
+      Defines which tests are for the "integration-testing" phase
+     -->
+    
<integration.test.code.path>**/microsling/integration</integration.test.code.path>
+    
+    <!-- 
+      Set this to true to stop mvn once the integration test Jetty instance is
+      started. Useful to manually test the integration testing webapp.
+     -->
+     <integration.test.wait>false</integration.test.wait>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.4</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-webapp</artifactId>
+      <version>${jackrabbit.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-servlet</artifactId>
+      <version>${jackrabbit.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>1.5</version>
+    </dependency>
+    <dependency>
+      <groupId>rhino</groupId>
+      <artifactId>js</artifactId>
+      <version>1.6R7</version>
+    </dependency>
+    <dependency>
+        <groupId>freemarker</groupId>
+        <artifactId>freemarker</artifactId>
+        <version>2.3.6</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <encoding>UTF-8</encoding>
+        </configuration>
+      </plugin>
+      <plugin>
+        <!-- SLING-66: create a jar in addition to our war, to make our 
servlets reusable -->
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-classes</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+            <configuration>
+              <!-- using the classifier makes the jar an attachement -->
+              <classifier>classes</classifier>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>maven-jetty-plugin</artifactId>
+        <version>6.1.5</version>
+        <configuration>
+          <contextPath>/</contextPath>
+          <scanIntervalSeconds>10</scanIntervalSeconds>
+          <connectors>
+            <connector 
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+              <port>8080</port>
+              <maxIdleTime>60000</maxIdleTime>
+            </connector>
+          </connectors>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemProperties>
+            <!-- 
+              WARNING: make sure these URLs are consistent with the
+              cargo-maven2-plugin settings: AFAIK Maven does not
+              expand variables in the <value> element.
+              And WARNING: these properties are duplicated somewhere in this
+              POM with slightly different values...there must be a better way. 
+            -->
+            <property>
+              <name>microsling.http.server.url</name>
+              <value>http://localhost:8080/microsling</value>
+            </property>
+            <property>
+              <name>microsling.webdav.server.url</name>
+              <value>http://localhost:8080/repository/default</value>
+            </property>
+          </systemProperties>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <!--
+        Run the cargo-based integration tests.
+        This profile is active by default, to deactivate it activate another
+        one, for example " mvn -P nullProfile".
+        
+        TODO there must be a way to control this with "mvn.test.skip", but I 
haven't
+        found it. 
+       -->
+      <id>cargoIntegrationTesting</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>surefire-integration-test</id>
+                <phase>integration-test</phase>
+                <goals>
+                  <goal>test</goal>
+                </goals>
+                <configuration>
+                  <excludes>
+                    <exclude>none</exclude>
+                  </excludes>
+                  <includes>
+                    
<include>${integration.test.code.path}/**Test.java</include>
+                  </includes>
+                  <systemProperties>
+                    <!-- 
+                      WARNING: make sure these URLs are consistent with the
+                      cargo-maven2-plugin settings: AFAIK Maven does not
+                      expand variables in the <value> element.
+                      And WARNING: these properties are duplicated somewhere 
in this
+                      POM with slightly different values...there must be a 
better way. 
+                    -->
+                    <property>
+                      <name>microsling.http.server.url</name>
+                      
<value>http://localhost:8080/microsling-1.0-SNAPSHOT/microsling</value>
+                    </property>
+                    <property>
+                      <name>microsling.webdav.server.url</name>
+                      
<value>http://localhost:8080/microsling-1.0-SNAPSHOT/repository/default</value>
+                    </property>
+                  </systemProperties>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.cargo</groupId>
+            <artifactId>cargo-maven2-plugin</artifactId>
+            <version>0.3.1</version>
+            <executions>
+              <execution>
+                <id>start-container</id>
+                <phase>pre-integration-test</phase>
+                <goals>
+                  <goal>start</goal>
+                </goals>
+              </execution>
+              <execution>
+                <id>stop-container</id>
+                <phase>post-integration-test</phase>
+                <goals>
+                  <goal>stop</goal>
+                </goals>
+              </execution>
+            </executions>
+            <configuration>
+              <wait>${integration.test.wait}</wait>
+              <container>
+                <containerId>jetty6x</containerId>
+                <type>embedded</type>
+              </container>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <!--
+        By default, do not run the integration tests in the test phase, as 
they have
+        no microsling to talk to.
+        To debug the integration tests faster than with the normal build cycle,
+        deactivate this profile (using -P nullProfile for example) and run a
+        separate instance of microsling that the tests can talk to.
+       -->
+      <id>disableIntegrationTestsInTestPhase</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>${integration.test.code.path}/**.java</exclude>
+              </excludes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <!-- 
+        Useful to deactivate other profiles from the command-line
+        Is there a better way? mvn doesn't have a "deactivate profile" option. 
+       -->
+      <id>nullMicroslingProfile</id>
+    </profile>
+  </profiles>
+
+</project>

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/Resource.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/Resource.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/Resource.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/Resource.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,49 @@
+/*
+ * 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.microsling.api;
+
+import javax.jcr.Item;
+
+/** Resources are pieces of content on which Sling acts  */
+public interface Resource {
+    /** This resource's URI - for now that could be a JCR path, but having
+     *  an URI makes it possible to use other data sources (not sure if we
+     *  really need that though).
+     */
+    String getURI();
+
+    /** The resource type is meant to point to rendering/processing scripts,
+     *  editing dialogs, etc. It is usually a path in the repository, where
+     *  scripts and other tools definitions are found.
+     */
+    String getResourceType();
+    
+    /**
+     * The JCR item addressed by the {@link #getURI() resource URI} or null
+     * if the resource URI does not actually address an item in a repository.
+     */
+    Item getItem();
+
+    /** Returns the object mapped from the {@link #getItem() item} or null,
+     * if the item cannot be mapped or mapping is not supported by the
+     * implementation.
+     */
+    Object getData();
+    
+    /** Content-related and/or Sling-related metadata about this Resource */
+    ResourceMetadata getMetadata();
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceMetadata.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceMetadata.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceMetadata.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceMetadata.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,35 @@
+/*
+ * 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.microsling.api;
+
+import java.util.HashMap;
+
+/** Metadata for the Resource, can hold content-related metadata 
+ *  (last modification time, etc.) as well as Sling-specific 
+ *  metadata (path used to resolve the Resource, etc.)
+ */
+public class ResourceMetadata extends HashMap<String, Object> {
+    private static final long serialVersionUID = 4529624506305380870L;
+
+    /** Use this prefix for Sling-specific metadata */
+    public final static String SLING_PREFIX = "sling.";
+
+    /** Set by the ResourceResolver when resolving the Resource 
+     *  @see ResourceResolver
+     */ 
+    public final static String RESOLUTION_PATH = SLING_PREFIX + 
"resolutionPath";
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceResolver.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceResolver.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceResolver.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ResourceResolver.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.microsling.api;
+
+import javax.jcr.RepositoryException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.microsling.api.exceptions.SlingException;
+
+/** Locates the Resource that the current request must process */
+public interface ResourceResolver {
+    
+    /** Find the Resource that request must process. The
+     *  Resource.getURI() method will indicate the actual URI
+     *  (which is by default the Resource node's JCR path) that
+     *  was used to load the Resource
+     */
+    Resource getResource(HttpServletRequest request) throws SlingException;
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ServiceLocator.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ServiceLocator.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ServiceLocator.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/ServiceLocator.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,77 @@
+/*
+ * 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.microsling.api;
+
+import org.apache.sling.microsling.api.exceptions.SlingException;
+
+/** Retrieve named services from a Services registry.
+ *  Sling OSGi, makes extensive use of this interface to
+ *  locate OSGi services.
+ *  Microsling also uses it, but that's mostly to do things 
+ *  the same way as in Sling OSGi, as services are statically
+ *  defined in microsling. 
+ */
+
+public interface ServiceLocator {
+    
+    /** Lookup a single service
+     * @param serviceName The name (interface) of the service.
+     * @return The service instance, or null if the service is not available.
+     */
+    Object getService(String serviceName);
+    
+    /** Same as getService, but throws a ServiceNotAvailableException if the 
requested
+     *  service is not currently available
+     */
+    Object getRequiredService(String serviceName) throws 
ServiceNotAvailableException;
+
+    /** Lookup one or several services
+     * @param serviceName The name (interface) of the service.
+     * @param filter An optional filter (LDAP-like, see OSGi spec)
+     * @return The services object or null.
+     */
+    Object[] getServices(String serviceName, String filter) throws 
InvalidServiceFilterSyntaxException;
+    
+    /** Thrown when an invalid service filter is used */ 
+    public static class InvalidServiceFilterSyntaxException extends 
SlingException {
+        private static final long serialVersionUID = 1L;
+
+        public InvalidServiceFilterSyntaxException(String reason) {
+            super(reason);
+        }
+        
+        public InvalidServiceFilterSyntaxException(String reason, Throwable 
cause) {
+            super(reason,cause);
+        }
+    };    
+
+    /** Thrown when a required service is not found */
+    public static class ServiceNotAvailableException extends SlingException {
+        private static final long serialVersionUID = 1L;
+
+        public ServiceNotAvailableException(String reason) {
+            super(reason);
+        }
+        
+        public ServiceNotAvailableException(String reason, Throwable cause) {
+            super(reason,cause);
+        }
+    };    
+    
+
+
+}
\ No newline at end of file

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestContext.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,80 @@
+/*
+ * 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.microsling.api;
+
+import javax.jcr.Session;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.microsling.api.exceptions.SlingException;
+import org.apache.sling.microsling.api.requestparams.RequestParameterMap;
+import 
org.apache.sling.microsling.helpers.exceptions.MissingRequestAttributeException;
+
+/** Provides Sling-specific information about the current Request.
+ *  Can be acquired using getFromRequest(...).
+ */
+public abstract class SlingRequestContext {
+
+    protected final HttpServletRequest request;
+    protected final HttpServletResponse response;
+    protected final ServletContext servletContext;
+    
+    /** Attribute name used to store this in the request */
+    protected final static String REQ_ATTR_NAME = 
SlingRequestContext.class.getName();
+    
+    /** Get the SlingRequestContext that's stored in req as an attribute */
+    public static SlingRequestContext getFromRequest(HttpServletRequest req) 
+    throws SlingException {
+        final SlingRequestContext ctx = 
(SlingRequestContext)req.getAttribute(REQ_ATTR_NAME);
+        if(ctx == null) {
+            throw new MissingRequestAttributeException(REQ_ATTR_NAME);
+        }
+        return ctx;
+    }
+    
+    /** Create a SlingRequestContext and store it as a request attribute */
+    public SlingRequestContext(ServletRequest req, ServletResponse resp, 
ServletContext sctx) throws SlingException {
+        this.request = (HttpServletRequest)req;
+        this.response = (HttpServletResponse)resp;
+        this.servletContext = sctx;
+        request.setAttribute(REQ_ATTR_NAME,this);
+    }
+    
+    /** The ServiceLocator provides access to other services */
+    public abstract ServiceLocator getServiceLocator() throws SlingException;
+
+    /** Acquire a JCR Session if not done yet, and return it */
+    public abstract Session getSession() throws SlingException;
+
+    /** Get the Resource that the current Request processes, null if not found 
*/
+    public abstract Resource getResource() throws SlingException;
+
+    /**  The preferred Content-Type to use for the response */
+    public abstract String getPreferredResponseContentType() throws 
SlingException;
+    
+    /** The possible Content-Type values for the response, in order of 
preference */
+    public abstract String [] getResponseContentTypes() throws SlingException;
+
+    /** Return the SlingRequestPathInfo for this request: selectors, 
extension, suffix, etc. */
+    public abstract SlingRequestPathInfo getRequestPathInfo() throws 
SlingException;
+
+    /** Return the map of request parameters */
+    public abstract RequestParameterMap getRequestParameterMap() throws 
SlingException;
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestPathInfo.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestPathInfo.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestPathInfo.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingRequestPathInfo.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,127 @@
+/*
+ * 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.microsling.api;
+
+/** Sling breaks the request URI into four parts: the path itself, 
+ *  optional dot-separated selectors and extension that follow it, and 
+ *  an optional path suffix.
+ *  
+ * <p id="decomp">
+ * <b>Decomposition of a Request URL</b>
+ * <li>{@link Content#getPath() content path} - The longest substring of the
+ * request URI resolving to a {@link Content} object such that the content path
+ * is either the complete request URI the next character in the request URI
+ * after the content path is either a dot (<code>.</code>) or a slash 
(<code>/</code>).
+ * <li>{@link #getSelectors() selectors} - If the first character in the
+ * request URI after the content path is a dot, the string after the dot upto
+ * but not including the last dot before the next slash character or the end of
+ * the request URI. If the content path spans the complete request URI or if a
+ * slash follows the content path in the request, the no seletors exist. If 
only
+ * one dot follows the content path before the end of the request URI or the
+ * next slash, no selectors exist. The selectors are available as
+ * {@link #getSelectorString() a single string}, an
+ * {@link #getSelectors() array of strings}, which is the selector string
+ * splitted on dots, or
+ * {@link #getSelector(int) selectively by zero-based index}.
+ * <li>{@link #getExtension() extension} - The string after the last dot after
+ * the content path in the request uri but before the end of the request uri or
+ * the next slash after the content path in the request uri. If a slash follows
+ * the content path in the request URI, the extension is empty.
+ * <li>{@link #getSuffix() suffix path} - If the request URI contains more a
+ * slash character after the content path and optional selectors and extension,
+ * the path starting with the slash upto the end of the request URI is the
+ * suffix path.
+ * </ol>
+ * TODO: copy examples from the Sling ComponentRequest, or better, generate 
them
+ * from test cases.
+ */
+
+public interface SlingRequestPathInfo {
+    /**
+     * Returns the extension from the URL or an empty string if the request URL
+     * does not contain an extension.
+     * <p>
+     * Decomposition of the request URL is defined in the <a
+     * href="#decomp">Decomposition of a Request URL</a> above.
+     *
+     * @return The extension from the request URL.
+     */
+    String getExtension();
+
+    /**
+     * Returns the i-th selector of the selector string split on dots or
+     * <code>null</code> if i&lt;0 or i&gt;getSelectors().length. Alyways
+     * returns <code>null</code> if the request has no selectors.
+     * <p>
+     * Decomposition of the request URL is defined in the <a
+     * href="#decomp">Decomposition of a Request URL</a> above.
+     *
+     * @param i The index of the selector to return.
+     * @return The value of the selector if 0 &lt;= i &lt;
+     *         <code>getSelectors().length</code> or <code>null</code>
+     *         otherwise.
+     * @see #getSelectorString()
+     * @see #getSelectors()
+     */
+    String getSelector(int i);
+
+    /**
+     * Returns the selectors decoded from the request URL as an array of
+     * strings. This array is derived from the
+     * {@link #getSelectorString() selector string} by splitting the string on
+     * dots. Returns an empty array if the request has no selectors.
+     * <p>
+     * Decomposition of the request URL is defined in the <a
+     * href="#decomp">Decomposition of a Request URL</a> above.
+     *
+     * @see #getSelectorString()
+     * @see #getSelector(int)
+     */
+    String[] getSelectors();
+
+    /**
+     * Returns the selectors decoded from the request URL as string. Returns an
+     * empty string if the request has no selectors.
+     * <p>
+     * Decomposition of the request URL is defined in the <a
+     * href="#decomp">Decomposition of a Request URL</a> above.
+     *
+     * @see #getSelectors()
+     * @see #getSelector(int)
+     */
+    String getSelectorString();
+
+    /**
+     * Returns the suffix part of the URL or an empty string if the request URL
+     * does not contain a suffix.
+     * <p>
+     * Decomposition of the request URL is defined in the <a
+     * href="#decomp">Decomposition of a Request URL</a> above.
+     *
+     * @return The suffix part of the request URL.
+     */
+    String getSuffix();
+    
+    /** The path that was used to resolve (=load) the Resource that we are 
processing */
+    String getResourcePath();
+    
+    /** 
+     * Return the unused "content path" part of the URL, what comes after the 
path of the 
+     * resolved Resource, but before selectors, extension and suffix
+     */
+    String getUnusedContentPath();
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/HttpStatusCodeException.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/HttpStatusCodeException.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/HttpStatusCodeException.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/HttpStatusCodeException.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,37 @@
+/*
+ * 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.microsling.api.exceptions;
+
+import java.io.IOException;
+
+/** An Exception that causes Sling to return the specified 
+ *  HTTP status code.
+ */
+
+public class HttpStatusCodeException extends IOException {
+    private static final long serialVersionUID = 1L;
+    private final int statusCode;
+    
+    public HttpStatusCodeException(int statusCode, String message) {
+        super(message);
+        this.statusCode = statusCode;
+    }
+    
+    public int getStatusCode() {
+        return statusCode;
+    }
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/SlingException.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/SlingException.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/SlingException.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/exceptions/SlingException.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,16 @@
+package org.apache.sling.microsling.api.exceptions;
+
+import javax.servlet.ServletException;
+
+/** Base class for Sling exceptions */
+public class SlingException extends ServletException {
+    private static final long serialVersionUID = 1L;
+
+    public SlingException(String reason) {
+        super(reason);
+    }
+
+    public SlingException(String reason,Throwable cause) {
+        super(reason,cause);
+    }
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/helpers/AbstractFilter.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/helpers/AbstractFilter.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/helpers/AbstractFilter.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/helpers/AbstractFilter.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,129 @@
+/*
+ * 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.microsling.api.helpers;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * The <code>AbstractFilter</code> is a basic abstract implementation of the
+ * <code>javax.servlet.Filter</code> interface.
+ */
+public abstract class AbstractFilter implements Filter {
+
+    private FilterConfig filterConfig;
+
+    /**
+     * Default implementation of filter initialization keeping the filter
+     * configuration made available through the {@link #getFilterConfig()}
+     * method and calls the {@link #init()} method.
+     * <p>
+     * Implementations should not overwrite this method but rather implement
+     * their initialization in the {@link #init()} method.
+     *
+     * @param filterConfig The filter configuration
+     * @throws ServletException forwarded from calling the {@link #init()}
+     *             method.
+     */
+    public void init(FilterConfig filterConfig) throws ServletException {
+        this.filterConfig = filterConfig;
+
+        init();
+    }
+
+    /**
+     * Further initialization by the implementation of this class.
+     *
+     * @throws ServletException may be thrown if an error occurrs initializing
+     *             the filter.
+     */
+    protected abstract void init() throws ServletException;
+
+    /**
+     * Calls the
+     * {@link #doFilter(HttpServletRequest, HttpServletResponse, FilterChain)}
+     * method casting the <code>request</code> and <code>response</code>
+     * objects to the respective HTTP request and response objects. In case of 
a
+     * non-http request and/or response a <code>ServletException</code> is
+     * thrown.
+     *
+     * @param request The servlet request
+     * @param response The servlet response
+     * @param filterChain The filter chain to which processing is to be handed.
+     * @throws IOException forwarded from calling the
+     *             {@link #doFilter(HttpServletRequest, HttpServletResponse, 
FilterChain)}
+     *             method
+     * @throws ServletException if <code>request</code> and/or
+     *             <code>response</code> is not a HTTP request or response or
+     *             forwarded from calling the
+     *             {@link #doFilter(HttpServletRequest, HttpServletResponse, 
FilterChain)}
+     *             method.
+     */
+    public void doFilter(ServletRequest request, ServletResponse response,
+            FilterChain filterChain) throws IOException, ServletException {
+
+        try {
+            HttpServletRequest req = (HttpServletRequest) request;
+            HttpServletResponse res = (HttpServletResponse) response;
+            doFilter(req, res, filterChain);
+        } catch (ClassCastException cce) {
+            throw new ServletException("HTTP Requests supported only");
+        }
+    }
+
+    /**
+     * Called by the
+     * {@link #doFilter(ServletRequest, ServletResponse, FilterChain)} method
+     * for HTTP requests.
+     *
+     * @param request The HTTP servlet request
+     * @param response The HTTP servlet response
+     * @param filterChain The filter chain to which processing is to be handed.
+     * @throws IOException may be thrown in case of an Input/Output problem
+     * @throws ServletException may be thrown in case of any other servlet
+     *             processing issue.
+     */
+    protected abstract void doFilter(HttpServletRequest request,
+            HttpServletResponse response, FilterChain filterChain)
+            throws IOException, ServletException;
+
+    /**
+     * This default implementation does nothing. Implementations of this class
+     * may overwrite but should for stability reasons call this base class
+     * implementation.
+     */
+    public void destroy() {
+    }
+
+    /**
+     * Returns the <code>FilterConfig</code> with which this filter has been
+     * initialized.
+     */
+    protected FilterConfig getFilterConfig() {
+        return filterConfig;
+    }
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameter.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameter.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameter.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameter.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,111 @@
+/*
+ * 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.microsling.api.requestparams;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * The <code>RequestParameter</code> class represents a single parameter sent
+ * with the client request. Instances of this class are returned by the
+ * {@link SlingRequest#getRequestParameter(String)},
+ * {@link SlingRequest#getRequestParameters(String)} and
+ * {@link SlingRequest#getRequestParameterMap()} method.
+ * 
+ * @see SlingRequest#getRequestParameter(String)
+ * @see SlingRequest#getRequestParameters(String)
+ * @see SlingRequest#getRequestParameterMap()
+ */
+public interface RequestParameter {
+
+    /**
+     * Determines whether or not this instance represents a simple form field 
or
+     * an uploaded file.
+     * 
+     * @return <code>true</code> if the instance represents a simple form
+     *         field; <code>false</code> if it represents an uploaded file.
+     */
+    boolean isFormField();
+
+    /**
+     * Returns the content type passed by the browser or <code>null</code> if
+     * not defined.
+     * 
+     * @return The content type passed by the browser or <code>null</code> if
+     *         not defined.
+     */
+    String getContentType();
+
+    /**
+     * Returns the size in bytes of the parameter.
+     * 
+     * @return The size in bytes of the parameter.
+     */
+    long getSize();
+
+    /**
+     * Returns the contents of the parameter as an array of bytes.
+     * 
+     * @return The contents of the parameter as an array of bytes.
+     */
+    byte[] get();
+
+    /**
+     * Returns an InputStream that can be used to retrieve the contents of the
+     * file.
+     * 
+     * @return An InputStream that can be used to retrieve the contents of the
+     *         file.
+     * @throws IOException if an error occurs.
+     */
+    InputStream getInputStream() throws IOException;
+
+    /**
+     * Returns the original filename in the client's filesystem, as provided by
+     * the browser (or other client software). In most cases, this will be the
+     * base file name, without path information. However, some clients, such as
+     * the Opera browser, do include path information.
+     * 
+     * @return The original filename in the client's filesystem.
+     */
+    String getFileName();
+
+    /**
+     * Returns the contents of the parameter as a String, using the default
+     * character encoding. This method uses {@link #get()} to retrieve the
+     * contents of the item.
+     * 
+     * @return The contents of the parameter, as a string.
+     */
+    String getString();
+
+    /**
+     * Returns the contents of the parameter as a String, using the specified
+     * encoding. This method uses link {@link #get()} to retrieve the contents
+     * of the item.
+     * 
+     * @param encoding The character encoding to use.
+     * @return The contents of the parameter, as a string.
+     * @throws UnsupportedEncodingException if the requested character encoding
+     *             is not available.
+     */
+    String getString(String encoding) throws UnsupportedEncodingException;
+
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameterMap.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameterMap.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameterMap.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/requestparams/RequestParameterMap.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,39 @@
+/*
+ * 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.microsling.api.requestparams;
+
+import java.util.Map;
+
+import org.apache.sling.microsling.api.requestparams.RequestParameter;
+
+/**
+ * The <code>RequestParameterMap</code> encapsulates all request parameters of
+ * a request.
+ */
+public interface RequestParameterMap extends Map<String, RequestParameter[]> {
+
+    /** Returns all values for the named parameter or null if none
+     */
+    RequestParameter[] getValues(String name);
+
+    /** Returns the first value for the named parameter or null if none
+     */
+    RequestParameter getValue(String name);
+
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,39 @@
+package org.apache.sling.microsling.contenttype;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.microsling.api.SlingRequestContext;
+import org.apache.sling.microsling.api.helpers.AbstractFilter;
+import org.apache.sling.microsling.request.MicroslingRequestContext;
+
+public class ResponseContentTypeResolverFilter extends AbstractFilter {
+
+    @Override
+    protected void init() {
+        // no further initialization
+    }
+
+    public void doFilter(HttpServletRequest request,
+            HttpServletResponse response, FilterChain filterChain)
+            throws IOException, ServletException {
+
+        final MicroslingRequestContext ctx = 
(MicroslingRequestContext)SlingRequestContext.getFromRequest(request);
+
+        String file = "dummy." + ctx.getRequestPathInfo().getExtension();
+        final String contentType = 
getFilterConfig().getServletContext().getMimeType(file);
+        if (contentType != null) {
+            // Need this info in the SlingRequestContext,
+            // for the SlingScriptResolver for example
+            ctx.setResponseContentType(contentType);
+        }
+
+        filterChain.doFilter(request, response);
+
+    }
+
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/constants/HttpConstants.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/constants/HttpConstants.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/constants/HttpConstants.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/constants/HttpConstants.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.microsling.helpers.constants;
+
+/** HTTP-related constants */
+public interface HttpConstants {
+    public static final String METHOD_OPTIONS = "OPTIONS";
+    public static final String METHOD_GET = "GET";
+    public static final String METHOD_HEAD = "HEAD";
+    public static final String METHOD_POST = "POST";
+    public static final String METHOD_PUT = "PUT";
+    public static final String METHOD_DELETE = "DELETE";
+    public static final String METHOD_TRACE = "TRACE";
+    public static final String METHOD_CONNECT = "CONNECT";
+
+    public static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since";
+    public static final String HEADER_LAST_MODIFIED = "Last-Modified";
+
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/exceptions/MissingRequestAttributeException.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/exceptions/MissingRequestAttributeException.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/exceptions/MissingRequestAttributeException.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/exceptions/MissingRequestAttributeException.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,12 @@
+package org.apache.sling.microsling.helpers.exceptions;
+
+import org.apache.sling.microsling.api.exceptions.SlingException;
+
+/** Indicates a missing Request attribute */
+public class MissingRequestAttributeException extends SlingException {
+    private static final long serialVersionUID = 1L;
+
+    public MissingRequestAttributeException(String attributeName) {
+        super("Missing request attribute '" + attributeName + "'");
+    }
+}

Added: 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/SlingAllMethodsServlet.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/SlingAllMethodsServlet.java?rev=1807480&view=auto
==============================================================================
--- 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/SlingAllMethodsServlet.java
 (added)
+++ 
sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/helpers/servlets/SlingAllMethodsServlet.java
 Wed Sep  6 13:24:23 2017
@@ -0,0 +1,205 @@
+/*
+ * 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.microsling.helpers.servlets;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.microsling.helpers.constants.HttpConstants;
+
+
+/**
+ * Helper base class for data modifying Servlets used in Sling. This class
+ * extends the {@link SlingSafeMethodsServlet} by support for the 
<em>POST</em>,
+ * <em>PUT</em> and <em>DELETE</em> methods.
+ *
+ * @see SlingSafeMethodsServlet for more information on supporting more HTTP 
methods
+ */
+public class SlingAllMethodsServlet extends SlingSafeMethodsServlet {
+
+    /**
+     * Called by the
+     * {@link #mayService(HttpServletRequest, HttpServletResponse)} method to
+     * handle an HTTP <em>POST</em> request.
+     * <p>
+     * This default implementation reports back to the client that the method 
is
+     * not supported.
+     * <p>
+     * Implementations of this class should overwrite this method with their
+     * implementation for the HTTP <em>POST</em> method support.
+     *
+     * @param request The HTTP request
+     * @param response The HTTP response
+     * @throws ServletException Not thrown by this implementation.
+     * @throws IOException This implementation throws a
+     *             {@link HttpStatusCodeException} exception with the
+     *             appropriate status code and message.
+     */
+    protected void doPost(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+        handleMethodNotImplemented(request);
+    }
+
+    /**
+     * Called by the
+     * {@link #mayService(HttpServletRequest, HttpServletResponse)} method to
+     * handle an HTTP <em>PUT</em> request.
+     * <p>
+     * This default implementation reports back to the client that the method 
is
+     * not supported.
+     * <p>
+     * Implementations of this class should overwrite this method with their
+     * implementation for the HTTP <em>PUT</em> method support.
+     *
+     * @param request The HTTP request
+     * @param response The HTTP response
+     * @throws ServletException Not thrown by this implementation.
+     * @throws IOException This implementation throws a
+     *             {@link HttpStatusCodeException} exception with the
+     *             appropriate status code and message.
+     */
+    protected void doPut(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+        handleMethodNotImplemented(request);
+    }
+
+    /**
+     * Called by the
+     * {@link #mayService(HttpServletRequest, HttpServletResponse)} method to
+     * handle an HTTP <em>DELETE</em> request.
+     * <p>
+     * This default implementation reports back to the client that the method 
is
+     * not supported.
+     * <p>
+     * Implementations of this class should overwrite this method with their
+     * implementation for the HTTP <em>DELETE</em> method support.
+     *
+     * @param request The HTTP request
+     * @param response The HTTP response
+     * @throws ServletException Not thrown by this implementation.
+     * @throws IOException This implementation throws a
+     *             {@link HttpStatusCodeException} exception with the
+     *             appropriate status code and message.
+     */
+    protected void doDelete(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+        handleMethodNotImplemented(request);
+    }
+
+    /**
+     * Tries to handle the request by calling a Java method implemented for the
+     * respective HTTP request method.
+     * <p>
+     * This implementation first calls the base class implementation and only 
if
+     * the base class cannot dispatch will try to dispatch the supported 
methods
+     * <em>POST</em>, <em>PUT</em> and <em>DELETE</em> and returns
+     * <code>true</code> if any of these methods is requested. Otherwise
+     * <code>false</code> is just returned.
+     *
+     * @param request The HTTP request
+     * @param response The HTTP response
+     * @return <code>true</code> if the requested method 
(<code>request.getMethod()</code>)
+     *         is known. Otherwise <code>false</code> is returned.
+     * @throws ServletException Forwarded from any of the dispatched methods
+     * @throws IOException Forwarded from any of the dispatched methods
+     */
+    protected boolean mayService(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+
+        // assume the method is known for now
+        if (super.mayService(request, response)) {
+            return true;
+        }
+
+        // assume the method is known for now
+        boolean methodKnown = true;
+
+        String method = request.getMethod().toUpperCase();
+        if (HttpConstants.METHOD_POST.equals(method)) {
+            doPost(request, response);
+        } else if (HttpConstants.METHOD_PUT.equals(method)) {
+            doPut(request, response);
+        } else if (HttpConstants.METHOD_DELETE.equals(method)) {
+            doDelete(request, response);
+        } else {
+            // actually we do not know the method
+            methodKnown = false;
+        }
+
+        // return whether we actually knew the request method or not
+        return methodKnown;
+    }
+
+    /**
+     * Helper method called by
+     * {@link #doOptions(HttpServletRequest, HttpServletResponse)} to calculate
+     * the value of the <em>Allow</em> header sent as the response to the HTTP
+     * <em>OPTIONS</em> request.
+     * <p>
+     * This implementation overwrites the base class implementation adding
+     * support for the <em>POST</em>, <em>PUT</em> and <em>DELETE</em>
+     * methods in addition to the methods returned by the base class
+     * implementation.
+     *
+     * @param declaredMethods The public and protected methods declared in the
+     *            extension of this class.
+     * @return A <code>StringBuffer</code> containing the list of HTTP methods
+     *         supported.
+     */
+    protected StringBuffer getAllowedRequestMethods(
+            Map<String, Method> declaredMethods) {
+        StringBuffer allowBuf = 
super.getAllowedRequestMethods(declaredMethods);
+
+        // add more method names depending on the methods found
+        String className = SlingAllMethodsServlet.class.getName();
+        if (isMethodValid(declaredMethods.get("doPost"), className)) {
+            allowBuf.append(", ").append(HttpConstants.METHOD_POST);
+
+        } else if (isMethodValid(declaredMethods.get("doPut"), className)) {
+            allowBuf.append(", ").append(HttpConstants.METHOD_PUT);
+
+        } else if (isMethodValid(declaredMethods.get("doDelete"), className)) {
+            allowBuf.append(", ").append(HttpConstants.METHOD_DELETE);
+        }
+
+        return allowBuf;
+    }
+
+    /**
+     * Returns <code>true</code> if <code>method</code> is not
+     * <code>null</code> and the method is not defined in the class named by
+     * <code>className</code>.
+     * <p>
+     * This method may be used to make sure a method is actually overwritten 
and
+     * not just the default implementation.
+     *
+     * @param method The Method to check
+     * @param className The name of class assumed to contained the initial
+     *            declaration of the method.
+     * @return <code>true</code> if <code>method</code> is not
+     *         <code>null</code> and the methods declaring class is not the
+     *         given class.
+     */
+    protected boolean isMethodValid(Method method, String className) {
+        return method != null && 
!method.getClass().getName().equals(className);
+    }
+}


Reply via email to