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:59:02 UTC

[sling-org-apache-sling-provisioning-model] annotated tag org.apache.sling.provisioning.model-1.8.0 created (now 4eaed01)

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

rombert pushed a change to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git.


      at 4eaed01  (tag)
 tagging 65d485989fe62cd7293e9889bb242060a35a4d61 (commit)
      by Carsten Ziegeler
      on Tue Dec 13 12:52:42 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.provisioning.model-1.8.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 11a204a  Add slingstart model
     new 03f094c  Add slingstart model
     new a86fcd4  Update javadocs and rename subsystem to deliverable and run mode to feature
     new 58cc5a6  Add simple txt parser
     new 43a5c06  Add simple txt parser
     new fdc1ccf  Fully support Apach Felix config file format. Move from properties to getter and setter methods
     new 470e4bc  Fully support Apach Felix config file format. Move from properties to getter and setter methods
     new 9857e6c  Fully support Apach Felix config file format. Move from properties to getter and setter methods
     new 75a411c  Simplify model, move completely to getter/setter methods
     new 1a36bd0  Implement txt format for reading and writing
     new 7bee16a  Add merger utility and variable replacement
     new ca9289e  Finish configuration support
     new 245be2d  Add resolver to resolve variables from environment, system properties etc.
     new ffb35f8  Don't output jar extension if not necessary
     new 252bf2d  Remove support for xml
     new 456ebb1  Implement provisioning model
     new 380d68e  Rename some constants
     new c58f1ab  Cleanup methods and constants
     new d3b6bc4  Update to Sling Parent POM 22 with baselining enabled
     new 5154296  Correct method name
     new 55e51ed  Remove old slingstart model
     new 4b98c32  Refactor model and add basic read/write test
     new 98736d5  Consistent method naming and javadocs
     new 2341da7  Rename to provisoning model
     new 4d55db0  Rename to provisioning model
     new dc48bc1  Keep ${sling.home} in settings
     new fb3de37  Remove artifact on merge regardless of the start level
     new 43e7bcf  Fix writing out raw configs
     new 54361e3  Fix writing out raw configs
     new d71c810  Fix reading configs
     new bbe9bcd  Allow comments in configurations
     new bccda6c  Add some tests to verify the parsed and effective models
     new c47da2f  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.0.0
     new e93aff8  [maven-release-plugin] prepare for next development iteration
     new 7aee9d5  Fix comments
     new ee05f2c  Update to latest launchpad base release
     new 523138f  SLING-4473 : Provide a way to remove settings, artifacts and features through a model SLING-4475 : Artifact is twice in feature after merge
     new 94c918f  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.1.0
     new 15d9a12  [maven-release-plugin] prepare for next development iteration
     new 89e8cf9  Add test case for run modes
     new 97ac28f  Update test case
     new 52ee32c  Fix javadocs
     new 7a21cc8  Add missing licence headers
     new ceeb1f7  SLING-4698 - Set parent.relativePath to empty for all modules
     new 43429c2  SLING-4768 : Sort entries alphabetical in written model
     new fba2533  SLING-4768 : Sort entries alphabetical in written model
     new ee04adc  SLING-4768 : Sort entries alphabetical in written model
     new 9c0eaaa  SLING-4766 Provisioning Model does not support adding variables to Sling Settings - allow escaping with \${var}
     new 9dcb074  SLING-4768 : Sort entries alphabetical in written model
     new 1f2cf68  SLING-4782 : Update to latest format from Apache Felix config admin
     new f66c21e  SLING-4786 : Attributes and configuration format are wronlgy written out
     new 2192bda  SLING-4126 : Provide a mechanism to merge configurations
     new 5f9f27c  SLING-4126 : Provide a mechanism to merge configurations
     new bd96e54  SLING-4124 : Bootstrap command file can't be appended
     new c2b343f  SLING-4790 : Removal of artifacts from inherited model is not possible
     new 9c0fcd5  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.2.0
     new 690eb71  [maven-release-plugin] prepare for next development iteration
     new 0972528  SLING-4807 : Variables in configurations are not replaced
     new 312ade9  Update to Sling Parent 23
     new 1d0ef5f  Remove superflous sling.java.version=6 as it's the default now
     new 58dbd4a  set parent version to 24 and add empty relativePath where missing
     new 3509c1f  SLING-4645 Update Tika to 1.9
     new bbf7873  SLING-4880 Allow to get artifact versions from POM
     new 6a392fa  SLING-4879 refactor model processing logic from ModelUtility#getEffectiveModel into separate class to make it reusable
     new 82e4d3f  SLING-4879 move resolver/replace logic to separate class ModelResolverUtility
     new 7d6e31f  SLING-4807 make sure variable replacement is applied whether custom resolver exists or not
     new 5eea7de  SLING-4879 add ModelUtility.applyVariables method that allows to inject further variables from a custom variable resolver
     new ce9607f  SLING-4880 apply resolved dependencies to raw model instead of attaching effective model add new optional parameter "allowUnresolvedPomDependencies" (default: false)
     new 84e3f39  fix some javadoc errors java 8 complains about
     new 9a36bf7  SLING-4807 introduce explicit boolean flag to make sure variable replacement does not take place when merging models
     new e3b7720  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.3.0
     new b0181cd  [maven-release-plugin] prepare for next development iteration
     new 9a80232  Update the main reactor to parent 25
     new b36cc99  SLING-5148 : Support OSGi Subsystems in the Sling Provisioning model. Apply patch from David Bosschaert
     new d0779ce  SLING-5172 : Provide support for custom sections in the provisioning model
     new 7fa8736  SLING-5148 : Support OSGi Subsystems in the Sling Provisioning model.
     new 94bc251  SLING-5174 : Refactor merging of models into separate utility class and add merge options
     new 4a90126  git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1709754 13f79535-47bb-0310-9956-ffa450edef68
     new b0f38e7  SLING-5172 : Provide support for custom sections in the provisioning model
     new 42a911c  SLING-5174 : Refactor merging of models into separate utility class and add merge options
     new b05b9ce  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.4.0
     new d7059e2  [maven-release-plugin] prepare for next development iteration
     new 6bb2a5e  SLING-5185 : Version comparision is wrong in case of qualifiers
     new 2c05c45  SLING-5189 : Improve start level handling when merging models
     new 967d25a  SLING-5318 : Sling provisioning model does not propagate Artifact metadata during processing. Apply patch from David Bosschaert
     new a4b997d  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.4.2
     new 7da6bc0  [maven-release-plugin] prepare for next development iteration
     new 90c365d  SLING-5355 - test multiline strings in configs
     new 5ba03f6  Switch to parent pom 26
     new f1b113a  SLING-5765 : No way to remove an artifact from a special runmode
     new 609d205  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.4.4
     new 3bd7409  [maven-release-plugin] prepare for next development iteration
     new 636f387  SLING-5914 - add tests that demonstrate the current behavior
     new af9d553  SLING-6181 : Support adding version info to Feature
     new 62c933d  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.5.0
     new 3502210  [maven-release-plugin] prepare for next development iteration
     new 52c62df  SLING-6215 : Catch IllegalArgumentException when comparing versions
     new 8cc4eef  SLING-6214 : Validate feature version to be a valid version
     new f12e1de  SLING-6216 : Merge versioned features by using highest version
     new d6876f6  SLING-6218 : Make usage of MergeOptions easier
     new 57a433e  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.6.0
     new 9f2afeb  [maven-release-plugin] prepare for next development iteration
     new e5c653f  SLING-6265 : Effective model does not get feature versions
     new 46bc2eb  SLING-6267 : Support OSGi versions and provide accessor methods of version parts
     new 070df11  SLING-6267 : Support OSGi versions and provide accessor methods of version parts
     new a734fed  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.7.0
     new 4777434  [maven-release-plugin] prepare for next development iteration
     new 97fe761  SLING-6272 : Comments in the provisioning model get lost
     new ab4c7d8  SLING-6278 : Provide tooling to create an archive with the provisioning model and all artifacts
     new 39d76f8  SLING-6389 : Avoid empty blank line at end of provisioning model
     new ac29edc  [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.8.0
     new 65d4859  [maven-release-plugin] copy for tag org.apache.sling.provisioning.model-1.8.0

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


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

[sling-org-apache-sling-provisioning-model] 03/06: SLING-6278 : Provide tooling to create an archive with the provisioning model and all artifacts

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

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit ab4c7d8e9caf7cfbf2257f232e5dcba8a7a39b52
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Nov 12 15:09:17 2016 +0000

    SLING-6278 : Provide tooling to create an archive with the provisioning model and all artifacts
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1769384 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/provisioning/model/ModelUtility.java     |  52 ++++++--
 .../provisioning/model/io/ModelArchiveReader.java  | 103 ++++++++++++++++
 .../provisioning/model/io/ModelArchiveWriter.java  | 137 +++++++++++++++++++++
 .../sling/provisioning/model/io/package-info.java  |   2 +-
 4 files changed, 284 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
index 0503f97..968bfce 100644
--- a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java
@@ -167,14 +167,14 @@ public abstract class ModelUtility {
         for(final Feature feature : model.getFeatures() ) {
             // validate feature
             if ( feature.getName() == null || feature.getName().isEmpty() ) {
-                errors.put(feature, "Name is required for a feature.");
+                addError(errors, feature, "Name is required for a feature.");
             }
             // version should be a valid version
             if ( feature.getVersion() != null ) {
                 try {
                     new Version(feature.getVersion());
                 } catch ( final IllegalArgumentException iae) {
-                    errors.put(feature, "Version is not a valid version: " + feature.getVersion());
+                    addError(errors, feature, "Version is not a valid version: " + feature.getVersion());
                 }
             }
             for(final RunMode runMode : feature.getRunModes()) {
@@ -193,12 +193,12 @@ public abstract class ModelUtility {
                                         hasSpecial = 2;
                                     } else {
                                         hasSpecial = 2;
-                                        errors.put(runMode, "Invalid modes " + Arrays.toString(rm));
+                                        addError(errors, runMode, "Invalid modes " + Arrays.toString(rm));
                                         break;
                                     }
                                 } else {
                                     hasSpecial++;
-                                    errors.put(runMode, "Invalid modes " + Arrays.toString(rm));
+                                    addError(errors, runMode, "Invalid modes " + Arrays.toString(rm));
                                     break;
                                 }
 
@@ -212,7 +212,7 @@ public abstract class ModelUtility {
 
                 for(final ArtifactGroup sl : runMode.getArtifactGroups()) {
                     if ( sl.getStartLevel() < 0 ) {
-                        errors.put(sl, "Invalid start level " + sl.getStartLevel());
+                        addError(errors, sl, "Invalid start level " + sl.getStartLevel());
                     }
                     for(final Artifact a : sl) {
                         String error = null;
@@ -229,7 +229,7 @@ public abstract class ModelUtility {
                             error = (error != null ? error + ", " : "") + "type missing";
                         }
                         if (error != null) {
-                            errors.put(a, error);
+                            addError(errors, a, error);
                         }
                     }
                 }
@@ -246,12 +246,12 @@ public abstract class ModelUtility {
                         error = (error != null ? error + ", " : "") + "configuration properties missing";
                     }
                     if (error != null) {
-                        errors.put(c, error);
+                        addError(errors, c, error);
                     }
                 }
             }
         }
-        if ( errors.size() == 0 ) {
+        if ( errors.isEmpty()) {
             return null;
         }
         return errors;
@@ -260,7 +260,7 @@ public abstract class ModelUtility {
     /**
      * Applies a set of variables to the given model.
      * All variables that are referenced anywhere within the model are detected and passed to the given variable resolver.
-     * The variable resolver may look up variables on it's own, or fallback to the variables already defined for the feature.
+     * The variable resolver may look up variables on it's own, or fall back to the variables already defined for the feature.
      * All resolved variable values are collected and put to the "variables" section of the resulting model.
      * @param model Original model
      * @param resolver Variable resolver
@@ -346,4 +346,38 @@ public abstract class ModelUtility {
         return versionUpdater.process(model);
     }
 
+    /**
+     * Validates the model and checks that each feature has a valid version.
+     *
+     * This method first calls {@link #validate(Model)} and then checks
+     * that each feature has a version.
+     *
+     * @param model The model to validate
+     * @return A map with errors or {@code null} if valid.
+     * @since 1.9
+     */
+    public static Map<Traceable, String> validateIncludingVersion(final Model model) {
+        Map<Traceable, String> errors = validate(model);
+        for(final Feature feature : model.getFeatures()) {
+            if ( feature.getVersion() == null ) {
+                if ( errors == null ) {
+                    errors = new HashMap<>();
+                }
+                addError(errors, feature, "Feature must have a version.");
+            }
+        }
+        return errors;
+    }
+
+    /**
+     * Add an error for the {@code Traceable} to the error map
+     * @param errors The map of errors
+     * @param object The traceable object
+     * @param error The error message
+     * @since 1.9
+     */
+    private static void addError(final Map<Traceable, String> errors, final Traceable object, final String error) {
+        String value = errors.get(object);
+        errors.put(object, (value == null ? error : value + " " + error));
+    }
 }
diff --git a/src/main/java/org/apache/sling/provisioning/model/io/ModelArchiveReader.java b/src/main/java/org/apache/sling/provisioning/model/io/ModelArchiveReader.java
new file mode 100644
index 0000000..38d0230
--- /dev/null
+++ b/src/main/java/org/apache/sling/provisioning/model/io/ModelArchiveReader.java
@@ -0,0 +1,103 @@
+/*
+ * 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.provisioning.model.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.sling.provisioning.model.Artifact;
+import org.apache.sling.provisioning.model.Model;
+import org.apache.sling.provisioning.model.ModelUtility;
+
+/**
+ * The model archive reader can be used to read an archive based on a model
+ * The archive contains the model file and all artifacts.
+ * @since 1.3
+ */
+public class ModelArchiveReader {
+
+    public interface ArtifactConsumer {
+
+        /**
+         * Consume the artifact from the archive
+         * The input stream must not be closed by the consumer.
+         * @param artifact The artifact
+         * @param is The input stream for the artifact
+         * @throws IOException If the artifact can't be consumed
+         */
+        void consume(Artifact artifact, final InputStream is) throws IOException;
+    }
+
+    /**
+     * Read a model archive.
+     * The input stream is not closed. It is up to the caller to close the input stream.
+     * @param in The input stream to read from.
+     * @return The model
+     * @throws IOException If anything goes wrong
+     */
+    @SuppressWarnings("resource")
+    public static Model read(final InputStream in,
+                             final ArtifactConsumer consumer)
+    throws IOException {
+        Model model = null;
+
+        final JarInputStream jis = new JarInputStream(in);
+
+        // check manifest
+        final Manifest manifest = jis.getManifest();
+        if ( manifest == null ) {
+            throw new IOException("Not a model archive - manifest is missing.");
+        }
+        // check manifest header
+        final String version = manifest.getMainAttributes().getValue(ModelArchiveWriter.MANIFEST_HEADER);
+        if ( version == null ) {
+            throw new IOException("Not a model archive - manifest header is missing.");
+        }
+        // validate manifest header
+        try {
+            final int number = Integer.valueOf(version);
+            if ( number < 1 || number > ModelArchiveWriter.ARCHIVE_VERSION ) {
+                throw new IOException("Not a model archive - invalid manifest header value: " + version);
+            }
+        } catch (final NumberFormatException nfe) {
+            throw new IOException("Not a model archive - invalid manifest header value: " + version);
+        }
+
+        // read contents
+        JarEntry entry = null;
+        while ( ( entry = jis.getNextJarEntry() ) != null ) {
+            if ( ModelArchiveWriter.MODEL_NAME.equals(entry.getName()) ) {
+                model = ModelUtility.getEffectiveModel(ModelReader.read(new InputStreamReader(jis, "UTF-8"), null));
+            } else if ( !entry.isDirectory() && entry.getName().startsWith(ModelArchiveWriter.ARTIFACTS_PREFIX) ) { // artifact
+                final Artifact artifact = Artifact.fromMvnUrl("mvn:" + entry.getName().substring(ModelArchiveWriter.ARTIFACTS_PREFIX.length()));
+                consumer.consume(artifact, jis);
+            }
+            jis.closeEntry();
+        }
+        if ( model == null ) {
+            throw new IOException("Not a model archive - model file is missing.");
+        }
+
+        // TODO - we could check whether all artifacts from the model are in the archive
+
+        return model;
+    }
+}
diff --git a/src/main/java/org/apache/sling/provisioning/model/io/ModelArchiveWriter.java b/src/main/java/org/apache/sling/provisioning/model/io/ModelArchiveWriter.java
new file mode 100644
index 0000000..7c6d9e9
--- /dev/null
+++ b/src/main/java/org/apache/sling/provisioning/model/io/ModelArchiveWriter.java
@@ -0,0 +1,137 @@
+/*
+ * 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.provisioning.model.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.apache.sling.provisioning.model.Artifact;
+import org.apache.sling.provisioning.model.ArtifactGroup;
+import org.apache.sling.provisioning.model.Feature;
+import org.apache.sling.provisioning.model.Model;
+import org.apache.sling.provisioning.model.ModelUtility;
+import org.apache.sling.provisioning.model.RunMode;
+import org.apache.sling.provisioning.model.Traceable;
+
+/**
+ * The model archive writer can be used to create an archive based on a model
+ * The archive contains the model file and all artifacts.
+ * @since 1.3
+ */
+public class ModelArchiveWriter {
+
+    /** The manifest header marking an archive as a model archive. */
+    public static final String MANIFEST_HEADER = "Model-Archive-Version";
+
+    /** Current support version of the model archive. */
+    public static final int ARCHIVE_VERSION = 1;
+
+    /** Default extension for model archives. */
+    public static final String DEFAULT_EXTENSION = "mar";
+
+    /** Model name. */
+    public static final String MODEL_NAME = "models/feature.model";
+
+    /** Artifacts prefix. */
+    public static final String ARTIFACTS_PREFIX = "artifacts/";
+
+    public interface ArtifactProvider {
+
+        /**
+         * Provide an input stream for the artifact.
+         * The input stream will be closed by the caller.
+         * @param artifact The artifact
+         * @return The input stream
+         * @throws IOException If the input stream can't be provided
+         */
+        InputStream getInputStream(Artifact artifact) throws IOException;
+    }
+
+    /**
+     * Create a model archive.
+     * The output stream will not be closed by this method. The caller
+     * must call {@link JarOutputStream#close()} or {@link JarOutputStream#finish()}
+     * on the return output stream. The caller can add additional files through
+     * the return stream.
+     *
+     * In order to create an archive for a model, each feature in the model must
+     * have a name and a version and the model must be valid, therefore {@link ModelUtility#validateIncludingVersion(Model)}
+     * is called first. If the model is invalid an {@code IOException} is thrown.
+     *
+     * @param out The output stream to write to
+     * @param model The model to write
+     * @param baseManifest Optional base manifest used for creating the manifest.
+     * @param provider The artifact provider
+     * @return The jar output stream.
+     * @throws IOException If anything goes wrong
+     */
+    public static JarOutputStream write(final OutputStream out,
+                             final Model model,
+                             final Manifest baseManifest,
+                             final ArtifactProvider provider)
+    throws IOException {
+        // check model
+        final Map<Traceable, String> errors = ModelUtility.validate(model);
+        if ( errors != null ) {
+            throw new IOException("Model is not valid: " + errors);
+        }
+
+        // create manifest
+        final Manifest manifest = (baseManifest == null ? new Manifest() : new Manifest(baseManifest));
+        manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
+        manifest.getMainAttributes().putValue(MANIFEST_HEADER, String.valueOf(ARCHIVE_VERSION));
+
+        // create archive
+        final JarOutputStream jos = new JarOutputStream(out, manifest);
+
+        // write model first
+        final JarEntry entry = new JarEntry(MODEL_NAME);
+        jos.putNextEntry(entry);
+        final Writer writer = new OutputStreamWriter(jos, "UTF-8");
+        ModelWriter.write(writer, model);
+        writer.flush();
+        jos.closeEntry();
+
+        final byte[] buffer = new byte[1024*1024*256];
+        for(final Feature f : model.getFeatures() ) {
+            for(final RunMode rm : f.getRunModes()) {
+                for(final ArtifactGroup g : rm.getArtifactGroups()) {
+                    for(final Artifact a : g) {
+                        final JarEntry artifactEntry = new JarEntry(ARTIFACTS_PREFIX + a.getRepositoryPath());
+                        jos.putNextEntry(artifactEntry);
+
+                        try (final InputStream is = provider.getInputStream(a)) {
+                            int l = 0;
+                            while ( (l = is.read(buffer)) > 0 ) {
+                                jos.write(buffer, 0, l);
+                            }
+                        }
+                        jos.closeEntry();
+                    }
+                }
+            }
+        }
+        return jos;
+    }
+}
diff --git a/src/main/java/org/apache/sling/provisioning/model/io/package-info.java b/src/main/java/org/apache/sling/provisioning/model/io/package-info.java
index a100458..748b2f7 100644
--- a/src/main/java/org/apache/sling/provisioning/model/io/package-info.java
+++ b/src/main/java/org/apache/sling/provisioning/model/io/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@org.osgi.annotation.versioning.Version("1.2")
+@org.osgi.annotation.versioning.Version("1.3")
 package org.apache.sling.provisioning.model.io;
 
 

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

[sling-org-apache-sling-provisioning-model] 01/06: [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 org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 4777434c4ccdba0928a358f86c9357ac3219c827
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Nov 10 06:00:44 2016 +0000

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

diff --git a/pom.xml b/pom.xml
index a6b94c4..29701bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     </parent>
 
     <artifactId>org.apache.sling.provisioning.model</artifactId>
-    <version>1.7.0</version>
+    <version>1.7.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Provisioning Model</name>
@@ -31,9 +31,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.7.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.7.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.provisioning.model-1.7.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/provisioning-model</url>
     </scm>
 
     <build>

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

[sling-org-apache-sling-provisioning-model] 05/06: [maven-release-plugin] prepare release org.apache.sling.provisioning.model-1.8.0

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

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit ac29edcfe0d94cbd4f90bab1d83daedde0a3efdb
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Dec 13 12:52:29 2016 +0000

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

diff --git a/pom.xml b/pom.xml
index 29701bd..4276687 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     </parent>
 
     <artifactId>org.apache.sling.provisioning.model</artifactId>
-    <version>1.7.1-SNAPSHOT</version>
+    <version>1.8.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Provisioning Model</name>
@@ -31,9 +31,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/provisioning-model</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.8.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.8.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.provisioning.model-1.8.0</url>
     </scm>
 
     <build>

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

[sling-org-apache-sling-provisioning-model] 04/06: SLING-6389 : Avoid empty blank line at end of provisioning model

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

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 39d76f8d6242095b30c5d6f3d2ea9a8a8c03a461
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Dec 12 13:18:22 2016 +0000

    SLING-6389 : Avoid empty blank line at end of provisioning model
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1773788 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/provisioning/model/io/ModelWriter.java   | 25 ++++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java b/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java
index d503628..ab0fa8b 100644
--- a/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java
+++ b/src/main/java/org/apache/sling/provisioning/model/io/ModelWriter.java
@@ -84,8 +84,15 @@ public class ModelWriter {
     throws IOException {
         final PrintWriter pw = new PrintWriter(writer);
 
+        boolean firstFeature = true;
+
         // features
         for(final Feature feature : model.getFeatures()) {
+            if ( firstFeature ) {
+                firstFeature = false;
+            } else {
+                pw.println();
+            }
             writeComment(pw, feature);
             pw.print("[feature name=");
             pw.print(feature.getName());
@@ -98,10 +105,10 @@ public class ModelWriter {
                 pw.print(feature.getVersion());
             }
             pw.println("]");
-            pw.println();
 
             // variables
             if ( !feature.getVariables().isEmpty() ) {
+                pw.println();
                 writeComment(pw, feature.getVariables());
                 pw.println("[variables]");
                 for(final Map.Entry<String, String> entry : feature.getVariables()) {
@@ -110,13 +117,13 @@ public class ModelWriter {
                     pw.print("=");
                     pw.println(entry.getValue());
                 }
-                pw.println();
             }
 
             // run modes
             for(final RunMode runMode : feature.getRunModes()) {
                 // settings
                 if ( !runMode.getSettings().isEmpty() ) {
+                    pw.println();
                     writeComment(pw, runMode.getSettings());
                     pw.print("[settings");
                     writeRunMode(pw, runMode);
@@ -128,7 +135,6 @@ public class ModelWriter {
                         pw.print("=");
                         pw.println(entry.getValue());
                     }
-                    pw.println();
                 }
 
                 // artifact groups
@@ -137,6 +143,7 @@ public class ModelWriter {
                     if ( group.isEmpty() ) {
                         continue;
                     }
+                    pw.println();
                     writeComment(pw, group);
                     pw.print("[artifacts");
                     if ( group.getStartLevel() > 0 ) {
@@ -145,7 +152,6 @@ public class ModelWriter {
                     }
                     writeRunMode(pw, runMode);
                     pw.println("]");
-                    pw.println();
 
                     // artifacts
                     for(final Artifact ad : group) {
@@ -169,16 +175,22 @@ public class ModelWriter {
                         }
                         pw.println();
                     }
-                    pw.println();
                 }
 
                 // configurations
                 if ( !runMode.getConfigurations().isEmpty() ) {
+                    pw.println();
                     writeComment(pw, runMode.getConfigurations());
                     pw.print("[configurations");
                     writeRunMode(pw, runMode);
                     pw.println("]");
+                    boolean firstConfig = true;
                     for(final Configuration config : runMode.getConfigurations()) {
+                        if ( firstConfig ) {
+                            firstConfig = false;
+                        } else{
+                            pw.println();
+                        }
                         writeComment(pw, config);
                         final String raw = (String)config.getProperties().get(ModelConstants.CFG_UNPROCESSED);
                         String format = (String)config.getProperties().get(ModelConstants.CFG_UNPROCESSED_FORMAT);
@@ -238,13 +250,13 @@ public class ModelWriter {
                             pw.print("    ");
                             pw.println(line.trim());
                         }
-                        pw.println();
                     }
                 }
             }
 
             // additional sections
             for(final Section section : feature.getAdditionalSections()) {
+                pw.println();
                 pw.print("  [:");
                 pw.print(section.getName());
                 for(final Map.Entry<String, String> entry : section.getAttributes().entrySet()) {
@@ -257,7 +269,6 @@ public class ModelWriter {
                 if ( section.getContents() != null ) {
                     pw.println(section.getContents());
                 }
-                pw.println();
             }
         }
     }

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

[sling-org-apache-sling-provisioning-model] 06/06: [maven-release-plugin] copy for tag org.apache.sling.provisioning.model-1.8.0

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

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 65d485989fe62cd7293e9889bb242060a35a4d61
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Dec 13 12:52:42 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.provisioning.model-1.8.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.provisioning.model-1.8.0@1774003 13f79535-47bb-0310-9956-ffa450edef68

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

[sling-org-apache-sling-provisioning-model] 02/06: SLING-6272 : Comments in the provisioning model get lost

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

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.8.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 97fe761234964661021a70356a68fa2435029af6
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Nov 11 06:37:33 2016 +0000

    SLING-6272 : Comments in the provisioning model get lost
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1769250 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/provisioning/model/MergeUtility.java     | 24 +++++++++++++++++++++-
 .../sling/provisioning/model/package-info.java     |  2 +-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
index 9cfdc3e..663efc5 100644
--- a/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
+++ b/src/main/java/org/apache/sling/provisioning/model/MergeUtility.java
@@ -140,15 +140,18 @@ public abstract class MergeUtility {
                 baseFeature.getRunModes().clear();
                 baseFeature.getAdditionalSections().clear();
                 baseFeature.getVariables().clear();
+                baseFeature.setComment(null);
             }
 
+            mergeComments(baseFeature, feature);
             baseFeature.setType(feature.getType());
 
-            // additional sections
+            // additional sections (sections are not cloned, therefore comments do not need to be merged)
             baseFeature.getAdditionalSections().addAll(feature.getAdditionalSections());
 
             // variables
             baseFeature.getVariables().putAll(feature.getVariables());
+            mergeComments(baseFeature.getVariables(), feature.getVariables());
 
             // run modes
             for(final RunMode runMode : feature.getRunModes()) {
@@ -165,6 +168,8 @@ public abstract class MergeUtility {
                 for(final ArtifactGroup group : runMode.getArtifactGroups()) {
                     final ArtifactGroup baseGroup = baseRunMode.getOrCreateArtifactGroup(group.getStartLevel());
 
+                    mergeComments(baseGroup, group);
+
                     int foundStartLevel = 0;
 
                     for(final Artifact artifact : group) {
@@ -198,6 +203,7 @@ public abstract class MergeUtility {
                             }
                         }
                         if ( addArtifact ) {
+                            // artifacts are not cloned, therefore comments do not need to be merged
                             if ( group.getStartLevel() == 0 && foundStartLevel != 0 ) {
                                 baseRunMode.getOrCreateArtifactGroup(foundStartLevel).add(artifact);
                             } else {
@@ -212,12 +218,14 @@ public abstract class MergeUtility {
                     final Configuration found = baseRunMode.getOrCreateConfiguration(config.getPid(), config.getFactoryPid());
 
                     mergeConfiguration(found, config);
+                    mergeComments(found, config);
                 }
 
                 // settings
                 for(final Map.Entry<String, String> entry : runMode.getSettings() ) {
                     baseRunMode.getSettings().put(entry.getKey(), entry.getValue());
                 }
+                mergeComments(baseRunMode.getSettings(), runMode.getSettings());
             }
 
         }
@@ -380,4 +388,18 @@ public abstract class MergeUtility {
             }
         }
     }
+
+    /**
+     * Merge the comments
+     * @param base The base model object
+     * @param additional The additional model object
+     * @since 1.9.0
+     */
+    public static void mergeComments(final Commentable base, final Commentable additional) {
+        if ( base.getComment() == null ) {
+            base.setComment(additional.getComment());
+        } else if ( additional.getComment() != null ) {
+            base.setComment(base.getComment() + "\n" + additional.getComment());
+        }
+    }
 }
diff --git a/src/main/java/org/apache/sling/provisioning/model/package-info.java b/src/main/java/org/apache/sling/provisioning/model/package-info.java
index 0a4616b..5547282 100644
--- a/src/main/java/org/apache/sling/provisioning/model/package-info.java
+++ b/src/main/java/org/apache/sling/provisioning/model/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@org.osgi.annotation.versioning.Version("1.8.0")
+@org.osgi.annotation.versioning.Version("1.9.0")
 package org.apache.sling.provisioning.model;
 
 

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