You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:30:28 UTC

[sling-org-apache-sling-tooling-support-install] branch master created (now 690c71e)

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

rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git.


      at 690c71e  Move to latest parent pom and official OSGi annotations

This branch includes the following new commits:

     new e61fdc8  SLING-3019 :  Provide a mechanism to install a bundle based on a directory
     new fddb6be  SLING-3019 - Provide a mechanism to install a bundle based on a directory
     new a6a9aba  SLING-3019 - Provide a mechanism to install a bundle based on a directory
     new c72ad51  SLING-3019 - Provide a mechanism to install a bundle based on a directory
     new 10b240d  SLING-3019 - Provide a mechanism to install a bundle based on a directory
     new 1bb35cf  [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.0
     new 324d128  [maven-release-plugin] prepare for next development iteration
     new 75e4247  no-jira : typo in error message
     new 3082373  SLING-4405 - Unable to install new bundle using the jar upload mechanism
     new 45a2b80  [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.2
     new 225eb2a  [maven-release-plugin] prepare for next development iteration
     new 9444538  Update the main reactor to parent 25
     new eb49cc2  Switch to parent pom 26
     new 595b44b  SLING-6907: Remove commons.json from Tooling Support Install
     new 4e1187d  [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.4
     new e544446  [maven-release-plugin] prepare for next development iteration
     new 72895ad  SLING-7167 Adjust READMEs
     new 690c71e  Move to latest parent pom and official OSGi annotations

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


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-tooling-support-install] 17/18: SLING-7167 Adjust READMEs

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 72895ad354ec1cefadf705ddbb213a8ddf953f2e
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Oct 3 09:42:25 2017 +0000

    SLING-7167 Adjust READMEs
    
    add missing README
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810810 13f79535-47bb-0310-9956-ffa450edef68
---
 README.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fbf0e6b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# Apache Sling Tooling Support Install
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 18/18: Move to latest parent pom and official OSGi annotations

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 690c71e10473c1779d9e984f09da3d93a6a078cb
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 4 14:41:35 2017 +0000

    Move to latest parent pom and official OSGi annotations
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1811077 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 21 +++--------------
 .../support/install/impl/InstallServlet.java       | 26 +++++++++++-----------
 2 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/pom.xml b/pom.xml
index d708da6..fb80a6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>26</version>
+        <version>32</version>
     </parent>
 
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
@@ -42,17 +42,10 @@
         <plugins>
             <plugin>
                 <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
-                        <Private-Package>
-                            org.apache.sling.tooling.support.install.impl
-                        </Private-Package>
                         <Embed-Dependency>
                                 org.apache.felix.utils;inline=org/apache/felix/utils/json/JSONWriter.class
                         </Embed-Dependency>
@@ -64,24 +57,16 @@
     
     <dependencies>
         <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
+            <artifactId>javax.servlet-api</artifactId>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
+            <artifactId>osgi.core</artifactId>
         </dependency>
         <dependency>
             <groupId>commons-io</groupId>
diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index 8eee97d..9501f9a 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -37,30 +37,30 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.io.IOUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.commons.io.IOUtils;
 
 /**
  * Prototype for installing/updating a bundle from a directory
  */
-@Component
-@Service(value = Servlet.class)
-@Property(name="alias", value="/system/sling/tooling/install")
+@Component(service = Servlet.class,
+    property = {
+            Constants.SERVICE_VENDOR + "=The Apache Software Foundation",
+            "alias=/system/sling/tooling/install"
+    })
 public class InstallServlet extends HttpServlet {
 
     private static final long serialVersionUID = -8820366266126231409L;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 15/18: [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.4

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 4e1187d197da06bc9e1f4c4c3d83e4eb2685759a
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Fri Jun 2 21:38:43 2017 +0000

    [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.4
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1797457 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index d28e5ce..1369c62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,15 +27,15 @@
     </parent>
 
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
-    <version>1.0.3-SNAPSHOT</version>
+    <version>1.0.4</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Tooling Support Install</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.4</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.4</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.tooling.support.install-1.0.4</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 04/18: SLING-3019 - Provide a mechanism to install a bundle based on a directory

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit c72ad519b8b0fb9741cfeb9f728605fa0e67f7ca
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Oct 22 14:31:50 2013 +0000

    SLING-3019 - Provide a mechanism to install a bundle based on a
    directory
    
    Code cleanups:
    
    - Use IOUtils.closeQuietly where applicable
    - Use logAndWriteError consistently
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1534646 13f79535-47bb-0310-9956-ffa450edef68
---
 .../tooling/support/install/impl/InstallServlet.java  | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index 47b3bc0..dd0239e 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -212,33 +212,24 @@ public class InstallServlet extends HttpServlet {
                                 result.render(resp.getWriter());
                                 return;
                             } catch ( final BundleException be ) {
-                                logger.info("Unable to install/update bundle from dir " + dir, be);
-                                result = new InstallationResult(false,
-                                        "Unable to install/update bundle from dir " + dir);
+                                logAndWriteError("Unable to install/update bundle from dir " + dir, be, resp);
                             }
                         } finally {
                             tempFile.delete();
                         }
                     } else {
-                        logger.info("Manifest in {} does not have a symbolic name", dir);
-                        result = new InstallationResult(false, "Manifest in " + dir + " does not have a symbolic name");
+                        logAndWriteError("Manifest in " + dir + " does not have a symbolic name", resp);
                     }
                 } finally {
-                    if ( fis != null ) {
-                        fis.close();
-                    }
+                    IOUtils.closeQuietly(fis);
                 }
             } else {
                 result = new InstallationResult(false, "Dir " + dir + " does not have a manifest");
-                logger.info("Dir {} does not have a manifest", dir);
+                logAndWriteError("Dir " + dir + " does have a manifest", resp);
             }
         } else {
             result = new InstallationResult(false, "Dir " + dir + " does not exist");
-            logger.info("Dir {} does not exist", dir);
-        }
-        resp.setStatus(500);
-        if (result != null) {
-            result.render(resp.getWriter());
+            logAndWriteError("Dir " + dir + " does not exist", resp);
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 01/18: SLING-3019 : Provide a mechanism to install a bundle based on a directory

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit e61fdc8db0dbea759b12d3795dabf9230a50ec97
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Aug 15 06:28:01 2013 +0000

    SLING-3019 :  Provide a mechanism to install a bundle based on a directory
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1514171 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  85 ++++++++++
 .../support/install/impl/InstallServlet.java       | 185 +++++++++++++++++++++
 2 files changed, 270 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..85e151a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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>17</version>
+    </parent>
+
+    <groupId>org.apache.sling</groupId>
+    <artifactId>org.apache.sling.tooling.support.install</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling Tooling Support Install</name>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Private-Package>
+                            org.apache.sling.tooling.support.install.impl
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
new file mode 100644
index 0000000..3c6f48d
--- /dev/null
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -0,0 +1,185 @@
+/*
+ * 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.tooling.support.install.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.Deflater;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Prototype for installing/updating a bundle from a directory
+ */
+@Component
+@Service(value = Servlet.class)
+@Property(name="alias", value="/system/sling/tooling/install")
+public class InstallServlet extends HttpServlet {
+
+    private static final long serialVersionUID = -8820366266126231409L;
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private static final String DIR = "dir";
+
+    private BundleContext bundleContext;
+
+    @Activate
+    protected void activate(final BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+            throws ServletException, IOException {
+        final String dirPath = req.getParameter(DIR);
+        if ( dirPath == null ) {
+            logger.error("No dir parameter specified : {}", req.getParameterMap());
+            resp.setStatus(500);
+            return;
+        }
+        final File dir = new File(dirPath);
+        if ( dir.exists() && dir.isDirectory() ) {
+            logger.info("Checking dir {} for bundle install", dir);
+            final File manifestFile = new File(dir, JarFile.MANIFEST_NAME);
+            if ( manifestFile.exists() ) {
+                FileInputStream fis = null;
+                try {
+                    fis = new FileInputStream(manifestFile);
+                    final Manifest mf = new Manifest(fis);
+
+                    final String symbolicName = mf.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+                    if ( symbolicName != null ) {
+                        // search bundle
+                        Bundle found = null;
+                        for(final Bundle b : this.bundleContext.getBundles() ) {
+                            if ( symbolicName.equals(b.getSymbolicName()) ) {
+                                found = b;
+                                break;
+                            }
+                        }
+
+                        final File tempFile = File.createTempFile(dir.getName(), "bundle");
+                        try {
+                            createJar(dir, tempFile, mf);
+
+                            final InputStream in = new FileInputStream(tempFile);
+                            try {
+                                if ( found != null ) {
+                                    // update
+                                    found.update(in);
+                                } else {
+                                    // install
+                                    final Bundle b = bundleContext.installBundle(dir.getAbsolutePath(), in);
+                                    b.start();
+                                }
+                                resp.setStatus(200);
+                                return;
+                            } catch ( final BundleException be ) {
+                                logger.info("Unable to install/update bundle from dir " + dir, be);
+                            }
+                        } finally {
+                            tempFile.delete();
+                        }
+                    } else {
+                        logger.info("Manifest in {} does not have a symbolic name", dir);
+                    }
+                } finally {
+                    if ( fis != null ) {
+                        fis.close();
+                    }
+                }
+            } else {
+                logger.info("Dir {} does not have a manifest", dir);
+            }
+        } else {
+            logger.info("Dir {} does not exist", dir);
+        }
+        resp.setStatus(500);
+    }
+
+    private static void createJar(final File sourceDir, final File jarFile, final Manifest mf)
+    throws IOException {
+        final JarOutputStream zos = new JarOutputStream(new FileOutputStream(jarFile));
+        try {
+            zos.setLevel(Deflater.NO_COMPRESSION);
+            // manifest first
+            final ZipEntry anEntry = new ZipEntry(JarFile.MANIFEST_NAME);
+            zos.putNextEntry(anEntry);
+            mf.write(zos);
+            zos.closeEntry();
+            zipDir(sourceDir, zos, "");
+        } finally {
+            try {
+                zos.close();
+            } catch ( final IOException ignore ) {
+                // ignore
+            }
+        }
+    }
+
+    public static void zipDir(final File sourceDir, final ZipOutputStream zos, final String path)
+    throws IOException {
+        final byte[] readBuffer = new byte[8192];
+        int bytesIn = 0;
+
+        for(final File f : sourceDir.listFiles()) {
+            if (f.isDirectory()) {
+                final String prefix = path + f.getName() + "/";
+                zos.putNextEntry(new ZipEntry(prefix));
+                zipDir(f, zos, prefix);
+            } else {
+                final String entry = path + f.getName();
+                if ( !JarFile.MANIFEST_NAME.equals(entry) ) {
+                    final FileInputStream fis = new FileInputStream(f);
+                    try {
+                        final ZipEntry anEntry = new ZipEntry(entry);
+                        zos.putNextEntry(anEntry);
+                        while ( (bytesIn = fis.read(readBuffer)) != -1) {
+                            zos.write(readBuffer, 0, bytesIn);
+                        }
+                    } finally {
+                        fis.close();
+                    }
+                }
+            }
+        }
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 08/18: no-jira : typo in error message

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 75e4247f290408cec172f07482b2735714159597
Author: Stefan Egli <st...@apache.org>
AuthorDate: Fri May 16 14:24:14 2014 +0000

    no-jira : typo in error message
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1595212 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/tooling/support/install/impl/InstallServlet.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index ae3e7ac..9eea9e5 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -225,7 +225,7 @@ public class InstallServlet extends HttpServlet {
                 }
             } else {
                 result = new InstallationResult(false, "Dir " + dir + " does not have a manifest");
-                logAndWriteError("Dir " + dir + " does have a manifest", resp);
+                logAndWriteError("Dir " + dir + " does not have a manifest", resp);
             }
         } else {
             result = new InstallationResult(false, "Dir " + dir + " does not exist");

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 03/18: SLING-3019 - Provide a mechanism to install a bundle based on a directory

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit a6a9abae9140935d13e5678f6bb06ed4a54f3aad
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Oct 22 14:31:41 2013 +0000

    SLING-3019 - Provide a mechanism to install a bundle based on a
    directory
    
    Allow updating a bundle from an uploaded jar file.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1534645 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |   6 +
 .../support/install/impl/InstallServlet.java       | 149 ++++++++++++++++++---
 2 files changed, 135 insertions(+), 20 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0ec7b01..99d5b37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,5 +99,11 @@
             <version>2.4</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>1.2.2</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index 765eda7..47b3bc0 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -22,7 +22,9 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.Deflater;
@@ -38,13 +40,20 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.io.IOUtils;
 
 /**
  * Prototype for installing/updating a bundle from a directory
@@ -60,8 +69,13 @@ public class InstallServlet extends HttpServlet {
 
     private static final String DIR = "dir";
 
+    private static final int UPLOAD_IN_MEMORY_SIZE_THRESHOLD = 512 * 1024 * 1024;
+
     private BundleContext bundleContext;
 
+    @Reference
+    private PackageAdmin packageAdmin;
+
     @Activate
     protected void activate(final BundleContext bundleContext) {
         this.bundleContext = bundleContext;
@@ -71,16 +85,98 @@ public class InstallServlet extends HttpServlet {
     protected void doPost(HttpServletRequest req, HttpServletResponse resp)
             throws ServletException, IOException {
         final String dirPath = req.getParameter(DIR);
-        if ( dirPath == null ) {
-            logger.error("No dir parameter specified : {}", req.getParameterMap());
+
+        boolean isMultipart = ServletFileUpload.isMultipartContent(req);
+
+        if (dirPath == null && !isMultipart) {
+            logger.error("No dir parameter specified : {} and no multipart content found", req.getParameterMap());
             resp.setStatus(500);
             InstallationResult result = new InstallationResult(false, "No dir parameter specified: "
-                    + req.getParameterMap());
+                    + req.getParameterMap() + " and no multipart content found");
             result.render(resp.getWriter());
             return;
         }
-        final File dir = new File(dirPath);
-        installBasedOnDirectory(resp, dir);
+
+        if (isMultipart) {
+            installBasedOnUploadedJar(req, resp);
+        } else {
+            installBasedOnDirectory(resp, new File(dirPath));
+        }
+    }
+
+    private void installBasedOnUploadedJar(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+
+        InstallationResult result = null;
+
+        try {
+            DiskFileItemFactory factory = new DiskFileItemFactory();
+            // try to hold even largish bundles in memory to potentially improve performance
+            factory.setSizeThreshold(UPLOAD_IN_MEMORY_SIZE_THRESHOLD);
+
+            ServletFileUpload upload = new ServletFileUpload();
+            upload.setFileItemFactory(factory);
+
+            @SuppressWarnings("unchecked")
+            List<FileItem> items = upload.parseRequest(req);
+            if (items.size() != 1) {
+                logAndWriteError("Found " + items.size() + " items to process, but only updating 1 bundle is supported", resp);
+                return;
+            }
+
+            FileItem item = items.get(0);
+
+            JarInputStream jar = null;
+            InputStream rawInput = null;
+            try {
+                jar = new JarInputStream(item.getInputStream());
+                Manifest manifest = jar.getManifest();
+                if (manifest == null) {
+                    logAndWriteError("Uploaded jar file does not contain a manifest", resp);
+                    return;
+                }
+
+                final String symbolicName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+                if (symbolicName == null) {
+                    logAndWriteError("Manifest does not have a " + Constants.BUNDLE_SYMBOLICNAME, resp);
+                    return;
+                }
+
+                // the JarInputStream is used only for validation, we need a fresh input stream for updating
+                rawInput = item.getInputStream();
+
+                Bundle found = getBundle(symbolicName);
+                try {
+                    installOrUpdateBundle(found, rawInput, null);
+
+                    result = new InstallationResult(true, null);
+                    resp.setStatus(200);
+                    result.render(resp.getWriter());
+                    return;
+                } catch (BundleException e) {
+                    logAndWriteError("Unable to install/update bundle " + symbolicName, e, resp);
+                    return;
+                }
+            } finally {
+                IOUtils.closeQuietly(jar);
+                IOUtils.closeQuietly(rawInput);
+            }
+
+        } catch (FileUploadException e) {
+            logAndWriteError("Failed parsing uploaded bundle", e, resp);
+            return;
+        }
+    }
+
+    private void logAndWriteError(String message, HttpServletResponse resp) throws IOException {
+        logger.info(message);
+        resp.setStatus(500);
+        new InstallationResult(false, message).render(resp.getWriter());
+    }
+
+    private void logAndWriteError(String message, Exception e, HttpServletResponse resp) throws IOException {
+        logger.info(message, e);
+        resp.setStatus(500);
+        new InstallationResult(false, message + " : " + e.getMessage()).render(resp.getWriter());
     }
 
     private void installBasedOnDirectory(HttpServletResponse resp, final File dir) throws FileNotFoundException,
@@ -100,13 +196,7 @@ public class InstallServlet extends HttpServlet {
                     final String symbolicName = mf.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
                     if ( symbolicName != null ) {
                         // search bundle
-                        Bundle found = null;
-                        for(final Bundle b : this.bundleContext.getBundles() ) {
-                            if ( symbolicName.equals(b.getSymbolicName()) ) {
-                                found = b;
-                                break;
-                            }
-                        }
+                        Bundle found = getBundle(symbolicName);
 
                         final File tempFile = File.createTempFile(dir.getName(), "bundle");
                         try {
@@ -114,14 +204,9 @@ public class InstallServlet extends HttpServlet {
 
                             final InputStream in = new FileInputStream(tempFile);
                             try {
-                                if ( found != null ) {
-                                    // update
-                                    found.update(in);
-                                } else {
-                                    // install
-                                    final Bundle b = bundleContext.installBundle(dir.getAbsolutePath(), in);
-                                    b.start();
-                                }
+                                String location = dir.getAbsolutePath();
+
+                                installOrUpdateBundle(found, in, location);
                                 result = new InstallationResult(true, null);
                                 resp.setStatus(200);
                                 result.render(resp.getWriter());
@@ -157,6 +242,30 @@ public class InstallServlet extends HttpServlet {
         }
     }
 
+    private void installOrUpdateBundle(Bundle bundle, final InputStream in, String location) throws BundleException {
+        if (bundle != null) {
+            // update
+            bundle.update(in);
+
+            packageAdmin.refreshPackages(new Bundle[] { bundle });
+        } else {
+            // install
+            final Bundle b = bundleContext.installBundle(location, in);
+            b.start();
+        }
+    }
+
+    private Bundle getBundle(final String symbolicName) {
+        Bundle found = null;
+        for (final Bundle b : this.bundleContext.getBundles()) {
+            if (symbolicName.equals(b.getSymbolicName())) {
+                found = b;
+                break;
+            }
+        }
+        return found;
+    }
+
     private static void createJar(final File sourceDir, final File jarFile, final Manifest mf)
     throws IOException {
         final JarOutputStream zos = new JarOutputStream(new FileOutputStream(jarFile));

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 11/18: [maven-release-plugin] prepare for next development iteration

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 225eb2a112c6c7539aa72ae191b4e2f922094ed7
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Feb 19 08:51:27 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1660813 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 30248fd..6949941 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
-    <version>1.0.2</version>
+    <version>1.0.3-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Tooling Support Install</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.2</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.2</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.tooling.support.install-1.0.2</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 14/18: SLING-6907: Remove commons.json from Tooling Support Install

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 595b44bce6129609676c1a408ed3fa578eb9f2b9
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Thu Jun 1 20:04:44 2017 +0000

    SLING-6907: Remove commons.json from Tooling Support Install
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1797257 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                  | 16 +++++++++-------
 .../tooling/support/install/impl/InstallationResult.java |  6 +++---
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2615b24..d28e5ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,6 @@
         <version>26</version>
     </parent>
 
-    <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
     <version>1.0.3-SNAPSHOT</version>
     <packaging>bundle</packaging>
@@ -54,6 +53,9 @@
                         <Private-Package>
                             org.apache.sling.tooling.support.install.impl
                         </Private-Package>
+                        <Embed-Dependency>
+                                org.apache.felix.utils;inline=org/apache/felix/utils/json/JSONWriter.class
+                        </Embed-Dependency>
                     </instructions>
                 </configuration>
             </plugin>
@@ -82,12 +84,6 @@
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.json</artifactId>
-            <version>2.0.6</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>2.4</version>
@@ -105,5 +101,11 @@
             <version>1.2.2</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.utils</artifactId>
+            <version>1.9.0</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java
index c498d88..bd85870 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java
@@ -16,11 +16,11 @@
  */
 package org.apache.sling.tooling.support.install.impl;
 
+import java.io.IOException;
 import java.io.Writer;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.io.JSONWriter;
+import org.apache.felix.utils.json.JSONWriter;
 
 public class InstallationResult {
 
@@ -42,7 +42,7 @@ public class InstallationResult {
                 writer.key("message").value(message);
             }
             writer.endObject();
-        } catch (JSONException e) {
+        } catch (IOException e) {
             // never happens
             throw new RuntimeException(e);
         }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 06/18: [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.0

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 1bb35cf024fb44e5d6d4f3d94746193388cd27e3
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri May 2 12:23:50 2014 +0000

    [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1591885 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 99d5b37..d424b25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
-    <version>0.0.1-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Tooling Support Install</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.tooling.support.install-1.0.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 12/18: Update the main reactor to parent 25

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 9444538e358f376de3a5018dce3cb6b4b959002e
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Oct 5 10:03:45 2015 +0000

    Update the main reactor to parent 25
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1706780 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6949941..f1f01dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>17</version>
+        <version>25</version>
     </parent>
 
     <groupId>org.apache.sling</groupId>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 02/18: SLING-3019 - Provide a mechanism to install a bundle based on a directory

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit fddb6be35baab1bf6e4ee9aed201d53dcb92d11f
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Oct 22 14:31:34 2013 +0000

    SLING-3019 - Provide a mechanism to install a bundle based on a
    directory
    
    Added JSON rendering of responses.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1534644 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 18 ++++++++
 .../support/install/impl/InstallServlet.java       | 22 ++++++++++
 .../support/install/impl/InstallationResult.java   | 51 ++++++++++++++++++++++
 3 files changed, 91 insertions(+)

diff --git a/pom.xml b/pom.xml
index 85e151a..0ec7b01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,5 +81,23 @@
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.json</artifactId>
+            <version>2.0.6</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index 3c6f48d..765eda7 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -18,6 +18,7 @@ package org.apache.sling.tooling.support.install.impl;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -73,9 +74,20 @@ public class InstallServlet extends HttpServlet {
         if ( dirPath == null ) {
             logger.error("No dir parameter specified : {}", req.getParameterMap());
             resp.setStatus(500);
+            InstallationResult result = new InstallationResult(false, "No dir parameter specified: "
+                    + req.getParameterMap());
+            result.render(resp.getWriter());
             return;
         }
         final File dir = new File(dirPath);
+        installBasedOnDirectory(resp, dir);
+    }
+
+    private void installBasedOnDirectory(HttpServletResponse resp, final File dir) throws FileNotFoundException,
+            IOException {
+
+        InstallationResult result = null;
+
         if ( dir.exists() && dir.isDirectory() ) {
             logger.info("Checking dir {} for bundle install", dir);
             final File manifestFile = new File(dir, JarFile.MANIFEST_NAME);
@@ -110,16 +122,21 @@ public class InstallServlet extends HttpServlet {
                                     final Bundle b = bundleContext.installBundle(dir.getAbsolutePath(), in);
                                     b.start();
                                 }
+                                result = new InstallationResult(true, null);
                                 resp.setStatus(200);
+                                result.render(resp.getWriter());
                                 return;
                             } catch ( final BundleException be ) {
                                 logger.info("Unable to install/update bundle from dir " + dir, be);
+                                result = new InstallationResult(false,
+                                        "Unable to install/update bundle from dir " + dir);
                             }
                         } finally {
                             tempFile.delete();
                         }
                     } else {
                         logger.info("Manifest in {} does not have a symbolic name", dir);
+                        result = new InstallationResult(false, "Manifest in " + dir + " does not have a symbolic name");
                     }
                 } finally {
                     if ( fis != null ) {
@@ -127,12 +144,17 @@ public class InstallServlet extends HttpServlet {
                     }
                 }
             } else {
+                result = new InstallationResult(false, "Dir " + dir + " does not have a manifest");
                 logger.info("Dir {} does not have a manifest", dir);
             }
         } else {
+            result = new InstallationResult(false, "Dir " + dir + " does not exist");
             logger.info("Dir {} does not exist", dir);
         }
         resp.setStatus(500);
+        if (result != null) {
+            result.render(resp.getWriter());
+        }
     }
 
     private static void createJar(final File sourceDir, final File jarFile, final Manifest mf)
diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java
new file mode 100644
index 0000000..c498d88
--- /dev/null
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallationResult.java
@@ -0,0 +1,51 @@
+/*
+ * 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.tooling.support.install.impl;
+
+import java.io.Writer;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.io.JSONWriter;
+
+public class InstallationResult {
+
+    private final boolean status;
+    private final String message;
+
+    public InstallationResult(boolean status, String message) {
+        this.status = status;
+        this.message = message;
+    }
+
+    public void render(Writer out) {
+
+        try {
+            JSONWriter writer = new JSONWriter(out);
+            writer.object();
+            writer.key("status").value(status ? "OK" : "FAILURE");
+            if (!StringUtils.isEmpty(message)) {
+                writer.key("message").value(message);
+            }
+            writer.endObject();
+        } catch (JSONException e) {
+            // never happens
+            throw new RuntimeException(e);
+        }
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 13/18: Switch to parent pom 26

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit eb49cc265362b2cd1128956f1c19e5017ebc953b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Jan 3 14:07:46 2016 +0000

    Switch to parent pom 26
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1722720 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index f1f01dc..2615b24 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>25</version>
+        <version>26</version>
     </parent>
 
     <groupId>org.apache.sling</groupId>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 10/18: [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.2

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 45a2b80f527c2c0c91c1b12af76b31d08934ed0a
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Feb 19 08:51:09 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.tooling.support.install-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1660811 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0ac917a..30248fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Tooling Support Install</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.2</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.2</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.tooling.support.install-1.0.2</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 05/18: SLING-3019 - Provide a mechanism to install a bundle based on a directory

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 10b240d1dfc380333a405c7fa5f536e8f72f26ed
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Oct 22 14:31:58 2013 +0000

    SLING-3019 - Provide a mechanism to install a bundle based on a
    directory
    
    Refresh bundles when both installing and updating, to make sure wirings
    are correct.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1534647 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/tooling/support/install/impl/InstallServlet.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index dd0239e..ae3e7ac 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -237,13 +237,15 @@ public class InstallServlet extends HttpServlet {
         if (bundle != null) {
             // update
             bundle.update(in);
-
-            packageAdmin.refreshPackages(new Bundle[] { bundle });
         } else {
             // install
             final Bundle b = bundleContext.installBundle(location, in);
             b.start();
         }
+
+        // take into account added/removed packages for updated bundles and newly satisfied optional package imports
+        // for new installed bundles
+        packageAdmin.refreshPackages(new Bundle[] { bundle });
     }
 
     private Bundle getBundle(final String symbolicName) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 16/18: [maven-release-plugin] prepare for next development iteration

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit e544446f05d8d87d336a2a112f87f1278ecc99d1
Author: Karl Pauls <pa...@apache.org>
AuthorDate: Fri Jun 2 21:39:00 2017 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1797459 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1369c62..d708da6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,15 +27,15 @@
     </parent>
 
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
-    <version>1.0.4</version>
+    <version>1.0.5-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Tooling Support Install</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.4</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.4</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.tooling.support.install-1.0.4</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 07/18: [maven-release-plugin] prepare for next development iteration

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 324d128de03123b8fa38ddf29b203e1ad53f6e3f
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri May 2 12:25:18 2014 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1591887 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index d424b25..0ac917a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.tooling.support.install</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Tooling Support Install</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.tooling.support.install-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.tooling.support.install-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/install</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/install</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-tooling-support-install] 09/18: SLING-4405 - Unable to install new bundle using the jar upload mechanism

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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-install.git

commit 3082373133dcf79a031f6393afc36a202d823f1e
Author: rombert <ro...@unknown>
AuthorDate: Tue Feb 17 23:29:58 2015 +0000

    SLING-4405 - Unable to install new bundle using the jar upload mechanism
    
    Make sure the bundles uploaded as jar files have a location set.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1660537 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/tooling/support/install/impl/InstallServlet.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
index 9eea9e5..8eee97d 100644
--- a/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
+++ b/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
@@ -136,17 +136,20 @@ public class InstallServlet extends HttpServlet {
                 }
 
                 final String symbolicName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+
                 if (symbolicName == null) {
                     logAndWriteError("Manifest does not have a " + Constants.BUNDLE_SYMBOLICNAME, resp);
                     return;
                 }
 
+                final String version = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+
                 // the JarInputStream is used only for validation, we need a fresh input stream for updating
                 rawInput = item.getInputStream();
 
                 Bundle found = getBundle(symbolicName);
                 try {
-                    installOrUpdateBundle(found, rawInput, null);
+                    installOrUpdateBundle(found, rawInput, "inputstream:" + symbolicName + "-" + version + ".jar");
 
                     result = new InstallationResult(true, null);
                     resp.setStatus(200);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.