You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2018/02/01 13:29:26 UTC
[sling-whiteboard] branch master updated: Change from start level
to start order
This is an automated email from the ASF dual-hosted git repository.
cziegeler 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 2d8ecfe Change from start level to start order
2d8ecfe is described below
commit 2d8ecfe190cec435e79a2b3746d814214f1fe11a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Feb 1 14:25:30 2018 +0100
Change from start level to start order
---
featuremodel/example/Example.md | 2 +
.../src/test/resources/feature_complete.json | 105 ++++++++++++++------
.../src/test/resources/feature_incomplete.json | 107 +++++++++++++++------
.../sling/feature/support/json/JSONReaderBase.java | 34 +++----
.../sling/feature/support/json/JSONWriterBase.java | 44 ++++-----
.../src/test/resources/features/test.json | 26 +++--
.../java/org/apache/sling/feature/Bundles.java | 8 ++
7 files changed, 216 insertions(+), 110 deletions(-)
diff --git a/featuremodel/example/Example.md b/featuremodel/example/Example.md
index daa99f6..e460bce 100644
--- a/featuremodel/example/Example.md
+++ b/featuremodel/example/Example.md
@@ -1,2 +1,4 @@
+The example are currently broken - the json needs to be updated to the latest format (change from start level to start order)
+
java -jar ../feature-applicationbuilder/target/org.apache.sling.feature.applicationbuilder-0.0.1-SNAPSHOT.jar -d sling -u ~/.m2/repository -o sling.json
java -jar ../feature-launcher/target/org.apache.sling.feature.launcher-0.0.1-SNAPSHOT.jar -a sling.json -I -v
diff --git a/featuremodel/feature-analyser/src/test/resources/feature_complete.json b/featuremodel/feature-analyser/src/test/resources/feature_complete.json
index 692ddfe..63b8bd0 100644
--- a/featuremodel/feature-analyser/src/test/resources/feature_complete.json
+++ b/featuremodel/feature-analyser/src/test/resources/feature_complete.json
@@ -1,31 +1,82 @@
{
"id" : "test/test.complete/0.1",
- "bundles" : {
- "1" : [
- "org.apache.sling/org.apache.sling.commons.log/5.0.0",
- "org.apache.sling/org.apache.sling.commons.logservice/1.0.6",
- "org.slf4j/jcl-over-slf4j/1.7.21",
- "org.slf4j/log4j-over-slf4j/1.7.21",
- "org.slf4j/slf4j-api/1.7.21",
- "org.apache.felix/org.apache.felix.configadmin/1.8.14"
- ],
- "4" : [
- "org.apache.felix/org.apache.felix.eventadmin/1.4.8",
- "org.apache.felix/org.apache.felix.metatype/1.1.2",
- "org.apache.felix/org.apache.felix.scr/2.0.12"
- ],
- "5" : [
- "org.apache.felix/org.apache.felix.http.jetty/3.4.2",
- "org.apache.felix/org.apache.felix.http.servlet-api/1.1.2",
- "commons-io/commons-io/2.5",
- "commons-fileupload/commons-fileupload/1.3.2",
- "org.apache.felix/org.apache.felix.inventory/1.0.4",
- "org.apache.felix/org.apache.felix.webconsole.plugins.ds/2.0.6",
- "org.apache.felix/org.apache.felix.webconsole.plugins.event/1.1.6",
- "org.apache.felix/org.apache.felix.webconsole.plugins.packageadmin/1.0.4",
- "org.apache.felix/org.apache.felix.webconsole/4.3.4",
- "org.apache.sling/org.apache.sling.commons.log.webconsole/1.0.0"
- ]
- }
+ "bundles" : [
+ {
+ "id" : "org.apache.sling/org.apache.sling.commons.log/5.0.0",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.sling/org.apache.sling.commons.logservice/1.0.6",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.slf4j/jcl-over-slf4j/1.7.21",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.slf4j/log4j-over-slf4j/1.7.21",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.slf4j/slf4j-api/1.7.21",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.configadmin/1.8.14",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.eventadmin/1.4.8",
+ "startOrder" : 4
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.metatype/1.1.2",
+ "startOrder" : 4
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.scr/2.0.12",
+ "startOrder" : 4
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.http.jetty/3.4.2",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.http.servlet-api/1.1.2",
+ "startOrder" : 5
+ },
+ {
+ "id" : "commons-io/commons-io/2.5",
+ "startOrder" : 5
+ },
+ {
+ "id" : "commons-fileupload/commons-fileupload/1.3.2",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.inventory/1.0.4",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole.plugins.ds/2.0.6",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole.plugins.event/1.1.6",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole.plugins.packageadmin/1.0.4",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole/4.3.4",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.sling/org.apache.sling.commons.log.webconsole/1.0.0",
+ "startOrder" : 5
+ }
+ ]
}
diff --git a/featuremodel/feature-analyser/src/test/resources/feature_incomplete.json b/featuremodel/feature-analyser/src/test/resources/feature_incomplete.json
index fee0e7f..3ab884c 100644
--- a/featuremodel/feature-analyser/src/test/resources/feature_incomplete.json
+++ b/featuremodel/feature-analyser/src/test/resources/feature_incomplete.json
@@ -1,33 +1,82 @@
{
"id" : "test/test.incomplete/0.1",
- "bundles" : {
- "1" : [
- "org.apache.sling/org.apache.sling.commons.log/5.0.0",
- "org.apache.sling/org.apache.sling.commons.logservice/1.0.6",
- "org.slf4j/jcl-over-slf4j/1.7.21",
- "org.slf4j/log4j-over-slf4j/1.7.21",
- "org.slf4j/slf4j-api/1.7.21",
- "org.apache.felix/org.apache.felix.configadmin/1.8.14"
- ],
- "4" : [
- "org.apache.felix/org.apache.felix.eventadmin/1.4.8",
- "org.apache.felix/org.apache.felix.metatype/1.1.2",
- "org.apache.felix/org.apache.felix.scr/2.0.12"
- ],
- "5" : [
- "org.apache.felix/org.apache.felix.http.servlet-api/1.1.2",
- "commons-io/commons-io/2.5",
- "commons-fileupload/commons-fileupload/1.3.2",
- "org.apache.felix/org.apache.felix.inventory/1.0.4",
- "org.apache.felix/org.apache.felix.webconsole.plugins.ds/2.0.6",
- "org.apache.felix/org.apache.felix.webconsole.plugins.event/1.1.6",
- "org.apache.felix/org.apache.felix.webconsole.plugins.packageadmin/1.0.4",
- "org.apache.felix/org.apache.felix.webconsole/4.3.4",
- "org.apache.sling/org.apache.sling.commons.log.webconsole/1.0.0"
- ],
- "6" : [
- "org.apache.sling/org.apache.sling.i18n/2.5.8"
- ]
- }
+ "bundles" : [
+ {
+ "id" : "org.apache.sling/org.apache.sling.commons.log/5.0.0",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.sling/org.apache.sling.commons.logservice/1.0.6",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.slf4j/jcl-over-slf4j/1.7.21",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.slf4j/log4j-over-slf4j/1.7.21",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.slf4j/slf4j-api/1.7.21",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.configadmin/1.8.14",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.eventadmin/1.4.8",
+ "startOrder" : 4
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.metatype/1.1.2",
+ "startOrder" : 4
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.scr/2.0.12",
+ "startOrder" : 4
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.http.servlet-api/1.1.2",
+ "startOrder" : 5
+ },
+ {
+ "id" : "commons-io/commons-io/2.5",
+ "startOrder" : 5
+ },
+ {
+ "id" : "commons-fileupload/commons-fileupload/1.3.2",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.inventory/1.0.4",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole.plugins.ds/2.0.6",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole.plugins.event/1.1.6",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole.plugins.packageadmin/1.0.4",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.felix/org.apache.felix.webconsole/4.3.4",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.sling/org.apache.sling.commons.log.webconsole/1.0.0",
+ "startOrder" : 5
+ },
+ {
+ "id" : "org.apache.sling/org.apache.sling.i18n/2.5.8",
+ "startOrder" : 6
+ }
+ ]
}
diff --git a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONReaderBase.java b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONReaderBase.java
index 36df699..f3182d4 100644
--- a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONReaderBase.java
+++ b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONReaderBase.java
@@ -105,28 +105,22 @@ abstract class JSONReaderBase {
final Configurations configContainer) throws IOException {
if ( map.containsKey(JSONConstants.FEATURE_BUNDLES)) {
final Object bundlesObj = map.get(JSONConstants.FEATURE_BUNDLES);
- checkType(JSONConstants.FEATURE_BUNDLES, bundlesObj, Map.class);
- @SuppressWarnings("unchecked")
- final Map<String, Object> bundles = (Map<String, Object>) bundlesObj;
- for(final String startLevelVal : bundles.keySet()) {
- int startLevel = -1;
- try {
- startLevel = Integer.valueOf(startLevelVal);
- } catch ( final NumberFormatException nfe) {
- throw new IOException(exceptionPrefix + "Illegal start level '" + startLevelVal + "'");
+ checkType(JSONConstants.FEATURE_BUNDLES, bundlesObj, List.class);
+
+ final List<Artifact> list = new ArrayList<>();
+ readArtifacts(JSONConstants.FEATURE_BUNDLES, "bundle", list, bundlesObj, configContainer);
+
+ for(final Artifact a : list) {
+ if ( container.containsSame(a.getId()) ) {
+ throw new IOException(exceptionPrefix + "Duplicate bundle " + a.getId().toMvnId());
}
- final Object val = bundles.get(startLevelVal);
- final List<Artifact> list = new ArrayList<>();
- readArtifacts("startLevel", "bundle", list, val, configContainer);
- for(final Artifact a : list) {
- if ( container.containsSame(a.getId()) ) {
- throw new IOException(exceptionPrefix + "Duplicate bundle " + a.getId().toMvnId());
- }
- if ( startLevel != 0 ) {
- a.getMetadata().put(Artifact.KEY_START_ORDER, startLevelVal);
- }
- container.add(a);
+ try {
+ // check start order
+ a.getStartOrder();
+ } catch ( final IllegalArgumentException nfe) {
+ throw new IOException(exceptionPrefix + "Illegal start order '" + a.getMetadata().get(Artifact.KEY_START_ORDER) + "'");
}
+ container.add(a);
}
}
}
diff --git a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONWriterBase.java b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONWriterBase.java
index 7fae7d3..ad6f1e0 100644
--- a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONWriterBase.java
+++ b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONWriterBase.java
@@ -45,34 +45,30 @@ abstract class JSONWriterBase {
final Bundles bundles,
final Configurations allConfigs) {
// bundles
- if ( !bundles.getBundlesByStartOrder().isEmpty() ) {
- w.writeStartObject(JSONConstants.FEATURE_BUNDLES);
- for(final Map.Entry<Integer, List<Artifact>> entry : bundles.getBundlesByStartOrder().entrySet()) {
- w.writeStartArray(String.valueOf(entry.getKey()));
-
- for(final Artifact artifact : entry.getValue()) {
- final Configurations cfgs = new Configurations();
- for(final Configuration cfg : allConfigs) {
- final String artifactProp = (String)cfg.getProperties().get(Configuration.PROP_ARTIFACT);
- if ( artifact.getId().toMvnId().equals(artifactProp) ) {
- cfgs.add(cfg);
- }
+ if ( !bundles.isEmpty() ) {
+ w.writeStartArray(JSONConstants.FEATURE_BUNDLES);
+
+ for(final Artifact artifact : bundles) {
+ final Configurations cfgs = new Configurations();
+ for(final Configuration cfg : allConfigs) {
+ final String artifactProp = (String)cfg.getProperties().get(Configuration.PROP_ARTIFACT);
+ if ( artifact.getId().toMvnId().equals(artifactProp) ) {
+ cfgs.add(cfg);
}
- if ( artifact.getMetadata().isEmpty() && cfgs.isEmpty() ) {
- w.write(artifact.getId().toMvnId());
- } else {
- w.writeStartObject();
- w.write(JSONConstants.ARTIFACT_ID, artifact.getId().toMvnId());
-
- for(final Map.Entry<String, String> me : artifact.getMetadata()) {
- w.write(me.getKey(), me.getValue());
- }
+ }
+ if ( artifact.getMetadata().isEmpty() && cfgs.isEmpty() ) {
+ w.write(artifact.getId().toMvnId());
+ } else {
+ w.writeStartObject();
+ w.write(JSONConstants.ARTIFACT_ID, artifact.getId().toMvnId());
- writeConfigurations(w, cfgs);
- w.writeEnd();
+ for(final Map.Entry<String, String> me : artifact.getMetadata()) {
+ w.write(me.getKey(), me.getValue());
}
+
+ writeConfigurations(w, cfgs);
+ w.writeEnd();
}
- w.writeEnd();
}
w.writeEnd();
diff --git a/featuremodel/feature-support/src/test/resources/features/test.json b/featuremodel/feature-support/src/test/resources/features/test.json
index 5c0348a..f4711c4 100644
--- a/featuremodel/feature-support/src/test/resources/features/test.json
+++ b/featuremodel/feature-support/src/test/resources/features/test.json
@@ -59,19 +59,25 @@
"brave" : "something",
"org.apache.felix.scr.directory" : "launchpad/scr"
},
- "bundles" : {
- "1" : [
+ "bundles" :[
{
"id" : "org.apache.sling/oak-server/1.0.0",
- "hash" : "4632463464363646436"
+ "hash" : "4632463464363646436",
+ "startOrder" : 1
},
- "org.apache.sling/application-bundle/2.0.0",
- "org.apache.sling/another-bundle/2.1.0"
- ],
- "2" : [
- "org.apache.sling/foo-xyz/1.2.3"
- ]
- },
+ {
+ "id" : "org.apache.sling/application-bundle/2.0.0",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.sling/another-bundle/2.1.0",
+ "startOrder" : 1
+ },
+ {
+ "id" : "org.apache.sling/foo-xyz/1.2.3",
+ "startOrder" : 2
+ }
+ ],
"configurations" : {
"my.pid" : {
"foo" : 5,
diff --git a/featuremodel/feature/src/main/java/org/apache/sling/feature/Bundles.java b/featuremodel/feature/src/main/java/org/apache/sling/feature/Bundles.java
index 12b5b52..7bf3f92 100644
--- a/featuremodel/feature/src/main/java/org/apache/sling/feature/Bundles.java
+++ b/featuremodel/feature/src/main/java/org/apache/sling/feature/Bundles.java
@@ -166,6 +166,14 @@ public class Bundles implements Iterable<Artifact> {
return Collections.unmodifiableList(this.bundles).iterator();
}
+ /**
+ * Check whether this container has bundles
+ * @return {@code true} if there are no bundles.
+ */
+ public boolean isEmpty() {
+ return this.bundles.isEmpty();
+ }
+
@Override
public String toString() {
return "Bundles " + this.bundles;
--
To stop receiving notification emails like this one, please contact
cziegeler@apache.org.