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/11/07 09:16:13 UTC

[sling-maven-sling-plugin] annotated tag maven-sling-plugin-2.0.4-incubator created (now 197c1d4)

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

rombert pushed a change to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git.


      at 197c1d4  (tag)
 tagging 2bb98deb99ea00f394f08e4662e88fae3d436782 (commit)
      by Felix Meschberger
      on Thu Jun 18 09:21:02 2009 +0000

- Log -----------------------------------------------------------------
maven-sling-plugin-2.0.4-incubator
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 14afbbd  Import initial Sling source
     new 56ed45e  Ignore target dirs
     new 9fb5752  Ignore Eclipse and build artifacts
     new 22fa502  Fix scm settings
     new e20a515  Ignore Eclipse .settings
     new 0037cc7  Fix license headers.
     new 2bfbdfa  Fix license headers.
     new a243ac7  SLING-10 Implement support to install bundles into a locally running Sling instance
     new a9dbefb  SLING-10 Implement support to install bundles into a locally running Sling instance   - skip does not really work   - only print the stack trace of the ConnectException at debug, else just print a line of info
     new 7447613  Remove default value from obr parameter
     new 37eea5b  SLING-14 Remove outdated Maven Sling Plugin goals copy and list
     new cc9903a  - Abstract bundle symbolic name extraction - Install: merge directory and file name parameter to bundleFileName
     new f6f3119  Add new plugin comparable to install named install-file which allows installation of a bundle without a POM
     new 8e820d3  Fail project build if installation fails
     new cbd59e3  - fix license header(s) - make abstract classes package level - cleanup imports
     new d10b297  Add new plugin comparable to deploy named deploy-file which allows deployment of a bundle without a POM
     new 95b877a  Allow skipping of bundle deploy goal even though it might be configured
     new b83577d  Do not throw an exception if jar does not exist. This allows a multi project deploy with other artifact types like poms, webapps etc.
     new 329f3a0  SLING-83 Move modules according to the new module structure
     new b197a9a  SLING-83: Add two maven modules.
     new db74a3c  Remove unused imports and use latest rhino, httpclient and jruby.
     new a7886ac  Update to commons-io 1.4 - no need for wrapper bundle anymore (RTC not needed)
     new 4770f37  Use OSGi core and cmpendium jars from Felix project.
     new 5cd3f52  SLING-204 - add svn ignore patterns for intellij
     new 2899a99  Move licence and notice to top level dir.
     new 27489f3  Add incubator disclaimer.
     new 30d1f92  Write first element in pom in one line (to avoid problems with the maven release plugin) and minor pom fixes.
     new b392ae3  Update notice files.
     new fa2d977  Update notice files for maven plugins.
     new c7d00b9  SLING-404: Remove/disable assembly related stuff.
     new 36f032a  SLING-404: Remove/disable assembly related stuff.
     new edfc010  Eclude maven-eclipse.xml generated by the maven eclipse plugin.
     new f6b4c24  SLING-463 Add support for refresh packages
     new 3f0fd80  SLING-483: Add excludes for javadocs (WiP)
     new 798c300  SLING-495 - NOTICE files generated using mknotice script
     new 77516af  SLING-495 - NOTICE files updated according to changes in revision 662927
     new e00b9fb  SLING-495 - NOTICE files regenerated with revision 663097 changes
     new 04c1f67  Use released version of parent pom.
     new aa3f6e6  [maven-release-plugin] prepare release maven-sling-plugin-2.0.0-incubator
     new e6bbb8a  [maven-release-plugin] prepare for next development iteration
     new 6311762  Fix reference to parent pom.
     new ec36bd6  SLING-521: Restore plugin notice files.
     new d495a20  SLING-532 Fix scope for http client dependency and add commons-logging
     new 8df9129  SLING-521: Separate between notice files for bin and src dists.
     new 384bfcc  SLING-521: Separate between notice files for bin and src dists.
     new fb8ac66  Change copyright year to 2008.
     new 3299e7f  Update to released versions.
     new d5b6c52  [maven-release-plugin] prepare release maven-sling-plugin-2.0.2-incubator
     new eb46ae1  [maven-release-plugin] prepare for next development iteration
     new 8ae53e4  Use latest snapshots again to make project buildable.
     new e323d6c  Use released parent pom where possible.
     new 46a3de9  SLING-555 : Update all poms to use the latest parent pom; update parent pom to include the incubator repo for plugins and use latest plugins.
     new 91a1d2a  SLING-798 : Initial support to create fs provider configs. New configs are currently posted on each sling:install
     new 7a126c4  SLING-808 : Increase version to 5-incubator-SNAPSHOT
     new db8a36b  Update notice files to include 2009 in copyright statement.
     new 301bf8b  SLING-811 Reduce DependencyManagement in the parent pom and add explicit versions to the modules
     new 8db8a25  SLING-798 : Get available configurations from web console before creating configs
     new bfc290f  SLING-829 Cosmetics to the bundle/project names
     new 0c7cb63  SLING-798 - Add web console version check.
     new 19b0fc0  SLING-798 - Don't use web console version check. Rely on the response content type.
     new de1cdac  SLING-798 - Adapt to latest web console and remove obsolete configurations.
     new df0b01c  SLING-834 - Provide uninstall to uninstall a bundle and remove fs configurations.
     new 349edbe  SLING-861 : Apply patch by Alexander Klimetschek to support PUT in the maven-sling-plugin
     new 1c70e6e  SLING-861 : Rename mimeTypeForPut to just mimeType.
     new 1d6da09  SLING-653 : Add validaion mojo for validating resources; added the validation of included json files.
     new 517bab9  SLING-876 : Handle optional target path on resource configuration when searching a resource.
     new 4539ff1  SLING-653 : Properly handle closing of file, json file might be a json array.
     new 21d4521  FS mounting should be disabled by default to have the same behaviour as previous version by default.
     new c94aed2  SLING-653 : Use new validator from commons.
     new e402842  Default resources directory might not exists.
     new d962bef  Fix fsresource provider and sling plugin after recent refactorings.
     new 2c55daa  SLING-941: Lots of svn:eol-style settings missing
     new f88c746  [maven-release-plugin]  copy for tag maven-sling-plugin-2.0.4-incubator
     new 2bb98de  Move Sling to new TLP location

The 74 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-maven-sling-plugin] 19/28: SLING-653 : Add validaion mojo for validating resources; added the validation of included json files.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 1d6da0967e33b04bb66c259da410ad897ae09bbf
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Mar 28 14:16:20 2009 +0000

    SLING-653 : Add validaion mojo for validating resources; added the validation of included json files.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@759465 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/maven/bundlesupport/ValidationMojo.java  | 127 +++++++++++++++++++++
 1 file changed, 127 insertions(+)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
new file mode 100644
index 0000000..1990ebd
--- /dev/null
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
@@ -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.maven.bundlesupport;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+/**
+ * Plugin to validate resources:
+ * - validate json files
+ *
+ * @goal validate
+ * @phase process-resources
+ */
+public class ValidationMojo extends AbstractMojo {
+
+    /**
+     * The Maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * Whether to skip the validation
+     *
+     * @parameter expression="${sling.validation.skip}" default-value="false"
+     * @required
+     */
+    private boolean skip;
+
+    /**
+     * Whether to skip the json validation
+     *
+     * @parameter expression="${sling.validation.skipJson}" default-value="false"
+     * @required
+     */
+    private boolean skipJson;
+
+    /**
+     * @see org.apache.maven.plugin.AbstractMojo#execute()
+     */
+    public void execute()
+    throws MojoExecutionException {
+        if ( this.skip ) {
+            getLog().info("Validation is skipped.");
+            return;
+        }
+        @SuppressWarnings("unchecked")
+        final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
+        while ( rsrcIterator.hasNext() ) {
+            final Resource rsrc = rsrcIterator.next();
+
+            getLog().debug("Scanning " + rsrc.getDirectory());
+            final File directory = new File(rsrc.getDirectory());
+            final DirectoryScanner scanner = new DirectoryScanner();
+            scanner.setBasedir( directory );
+
+            if ( rsrc.getExcludes() != null && rsrc.getExcludes().size() > 0 ) {
+                scanner.setExcludes( (String[]) rsrc.getExcludes().toArray(new String[rsrc.getExcludes().size()] ) );
+            }
+            scanner.addDefaultExcludes();
+            if ( rsrc.getIncludes() != null && rsrc.getIncludes().size() > 0 ) {
+                scanner.setIncludes( (String[]) rsrc.getIncludes().toArray(new String[rsrc.getIncludes().size()] ));
+            }
+
+            scanner.scan();
+
+            final String[] files = scanner.getIncludedFiles();
+            if ( files != null ) {
+                for(int m=0; m<files.length; m++) {
+                    this.validate(directory, files[m]);
+                }
+            }
+        }
+    }
+
+    private void validate(final File directory, final String fileName)
+    throws MojoExecutionException {
+        getLog().debug("Validating " + fileName);
+        final File file = new File(directory, fileName);
+        if ( file.isFile() ) {
+            if ( fileName.endsWith(".json") && !this.skipJson ) {
+                try {
+                    final FileInputStream fis = new FileInputStream(file);
+                    getLog().debug("Validation JSON file " + fileName);
+                    final String json = IOUtils.toString(fis);
+                    new JSONObject(json);
+                    fis.close();
+                } catch (JSONException e) {
+                    throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", e);
+                } catch (IOException e) {
+                    throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", e);
+                }
+            }
+        }
+    }
+}

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

