incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1092638 - in /sling/trunk/launchpad: builder/src/main/bundles/list.xml installer/pom.xml installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
Date Fri, 15 Apr 2011 09:30:38 GMT
Author: cziegeler
Date: Fri Apr 15 09:30:38 2011
New Revision: 1092638

URL: http://svn.apache.org/viewvc?rev=1092638&view=rev
Log:
SLING-2052 : Launchpad installer does not support nested structure

Modified:
    sling/trunk/launchpad/builder/src/main/bundles/list.xml
    sling/trunk/launchpad/installer/pom.xml
    sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java

Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=1092638&r1=1092637&r2=1092638&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original)
+++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Fri Apr 15 09:30:38 2011
@@ -208,12 +208,17 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.launchpad.installer</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.installer.core</artifactId>
-            <version>3.1.2</version>
+            <version>3.1.3-SNAPSHOT</version>
+        </bundle>
+        <bundle>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.installer.factory.configuration</artifactId>
+            <version>0.9.0-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>
@@ -223,7 +228,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.installer.provider.jcr</artifactId>
-            <version>3.0.4</version>
+            <version>3.0.5-SNAPSHOT</version>
         </bundle>
     </startLevel>
     <startLevel level="1">

Modified: sling/trunk/launchpad/installer/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/installer/pom.xml?rev=1092638&r1=1092637&r2=1092638&view=diff
==============================================================================
--- sling/trunk/launchpad/installer/pom.xml (original)
+++ sling/trunk/launchpad/installer/pom.xml Fri Apr 15 09:30:38 2011
@@ -61,7 +61,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.installer.core</artifactId>
-            <version>3.1.0</version>
+            <version>3.1.3-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java?rev=1092638&r1=1092637&r2=1092638&view=diff
==============================================================================
--- sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
(original)
+++ sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
Fri Apr 15 09:30:38 2011
@@ -18,7 +18,9 @@ package org.apache.sling.launchpad.insta
 
 import java.io.InputStream;
 import java.util.Collection;
+import java.util.Dictionary;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
 
 import org.apache.sling.installer.api.InstallableResource;
@@ -43,6 +45,37 @@ public class LaunchpadConfigInstaller {
      */
     private static final String ROOT_INSTALL_PATH = "resources/install";
 
+    private static boolean checkPath(final LaunchpadContentProvider resourceProvider,
+            final Collection<InstallableResource> installables,
+            final String rootPath,
+            final String resourceType) {
+        int count = 0;
+        final Logger logger = LoggerFactory.getLogger(LaunchpadConfigInstaller.class);
+        final Iterator<String> configPaths = resourceProvider.getChildren(rootPath);
+        if ( configPaths != null ) {
+            final int hintPos = rootPath.lastIndexOf('/');
+            final String hint = rootPath.substring(hintPos + 1);
+            while (configPaths.hasNext()) {
+                String path = configPaths.next();
+                if ( path.endsWith("/") ) {
+                    path = path.substring(0, path.length() - 1);
+                }
+                if ( !checkPath(resourceProvider, installables, path, resourceType) ) {
+                    logger.info("Launchpad {} file will be installed: {}", resourceType,
path);
+                    Dictionary<String, Object> dict = null;
+                    if ( InstallableResource.TYPE_FILE.equals(resourceType) ) {
+                        dict = new Hashtable<String, Object>();
+                        dict.put(InstallableResource.INSTALLATION_HINT, hint);
+                    }
+                    final InputStream stream = resourceProvider.getResourceAsStream(path);
+                    installables.add(new InstallableResource(path, stream, dict, null, resourceType,
null));
+                    count++;
+                }
+            }
+        }
+        return count > 0;
+    }
+
     public static void install(final OsgiInstaller installer,
             final LaunchpadContentProvider resourceProvider) {
         final Logger logger = LoggerFactory.getLogger(LaunchpadConfigInstaller.class);
@@ -52,26 +85,10 @@ public class LaunchpadConfigInstaller {
         final Collection<InstallableResource> installables = new HashSet<InstallableResource>();
 
         // configurations
-        final Iterator<String> configPaths = resourceProvider.getChildren(ROOT_CONFIG_PATH);
-        if ( configPaths != null ) {
-            while (configPaths.hasNext()) {
-                final String path = configPaths.next();
-                logger.info("Config launchpad file will be installed: {}", path);
-                final InputStream stream = resourceProvider.getResourceAsStream(path);
-                installables.add(new InstallableResource(path, stream, null, null, InstallableResource.TYPE_PROPERTIES,
null));
-            }
-        }
+        checkPath(resourceProvider, installables, ROOT_CONFIG_PATH, InstallableResource.TYPE_PROPERTIES);
 
         // files
-        final Iterator<String> filePaths = resourceProvider.getChildren(ROOT_INSTALL_PATH);
-        if ( filePaths != null ) {
-            while (filePaths.hasNext()) {
-                final String path = filePaths.next();
-                logger.info("Launchpad file will be installed: {}", path);
-                final InputStream stream = resourceProvider.getResourceAsStream(path);
-                installables.add(new InstallableResource(path, stream, null, null, InstallableResource.TYPE_FILE,
null));
-            }
-        }
+        checkPath(resourceProvider, installables, ROOT_INSTALL_PATH, InstallableResource.TYPE_FILE);
 
         final InstallableResource [] toInstall = installables.toArray(new InstallableResource
[]{});
         installer.registerResources("launchpad", (toInstall));



Mime
View raw message