incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r629898 - in /incubator/sling/trunk/launchpad: launchpad-content/ launchpad-content/src/ launchpad-content/src/main/ launchpad-content/src/main/resources/ launchpad-content/src/main/resources/content/ launchpad-servlets/src/main/java/org/ap...
Date Thu, 21 Feb 2008 18:10:36 GMT
Author: bdelacretaz
Date: Thu Feb 21 10:10:32 2008
New Revision: 629898

URL: http://svn.apache.org/viewvc?rev=629898&view=rev
Log:
SLING-265 - Configurable root redirect for LaunchpadDefaultServlet. Also added the launchpad-content
module, meant for launchpad examples

Added:
    incubator/sling/trunk/launchpad/launchpad-content/   (with props)
    incubator/sling/trunk/launchpad/launchpad-content/pom.xml   (with props)
    incubator/sling/trunk/launchpad/launchpad-content/src/
    incubator/sling/trunk/launchpad/launchpad-content/src/main/
    incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/
    incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/
    incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/index.html
  (with props)
Modified:
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/resources/OSGI-INF/metatype/metatype.properties
    incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml
    incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpPingTest.java

Propchange: incubator/sling/trunk/launchpad/launchpad-content/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Feb 21 10:10:32 2008
@@ -0,0 +1,9 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders

Added: incubator/sling/trunk/launchpad/launchpad-content/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-content/pom.xml?rev=629898&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-content/pom.xml (added)
+++ incubator/sling/trunk/launchpad/launchpad-content/pom.xml Thu Feb 21 10:10:32 2008
@@ -0,0 +1,64 @@
+<?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>
+  <parent>
+    <groupId>org.apache.sling</groupId>
+    <artifactId>sling</artifactId>
+    <version>1-incubator-SNAPSHOT</version>
+    <relativePath>../../parent/pom.xml</relativePath>
+  </parent>
+
+  <artifactId>org.apache.sling.launchpad.content</artifactId>
+  <packaging>bundle</packaging>
+  <version>2.0.0-incubator-SNAPSHOT</version>
+
+  <name>Sling Launchpad Content</name>
+  <description>
+    This bundle provides content that is loaded in the JCR repository
+    for the Sling Launchpad.
+  </description>
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/launchpad-content</connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/launchpad-content
+    </developerConnection>
+    <url>http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-content</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package></Export-Package>
+            <Sling-Initial-Content>content</Sling-Initial-Content>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: incubator/sling/trunk/launchpad/launchpad-content/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/index.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/index.html?rev=629898&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/index.html
(added)
+++ incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/index.html
Thu Feb 21 10:10:32 2008
@@ -0,0 +1,9 @@
+<html>
+  <!-- Do not remove this comment, used for Launchpad integration tests -->
+  <body>
+    <h1>Welcome to the Sling Launchpad</h1>
+    <p>
+      We'll have more content for you here, hopefully soon...
+    </p>
+  </body>
+</html>
\ No newline at end of file

Propchange: incubator/sling/trunk/launchpad/launchpad-content/src/main/resources/content/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java?rev=629898&r1=629897&r2=629898&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
(original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
Thu Feb 21 10:10:32 2008
@@ -37,6 +37,7 @@
 import org.apache.sling.launchpad.renderers.PlainTextRendererServlet;
 import org.apache.sling.launchpad.renderers.StreamRendererServlet;
 import org.apache.sling.ujax.UjaxPostServlet;
+import org.osgi.service.component.ComponentContext;
 
 /**
  * Replaces the Sling default servlet (that bundle must NOT be
@@ -49,7 +50,6 @@
  *  
  * @scr.component 
  *  immediate="true" 
- *  metatype="false"
  *  
  * @scr.property 
  *  name="service.description"
@@ -77,6 +77,10 @@
 
     private Map<String, Servlet> getServlets;
 
+    /** @scr.property value="index.html" */
+    private static final String PROP_ROOT_REDIRECT = "root.redirect";
+    private String rootRedirect;
+    
     @Override
     public void init(ServletConfig config) throws ServletException {
 
@@ -104,6 +108,11 @@
             ServletException {
         final Resource resource = request.getResource();
 
+        if(rootRedirect!= null && rootRedirect.length() > 0 && "/".equals(request.getPathInfo()))
{
+            response.sendRedirect(rootRedirect);
+            return;
+        }
+        
         if (request.getPathInfo().startsWith(UjaxInfoServlet.PATH_PREFIX)) {
             ujaxInfoServlet.service(request, response);
             return;
@@ -142,5 +151,8 @@
             IOException {
         postServlet.service(request, response);
     }
-
+    
+    protected void activate(ComponentContext componentContext) throws Exception {
+        rootRedirect = (String)componentContext.getProperties().get(PROP_ROOT_REDIRECT);
+    }
 }

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=629898&r1=629897&r2=629898&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/resources/OSGI-INF/metatype/metatype.properties
Thu Feb 21 10:10:32 2008
@@ -17,10 +17,12 @@
 #  under the License.
 #
 
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor generated by the
-# the Sling SCR plugin
+org.apache.sling.launchpad.servlets.LaunchpadDefaultServlet.name = Sling Launchpad Default
Servlet
 
-UslingMainServlet.name = ┬Ásling main servlet
-UslingMainServlet.description = Routes HTTP request to the ┬Ásling default servlets  
\ No newline at end of file
+sling.servlet.resourceTypes.name = Servlet resource types
+sling.servlet.resourceTypes.description = Must be 'sling/servlet/default' to use this servlet
as \
+the default Sling servlet. 
+
+root.redirect.name = Root redirect 
+root.redirect.description = If not empty, requests to / are redirected \
+to this URL.  
\ No newline at end of file

Modified: incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml?rev=629898&r1=629897&r2=629898&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml (original)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml Thu Feb 21 10:10:32 2008
@@ -420,6 +420,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.launchpad.content</artifactId>
+      <version>2.0.0-incubator-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.api</artifactId>
       <version>2.0.0-incubator-SNAPSHOT</version>
       <scope>provided</scope>

Modified: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpPingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpPingTest.java?rev=629898&r1=629897&r2=629898&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpPingTest.java
(original)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpPingTest.java
Thu Feb 21 10:10:32 2008
@@ -16,18 +16,26 @@
  */
 package org.apache.sling.launchpad.webapp.integrationtest;
 
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.methods.GetMethod;
+
 
 /** Ping the Sling server to verify that our integration test
  *  setup is ok.
  */
 public class HttpPingTest extends HttpTestBase {
     
-    public void TODO_FAILS_testWebServerRoot() throws Exception
+    public void testWebServerRoot() throws Exception
     {
-        // disabled for now: an empty repository returns 404,
-        // but if there's someting under /content it is returned
-        // due to the default mappings
-        assertHttpStatus(HTTP_BASE_URL + "/", 404);
+        // by default, the Launchpad default servlet redirects / to index.html
+        final String url = HTTP_BASE_URL + "/";
+        final GetMethod get = new GetMethod(url);
+        get.setFollowRedirects(false);
+        final int status = httpClient.executeMethod(get);
+        assertEquals("Status must be 302 for " + url, 302, status);
+        final Header h = get.getResponseHeader("Location");
+        assertNotNull("Location header must be provided",h);
+        assertEquals(HTTP_BASE_URL + "/index.html", h.getValue());
     }
     
     public void test404() throws Exception



Mime
View raw message