[sling-maven-sling-plugin] 07/28: SLING-798 : Initial support to create fs provider configs. New configs are currently posted on each sling:install

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 91a1d2a3a0c183b7f98d0ba444f078fee3f3a32e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jan 2 11:21:19 2009 +0000

    SLING-798 : Initial support to create fs provider configs. New configs are currently posted on each sling:install
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@730701 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  10 ++
 .../bundlesupport/AbstractBundleInstallMojo.java   | 164 ++++++++++++++++++++-
 2 files changed, 166 insertions(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index c7cac3a..ed3e7b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,16 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.json</artifactId>
+            <version>2.0.2-incubator</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.0.2-incubator</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-plugin-api</artifactId>
             <version>2.0</version>
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 2ac5385..5da5bfe 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -19,11 +19,16 @@
 package org.apache.sling.maven.bundlesupport;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
 
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
@@ -33,22 +38,29 @@ import org.apache.commons.httpclient.methods.multipart.FilePartSource;
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
 import org.apache.commons.httpclient.methods.multipart.Part;
 import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.sling.commons.osgi.ManifestHeader;
+import org.apache.sling.commons.osgi.ManifestHeader.Entry;
 
 abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
+    private static final String HEADER_INITIAL_CONTENT = "Sling-Initial-Content";
+    private static final String FS_FACTORY = "org.apache.sling.fsprovider.FsResourceProvider";
+
     /**
      * The URL of the running Sling instance.
-     * 
+     *
      * @parameter expression="${sling.url}"
-     *            default-value="http://localhost:8080/sling"
+     *            default-value="http://localhost:8080/system/console"
      * @required
      */
     private String slingUrl;
 
     /**
      * The user name to authenticate at the running Sling instance.
-     * 
+     *
      * @parameter expression="${sling.user}" default-value="admin"
      * @required
      */
@@ -56,7 +68,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
     /**
      * The password to authenticate at the running Sling instance.
-     * 
+     *
      * @parameter expression="${sling.password}" default-value="admin"
      * @required
      */
@@ -64,7 +76,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
     /**
      * The startlevel for the uploaded bundle
-     * 
+     *
      * @parameter expression="${sling.bundle.startlevel}" default-value="20"
      * @required
      */
@@ -72,7 +84,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
     /**
      * Whether to start the uploaded bundle or not
-     * 
+     *
      * @parameter expression="${sling.bundle.start}" default-value="true"
      * @required
      */
@@ -86,6 +98,23 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
      */
     private boolean refreshPackages;
 
+    /**
+     * Whether to add the mapping for the fs provider
+     *
+     * @parameter expression="${sling.mountByFS}" default-value="true"
+     * @required
+     */
+    private boolean mountByFS;
+
+    /**
+     * The Maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+
     public AbstractBundleInstallMojo() {
         super();
     }
@@ -108,7 +137,10 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         getLog().info(
             "Installing Bundle " + bundleName + "(" + bundleFile + ") to "
                 + slingUrl);
-        post(slingUrl, bundleFile);
+        configure(slingUrl, bundleFile);
+        if ( mountByFS ) {
+            post(slingUrl, bundleFile);
+        }
     }
 
     protected void post(String targetURL, File file)
@@ -129,7 +161,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             if (bundleStart) {
                 partList.add(new StringPart("bundlestart", "start"));
             }
-            
+
             if (refreshPackages) {
                 partList.add(new StringPart("refreshPackages", "true"));
             }
@@ -163,4 +195,120 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             filePost.releaseConnection();
         }
     }
+
+    protected void configure(String targetURL, File file)
+    throws MojoExecutionException {
+        // first, let's get the manifest and see if initial content is configured
+        ManifestHeader header = null;
+        try {
+            final Manifest mf = this.getManifest(file);
+            final String value = mf.getMainAttributes().getValue(HEADER_INITIAL_CONTENT);
+            if ( value == null ) {
+                getLog().debug("Bundle has no initial content - no file system provider config created.");
+                return;
+            }
+            header = ManifestHeader.parse(value);
+            if ( header == null || header.getEntries().length == 0 ) {
+                getLog().warn("Unable to parse header or header is empty: " + value);
+                return;
+            }
+        } catch (IOException ioe) {
+            throw new MojoExecutionException("Unable to read manifest from file " + file, ioe);
+        }
+        // setup http client
+        final HttpClient client = new HttpClient();
+        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
+
+        // authentication stuff
+        client.getParams().setAuthenticationPreemptive(true);
+        Credentials defaultcreds = new UsernamePasswordCredentials(user,
+                password);
+        client.getState().setCredentials(AuthScope.ANY, defaultcreds);
+
+        getLog().info("Trying to configure file system provider...");
+        // quick check if resources are configured
+        final List resources = project.getResources();
+        if ( resources == null || resources.size() == 0 ) {
+            throw new MojoExecutionException("No resources configured for this project.");
+        }
+        final Entry[] entries = header.getEntries();
+        for(final Entry entry : entries) {
+            final String path = entry.getValue();
+            // check if we should ignore this
+            final String ignoreValue = entry.getDirectiveValue("maven:mount");
+            if ( ignoreValue != null && ignoreValue.equalsIgnoreCase("false") ) {
+                getLog().debug("Ignoring " + path);
+                continue;
+            }
+            String installPath = entry.getDirectiveValue("path");
+            if ( installPath == null ) {
+                installPath = "/";
+            }
+            // search the path in the resources (usually this should be the first resource
+            // entry but this might be reconfigured
+            File dir = null;
+            final Iterator i = resources.iterator();
+            while ( dir == null && i.hasNext() ) {
+                final Resource rsrc = (Resource)i.next();
+                dir = new File(rsrc.getDirectory(), path);
+                if ( !dir.exists() ) {
+                    dir = null;
+                }
+            }
+            if ( dir == null ) {
+                throw new MojoExecutionException("No resource entry found containing " + path);
+            }
+            // check for root mapping - which we don't support atm
+            if ( "/".equals(installPath) ) {
+                throw new MojoExecutionException("Mapping to root path not supported by fs provider at the moment. Please adapt your initial content configuration.");
+            }
+            getLog().info("Mapping " + dir + " to " + installPath);
+            final String postUrl = targetURL  + "/configMgr/" + FS_FACTORY;
+            final PostMethod post = new PostMethod(postUrl);
+            post.addParameter("apply", "true");
+            post.addParameter("factoryPid", FS_FACTORY);
+            post.addParameter("pid", "new");
+            post.addParameter("provider.file", dir.toString());
+            post.addParameter("provider.roots", installPath);
+            post.addParameter("propertylist", "provider.roots,provider.file");
+            try {
+                final int status = client.executeMethod(post);
+                // we get a moved temporarily back from the configMgr plugin
+                if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
+                    getLog().info("Configuration created.");
+                } else {
+                    getLog().error(
+                        "Configuration failed, cause: "
+                            + HttpStatus.getStatusText(status));
+                }
+            } catch (HttpException ex) {
+                throw new MojoExecutionException("Configuration on " + postUrl
+                        + " failed, cause: " + ex.getMessage(), ex);
+            } catch (IOException ex) {
+                throw new MojoExecutionException("Configuration on " + postUrl
+                        + " failed, cause: " + ex.getMessage(), ex);
+            }
+        }
+    }
+
+    /**
+     * Get the manifest from the File.
+     * @param bundleFile The bundle jar
+     * @return The manifest.
+     * @throws IOException
+     */
+    protected Manifest getManifest(final File bundleFile) throws IOException {
+        JarFile file = null;
+        try {
+            file = new JarFile(bundleFile);
+            return file.getManifest();
+        } finally {
+            if (file != null) {
+                try {
+                    file.close();
+                } catch (IOException ignore) {
+                }
+            }
+        }
+    }
 }
\ No newline at end of file

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

