You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/06/27 21:59:25 UTC
[sling-whiteboard] branch master updated: removed promoted
whitebeard bundles
This is an automated email from the ASF dual-hosted git repository.
simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 67ba734 removed promoted whitebeard bundles
67ba734 is described below
commit 67ba7349192631094d1443de7c5897fa639dcdee
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Thu Jun 27 23:59:10 2019 +0200
removed promoted whitebeard bundles
---
feature-diff/CODE_OF_CONDUCT.md | 22 ---
feature-diff/CONTRIBUTING.md | 24 ---
feature-diff/LICENSE | 201 ---------------------
feature-diff/README.md | 60 ------
feature-diff/pom.xml | 99 ----------
.../org/apache/sling/feature/diff/DiffRequest.java | 72 --------
.../org/apache/sling/feature/diff/FeatureDiff.java | 92 ----------
.../impl/AbstractFeatureElementComparator.java | 37 ----
.../sling/feature/diff/impl/BundlesComparator.java | 61 -------
.../diff/impl/ConfigurationsComparator.java | 195 --------------------
.../feature/diff/impl/ExtensionsComparator.java | 145 ---------------
.../diff/impl/FeatureElementComparator.java | 43 -----
.../diff/impl/FrameworkPropertiesComparator.java | 63 -------
.../apache/sling/feature/diff/package-info.java | 22 ---
.../apache/sling/feature/diff/FeatureDiffTest.java | 78 --------
.../feature/diff/impl/AbstractComparatorTest.java | 46 -----
.../feature/diff/impl/BundlesComparatorTest.java | 83 ---------
.../diff/impl/ConfigurationsComparatorTest.java | 97 ----------
.../diff/impl/ExtensionsComparatorTest.java | 133 --------------
.../impl/FrameworkPropertiesComparatorTest.java | 79 --------
runtime2feature/CODE_OF_CONDUCT.md | 22 ---
runtime2feature/CONTRIBUTING.md | 24 ---
runtime2feature/LICENSE | 201 ---------------------
runtime2feature/README.md | 66 -------
runtime2feature/pom.xml | 99 ----------
.../r2f/RuntimeEnvironment2FeatureModel.java | 31 ----
.../r2f/impl/AbstractFeatureElementConsumer.java | 35 ----
.../feature/r2f/impl/Bundle2ArtifactMapper.java | 127 -------------
...GiConfiguration2FeatureConfigurationMapper.java | 55 ------
.../RuntimeEnvironment2FeatureModelService.java | 181 -------------------
.../org/apache/sling/feature/r2f/package-info.java | 19 --
31 files changed, 2512 deletions(-)
diff --git a/feature-diff/CODE_OF_CONDUCT.md b/feature-diff/CODE_OF_CONDUCT.md
deleted file mode 100644
index 0fa18e5..0000000
--- a/feature-diff/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Apache Software Foundation Code of Conduct
-====
-
-Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/feature-diff/CONTRIBUTING.md b/feature-diff/CONTRIBUTING.md
deleted file mode 100644
index ac82a1a..0000000
--- a/feature-diff/CONTRIBUTING.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Contributing
-====
-
-Thanks for choosing to contribute!
-
-You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/feature-diff/LICENSE b/feature-diff/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/feature-diff/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
diff --git a/feature-diff/README.md b/feature-diff/README.md
deleted file mode 100644
index a026988..0000000
--- a/feature-diff/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-[<img src="http://sling.apache.org/res/logos/sling.png"/>](http://sling.apache.org)
-
-# Apache Sling Feature Model diff tool
-
-This tool aims to provide to Apache Sling users an easy-to-use tool which is able to detect differences between different released version of the same Apache Sling Feature Model.
-
-## Simple APIs
-
-Given two different versions of the same `org.apache.sling.feature.Feature`, all we need to do is comparing them
-
-```java
-import static org.apache.sling.feature.diff.FeatureDiff.compareFeatures;
-
-import org.apache.sling.feature.Feature
-import org.apache.sling.feature.diff.DiffRequest;
-import org.apache.sling.feature.diff.DiffRequest;
-
-...
-
-Feature previous = // somehow obtained
-Feature current = // somehow obtained
-
-DiffRequest diffRequest = new DiffRequest()
- .setPrevious(previous)
- .setCurrent(current)
- .setResultId("org.apache.sling:org.apache.sling.diff:1.0.0");
-
-Feature featureDiff = compareFeatures(previous, current);
-```
-
-The resulting `featureDiff` is a new `Feature` instance which prototypes from `previous` and where necessary removals sections are populated and new elements may be added.
-
-###Please note
-
-The `FeatureDiff.compareFeatures(Feature, Feature)` rejects (aka throws an `IllegalArgumentException`) `Feature` inputs that:
-
- * are `null` (bien sûr);
- * refer exactly to the same `Feature`.
-
-## Excluding sections
-
-The `DiffRequest` data object can be configured in order to include/exclude one ore more Feature section(s), available are:
-
- * `bundles`
- * `configurations`
- * `extensions`
- * `framework-properties`
-
-Users can simply add via the include/exclude methods the section(s) they are interested:
-
-```java
-DiffRequest diffRequest = new DiffRequest()
- .setPrevious(previous)
- .setCurrent(current)
- .addIncludeComparator("bundles")
- .addIncludeComparator("configurations")
- .setResultId("org.apache.sling:org.apache.sling.diff:1.0.0");
-
-Feature featureDiff = compareFeatures(previous, current);
-```
diff --git a/feature-diff/pom.xml b/feature-diff/pom.xml
deleted file mode 100644
index 8ea030d..0000000
--- a/feature-diff/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with this
- work for additional information regarding copyright ownership. The ASF
- licenses this file to You under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- License for the specific language governing permissions and limitations under
- the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling-bundle-parent</artifactId>
- <version>35</version>
- <relativePath />
- </parent>
-
- <artifactId>org.apache.sling.feature.diff</artifactId>
- <version>0.0.1-SNAPSHOT</version>
-
- <name>Apache Sling Feature Model diff tool</name>
- <description>Feature Model diff tool for Apache Sling</description>
-
- <properties>
- <sling.java.version>8</sling.java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <bnd.baseline.skip>true</bnd.baseline.skip>
- </properties>
-
- <dependencies>
- <!--
- | utilities
- -->
- <dependency>
- <groupId>com.google.auto.service</groupId>
- <artifactId>auto-service</artifactId>
- <version>1.0-rc5</version>
- <scope>provided</scope>
- </dependency>
-
- <!--
- | Sling Feature Model libraries
- -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation.versioning</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature</artifactId>
- <version>1.0.4</version>
- <scope>provided</scope>
- </dependency>
-
- <!--
- | JSON patch
- -->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- <version>1.0-alpha-1</version>
- <scope>provided</scope>
- </dependency>
-
- <!--
- | Test only dependencies
- -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java
deleted file mode 100644
index 772b986..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/DiffRequest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.feature.diff;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.sling.feature.Feature;
-
-public final class DiffRequest {
-
- private final Set<String> includeComparators = new HashSet<>();
-
- private final Set<String> excludeComparators = new HashSet<>();
-
- private Feature previous;
-
- private Feature current;
-
- public Feature getPrevious() {
- return previous;
- }
-
- public DiffRequest setPrevious(Feature previous) {
- this.previous = requireNonNull(previous, "Impossible to compare null previous feature.");
- return this;
- }
-
- public Feature getCurrent() {
- return current;
- }
-
- public DiffRequest setCurrent(Feature current) {
- this.current = requireNonNull(current, "Impossible to compare null current feature.");
- return this;
- }
-
- public DiffRequest addIncludeComparator(String includeComparator) {
- includeComparators.add(requireNonNull(includeComparator, "A null include comparator id is not valid"));
- return this;
- }
-
- public Set<String> getIncludeComparators() {
- return includeComparators;
- }
-
- public DiffRequest addExcludeComparator(String excludeComparator) {
- excludeComparators.add(requireNonNull(excludeComparator, "A null exclude comparator id is not valid"));
- return this;
- }
-
- public Set<String> getExcludeComparators() {
- return excludeComparators;
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
deleted file mode 100644
index f1ccb3b..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.feature.diff;
-
-import static java.util.Objects.requireNonNull;
-import static java.util.ServiceLoader.load;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.Prototype;
-import org.apache.sling.feature.diff.impl.FeatureElementComparator;
-
-public final class FeatureDiff {
-
- private static final String UPDATER_CLASSIFIER = "updater";
-
- public static Feature compareFeatures(DiffRequest diffRequest) {
- requireNonNull(diffRequest, "Impossible to compare features without specifying them.");
- Feature previous = requireNonNull(diffRequest.getPrevious(), "Impossible to compare null previous feature.");
- Feature current = requireNonNull(diffRequest.getCurrent(), "Impossible to compare null current feature.");
-
- if (previous.getId().equals(current.getId())) {
- throw new IllegalArgumentException("Input Features refer to the the same Feature version.");
- }
-
- StringBuilder classifier = new StringBuilder();
- if (current.getId().getClassifier() != null && !current.getId().getClassifier().isEmpty()) {
- classifier.append(current.getId().getClassifier())
- .append('_');
- }
- classifier.append(UPDATER_CLASSIFIER);
-
- ArtifactId resultId = new ArtifactId(current.getId().getGroupId(),
- current.getId().getArtifactId(),
- current.getId().getVersion(),
- classifier.toString(),
- current.getId().getType());
-
- Feature target = new Feature(resultId);
- target.setTitle(previous.getId() + " to " + current.getId());
- target.setDescription("Computed " + previous.getId() + " to " + current.getId() + " Feature update");
-
- Prototype prototype = new Prototype(previous.getId());
- target.setPrototype(prototype);
-
- for (FeatureElementComparator comparator : loadComparators(diffRequest)) {
- comparator.computeDiff(previous, current, target);
- }
-
- return target;
- }
-
- protected static Iterable<FeatureElementComparator> loadComparators(DiffRequest diffRequest) {
- Collection<FeatureElementComparator> filteredComparators = new LinkedList<>();
-
- for (FeatureElementComparator comparator : load(FeatureElementComparator.class)) {
- boolean included = !diffRequest.getIncludeComparators().isEmpty() ? diffRequest.getIncludeComparators().contains(comparator.getId()) : true;
- boolean excluded = diffRequest.getExcludeComparators().contains(comparator.getId());
-
- if (included && !excluded) {
- filteredComparators.add(comparator);
- }
- }
-
- return filteredComparators;
- }
-
- /**
- * this class must not be instantiated directly
- */
- private FeatureDiff() {
- // do nothing
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/AbstractFeatureElementComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/AbstractFeatureElementComparator.java
deleted file mode 100644
index 33364f2..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/AbstractFeatureElementComparator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-abstract class AbstractFeatureElementComparator implements FeatureElementComparator {
-
- private final String id;
-
- public AbstractFeatureElementComparator(String id) {
- this.id = id;
- }
-
- @Override
- public final String getId() {
- return id;
- }
-
- @Override
- public String toString() {
- return "FeatureElementComparator [id=" + id + "]";
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/BundlesComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/BundlesComparator.java
deleted file mode 100644
index e225a11..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/BundlesComparator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.Artifacts;
-import org.apache.sling.feature.Feature;
-
-import com.google.auto.service.AutoService;
-
-@AutoService(FeatureElementComparator.class)
-public final class BundlesComparator extends AbstractFeatureElementComparator {
-
- public BundlesComparator() {
- super("bundles");
- }
-
- @Override
- public void computeDiff(Feature previous, Feature current, Feature target) {
- computeDiff(previous.getBundles(), current.getBundles(), target);
- }
-
- protected void computeDiff(Artifacts previouses, Artifacts currents, Feature target) {
- for (Artifact previous : previouses) {
- Artifact current = currents.getSame(previous.getId());
-
- boolean add = false;
-
- if (current == null || (add = !previous.getId().equals(current.getId()))) {
- target.getPrototype().getBundleRemovals().add(previous.getId());
- }
-
- if (add) {
- target.getBundles().add(current);
- }
- }
-
- for (Artifact current : currents) {
- Artifact previous = previouses.getSame(current.getId());
-
- if (previous == null) {
- target.getBundles().add(current);
- }
- }
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ConfigurationsComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ConfigurationsComparator.java
deleted file mode 100644
index e4190fc..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ConfigurationsComparator.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import static java.util.Objects.deepEquals;
-
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Configurations;
-import org.apache.sling.feature.Feature;
-
-import com.google.auto.service.AutoService;
-
-@AutoService(FeatureElementComparator.class)
-public final class ConfigurationsComparator extends AbstractFeatureElementComparator {
-
- public ConfigurationsComparator() {
- super("configurations");
- }
-
- @Override
- public void computeDiff(Feature previous, Feature current, Feature target) {
- computeDiff(previous.getConfigurations(), current.getConfigurations(), target);
- }
-
- protected void computeDiff(Configurations previouses, Configurations currents, Feature target) {
- for (Configuration previousConfiguration : previouses) {
- Configuration currentConfiguration = currents.getConfiguration(previousConfiguration.getPid());
-
- if (currentConfiguration == null) {
- target.getPrototype().getConfigurationRemovals().add(previousConfiguration.getPid());
- } else {
- computeDiff(previousConfiguration, currentConfiguration, target);
- }
- }
-
- for (Configuration currentConfiguration : currents) {
- Configuration previousConfiguration = previouses.getConfiguration(currentConfiguration.getPid());
-
- if (previousConfiguration == null) {
- target.getConfigurations().add(currentConfiguration);
- }
- }
- }
-
- protected void computeDiff(Configuration previous, Configuration current, Feature target) {
- Dictionary<String, Object> previousProperties = previous.getProperties();
- Dictionary<String, Object> currentProperties = current.getProperties();
-
- Configuration targetConfiguration = new Configuration(previous.getPid());
- Dictionary<String, Object> targetProperties = targetConfiguration.getProperties();
-
- Enumeration<String> previousKeys = previousProperties.keys();
- while (previousKeys.hasMoreElements()) {
- String previousKey = previousKeys.nextElement();
-
- // no other way to check if a key was removed in a dictionary
- if (hasKey(previousKey, currentProperties.keys())) {
- Object previousValue = previousProperties.get(previousKey);
- Object currentValue = currentProperties.get(previousKey);
-
- if (!areEquals(previousValue, currentValue)) {
- targetProperties.put(previousKey, currentValue);
- }
- }
- }
-
- Enumeration<String> currentKeys = currentProperties.keys();
- while (currentKeys.hasMoreElements()) {
- String currentKey = currentKeys.nextElement();
-
- Object previousValue = previousProperties.get(currentKey);
- Object currentValue = currentProperties.get(currentKey);
-
- if (previousValue == null && currentValue != null) {
- targetProperties.put(currentKey, currentValue);
- }
- }
-
- if (!targetProperties.isEmpty()) {
- target.getConfigurations().add(targetConfiguration);
- }
- }
-
- private static boolean areEquals(Object lhs, Object rhs) {
- if (lhs == rhs) {
- return true;
- }
-
- if (lhs == null ^ rhs == null) {
- return false;
- }
-
- // Find the leaf class since there may be transients in the leaf
- // class or in classes between the leaf and root.
- // If we are not testing transients or a subclass has no ivars,
- // then a subclass can test equals to a superclass.
- final Class<?> lhsClass = lhs.getClass();
- final Class<?> rhsClass = rhs.getClass();
- Class<?> testClass;
-
- if (lhsClass.isInstance(rhs)) {
- testClass = lhsClass;
- if (!rhsClass.isInstance(lhs)) {
- // rhsClass is a subclass of lhsClass
- testClass = rhsClass;
- }
- } else if (rhsClass.isInstance(lhs)) {
- testClass = rhsClass;
- if (!lhsClass.isInstance(rhs)) {
- // lhsClass is a subclass of rhsClass
- testClass = lhsClass;
- }
- } else {
- // The two classes are not related.
- return false;
- }
-
- if (testClass.isArray()) {
- return deepEquals(lhs, rhs);
- } else if (Collection.class.isAssignableFrom(testClass)) {
- return areEquals((Collection<?>) lhs, (Collection<?>) rhs);
- } else if (Map.class.isAssignableFrom(testClass)) {
- return areEquals((Map<?, ?>) lhs, (Map<?, ?>) rhs);
- }
-
- return Objects.equals(lhs, rhs);
- }
-
- private static boolean areEquals(Collection<?> lhs, Collection<?> rhs) {
- if (lhs.size() != rhs.size()) {
- return false;
- }
-
- return deepEquals(lhs.toArray(), rhs.toArray());
- }
-
- private static boolean areEquals(Map<?, ?> lhs, Map<?, ?> rhs) {
- for (Entry<?, ?> previousEntry : lhs.entrySet()) {
- Object previousKey = previousEntry.getKey();
-
- if (!rhs.containsKey(previousKey)) {
- return false;
- } else {
- Object previousValue = previousEntry.getValue();
- Object currentValue = rhs.get(previousKey);
-
- if (!areEquals(previousValue, currentValue)) {
- return false;
- }
- }
- }
-
- for (Object currentKey : rhs.keySet()) {
- if (!lhs.containsKey(currentKey)) {
- return false;
- }
- }
-
- return true;
- }
-
- private static boolean hasKey(String key, Enumeration<String> keys) {
- while (keys.hasMoreElements()) {
- String current = keys.nextElement();
-
- if (key.equals(current)) {
- return true;
- }
- }
-
- return false;
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
deleted file mode 100644
index b30cfe0..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import static javax.json.Json.createReader;
-
-import java.io.StringReader;
-import java.util.LinkedList;
-
-import javax.json.JsonValue;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Extensions;
-import org.apache.sling.feature.Feature;
-
-import com.google.auto.service.AutoService;
-
-@AutoService(FeatureElementComparator.class)
-public final class ExtensionsComparator extends AbstractFeatureElementComparator {
-
- public ExtensionsComparator() {
- super("extensions");
- }
-
- @Override
- public void computeDiff(Feature previous, Feature current, Feature target) {
- computeDiff(previous.getExtensions(), current.getExtensions(), target);
- }
-
- protected void computeDiff(Extensions previousExtensions, Extensions currentExtensions, Feature target) {
- for (Extension previousExtension : previousExtensions) {
- Extension currentExtension = currentExtensions.getByName(previousExtension.getName());
-
- if (currentExtension == null) {
- target.getPrototype().getExtensionRemovals().add(previousExtension.getName());
- } else {
- computeDiff(previousExtension, currentExtension, target);
- }
- }
-
- for (Extension currentExtension : currentExtensions) {
- Extension previousConfiguration = previousExtensions.getByName(currentExtension.getName());
-
- if (previousConfiguration == null) {
- target.getExtensions().add(currentExtension);
- }
- }
- }
-
- protected void computeDiff(Extension previousExtension, Extension currentExtension, Feature target) {
- boolean replace = false;
-
- switch (previousExtension.getType()) {
- case ARTIFACTS:
- Extension targetExtension = new Extension(previousExtension.getType(), previousExtension.getName(), previousExtension.isRequired());
-
- for (Artifact previous : previousExtension.getArtifacts()) {
- Artifact current = currentExtension.getArtifacts().getSame(previous.getId());
-
- boolean add = false;
-
- if (current == null || (add = !previous.getId().equals(current.getId()))) {
- target.getPrototype().getArtifactExtensionRemovals()
- .computeIfAbsent(previousExtension.getName(), k -> new LinkedList<ArtifactId>())
- .add(previous.getId());
- }
-
- if (add) {
- targetExtension.getArtifacts().add(current);
- }
- }
-
- for (Artifact current : currentExtension.getArtifacts()) {
- Artifact previous = previousExtension.getArtifacts().getSame(current.getId());
-
- if (previous == null) {
- targetExtension.getArtifacts().add(current);
- }
- }
-
- if (!targetExtension.getArtifacts().isEmpty()) {
- target.getExtensions().add(targetExtension);
- }
-
- break;
-
- case TEXT:
- if (!previousExtension.getText().equals(currentExtension.getText())) {
- replace = true;
- }
- break;
-
- case JSON:
- String previousJSON = previousExtension.getJSON();
- String currentJSON = currentExtension.getJSON();
-
- try {
- JsonValue previousNode = parseJSON(previousJSON);
- JsonValue currentNode = parseJSON(currentJSON);
-
- if (!previousNode.equals(currentNode)) {
- replace = true;
- }
- } catch (Throwable t) {
- // should not happen
- throw new RuntimeException("A JSON parse error occurred while parsing previous '"
- + previousJSON
- + "' and current '"
- + currentJSON
- + "', see nested errors:", t);
- }
- break;
-
- // it doesn't happen
- default:
- break;
- }
-
- if (replace) {
- target.getPrototype().getExtensionRemovals().add(currentExtension.getName());
- target.getExtensions().add(currentExtension);
- }
- }
-
- private static JsonValue parseJSON(String json) {
- return createReader(new StringReader(json)).read();
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/FeatureElementComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/FeatureElementComparator.java
deleted file mode 100644
index 9b3c1cc..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/FeatureElementComparator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import org.apache.sling.feature.Feature;
-
-/**
- * A simple service to compare a specific Feature section.
- */
-public interface FeatureElementComparator {
-
- /**
- * Returns a short id which identifies the Feature section for which differences will be computed.
- *
- * @return a short id which identifies the Feature section for which differences will be computed.
- */
- String getId();
-
- /**
- * Compares a specific Feature sections between the previous and the current,
- * reporting additions/updates/removals in the target.
- *
- * @param previous
- * @param current
- * @param target
- */
- public void computeDiff(Feature previous, Feature current, Feature target);
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/FrameworkPropertiesComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/FrameworkPropertiesComparator.java
deleted file mode 100644
index 0dd5f4e..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/impl/FrameworkPropertiesComparator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-
-import org.apache.sling.feature.Feature;
-
-import com.google.auto.service.AutoService;
-
-@AutoService(FeatureElementComparator.class)
-public final class FrameworkPropertiesComparator extends AbstractFeatureElementComparator {
-
- public FrameworkPropertiesComparator() {
- super("framework-properties");
- }
-
- @Override
- public void computeDiff(Feature previous, Feature current, Feature target) {
- computeDiff(previous.getFrameworkProperties(), current.getFrameworkProperties(), target);
- }
-
- public void computeDiff(Map<String, String> previous, Map<String, String> current, Feature target) {
- for (Entry<String, String> previousEntry : previous.entrySet()) {
- String previousKey = previousEntry.getKey();
-
- if (!current.containsKey(previousKey)) {
- target.getPrototype().getFrameworkPropertiesRemovals().add(previousKey);
- } else {
- String previousValue = previousEntry.getValue();
- String currentValue = current.get(previousKey);
-
- // override the previous set value
- if (!Objects.equals(previousValue, currentValue)) {
- target.getFrameworkProperties().put(previousKey, currentValue);
- }
- }
- }
-
- for (Entry<String, String> currentEntry : current.entrySet()) {
- if (!previous.containsKey(currentEntry.getKey())) {
- target.getFrameworkProperties().put(currentEntry.getKey(), currentEntry.getValue());
- }
- }
- }
-
-}
diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/package-info.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/package-info.java
deleted file mode 100644
index 8a67aff..0000000
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Core APIs to compare different Apache Sling Feature models.
- */
-@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.feature.diff;
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/FeatureDiffTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/FeatureDiffTest.java
deleted file mode 100644
index 7a16d22..0000000
--- a/feature-diff/src/test/java/org/apache/sling/feature/diff/FeatureDiffTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.feature.diff;
-
-import static org.apache.sling.feature.diff.FeatureDiff.loadComparators;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.sling.feature.diff.impl.FeatureElementComparator;
-import org.junit.Test;
-
-public final class FeatureDiffTest {
-
- @Test
- public void loadAllComparators() {
- Set<String> comparators = filterComparators(new DiffRequest());
-
- assertTrue(comparators.isEmpty());
- }
-
- @Test
- public void loadIncludedComparators() {
- Set<String> comparators = filterComparators(new DiffRequest()
- .addIncludeComparator("bundles")
- .addIncludeComparator("configurations"));
-
- assertFalse(comparators.isEmpty());
- assertFalse(comparators.contains("bundles"));
- assertFalse(comparators.contains("configurations"));
- assertTrue(comparators.contains("extensions"));
- assertTrue(comparators.contains("framework-properties"));
- }
-
- @Test
- public void loadExcludedComparators() {
- Set<String> comparators = filterComparators(new DiffRequest()
- .addExcludeComparator("bundles")
- .addExcludeComparator("configurations"));
-
- assertFalse(comparators.isEmpty());
- assertTrue(comparators.contains("bundles"));
- assertTrue(comparators.contains("configurations"));
- assertFalse(comparators.contains("extensions"));
- assertFalse(comparators.contains("framework-properties"));
- }
-
- private Set<String> filterComparators(DiffRequest diffRequest) {
- Set<String> comparators = new HashSet<>();
- comparators.add("bundles");
- comparators.add("configurations");
- comparators.add("extensions");
- comparators.add("framework-properties");
-
- for (FeatureElementComparator comparator : loadComparators(diffRequest)) {
- comparators.remove(comparator.getId());
- }
-
- return comparators;
- }
-
-}
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/AbstractComparatorTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/AbstractComparatorTest.java
deleted file mode 100644
index e68dfbe..0000000
--- a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/AbstractComparatorTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.Prototype;
-import org.junit.After;
-import org.junit.Before;
-
-public abstract class AbstractComparatorTest<C extends FeatureElementComparator> {
-
- protected Feature targetFeature;
-
- protected C comparator;
-
- @Before
- public void setUp() {
- targetFeature = new Feature(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.difftool:1.0"));
- targetFeature.setPrototype(new Prototype(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.difftoolproto:1.0")));
- comparator = newComparatorInstance();
- }
-
- @After
- public void tearDown() {
- targetFeature = null;
- comparator = null;
- }
-
- protected abstract C newComparatorInstance();
-
-}
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/BundlesComparatorTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/BundlesComparatorTest.java
deleted file mode 100644
index 0d60724..0000000
--- a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/BundlesComparatorTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Artifacts;
-import org.apache.sling.feature.diff.impl.BundlesComparator;
-import org.junit.Test;
-
-public class BundlesComparatorTest extends AbstractComparatorTest<BundlesComparator> {
-
- @Override
- protected BundlesComparator newComparatorInstance() {
- return new BundlesComparator();
- }
-
- @Test
- public void checkRemoved() {
- Artifacts previousArtifacts = new Artifacts();
- Artifact previousArtifact = new Artifact(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.diff:1.0.0"));
- previousArtifacts.add(previousArtifact);
-
- Artifacts currentArtifacts = new Artifacts();
-
- comparator.computeDiff(previousArtifacts, currentArtifacts, targetFeature);
-
- assertFalse(targetFeature.getPrototype().getBundleRemovals().isEmpty());
- assertEquals(previousArtifact.getId(), targetFeature.getPrototype().getBundleRemovals().iterator().next());
- }
-
- @Test
- public void checkAdded() {
- Artifacts previousArtifacts = new Artifacts();
-
- Artifacts currentArtifacts = new Artifacts();
- Artifact currentArtifact = new Artifact(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.diff:1.0.0"));
- currentArtifacts.add(currentArtifact);
-
- comparator.computeDiff(previousArtifacts, currentArtifacts, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getBundleRemovals().isEmpty());
- assertEquals(currentArtifact.getId(), targetFeature.getBundles().iterator().next().getId());
- }
-
- @Test
- public void checkUpdated() {
- Artifacts previousArtifacts = new Artifacts();
- Artifact previousArtifact = new Artifact(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.diff:0.0.1"));
- previousArtifacts.add(previousArtifact);
-
- Artifacts currentArtifacts = new Artifacts();
- Artifact currentArtifact = new Artifact(ArtifactId.fromMvnId("org.apache.sling:org.apache.sling.feature.diff:1.0.0"));
- currentArtifacts.add(currentArtifact);
-
- comparator.computeDiff(previousArtifacts, currentArtifacts, targetFeature);
-
- assertFalse(targetFeature.getPrototype().getBundleRemovals().isEmpty());
- assertEquals(previousArtifact.getId(), targetFeature.getPrototype().getBundleRemovals().iterator().next());
-
- assertFalse(targetFeature.getBundles().isEmpty());
- assertEquals(currentArtifact.getId(), targetFeature.getBundles().iterator().next().getId());
- }
-
-}
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/ConfigurationsComparatorTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/ConfigurationsComparatorTest.java
deleted file mode 100644
index 1e333fc..0000000
--- a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/ConfigurationsComparatorTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Dictionary;
-
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Configurations;
-import org.apache.sling.feature.diff.impl.ConfigurationsComparator;
-import org.junit.Test;
-
-public class ConfigurationsComparatorTest extends AbstractComparatorTest<ConfigurationsComparator> {
-
- @Override
- protected ConfigurationsComparator newComparatorInstance() {
- return new ConfigurationsComparator();
- }
-
- @Test
- public void checkRemoved() {
- Configuration previousConfiguration = new Configuration("org.apache.sling.feature.diff.config");
- Configurations previousConfigurations = new Configurations();
- previousConfigurations.add(previousConfiguration);
-
- Configurations currentConfigurations = new Configurations();
-
- comparator.computeDiff(previousConfigurations, currentConfigurations, targetFeature);
-
- assertFalse(targetFeature.getPrototype().getConfigurationRemovals().isEmpty());
- assertEquals(previousConfiguration.getPid(), targetFeature.getPrototype().getConfigurationRemovals().iterator().next());
- assertTrue(targetFeature.getConfigurations().isEmpty());
- }
-
- @Test
- public void checkAdded() {
- Configurations previousConfigurations = new Configurations();
-
- Configuration currentConfiguration = new Configuration("org.apache.sling.feature.diff.config");
- Configurations currentConfigurations = new Configurations();
- currentConfigurations.add(currentConfiguration);
-
- comparator.computeDiff(previousConfigurations, currentConfigurations, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getConfigurationRemovals().isEmpty());
- assertFalse(targetFeature.getConfigurations().isEmpty());
-
- assertEquals(currentConfiguration.getPid(), targetFeature.getConfigurations().iterator().next().getPid());
- }
-
- @Test
- public void checkUpdated() {
- Configuration previousConfiguration = new Configuration("org.apache.sling.feature.diff.config");
- previousConfiguration.getProperties().put("removed", 123);
- previousConfiguration.getProperties().put("updated", new String[] { "/log" });
-
- Configurations previousConfigurations = new Configurations();
- previousConfigurations.add(previousConfiguration);
-
- Configuration currentConfiguration = new Configuration("org.apache.sling.feature.diff.config");
- currentConfiguration.getProperties().put("updated", new String[] { "/log", "/etc" });
- currentConfiguration.getProperties().put("added", true);
-
- Configurations currentConfigurations = new Configurations();
- currentConfigurations.add(currentConfiguration);
-
- comparator.computeDiff(previousConfigurations, currentConfigurations, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getConfigurationRemovals().isEmpty());
- assertFalse(targetFeature.getConfigurations().isEmpty());
-
- assertEquals(currentConfiguration.getPid(), targetFeature.getConfigurations().iterator().next().getPid());
- Dictionary<String, Object> properties = targetFeature.getConfigurations().iterator().next().getProperties();
-
- assertTrue((boolean) properties.get("added"));
- assertArrayEquals(new String[] { "/log", "/etc" }, (String[]) properties.get("updated"));
- }
-
-}
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java
deleted file mode 100644
index 4c2c81f..0000000
--- a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import static org.apache.sling.feature.ExtensionType.ARTIFACTS;
-import static org.apache.sling.feature.ExtensionType.JSON;
-import static org.apache.sling.feature.ExtensionType.TEXT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Extensions;
-import org.junit.Test;
-
-public class ExtensionsComparatorTest extends AbstractComparatorTest<ExtensionsComparator> {
-
- @Override
- protected ExtensionsComparator newComparatorInstance() {
- return new ExtensionsComparator();
- }
-
- @Test
- public void checkTextExtensionRemoved() {
- Extension removed = new Extension(TEXT, "removed-TEXT-extension", true);
- removed.setText("This is just a test");
- checkRemovedExtension(removed);
- }
-
- @Test
- public void checkJSONExtensionRemoved() {
- Extension removed = new Extension(JSON, "removed-JSON-extension", true);
- removed.setJSON("[true, 100, null]");
- checkRemovedExtension(removed);
- }
-
- @Test
- public void checkArtifactsExtensionRemoved() {
- Extension removed = new Extension(ARTIFACTS, "removed-ARTIFACTS-extension", true);
- removed.getArtifacts().add(new Artifact(ArtifactId.parse("org.apache.sling:org.apache.sling.diff:1.0.0")));
- checkRemovedExtension(removed);
- }
-
- private void checkRemovedExtension(Extension removedExtension) {
- Extensions previous = new Extensions();
- previous.add(removedExtension);
-
- Extensions current = new Extensions();
-
- comparator.computeDiff(previous, current, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getExtensionRemovals().contains(removedExtension.getName()));
- }
-
- @Test
- public void checkRemovedArtifacts() {
- Extension previousExtension = new Extension(ARTIFACTS, "content-packages", true);
- ArtifactId removedId = ArtifactId.parse("org.apache.sling:org.apache.sling.diff:1.0.0");
- previousExtension.getArtifacts().add(new Artifact(removedId));
-
- Extension currentExtension = new Extension(ARTIFACTS, "content-packages", true);
-
- comparator.computeDiff(previousExtension, currentExtension, targetFeature);
-
- Map<String, List<ArtifactId>> artifactExtensionRemovals = targetFeature.getPrototype().getArtifactExtensionRemovals();
- assertFalse(artifactExtensionRemovals.isEmpty());
- assertTrue(artifactExtensionRemovals.containsKey("content-packages"));
- assertTrue(artifactExtensionRemovals.get("content-packages").contains(removedId));
- }
-
- @Test
- public void checkTextExtensionUpdated() {
- Extension previous = new Extension(TEXT, "repoinit", true);
- previous.setText("create path /content/example.com(mixin mix:referenceable)");
-
- Extension current = new Extension(TEXT, "repoinit", true);
- current.setText("create path /content/example.com(mixin mix:referenceable)\ncreate path (nt:unstructured) /var");
- comparator.computeDiff(previous, current, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getExtensionRemovals().contains(current.getName()));
- assertEquals(current.getText(), targetFeature.getExtensions().getByName(current.getName()).getText());
- }
-
- @Test
- public void checkJSONExtensionUpdated() {
- Extension previous = new Extension(JSON, "api-regions", true);
- previous.setJSON("{\"name\": \"global\"}");
-
- Extension current = new Extension(JSON, "api-regions", true);
- current.setJSON("{\"name\": \"deprecated\"}");
- comparator.computeDiff(previous, current, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getExtensionRemovals().contains(current.getName()));
- assertEquals(current.getJSON(), targetFeature.getExtensions().getByName(current.getName()).getJSON());
- }
-
- @Test
- public void checkArtifactsExtensionUpdated() {
- Extension previous = new Extension(ARTIFACTS, "content-packages", true);
- ArtifactId removedId = ArtifactId.parse("org.apache.sling:org.apache.sling.diff:1.0.0");
- previous.getArtifacts().add(new Artifact(removedId));
-
- Extension current = new Extension(ARTIFACTS, "content-packages", true);
- ArtifactId updatedId = ArtifactId.parse("org.apache.sling:org.apache.sling.diff:2.0.0");
- current.getArtifacts().add(new Artifact(updatedId));
-
- comparator.computeDiff(previous, current, targetFeature);
-
- Map<String, List<ArtifactId>> artifactExtensionRemovals = targetFeature.getPrototype().getArtifactExtensionRemovals();
- assertTrue(artifactExtensionRemovals.get("content-packages").contains(removedId));
- assertTrue(targetFeature.getExtensions().getByName(current.getName()).getArtifacts().contains(current.getArtifacts().iterator().next()));
- }
-
-}
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/FrameworkPropertiesComparatorTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/FrameworkPropertiesComparatorTest.java
deleted file mode 100644
index 9c4122f..0000000
--- a/feature-diff/src/test/java/org/apache/sling/feature/diff/impl/FrameworkPropertiesComparatorTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.feature.diff.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.sling.feature.diff.impl.FrameworkPropertiesComparator;
-import org.junit.Test;
-
-public class FrameworkPropertiesComparatorTest extends AbstractComparatorTest<FrameworkPropertiesComparator> {
-
- @Override
- protected FrameworkPropertiesComparator newComparatorInstance() {
- return new FrameworkPropertiesComparator();
- }
-
- @Test
- public void checkRemoved() {
- Map<String, String> previous = new HashMap<>();
- previous.put("removed", "removed entry");
-
- Map<String, String> current = new HashMap<>();
-
- comparator.computeDiff(previous, current, targetFeature);
-
- assertFalse(targetFeature.getPrototype().getFrameworkPropertiesRemovals().isEmpty());
- assertFalse(targetFeature.getFrameworkProperties().containsKey("removed"));
- }
-
- @Test
- public void checkAdded() {
- Map<String, String> previous = new HashMap<>();
-
- Map<String, String> current = new HashMap<>();
- current.put("added", "added entry");
-
- comparator.computeDiff(previous, current, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getFrameworkPropertiesRemovals().isEmpty());
- assertFalse(targetFeature.getFrameworkProperties().isEmpty());
- assertTrue(targetFeature.getFrameworkProperties().containsKey("added"));
- }
-
- @Test
- public void checkUpdated() {
- Map<String, String> previous = new HashMap<>();
- previous.put("updated", "regular entry");
-
- Map<String, String> current = new HashMap<>();
- current.put("updated", "updated entry");
-
- comparator.computeDiff(previous, current, targetFeature);
-
- assertTrue(targetFeature.getPrototype().getFrameworkPropertiesRemovals().isEmpty());
- assertFalse(targetFeature.getFrameworkProperties().isEmpty());
- assertTrue(targetFeature.getFrameworkProperties().containsKey("updated"));
- assertEquals("updated entry", targetFeature.getFrameworkProperties().get("updated"));
- }
-
-}
diff --git a/runtime2feature/CODE_OF_CONDUCT.md b/runtime2feature/CODE_OF_CONDUCT.md
deleted file mode 100644
index 0fa18e5..0000000
--- a/runtime2feature/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Apache Software Foundation Code of Conduct
-====
-
-Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/runtime2feature/CONTRIBUTING.md b/runtime2feature/CONTRIBUTING.md
deleted file mode 100644
index ac82a1a..0000000
--- a/runtime2feature/CONTRIBUTING.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Contributing
-====
-
-Thanks for choosing to contribute!
-
-You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/runtime2feature/LICENSE b/runtime2feature/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/runtime2feature/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
diff --git a/runtime2feature/README.md b/runtime2feature/README.md
deleted file mode 100644
index 9568bef..0000000
--- a/runtime2feature/README.md
+++ /dev/null
@@ -1,66 +0,0 @@
-[<img src="http://sling.apache.org/res/logos/sling.png"/>](http://sling.apache.org)
-
-# Apache Sling OSGi runtime environment to Feature Model generator
-
-## Running Feature
-
-This is a simple OSGi service which is able to convert, given a `BundleContext` instance, a currently running OSGi container to an Apache Sling Feature Model definition.
-
-APIs are really simple: it is necessary first to obtain the `RuntimeEnvironment2FeatureModel` instance from the OSGi Service Registry, then
-
-```java
-import org.apache.sling.feature.r2f.*;
-
-@Reference
-RuntimeEnvironment2FeatureModel generator;
-
-...
-Feature runtimeFeature = generator.getRunningFeature();
-```
-
-## Please Note
-
-Currently version will include in the generated Feature Model `bundles` and `configurations` only, which are the only informations that can be extracted from a `BundleContext` instance.
-
-## Launch Feature
-
-The `RuntimeEnvironment2FeatureModel` OSGi service is also able to retrieve the (assembled) Feature used to launch the platform:
-
-```java
-import org.apache.sling.feature.r2f.*;
-
-@Reference
-RuntimeEnvironment2FeatureModel generator;
-
-...
-Feature launchFeature = generator.getLaunchFeature();
-```
-
-## Upgrade Feature
-
-The `RuntimeEnvironment2FeatureModel` OSGi service is also able to compute the upgrade Feature which prototypes from the Feature used to launch the platform and that targets the runtime Feature:
-
-```java
-import org.apache.sling.feature.r2f.*;
-
-@Reference
-RuntimeEnvironment2FeatureModel generator;
-
-...
-Feature launchFeature = generator.getLaunch2RuntimeUpgradingFeature();
-```
-
-## The effective Runtime Feature
-
-Finally, the `RuntimeEnvironment2FeatureModel` OSGi service is also able to compute the real runtime Feature which is assembled from the Feature used to launch the platform and that targets the runtime Feature:
-
-```java
-import org.apache.sling.feature.r2f.*;
-
-@Reference
-RuntimeEnvironment2FeatureModel generator;
-
-...
-Feature launchFeature = generator.getLaunch2RuntimeUpgradingFeature();
-```
-
diff --git a/runtime2feature/pom.xml b/runtime2feature/pom.xml
deleted file mode 100644
index d1ece0f..0000000
--- a/runtime2feature/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with this
- work for additional information regarding copyright ownership. The ASF
- licenses this file to You under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- License for the specific language governing permissions and limitations under
- the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling-bundle-parent</artifactId>
- <version>35</version>
- <relativePath />
- </parent>
-
- <artifactId>org.apache.sling.feature.r2f</artifactId>
- <version>0.0.1-SNAPSHOT</version>
-
- <name>Apache Sling Feature Model runtime creator</name>
- <description>Feature Model runtime creator tool for Apache Sling</description>
-
- <properties>
- <sling.java.version>8</sling.java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <bnd.baseline.skip>true</bnd.baseline.skip>
- </properties>
-
- <dependencies>
- <!--
- | core OSGi APIs
- -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>5.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation.versioning</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component.annotations</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!--
- | Apache Sling Feature APIs
- -->
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature</artifactId>
- <version>1.0.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature.io</artifactId>
- <version>1.0.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature.diff</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
-
- <!--
- | Test only dependencies
- -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java
deleted file mode 100644
index 9c52006..0000000
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.feature.r2f;
-
-import org.apache.sling.feature.Feature;
-
-public interface RuntimeEnvironment2FeatureModel {
-
- Feature getLaunchFeature();
-
- Feature getRunningFeature();
-
- Feature getLaunch2RunningUpgradingFeature();
-
- Feature getRuntimeFeature();
-
-}
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/AbstractFeatureElementConsumer.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/AbstractFeatureElementConsumer.java
deleted file mode 100644
index f557a8b..0000000
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/AbstractFeatureElementConsumer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.feature.r2f.impl;
-
-import java.util.function.Consumer;
-
-import org.apache.sling.feature.Feature;
-
-abstract class AbstractFeatureElementConsumer<T> implements Consumer<T> {
-
- private final Feature targetFeature;
-
- public AbstractFeatureElementConsumer(Feature targetFeature) {
- this.targetFeature = targetFeature;
- }
-
- protected final Feature getTargetFeature() {
- return targetFeature;
- }
-
-}
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/Bundle2ArtifactMapper.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/Bundle2ArtifactMapper.java
deleted file mode 100644
index 26f31ed..0000000
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/Bundle2ArtifactMapper.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.feature.r2f.impl;
-
-import static org.osgi.framework.wiring.BundleWiring.LISTRESOURCES_RECURSE;
-
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Collection;
-import java.util.Properties;
-import java.util.function.Function;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Feature;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.startlevel.BundleStartLevel;
-import org.osgi.framework.wiring.BundleWiring;
-
-final class Bundle2ArtifactMapper extends AbstractFeatureElementConsumer<Artifact> implements Function<Bundle, Artifact> {
-
- private static final String MAVEN_METADATA_PATH = "/META-INF/maven";
-
- private static final String POM_PROPERTIES_RESOURCE_NAME = "pom.properties";
-
- private static final String GROUP_ID = "groupId";
-
- private static final String ARTIFACT_ID = "artifactId";
-
- private static final String VERSION = "version";
-
- private static final String CLASSIFIER = "classifier";
-
- public Bundle2ArtifactMapper(Feature targetFeature) {
- super(targetFeature);
- }
-
- @Override
- public Artifact apply(Bundle bundle) {
- Properties pomProperties = new Properties();
-
- BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
- Collection<String> pomPropertiesResources = bundleWiring.listResources(MAVEN_METADATA_PATH, POM_PROPERTIES_RESOURCE_NAME, LISTRESOURCES_RECURSE);
-
- if (pomPropertiesResources == null || pomPropertiesResources.isEmpty()) {
- return null;
- }
-
- URL pomPropertiesURL = getPomPropertiesURL(pomPropertiesResources, bundle);
- if (pomPropertiesURL == null) {
- return null;
- }
-
- try {
- URLConnection connection = pomPropertiesURL.openConnection();
- connection.connect();
-
- try (InputStream inStream = connection.getInputStream()) {
- pomProperties.load(inStream);
- }
-
- if (connection instanceof HttpURLConnection) {
- ((HttpURLConnection) connection).disconnect();
- }
- } catch (Throwable t) {
- throw new RuntimeException("An error occurred while reading "
- + pomPropertiesURL
- + " properties file from Bundle "
- + bundle.getSymbolicName(), t);
- }
-
- if (pomProperties.isEmpty()) {
- throw new RuntimeException("Bundle "
- + bundle.getSymbolicName()
- + " does not export valid Maven metadata");
- }
-
- String groupId = pomProperties.getProperty(GROUP_ID);
- String artifactId = pomProperties.getProperty(ARTIFACT_ID);
- String version = pomProperties.getProperty(VERSION);
- String classifier = pomProperties.getProperty(CLASSIFIER);
-
- Artifact artifact = new Artifact(new ArtifactId(groupId, artifactId, version, classifier, null));
-
- BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class);
- int startOrder = bundleStartLevel.getStartLevel();
- artifact.setStartOrder(startOrder);
-
- return artifact;
- }
-
- private static URL getPomPropertiesURL(Collection<String> pomPropertiesResources, Bundle bundle) {
- for (String pomPropertiesResource : pomPropertiesResources) {
- URL pomPropertiesURL = bundle.getEntry(pomPropertiesResource);
-
- if (pomPropertiesURL != null) {
- return pomPropertiesURL;
- }
- }
-
- return null;
- }
-
- @Override
- public void accept(Artifact artifact) {
- if (artifact != null) {
- getTargetFeature().getBundles().add(artifact);
- }
- }
-
-}
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/OSGiConfiguration2FeatureConfigurationMapper.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/OSGiConfiguration2FeatureConfigurationMapper.java
deleted file mode 100644
index afe8695..0000000
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/OSGiConfiguration2FeatureConfigurationMapper.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.feature.r2f.impl;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.function.Function;
-
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Feature;
-
-final class OSGiConfiguration2FeatureConfigurationMapper
- extends AbstractFeatureElementConsumer<Configuration>
- implements Function<org.osgi.service.cm.Configuration, Configuration> {
-
- public OSGiConfiguration2FeatureConfigurationMapper(Feature targetFeature) {
- super(targetFeature);
- }
-
- @Override
- public Configuration apply(org.osgi.service.cm.Configuration sourceConfiguration) {
- Configuration targetConfiguration = new Configuration(sourceConfiguration.getPid());
-
- Dictionary<String, Object> configurationProperties = sourceConfiguration.getProperties();
- Enumeration<String> keys = configurationProperties.keys();
- while (keys.hasMoreElements()) {
- String key = keys.nextElement();
- Object value = configurationProperties.get(key);
-
- targetConfiguration.getProperties().put(key, value);
- }
-
- return targetConfiguration;
- }
-
- @Override
- public void accept(Configuration configuration) {
- getTargetFeature().getConfigurations().add(configuration);
- }
-
-}
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
deleted file mode 100644
index 484aec1..0000000
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.feature.r2f.impl;
-
-import static java.nio.file.Files.newBufferedReader;
-import static org.apache.sling.feature.builder.FeatureBuilder.assemble;
-import static org.apache.sling.feature.diff.FeatureDiff.compareFeatures;
-import static org.apache.sling.feature.io.json.FeatureJSONReader.read;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.net.URI;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.stream.Stream;
-
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.Prototype;
-import org.apache.sling.feature.builder.BuilderContext;
-import org.apache.sling.feature.builder.FeatureProvider;
-import org.apache.sling.feature.diff.DiffRequest;
-import org.apache.sling.feature.r2f.RuntimeEnvironment2FeatureModel;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-
-@Component(service = RuntimeEnvironment2FeatureModel.class)
-public class RuntimeEnvironment2FeatureModelService implements RuntimeEnvironment2FeatureModel, FeatureProvider {
-
- private static final String SLING_FEATURE_PROPERTY_NAME = "sling.feature";
-
- private static final String RUNNING_CLASSIFIER = "running";
-
- private static final String RUNTIME_CLASSIFIER = "runtime";
-
- private static final String PACKAGING_FEATURE = "slingosgifeature";
-
- protected BundleContext bundleContext;
-
- private Feature launchFeature;
-
- @Activate
- public void start(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
-
- String launchFeatureLocation = bundleContext.getProperty(SLING_FEATURE_PROPERTY_NAME);
-
- if (launchFeatureLocation == null) {
- throw new IllegalStateException("Framework property 'sling.feature' is not set, impossible to assemble the launch Feature");
- }
-
- URI launchFeatureURI = URI.create(launchFeatureLocation);
- Path launchFeaturePath = Paths.get(launchFeatureURI);
-
- try (BufferedReader reader = newBufferedReader(launchFeaturePath)) {
- launchFeature = read(reader, launchFeatureLocation);
- } catch (IOException cause) {
- throw new UncheckedIOException(cause);
- }
- }
-
- @Deactivate
- public void stop() {
- bundleContext = null;
- launchFeature = null;
- }
-
- @Override
- public Feature getLaunchFeature() {
- return launchFeature;
- }
-
- @Override
- public Feature getRunningFeature() {
- Feature targetFeature = new Feature(newId(RUNNING_CLASSIFIER));
-
- // collect all bundles
-
- Bundle[] bundles = bundleContext.getBundles();
- if (bundles != null) {
- Bundle2ArtifactMapper mapper = new Bundle2ArtifactMapper(targetFeature);
-
- Stream.of(bundles).map(mapper).forEach(mapper);
- }
-
- // collect all configurations
-
- ServiceReference<ConfigurationAdmin> configurationAdminReference = bundleContext.getServiceReference(ConfigurationAdmin.class);
- if (configurationAdminReference != null) {
- ConfigurationAdmin configurationAdmin = bundleContext.getService(configurationAdminReference);
-
- if (configurationAdmin != null) {
- try {
- Configuration[] configurations = configurationAdmin.listConfigurations(null);
- if (configurations != null) {
- OSGiConfiguration2FeatureConfigurationMapper mapper = new OSGiConfiguration2FeatureConfigurationMapper(targetFeature);
-
- Stream.of(configurations).map(mapper).forEach(mapper);
- }
- } catch (Exception e) {
- // that should not happen
- throw new RuntimeException("Something went wrong while iterating over all available Configurations", e);
- }
- }
- }
-
- return targetFeature;
- }
-
- @Override
- public Feature getLaunch2RunningUpgradingFeature() {
- Feature runningFeature = getRunningFeature();
-
- // framework-properties can not be scanned in the BundleContext ATM
- // extensions can not be computed at runtime
- return compareFeatures(new DiffRequest()
- .setPrevious(launchFeature)
- .setCurrent(runningFeature)
- .addIncludeComparator("bundles")
- .addIncludeComparator("configurations"));
- }
-
- @Override
- public Feature getRuntimeFeature() {
- Feature launch2RunningUpgradingFeature = getLaunch2RunningUpgradingFeature();
- Prototype prototype = launch2RunningUpgradingFeature.getPrototype();
-
- // if there are no differences, no need to assemble the new Feature, it is a vanilla Feature
-
- if (launch2RunningUpgradingFeature.getBundles().isEmpty()
- && launch2RunningUpgradingFeature.getConfigurations().isEmpty()
- && prototype.getBundleRemovals().isEmpty()
- && prototype.getConfigurationRemovals().isEmpty()) {
- return launchFeature;
- }
-
- ArtifactId runtimeId = newId(RUNTIME_CLASSIFIER);
-
- BuilderContext context = new BuilderContext(this);
-
- return assemble(runtimeId, context, launch2RunningUpgradingFeature);
- }
-
- @Override
- public Feature provide(ArtifactId id) {
- if (launchFeature.getId().equals(id)) {
- return launchFeature;
- }
- return null;
- }
-
- private ArtifactId newId(String classifier) {
- String groupId = launchFeature.getId().getGroupId();
- String artifactId = launchFeature.getId().getArtifactId();
- String version = launchFeature.getId().getVersion();
-
- return new ArtifactId(groupId, artifactId, version, classifier, PACKAGING_FEATURE);
- }
-
-}
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/package-info.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/package-info.java
deleted file mode 100644
index 151085c..0000000
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
-@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.feature.r2f;