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 <[email protected]> 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. */ [email protected]("1.8.0") [email protected]("1.9.0") package org.apache.sling.provisioning.model; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