[sling-maven-sling-plugin] 03/28: [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 annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit eb46ae1c34e90ac203e49991a54e756d4201b82c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 17 06:58:24 2008 +0000

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

diff --git a/pom.xml b/pom.xml
index 5e069b4..72e8bf2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>maven-sling-plugin</artifactId>
-    <version>2.0.2-incubator</version>
+    <version>2.0.3-incubator-SNAPSHOT</version>
     <packaging>maven-plugin</packaging>
 
     <name>Sling - Maven Plugin for Supporting Bundle Development</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.2-incubator</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.2-incubator</developerConnection>
-        <url>http://svn.apache.org/viewvc/incubator/sling/tags/maven-sling-plugin-2.0.2-incubator</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin</developerConnection>
+        <url>http://svn.apache.org/viewvc/incubator/sling/trunk/maven/maven-sling-plugin</url>
     </scm>
 
     <reporting>

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

[sling-maven-sling-plugin] 16/28: SLING-834 - Provide uninstall to uninstall a bundle and remove fs configurations.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit df0b01c8ed429c537c368877f6736780364de9dc
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 19 17:17:49 2009 +0000

    SLING-834 - Provide uninstall to uninstall a bundle and remove fs configurations.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@735750 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   |  10 +-
 .../maven/bundlesupport/BundleUninstallMojo.java   | 118 +++++++++++++++++++++
 2 files changed, 126 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 38e1e7e..2b351e1 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -68,7 +68,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
      *            default-value="http://localhost:8080/system/console"
      * @required
      */
-    private String slingUrl;
+    protected String slingUrl;
 
     /**
      * The user name to authenticate at the running Sling instance.
@@ -343,7 +343,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             final int status = client.executeMethod(post);
             // we get a moved temporarily back from the configMgr plugin
             if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
-                getLog().info("Configuration removed.");
+                getLog().debug("Configuration removed.");
             } else {
                 getLog().error(
                     "Removing configuration failed, cause: "
@@ -355,6 +355,8 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         } catch (IOException ex) {
             throw new MojoExecutionException("Removing configuration at " + postUrl
                     + " failed, cause: " + ex.getMessage(), ex);
+        } finally {
+            post.releaseConnection();
         }
     }
 
@@ -388,6 +390,8 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         } catch (IOException ex) {
             throw new MojoExecutionException("Configuration on " + postUrl
                     + " failed, cause: " + ex.getMessage(), ex);
+        } finally {
+            post.releaseConnection();
         }
     }
 
@@ -442,6 +446,8 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         } catch (IOException ex) {
             throw new MojoExecutionException("Reading configuration from " + getUrl
                     + " failed, cause: " + ex.getMessage(), ex);
+        } finally {
+            get.releaseConnection();
         }
         return result;
     }
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java
new file mode 100644
index 0000000..b019c79
--- /dev/null
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java
@@ -0,0 +1,118 @@
+/*
+ * 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.maven.bundlesupport;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Uninstall an OSGi bundle from a running Sling instance.
+ *
+ * @goal uninstall
+ * @description uninstall an OSGi bundle from a running Sling instance
+ */
+public class BundleUninstallMojo extends AbstractBundleInstallMojo {
+
+    /**
+     * The name of the generated JAR file.
+     *
+     * @parameter expression="${sling.file}" default-value="${project.build.directory}/${project.build.finalName}.jar"
+     * @required
+     */
+    private String bundleFileName;
+
+    @Override
+    protected String getBundleFileName() {
+        return bundleFileName;
+    }
+
+    /**
+     * @see org.apache.maven.plugin.AbstractMojo#execute()
+     */
+    public void execute() throws MojoExecutionException {
+        // only upload if packaging as an osgi-bundle
+        final File bundleFile = new File(bundleFileName);
+        final String bundleName = getBundleSymbolicName(bundleFile);
+        if (bundleName == null) {
+            getLog().info(bundleFile + " is not an OSGi Bundle, not uploading");
+            return;
+        }
+
+        getLog().info(
+            "Unistalling Bundle " + bundleName + ") from "
+                + slingUrl);
+        configure(slingUrl, bundleFile);
+        post(slingUrl, bundleName);
+    }
+
+    protected void post(String targetURL, String symbolicName)
+    throws MojoExecutionException {
+        final PostMethod post = new PostMethod(targetURL + "/bundles/" + symbolicName);
+        post.addParameter("action", "uninstall");
+
+        try {
+
+            int status = getHttpClient().executeMethod(post);
+            if (status == HttpStatus.SC_OK) {
+                getLog().info("Bundle uninstalled");
+            } else {
+                getLog().error(
+                    "Uninstall failed, cause: "
+                        + HttpStatus.getStatusText(status));
+            }
+        } catch (Exception ex) {
+            throw new MojoExecutionException("Uninstall from " + targetURL
+                + " failed, cause: " + ex.getMessage(), ex);
+        } finally {
+            post.releaseConnection();
+        }
+    }
+
+    /**
+     * Add configurations to a running OSGi instance for initial content.
+     * @param targetURL The web console base url
+     * @param file The artifact (bundle)
+     * @throws MojoExecutionException
+     */
+    protected void configure(String targetURL, File file)
+    throws MojoExecutionException {
+        getLog().info("Removing file system provider configurations...");
+
+        // now get current configurations
+        final HttpClient client = this.getHttpClient();
+        final Map oldConfigs = this.getCurrentFileProviderConfigs(targetURL, client);
+
+
+        final Iterator entryIterator = oldConfigs.entrySet().iterator();
+        while ( entryIterator.hasNext() ) {
+            final Map.Entry current = (Map.Entry) entryIterator.next();
+            final String[] value = (String[])current.getValue();
+            getLog().debug("Removing old configuration for " + value[0] + " and " + value[1]);
+            // remove old config
+            removeConfiguration(client, targetURL, current.getKey().toString());
+        }
+    }
+
+}
\ No newline at end of file

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

[sling-maven-sling-plugin] 01/28: Update to released versions.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 3299e7f4a5110e02471b7d4cedafde9972e6c05e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 17 06:57:15 2008 +0000

    Update to released versions.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@668413 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index e74a739..748bb1b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>2-incubator-SNAPSHOT</version>
+        <version>3-incubator</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-maven-sling-plugin] 24/28: Default resources directory might not exists.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit e402842506dec390c9243d056104b4b88dc4d6c3
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Apr 9 08:27:41 2009 +0000

    Default resources directory might not exists.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@763554 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/maven/bundlesupport/ValidationMojo.java  | 32 ++++++++++++----------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
index 39ce9f7..8cd8479 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
@@ -80,25 +80,27 @@ public class ValidationMojo extends AbstractMojo {
         while ( rsrcIterator.hasNext() ) {
             final Resource rsrc = rsrcIterator.next();
 
-            getLog().debug("Scanning " + rsrc.getDirectory());
             final File directory = new File(rsrc.getDirectory());
-            final DirectoryScanner scanner = new DirectoryScanner();
-            scanner.setBasedir( directory );
+            if ( directory.exists() ) {
+                getLog().debug("Scanning " + rsrc.getDirectory());
+                final DirectoryScanner scanner = new DirectoryScanner();
+                scanner.setBasedir( directory );
 
-            if ( rsrc.getExcludes() != null && rsrc.getExcludes().size() > 0 ) {
-                scanner.setExcludes( (String[]) rsrc.getExcludes().toArray(new String[rsrc.getExcludes().size()] ) );
-            }
-            scanner.addDefaultExcludes();
-            if ( rsrc.getIncludes() != null && rsrc.getIncludes().size() > 0 ) {
-                scanner.setIncludes( (String[]) rsrc.getIncludes().toArray(new String[rsrc.getIncludes().size()] ));
-            }
+                if ( rsrc.getExcludes() != null && rsrc.getExcludes().size() > 0 ) {
+                    scanner.setExcludes( (String[]) rsrc.getExcludes().toArray(new String[rsrc.getExcludes().size()] ) );
+                }
+                scanner.addDefaultExcludes();
+                if ( rsrc.getIncludes() != null && rsrc.getIncludes().size() > 0 ) {
+                    scanner.setIncludes( (String[]) rsrc.getIncludes().toArray(new String[rsrc.getIncludes().size()] ));
+                }
 
-            scanner.scan();
+                scanner.scan();
 
-            final String[] files = scanner.getIncludedFiles();
-            if ( files != null ) {
-                for(int m=0; m<files.length; m++) {
-                    this.validate(directory, files[m]);
+                final String[] files = scanner.getIncludedFiles();
+                if ( files != null ) {
+                    for(int m=0; m<files.length; m++) {
+                        this.validate(directory, files[m]);
+                    }
                 }
             }
         }

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

[sling-maven-sling-plugin] 23/28: SLING-653 : Use new validator from commons.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit c94aed2882f1023fc329e27b09951c2aee2afecb
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Mar 29 16:49:15 2009 +0000

    SLING-653 : Use new validator from commons.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@759724 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                      |  2 +-
 .../org/apache/sling/maven/bundlesupport/ValidationMojo.java | 12 +++---------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index 84d67ed..19e7f91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,7 +90,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.json</artifactId>
-            <version>2.0.2-incubator</version>
+            <version>2.0.3-incubator-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
index 034ead8..39ce9f7 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
@@ -28,9 +28,8 @@ import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
-import org.apache.sling.commons.json.JSONArray;
 import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.commons.json.util.Validator;
 import org.codehaus.plexus.util.DirectoryScanner;
 
 /**
@@ -124,14 +123,9 @@ public class ValidationMojo extends AbstractMojo {
                 }
                 // first, let's see if this is a json array
                 try {
-                    new JSONArray(json);
+                    Validator.validate(json);
                 } catch (JSONException e) {
-                    // it might be a json object
-                    try {
-                        new JSONObject(json);
-                    } catch (JSONException je) {
-                        throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", je);
-                    }
+                    throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", e);
                 }
             }
         }

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

[sling-maven-sling-plugin] 12/28: SLING-829 Cosmetics to the bundle/project names

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit bfc290fd250f88501e3d03e2c515caf740d7cbd4
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Thu Jan 15 10:25:41 2009 +0000

    SLING-829 Cosmetics to the bundle/project names
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@734658 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 3453c2d..84d67ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
     <version>2.0.3-incubator-SNAPSHOT</version>
     <packaging>maven-plugin</packaging>
 
-    <name>Sling - Maven Plugin for Supporting Bundle Development</name>
+    <name>Apache Sling Maven Plugin for Supporting Bundle Development</name>
     <description>
         Maven Plugin supporting various Sling Development Tasks
     </description>

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

[sling-maven-sling-plugin] 05/28: Use released parent pom where possible.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit e323d6c4ad7281bfea850429882bcc4c41e4e1ff
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jun 23 12:07:27 2008 +0000

    Use released parent pom where possible.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@670529 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index c7cac3a..72e8bf2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>4-incubator-SNAPSHOT</version>
+        <version>3-incubator</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-maven-sling-plugin] 25/28: Fix fsresource provider and sling plugin after recent refactorings.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit d962bef4354b3031c881d87477c697afcdab770c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 22 06:20:35 2009 +0000

    Fix fsresource provider and sling plugin after recent refactorings.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@767389 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 5ffc224..0feac2e 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -57,7 +57,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
     /** Header containing the sling initial content information. */
     private static final String HEADER_INITIAL_CONTENT = "Sling-Initial-Content";
     /** The fs resource provider factory. */
-    private static final String FS_FACTORY = "org.apache.sling.fsprovider.FsResourceProvider";
+    private static final String FS_FACTORY = "org.apache.sling.fsprovider.internal.FsResourceProvider";
     /** Mime type for json response. */
     private static final String JSON_MIME_TYPE = "application/json";
     /** Http header for content type. */

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

[sling-maven-sling-plugin] 28/28: Move Sling to new TLP location

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 2bb98deb99ea00f394f08e4662e88fae3d436782
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Thu Jun 18 09:21:02 2009 +0000

    Move Sling to new TLP location
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/maven-sling-plugin-2.0.4-incubator@785979 13f79535-47bb-0310-9956-ffa450edef68

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

[sling-maven-sling-plugin] 02/28: [maven-release-plugin] prepare release maven-sling-plugin-2.0.2-incubator

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit d5b6c523776f1ec6facf34249b3d2d291f7f262f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 17 06:58:15 2008 +0000

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

diff --git a/pom.xml b/pom.xml
index 748bb1b..5e069b4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>maven-sling-plugin</artifactId>
-    <version>2.0.1-incubator-SNAPSHOT</version>
+    <version>2.0.2-incubator</version>
     <packaging>maven-plugin</packaging>
 
     <name>Sling - Maven Plugin for Supporting Bundle Development</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin</developerConnection>
-        <url>http://svn.apache.org/viewvc/incubator/sling/trunk/maven/maven-sling-plugin</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.2-incubator</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.2-incubator</developerConnection>
+        <url>http://svn.apache.org/viewvc/incubator/sling/tags/maven-sling-plugin-2.0.2-incubator</url>
     </scm>
 
     <reporting>

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

[sling-maven-sling-plugin] 04/28: Use latest snapshots again to make project buildable.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 8ae53e443cb50e249c8f28f6e127417c33a8693e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 17 08:55:12 2008 +0000

    Use latest snapshots again to make project buildable.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@668571 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 72e8bf2..c7cac3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>3-incubator</version>
+        <version>4-incubator-SNAPSHOT</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-maven-sling-plugin] 15/28: SLING-798 - Adapt to latest web console and remove obsolete configurations.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit de1cdac9787f6df2f93e892fb3b46cfb00f0b509
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 19 16:32:41 2009 +0000

    SLING-798 - Adapt to latest web console and remove obsolete configurations.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@735742 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   | 102 ++++++++++++++-------
 1 file changed, 71 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 5be7508..38e1e7e 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -304,45 +304,22 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             while ( !found && entryIterator.hasNext() ) {
                 final Map.Entry current = (Map.Entry) entryIterator.next();
                 final String[] value = (String[])current.getValue();
+                getLog().debug("Comparing " + dir.getAbsolutePath() + " with " + value[0] + " (" + value[1] + ")");
                 if ( dir.getAbsolutePath().equals(value[0]) ) {
                     if ( installPath.equals(value[1]) ) {
                         getLog().debug("Using existing configuration for " + dir + " and " + installPath);
                         found = true;
                     } else {
-                        getLog().debug("Removing old configuration for " + value[0] + " and " + value[1]);
                         // remove old config
-                        // TODO
+                        getLog().debug("Removing old configuration for " + value[0] + " and " + value[1]);
+                        removeConfiguration(client, targetURL, current.getKey().toString());
                     }
                     entryIterator.remove();
                 }
             }
             if ( !found ) {
                 getLog().debug("Adding new configuration for " + dir + " and " + installPath);
-                final String postUrl = targetURL  + "/configMgr/" + FS_FACTORY;
-                final PostMethod post = new PostMethod(postUrl);
-                post.addParameter("apply", "true");
-                post.addParameter("factoryPid", FS_FACTORY);
-                post.addParameter("pid", "new");
-                post.addParameter("provider.file", dir.getAbsolutePath());
-                post.addParameter("provider.roots", installPath);
-                post.addParameter("propertylist", "provider.roots,provider.file");
-                try {
-                    final int status = client.executeMethod(post);
-                    // we get a moved temporarily back from the configMgr plugin
-                    if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
-                        getLog().info("Configuration created.");
-                    } else {
-                        getLog().error(
-                            "Configuration failed, cause: "
-                                + HttpStatus.getStatusText(status));
-                    }
-                } catch (HttpException ex) {
-                    throw new MojoExecutionException("Configuration on " + postUrl
-                            + " failed, cause: " + ex.getMessage(), ex);
-                } catch (IOException ex) {
-                    throw new MojoExecutionException("Configuration on " + postUrl
-                            + " failed, cause: " + ex.getMessage(), ex);
-                }
+                addConfiguration(client, targetURL, dir.getAbsolutePath(), installPath);
             }
         }
         // finally remove old configs
@@ -352,7 +329,65 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             final String[] value = (String[])current.getValue();
             getLog().debug("Removing old configuration for " + value[0] + " and " + value[1]);
             // remove old config
-            // TODO
+            removeConfiguration(client, targetURL, current.getKey().toString());
+        }
+    }
+
+    protected void removeConfiguration(final HttpClient client, final String targetURL, String pid)
+    throws MojoExecutionException {
+        final String postUrl = targetURL  + "/configMgr/" + pid;
+        final PostMethod post = new PostMethod(postUrl);
+        post.addParameter("apply", "true");
+        post.addParameter("delete", "true");
+        try {
+            final int status = client.executeMethod(post);
+            // we get a moved temporarily back from the configMgr plugin
+            if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
+                getLog().info("Configuration removed.");
+            } else {
+                getLog().error(
+                    "Removing configuration failed, cause: "
+                        + HttpStatus.getStatusText(status));
+            }
+        } catch (HttpException ex) {
+            throw new MojoExecutionException("Removing configuration at " + postUrl
+                    + " failed, cause: " + ex.getMessage(), ex);
+        } catch (IOException ex) {
+            throw new MojoExecutionException("Removing configuration at " + postUrl
+                    + " failed, cause: " + ex.getMessage(), ex);
+        }
+    }
+
+    /**
+     * Add a new configuration for the file system provider
+     * @throws MojoExecutionException
+     */
+    protected void addConfiguration(final HttpClient client, final String targetURL, String dir, String path)
+    throws MojoExecutionException {
+        final String postUrl = targetURL  + "/configMgr/" + FS_FACTORY;
+        final PostMethod post = new PostMethod(postUrl);
+        post.addParameter("apply", "true");
+        post.addParameter("factoryPid", FS_FACTORY);
+        post.addParameter("pid", "[Temporary PID replaced by real PID upon save]");
+        post.addParameter("provider.file", dir);
+        post.addParameter("provider.roots", path);
+        post.addParameter("propertylist", "provider.roots,provider.file");
+        try {
+            final int status = client.executeMethod(post);
+            // we get a moved temporarily back from the configMgr plugin
+            if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
+                getLog().info("Configuration created.");
+            } else {
+                getLog().error(
+                    "Configuration failed, cause: "
+                        + HttpStatus.getStatusText(status));
+            }
+        } catch (HttpException ex) {
+            throw new MojoExecutionException("Configuration on " + postUrl
+                    + " failed, cause: " + ex.getMessage(), ex);
+        } catch (IOException ex) {
+            throw new MojoExecutionException("Configuration on " + postUrl
+                    + " failed, cause: " + ex.getMessage(), ex);
         }
     }
 
@@ -373,9 +408,14 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
         try {
             final int status = client.executeMethod(get);
-            if ( status == 200 )
-            {
-                if ( !JSON_MIME_TYPE.equals(get.getResponseHeader(HEADER_CONTENT_TYPE).getValue()) ) {
+            if ( status == 200 ) {
+                String contentType = get.getResponseHeader(HEADER_CONTENT_TYPE).getValue();
+                int pos = contentType.indexOf(';');
+                if ( pos != -1 ) {
+                    contentType = contentType.substring(0, pos);
+                }
+                if ( !JSON_MIME_TYPE.equals(contentType) ) {
+                    getLog().debug("Response type from web console is not JSON, but " + contentType);
                     throwWebConsoleTooOldException();
                 }
                 final String jsonText = get.getResponseBodyAsString();

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

[sling-maven-sling-plugin] 11/28: SLING-798 : Get available configurations from web console before creating configs

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 8db8a257cf928f4d3a19251f931745ff3578f2c2
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jan 14 21:09:21 2009 +0000

    SLING-798 : Get available configurations from web console before creating configs
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@734513 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   | 64 +++++++++++++++++++++-
 1 file changed, 61 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 5da5bfe..bbf4e12 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -21,8 +21,10 @@ package org.apache.sling.maven.bundlesupport;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 
@@ -32,6 +34,7 @@ import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.multipart.FilePart;
 import org.apache.commons.httpclient.methods.multipart.FilePartSource;
@@ -41,6 +44,9 @@ import org.apache.commons.httpclient.methods.multipart.StringPart;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.commons.osgi.ManifestHeader;
 import org.apache.sling.commons.osgi.ManifestHeader.Entry;
 
@@ -137,9 +143,9 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         getLog().info(
             "Installing Bundle " + bundleName + "(" + bundleFile + ") to "
                 + slingUrl);
-        configure(slingUrl, bundleFile);
+        post(slingUrl, bundleFile);
         if ( mountByFS ) {
-            post(slingUrl, bundleFile);
+            configure(slingUrl, bundleFile);
         }
     }
 
@@ -221,7 +227,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
         // authentication stuff
         client.getParams().setAuthenticationPreemptive(true);
-        Credentials defaultcreds = new UsernamePasswordCredentials(user,
+        final Credentials defaultcreds = new UsernamePasswordCredentials(user,
                 password);
         client.getState().setCredentials(AuthScope.ANY, defaultcreds);
 
@@ -231,6 +237,13 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         if ( resources == null || resources.size() == 0 ) {
             throw new MojoExecutionException("No resources configured for this project.");
         }
+        // now get current configurations
+        final Map configs = this.getCurrentFileProviderConfigs(targetURL, client);
+        final Iterator configIter = configs.keySet().iterator();
+        while ( configIter.hasNext() ) {
+            final String key = configIter.next().toString();
+            getLog().info("Found " + key + " : " + configs.get(key));
+        }
         final Entry[] entries = header.getEntries();
         for(final Entry entry : entries) {
             final String path = entry.getValue();
@@ -292,6 +305,51 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
     }
 
     /**
+     * Return all file provider configs for this project
+     * @param targetURL The targetURL of the webconsole
+     * @param client The http client
+     * @return A map (may be empty) with the pids as keys and the path as value
+     * @throws MojoExecutionException
+     */
+    protected Map getCurrentFileProviderConfigs(final String targetURL, final HttpClient client)
+    throws MojoExecutionException {
+        getLog().debug("Getting current file provider configurations.");
+        final Map result = new HashMap();
+        final String getUrl = targetURL  + "/configMgr/(service.factoryPid=" + FS_FACTORY + ").json";
+        final GetMethod get = new GetMethod(getUrl);
+
+        try {
+            final int status = client.executeMethod(get);
+            if ( status == 200 )
+            {
+                final String jsonText = get.getResponseBodyAsString();
+                try {
+                    JSONArray array = new JSONArray(jsonText);
+                    for(int i=0; i<array.length(); i++) {
+                        final JSONObject obj = array.getJSONObject(i);
+                        final String pid = obj.getString("pid");
+                        final String path = obj.getJSONObject("provider.file").getString("value");
+                        if ( path != null && path.startsWith(this.project.getBasedir().getAbsolutePath()) ) {
+                            getLog().debug("Found configuration with pid: " + pid + ", path: " + path);
+                            result.put(pid, path);
+                        }
+                    }
+                } catch (JSONException ex) {
+                    throw new MojoExecutionException("Reading configuration from " + getUrl
+                            + " failed, cause: " + ex.getMessage(), ex);
+                }
+            }
+        } catch (HttpException ex) {
+            throw new MojoExecutionException("Reading configuration from " + getUrl
+                    + " failed, cause: " + ex.getMessage(), ex);
+        } catch (IOException ex) {
+            throw new MojoExecutionException("Reading configuration from " + getUrl
+                    + " failed, cause: " + ex.getMessage(), ex);
+        }
+        return result;
+    }
+
+    /**
      * Get the manifest from the File.
      * @param bundleFile The bundle jar
      * @return The manifest.

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

[sling-maven-sling-plugin] 26/28: SLING-941: Lots of svn:eol-style settings missing

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 2c55daae9e334725eb12b1065c7e80bcc9729e25
Author: Jukka Zitting <ju...@apache.org>
AuthorDate: Fri Apr 24 12:14:03 2009 +0000

    SLING-941: Lots of svn:eol-style settings missing
    
    Set svn:eol-style to native on all Java files that lack the setting.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@768268 13f79535-47bb-0310-9956-ffa450edef68

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

[sling-maven-sling-plugin] 14/28: SLING-798 - Don't use web console version check. Rely on the response content type.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 19b0fc0cdc920742759fd589d9c7068bbdd23be2
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 19 15:20:39 2009 +0000

    SLING-798 - Don't use web console version check. Rely on the response content type.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@735727 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   | 127 ++++++++++++++-------
 1 file changed, 88 insertions(+), 39 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index e5c83a2..5be7508 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -52,8 +52,14 @@ import org.apache.sling.commons.osgi.ManifestHeader.Entry;
 
 abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
+    /** Header containing the sling initial content information. */
     private static final String HEADER_INITIAL_CONTENT = "Sling-Initial-Content";
+    /** The fs resource provider factory. */
     private static final String FS_FACTORY = "org.apache.sling.fsprovider.FsResourceProvider";
+    /** Mime type for json response. */
+    private static final String JSON_MIME_TYPE = "application/json";
+    /** Http header for content type. */
+    private static final String HEADER_CONTENT_TYPE = "Content-Type";
 
     /**
      * The URL of the running Sling instance.
@@ -145,18 +151,23 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
                 + slingUrl);
         post(slingUrl, bundleFile);
         if ( mountByFS ) {
-            // if we get a version, we have a recent web console
-            final String version = checkWebConsoleVersion(slingUrl);
-            if ( version == null ) {
-                throw new MojoExecutionException("Apache Felix Web Console is too old to mount " +
-                        "the initial content through file system provider configs. " +
-                        "Either upgrade the web console or disable this feature.");
-            }
             configure(slingUrl, bundleFile);
         }
     }
 
     /**
+     * Helper method to throw a meaningful exception for an outdated felix
+     * web console.
+     * @throws MojoExecutionException
+     */
+    protected void throwWebConsoleTooOldException()
+    throws MojoExecutionException {
+        throw new MojoExecutionException("The Apache Felix Web Console is too old to mount " +
+                "the initial content through file system provider configs. " +
+                "Either upgrade the web console or disable this feature.");
+    }
+
+    /**
      * Get the http client
      */
     protected HttpClient getHttpClient() {
@@ -217,6 +228,12 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         }
     }
 
+    /**
+     * Add configurations to a running OSGi instance for initial content.
+     * @param targetURL The web console base url
+     * @param file The artifact (bundle)
+     * @throws MojoExecutionException
+     */
     protected void configure(String targetURL, File file)
     throws MojoExecutionException {
         // first, let's get the manifest and see if initial content is configured
@@ -246,12 +263,8 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             throw new MojoExecutionException("No resources configured for this project.");
         }
         // now get current configurations
-        final Map configs = this.getCurrentFileProviderConfigs(targetURL, client);
-        final Iterator configIter = configs.keySet().iterator();
-        while ( configIter.hasNext() ) {
-            final String key = configIter.next().toString();
-            getLog().info("Found " + key + " : " + configs.get(key));
-        }
+        final Map oldConfigs = this.getCurrentFileProviderConfigs(targetURL, client);
+
         final Entry[] entries = header.getEntries();
         for(final Entry entry : entries) {
             final String path = entry.getValue();
@@ -284,39 +297,71 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
                 throw new MojoExecutionException("Mapping to root path not supported by fs provider at the moment. Please adapt your initial content configuration.");
             }
             getLog().info("Mapping " + dir + " to " + installPath);
-            final String postUrl = targetURL  + "/configMgr/" + FS_FACTORY;
-            final PostMethod post = new PostMethod(postUrl);
-            post.addParameter("apply", "true");
-            post.addParameter("factoryPid", FS_FACTORY);
-            post.addParameter("pid", "new");
-            post.addParameter("provider.file", dir.toString());
-            post.addParameter("provider.roots", installPath);
-            post.addParameter("propertylist", "provider.roots,provider.file");
-            try {
-                final int status = client.executeMethod(post);
-                // we get a moved temporarily back from the configMgr plugin
-                if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
-                    getLog().info("Configuration created.");
-                } else {
-                    getLog().error(
-                        "Configuration failed, cause: "
-                            + HttpStatus.getStatusText(status));
+
+            // check if this is already configured
+            boolean found = false;
+            final Iterator entryIterator = oldConfigs.entrySet().iterator();
+            while ( !found && entryIterator.hasNext() ) {
+                final Map.Entry current = (Map.Entry) entryIterator.next();
+                final String[] value = (String[])current.getValue();
+                if ( dir.getAbsolutePath().equals(value[0]) ) {
+                    if ( installPath.equals(value[1]) ) {
+                        getLog().debug("Using existing configuration for " + dir + " and " + installPath);
+                        found = true;
+                    } else {
+                        getLog().debug("Removing old configuration for " + value[0] + " and " + value[1]);
+                        // remove old config
+                        // TODO
+                    }
+                    entryIterator.remove();
+                }
+            }
+            if ( !found ) {
+                getLog().debug("Adding new configuration for " + dir + " and " + installPath);
+                final String postUrl = targetURL  + "/configMgr/" + FS_FACTORY;
+                final PostMethod post = new PostMethod(postUrl);
+                post.addParameter("apply", "true");
+                post.addParameter("factoryPid", FS_FACTORY);
+                post.addParameter("pid", "new");
+                post.addParameter("provider.file", dir.getAbsolutePath());
+                post.addParameter("provider.roots", installPath);
+                post.addParameter("propertylist", "provider.roots,provider.file");
+                try {
+                    final int status = client.executeMethod(post);
+                    // we get a moved temporarily back from the configMgr plugin
+                    if (status == HttpStatus.SC_MOVED_TEMPORARILY || status == HttpStatus.SC_OK) {
+                        getLog().info("Configuration created.");
+                    } else {
+                        getLog().error(
+                            "Configuration failed, cause: "
+                                + HttpStatus.getStatusText(status));
+                    }
+                } catch (HttpException ex) {
+                    throw new MojoExecutionException("Configuration on " + postUrl
+                            + " failed, cause: " + ex.getMessage(), ex);
+                } catch (IOException ex) {
+                    throw new MojoExecutionException("Configuration on " + postUrl
+                            + " failed, cause: " + ex.getMessage(), ex);
                 }
-            } catch (HttpException ex) {
-                throw new MojoExecutionException("Configuration on " + postUrl
-                        + " failed, cause: " + ex.getMessage(), ex);
-            } catch (IOException ex) {
-                throw new MojoExecutionException("Configuration on " + postUrl
-                        + " failed, cause: " + ex.getMessage(), ex);
             }
         }
+        // finally remove old configs
+        final Iterator entryIterator = oldConfigs.entrySet().iterator();
+        while ( entryIterator.hasNext() ) {
+            final Map.Entry current = (Map.Entry) entryIterator.next();
+            final String[] value = (String[])current.getValue();
+            getLog().debug("Removing old configuration for " + value[0] + " and " + value[1]);
+            // remove old config
+            // TODO
+        }
     }
 
     /**
      * Return all file provider configs for this project
      * @param targetURL The targetURL of the webconsole
      * @param client The http client
-     * @return A map (may be empty) with the pids as keys and the path as value
+     * @return A map (may be empty) with the pids as keys and a string array
+     *         containing the path and the root
      * @throws MojoExecutionException
      */
     protected Map getCurrentFileProviderConfigs(final String targetURL, final HttpClient client)
@@ -330,6 +375,9 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             final int status = client.executeMethod(get);
             if ( status == 200 )
             {
+                if ( !JSON_MIME_TYPE.equals(get.getResponseHeader(HEADER_CONTENT_TYPE).getValue()) ) {
+                    throwWebConsoleTooOldException();
+                }
                 final String jsonText = get.getResponseBodyAsString();
                 try {
                     JSONArray array = new JSONArray(jsonText);
@@ -337,9 +385,10 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
                         final JSONObject obj = array.getJSONObject(i);
                         final String pid = obj.getString("pid");
                         final String path = obj.getJSONObject("provider.file").getString("value");
+                        final String roots = obj.getJSONObject("provider.roots").getString("value");
                         if ( path != null && path.startsWith(this.project.getBasedir().getAbsolutePath()) ) {
-                            getLog().debug("Found configuration with pid: " + pid + ", path: " + path);
-                            result.put(pid, path);
+                            getLog().debug("Found configuration with pid: " + pid + ", path: " + path + ", roots: " + roots);
+                            result.put(pid, new String[] {path, roots});
                         }
                     }
                 } catch (JSONException ex) {

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

[sling-maven-sling-plugin] 22/28: FS mounting should be disabled by default to have the same behaviour as previous version by default.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 21d4521446c5e866ddfc8d1c5e98eddf2a23b137
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Mar 29 16:06:18 2009 +0000

    FS mounting should be disabled by default to have the same behaviour as previous version by default.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@759712 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 7604b30..5ffc224 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -147,7 +147,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
     /**
      * Whether to add the mapping for the fs provider
      *
-     * @parameter expression="${sling.mountByFS}" default-value="true"
+     * @parameter expression="${sling.mountByFS}" default-value="false"
      * @required
      */
     private boolean mountByFS;

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

[sling-maven-sling-plugin] 09/28: Update notice files to include 2009 in copyright statement.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit db8a36b7561db89e6665cecf75224ee750204418
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jan 7 09:07:02 2009 +0000

    Update notice files to include 2009 in copyright statement.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@732280 13f79535-47bb-0310-9956-ffa450edef68
---
 NOTICE                             | 2 +-
 src/main/resources/META-INF/NOTICE | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/NOTICE b/NOTICE
index 3513e57..6df74a3 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
 Apache Sling Maven Plugin
-Copyright 2008 The Apache Software Foundation
+Copyright 2008-2009 The Apache Software Foundation
 
 Apache Sling is based on source code originally developed 
 by Day Software (http://www.day.com/).
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
index 2cc661d..bea081b 100644
--- a/src/main/resources/META-INF/NOTICE
+++ b/src/main/resources/META-INF/NOTICE
@@ -1,5 +1,5 @@
 Apache Sling Maven Plugin
-Copyright 2008 The Apache Software Foundation
+Copyright 2008-2009 The Apache Software Foundation
 
 Apache Sling is based on source code originally developed 
 by Day Software (http://www.day.com/).

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

[sling-maven-sling-plugin] 21/28: SLING-653 : Properly handle closing of file, json file might be a json array.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 4539ff17ce9719f874d3f4dc6f8926ce0eb52b07
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Mar 28 16:14:47 2009 +0000

    SLING-653 : Properly handle closing of file, json file might be a json array.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@759494 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/maven/bundlesupport/ValidationMojo.java  | 26 ++++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
index 1990ebd..034ead8 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/ValidationMojo.java
@@ -28,6 +28,7 @@ import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.sling.commons.json.JSONArray;
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
 import org.codehaus.plexus.util.DirectoryScanner;
@@ -110,16 +111,27 @@ public class ValidationMojo extends AbstractMojo {
         final File file = new File(directory, fileName);
         if ( file.isFile() ) {
             if ( fileName.endsWith(".json") && !this.skipJson ) {
+                getLog().debug("Validation JSON file " + fileName);
+                FileInputStream fis = null;
+                String json = null;
                 try {
-                    final FileInputStream fis = new FileInputStream(file);
-                    getLog().debug("Validation JSON file " + fileName);
-                    final String json = IOUtils.toString(fis);
-                    new JSONObject(json);
-                    fis.close();
-                } catch (JSONException e) {
-                    throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", e);
+                    fis = new FileInputStream(file);
+                    json = IOUtils.toString(fis);
                 } catch (IOException e) {
                     throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", e);
+                } finally {
+                    IOUtils.closeQuietly(fis);
+                }
+                // first, let's see if this is a json array
+                try {
+                    new JSONArray(json);
+                } catch (JSONException e) {
+                    // it might be a json object
+                    try {
+                        new JSONObject(json);
+                    } catch (JSONException je) {
+                        throw new MojoExecutionException("An Error occured while validating the file '"+fileName+"'", je);
+                    }
                 }
             }
         }

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

[sling-maven-sling-plugin] 10/28: SLING-811 Reduce DependencyManagement in the parent pom and add explicit versions to the modules

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 301bf8bc493a27eb809eeefc9d295f3627f208df
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Wed Jan 7 14:41:02 2009 +0000

    SLING-811 Reduce DependencyManagement in the parent pom and add explicit versions to the modules
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@732352 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pom.xml b/pom.xml
index b713f6d..3453c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,7 @@
         <dependency>
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -82,6 +83,7 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
+            <version>1.4</version>
             <scope>compile</scope>
         </dependency>
 

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

[sling-maven-sling-plugin] 20/28: SLING-876 : Handle optional target path on resource configuration when searching a resource.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 517bab9e0590c0389dc57773e1092936edca4ac7
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Mar 28 14:25:18 2009 +0000

    SLING-876 : Handle optional target path on resource configuration when searching a resource.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@759467 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/maven/bundlesupport/AbstractBundleInstallMojo.java  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 1f5a883..7604b30 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -369,7 +369,16 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             final Iterator i = resources.iterator();
             while ( dir == null && i.hasNext() ) {
                 final Resource rsrc = (Resource)i.next();
-                dir = new File(rsrc.getDirectory(), path);
+                String child = path;
+                // if resource mapping defines a target path: remove target path from checked resource path
+                String targetPath = rsrc.getTargetPath();
+                if ( targetPath != null && !targetPath.endsWith("/") ) {
+                    targetPath = targetPath + "/";
+                }
+                if ( targetPath != null && path.startsWith(targetPath) ) {
+                    child = child.substring(targetPath.length());
+                }
+                dir = new File(rsrc.getDirectory(), child);
                 if ( !dir.exists() ) {
                     dir = null;
                 }

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

[sling-maven-sling-plugin] 06/28: SLING-555 : Update all poms to use the latest parent pom; update parent pom to include the incubator repo for plugins and use latest plugins.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 46a3de988f4bf1fe599258655f4d98fcf19ea4bd
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jul 21 14:24:25 2008 +0000

    SLING-555 : Update all poms to use the latest parent pom; update parent pom to include the incubator repo for plugins and use latest plugins.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@678436 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 72e8bf2..c7cac3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>3-incubator</version>
+        <version>4-incubator-SNAPSHOT</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-maven-sling-plugin] 13/28: SLING-798 - Add web console version check.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 0c7cb636b46419b1143194e48b9830e6c95120c8
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 19 09:33:18 2009 +0000

    SLING-798 - Add web console version check.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@735637 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   | 92 +++++++++++++++++-----
 1 file changed, 74 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index bbf4e12..e5c83a2 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -145,10 +145,34 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
                 + slingUrl);
         post(slingUrl, bundleFile);
         if ( mountByFS ) {
+            // if we get a version, we have a recent web console
+            final String version = checkWebConsoleVersion(slingUrl);
+            if ( version == null ) {
+                throw new MojoExecutionException("Apache Felix Web Console is too old to mount " +
+                        "the initial content through file system provider configs. " +
+                        "Either upgrade the web console or disable this feature.");
+            }
             configure(slingUrl, bundleFile);
         }
     }
 
+    /**
+     * Get the http client
+     */
+    protected HttpClient getHttpClient() {
+        final HttpClient client = new HttpClient();
+        client.getHttpConnectionManager().getParams().setConnectionTimeout(
+            5000);
+
+        // authentication stuff
+        client.getParams().setAuthenticationPreemptive(true);
+        Credentials defaultcreds = new UsernamePasswordCredentials(user,
+            password);
+        client.getState().setCredentials(AuthScope.ANY, defaultcreds);
+
+        return client;
+    }
+
     protected void post(String targetURL, File file)
             throws MojoExecutionException {
 
@@ -176,17 +200,8 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
             filePost.setRequestEntity(new MultipartRequestEntity(parts,
                 filePost.getParams()));
-            HttpClient client = new HttpClient();
-            client.getHttpConnectionManager().getParams().setConnectionTimeout(
-                5000);
-
-            // authentication stuff
-            client.getParams().setAuthenticationPreemptive(true);
-            Credentials defaultcreds = new UsernamePasswordCredentials(user,
-                password);
-            client.getState().setCredentials(AuthScope.ANY, defaultcreds);
 
-            int status = client.executeMethod(filePost);
+            int status = getHttpClient().executeMethod(filePost);
             if (status == HttpStatus.SC_OK) {
                 getLog().info("Bundle installed");
             } else {
@@ -222,14 +237,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             throw new MojoExecutionException("Unable to read manifest from file " + file, ioe);
         }
         // setup http client
-        final HttpClient client = new HttpClient();
-        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
-
-        // authentication stuff
-        client.getParams().setAuthenticationPreemptive(true);
-        final Credentials defaultcreds = new UsernamePasswordCredentials(user,
-                password);
-        client.getState().setCredentials(AuthScope.ANY, defaultcreds);
+        final HttpClient client = getHttpClient();
 
         getLog().info("Trying to configure file system provider...");
         // quick check if resources are configured
@@ -369,4 +377,52 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             }
         }
     }
+
+    /**
+     * Try to get the version of the web console
+     * @return The version or <code>null</code> if version is not detectable.
+     */
+    protected String checkWebConsoleVersion(final String targetUrl) {
+        getLog().debug("Checking web console version....");
+        final String bundleUrl = targetUrl + "/bundles/org.apache.felix.webconsole.json";
+        final HttpClient client = getHttpClient();
+        final GetMethod gm = new GetMethod(bundleUrl);
+        // if something goes wrong, we assume an older version!!
+        try {
+            final int status = client.executeMethod(gm);
+            if ( status == 200 ) {
+                if ( gm.getResponseContentLength() == 0 ) {
+                    getLog().debug("Response has zero length. Assuming older version of web console.");
+                    return null;
+                }
+                final String jsonText = gm.getResponseBodyAsString();
+                try {
+                    final JSONObject obj = new JSONObject(jsonText);
+                    final JSONArray props = obj.getJSONArray("props");
+                    for(int i=0; i<props.length(); i++) {
+                        final JSONObject property = props.getJSONObject(i);
+                        if ( "Version".equals(property.get("key")) ) {
+                            final String version = property.getString("value");
+                            getLog().debug("Found web console version " + version);
+                            return version;
+                        }
+                    }
+                    getLog().debug("Version property not found in response. Assuming older version.");
+                    return null;
+                } catch (JSONException ex) {
+                    getLog().debug("Converting response to JSON failed. Assuming older version: " + ex.getMessage());
+                    return null;
+                }
+
+            }
+            getLog().debug("Status code from web console: " + status);
+       } catch (HttpException e) {
+            getLog().debug("HttpException: " + e.getMessage());
+        } catch (IOException e) {
+            getLog().debug("IOException: " + e.getMessage());
+        }
+
+        getLog().debug("Unknown version.");
+        return null;
+    }
 }
\ No newline at end of file

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

[sling-maven-sling-plugin] 27/28: [maven-release-plugin] copy for tag maven-sling-plugin-2.0.4-incubator

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit f88c74696bf0c57463d38ee240b49b6fdc5a5c81
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue May 5 16:24:00 2009 +0000

    [maven-release-plugin]  copy for tag maven-sling-plugin-2.0.4-incubator
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.4-incubator@771895 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index 19e7f91..fcc7178 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,13 +23,13 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>5-incubator-SNAPSHOT</version>
+        <version>5-incubator</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.sling</groupId>
     <artifactId>maven-sling-plugin</artifactId>
-    <version>2.0.3-incubator-SNAPSHOT</version>
+    <version>2.0.4-incubator</version>
     <packaging>maven-plugin</packaging>
 
     <name>Apache Sling Maven Plugin for Supporting Bundle Development</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin</developerConnection>
-        <url>http://svn.apache.org/viewvc/incubator/sling/trunk/maven/maven-sling-plugin</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.4-incubator</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/maven-sling-plugin-2.0.4-incubator</developerConnection>
+        <url>http://svn.apache.org/viewvc/incubator/sling/tags/maven-sling-plugin-2.0.4-incubator</url>
     </scm>
 
     <reporting>
@@ -90,7 +90,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.json</artifactId>
-            <version>2.0.3-incubator-SNAPSHOT</version>
+            <version>2.0.4-incubator</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>

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

[sling-maven-sling-plugin] 18/28: SLING-861 : Rename mimeTypeForPut to just mimeType.

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 1c70e6ee2b6f2939fe123c41d519c7d8ab581302
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Feb 18 13:58:22 2009 +0000

    SLING-861 : Rename mimeTypeForPut to just mimeType.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@745515 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 01e62b7..1f5a883 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -88,7 +88,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
      * If a simple HTTP PUT should be used instead of the standard POST to the
      * felix console. In the <code>uninstall</code> goal, a HTTP DELETE will be
      * used.
-     * 
+     *
      * @parameter expression="${sling.usePut}" default-value="false"
      * @required
      */
@@ -97,13 +97,13 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
     /**
      * The content type / mime type used for the HTTP PUT (if
      * <code>sling.usePut=true</code>).
-     * 
-     * @parameter expression="${sling.mimeTypeForPut}"
+     *
+     * @parameter expression="${sling.mimeType}"
      *            default-value="application/java-archive"
      * @required
      */
-    protected String mimeTypeForPut;
-    
+    protected String mimeType;
+
     /**
      * The user name to authenticate at the running Sling instance.
      *
@@ -199,19 +199,19 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             getLog().info(bundleFile + " is not an OSGi Bundle, not uploading");
             return;
         }
-        
+
         String targetURL = getTargetURL();
 
         getLog().info(
             "Installing Bundle " + bundleName + "(" + bundleFile + ") to "
                 + targetURL + " via " + (usePut ? "PUT" : "POST"));
-        
+
         if (usePut) {
             put(targetURL, bundleFile);
         } else {
             post(targetURL, bundleFile);
         }
-        
+
         if ( mountByFS ) {
             configure(targetURL, bundleFile);
         }
@@ -293,10 +293,10 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
     protected void put(String targetURL, File file) throws MojoExecutionException {
 
         PutMethod filePut = new PutMethod(getPutURL(targetURL, file.getName()));
-        
+
         try {
-            filePut.setRequestEntity(new FileRequestEntity(file, mimeTypeForPut));
-        
+            filePut.setRequestEntity(new FileRequestEntity(file, mimeType));
+
             int status = getHttpClient().executeMethod(filePut);
             if (status >= 200 && status < 300) {
                 getLog().info("Bundle installed");
@@ -312,7 +312,7 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             filePut.releaseConnection();
         }
     }
-        
+
     /**
      * Add configurations to a running OSGi instance for initial content.
      * @param targetURL The web console base url

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

[sling-maven-sling-plugin] 08/28: SLING-808 : Increase version to 5-incubator-SNAPSHOT

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 7a126c43c979374e0a75fd537ebf9a6fcec86a93
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 5 11:07:35 2009 +0000

    SLING-808 : Increase version to 5-incubator-SNAPSHOT
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@731526 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index ed3e7b9..b713f6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>4-incubator-SNAPSHOT</version>
+        <version>5-incubator-SNAPSHOT</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-maven-sling-plugin] 17/28: SLING-861 : Apply patch by Alexander Klimetschek to support PUT in the maven-sling-plugin

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

rombert pushed a commit to annotated tag maven-sling-plugin-2.0.4-incubator
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git

commit 349edbe5cad5eedcab3c5747e84cd41932a2b15b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Feb 18 13:32:18 2009 +0000

    SLING-861 : Apply patch by Alexander Klimetschek to support PUT in the maven-sling-plugin
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/maven/maven-sling-plugin@745510 13f79535-47bb-0310-9956-ffa450edef68
---
 .../bundlesupport/AbstractBundleInstallMojo.java   | 91 +++++++++++++++++++++-
 .../maven/bundlesupport/BundleUninstallMojo.java   | 38 ++++++++-
 2 files changed, 123 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 2b351e1..01e62b7 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -34,8 +34,10 @@ import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.FileRequestEntity;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.multipart.FilePart;
 import org.apache.commons.httpclient.methods.multipart.FilePartSource;
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
@@ -71,6 +73,38 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
     protected String slingUrl;
 
     /**
+     * An optional url suffix which will be appended to the <code>sling.url</code>
+     * for use as the real target url. This allows to configure different target URLs
+     * in each POM, while using the same common <code>sling.url</code> in a parent
+     * POM (eg. <code>sling.url=http://localhost:8080</code> and
+     * <code>sling.urlSuffix=/project/specific/path</code>). This is typically used
+     * in conjunction with a HTTP PUT (<code>sling.usePut=true</code>).
+     *
+     * @parameter expression="${sling.urlSuffix}"
+     */
+    protected String slingUrlSuffix;
+
+    /**
+     * If a simple HTTP PUT should be used instead of the standard POST to the
+     * felix console. In the <code>uninstall</code> goal, a HTTP DELETE will be
+     * used.
+     * 
+     * @parameter expression="${sling.usePut}" default-value="false"
+     * @required
+     */
+    protected boolean usePut;
+
+    /**
+     * The content type / mime type used for the HTTP PUT (if
+     * <code>sling.usePut=true</code>).
+     * 
+     * @parameter expression="${sling.mimeTypeForPut}"
+     *            default-value="application/java-archive"
+     * @required
+     */
+    protected String mimeTypeForPut;
+    
+    /**
      * The user name to authenticate at the running Sling instance.
      *
      * @parameter expression="${sling.user}" default-value="admin"
@@ -133,6 +167,26 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
 
     protected abstract String getBundleFileName() throws MojoExecutionException;
 
+    /**
+     * Returns the combination of <code>sling.url</code> and
+     * <code>sling.urlSuffix</code>.
+     */
+    protected String getTargetURL() {
+        String targetURL = slingUrl;
+        if (slingUrlSuffix != null) {
+            targetURL += slingUrlSuffix;
+        }
+        return targetURL;
+    }
+
+    /**
+     * Returns the URL for PUT or DELETE by appending the filename to the
+     * targetURL.
+     */
+    protected String getPutURL(String targetURL, String fileName) {
+        return targetURL + (targetURL.endsWith("/") ? "" : "/") + fileName;
+    }
+
     public void execute() throws MojoExecutionException {
 
         // get the file to upload
@@ -145,13 +199,21 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
             getLog().info(bundleFile + " is not an OSGi Bundle, not uploading");
             return;
         }
+        
+        String targetURL = getTargetURL();
 
         getLog().info(
             "Installing Bundle " + bundleName + "(" + bundleFile + ") to "
-                + slingUrl);
-        post(slingUrl, bundleFile);
+                + targetURL + " via " + (usePut ? "PUT" : "POST"));
+        
+        if (usePut) {
+            put(targetURL, bundleFile);
+        } else {
+            post(targetURL, bundleFile);
+        }
+        
         if ( mountByFS ) {
-            configure(slingUrl, bundleFile);
+            configure(targetURL, bundleFile);
         }
     }
 
@@ -228,6 +290,29 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
         }
     }
 
+    protected void put(String targetURL, File file) throws MojoExecutionException {
+
+        PutMethod filePut = new PutMethod(getPutURL(targetURL, file.getName()));
+        
+        try {
+            filePut.setRequestEntity(new FileRequestEntity(file, mimeTypeForPut));
+        
+            int status = getHttpClient().executeMethod(filePut);
+            if (status >= 200 && status < 300) {
+                getLog().info("Bundle installed");
+            } else {
+                getLog().error(
+                    "Installation failed, cause: "
+                        + HttpStatus.getStatusText(status));
+            }
+        } catch (Exception ex) {
+            throw new MojoExecutionException("Installation on " + targetURL
+                + " failed, cause: " + ex.getMessage(), ex);
+        } finally {
+            filePut.releaseConnection();
+        }
+    }
+        
     /**
      * Add configurations to a running OSGi instance for initial content.
      * @param targetURL The web console base url
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java
index b019c79..53e41a4 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.maven.plugin.MojoExecutionException;
 
@@ -60,11 +61,42 @@ public class BundleUninstallMojo extends AbstractBundleInstallMojo {
             return;
         }
 
+        String targetURL = getTargetURL();
+        
         getLog().info(
             "Unistalling Bundle " + bundleName + ") from "
-                + slingUrl);
-        configure(slingUrl, bundleFile);
-        post(slingUrl, bundleName);
+                + targetURL + " via " + (usePut ? "DELETE" : "POST"));
+        
+        configure(targetURL, bundleFile);
+        
+        if (usePut) {
+            delete(targetURL, bundleFile);
+        } else {
+            post(targetURL, bundleName);
+        }
+    }
+
+    protected void delete(String targetURL, File file)
+        throws MojoExecutionException {
+        
+        final DeleteMethod delete = new DeleteMethod(getPutURL(targetURL, file.getName()));
+
+        try {
+
+            int status = getHttpClient().executeMethod(delete);
+            if (status >= 200 && status < 300) {
+                getLog().info("Bundle uninstalled");
+            } else {
+                getLog().error(
+                    "Uninstall failed, cause: "
+                        + HttpStatus.getStatusText(status));
+            }
+        } catch (Exception ex) {
+            throw new MojoExecutionException("Uninstall from " + targetURL
+                + " failed, cause: " + ex.getMessage(), ex);
+        } finally {
+            delete.releaseConnection();
+        }
     }
 
     protected void post(String targetURL, String symbolicName)

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