This is an automated email from the ASF dual-hosted git repository.
davidb 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 16376e9 [Feature Model] Support the declaration of the Model Version
16376e9 is described below
commit 16376e9eab4cf4130d9b674b4dda94f21b8dc3d5
Author: David Bosschaert <[email protected]>
AuthorDate: Fri Mar 16 14:51:18 2018 +0000
[Feature Model] Support the declaration of the Model Version
The model version is a String, currently only "1" is supported.
---
.../apache/sling/feature/support/json/FeatureJSONReader.java | 12 ++++++++++++
.../org/apache/sling/feature/support/json/JSONConstants.java | 3 +++
.../feature-support/src/test/resources/features/test2.json | 1 +
3 files changed, 16 insertions(+)
diff --git
a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/FeatureJSONReader.java
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/FeatureJSONReader.java
index 13fa62d..d6f8bd7 100644
---
a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/FeatureJSONReader.java
+++
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/FeatureJSONReader.java
@@ -121,6 +121,8 @@ public class FeatureJSONReader extends JSONReaderBase {
final JsonObject json = Json.createReader(new
StringReader(minify(reader))).readObject();
final Map<String, Object> map = getJsonMap(json);
+ checkModelVersion(map);
+
final ArtifactId fId;
if ( !map.containsKey(JSONConstants.FEATURE_ID) ) {
if ( this.providedId == null ) {
@@ -158,6 +160,16 @@ public class FeatureJSONReader extends JSONReaderBase {
return feature;
}
+ private void checkModelVersion(final Map<String, Object> map) throws
IOException {
+ String modelVersion = getProperty(map,
JSONConstants.FEATURE_MODEL_VERSION);
+ if (modelVersion == null) {
+ modelVersion = "1";
+ }
+ if (!"1".equals(modelVersion)) {
+ throw new IOException("Unsupported model version: " +
modelVersion);
+ }
+ }
+
@Override
protected Object handleResolveVars(Object val) {
if (phase == Phase.RESOLVE) {
diff --git
a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONConstants.java
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONConstants.java
index 1b52d73..7f34ef3 100644
---
a/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONConstants.java
+++
b/featuremodel/feature-support/src/main/java/org/apache/sling/feature/support/json/JSONConstants.java
@@ -47,7 +47,10 @@ public abstract class JSONConstants {
public static final String FEATURE_LICENSE = "license";
+ public static final String FEATURE_MODEL_VERSION = "model-version";
+
public static final List<String> FEATURE_KNOWN_PROPERTIES =
Arrays.asList(FEATURE_ID,
+ FEATURE_MODEL_VERSION,
FEATURE_VARIABLES,
FEATURE_BUNDLES,
FEATURE_FRAMEWORK_PROPERTIES,
diff --git
a/featuremodel/feature-support/src/test/resources/features/test2.json
b/featuremodel/feature-support/src/test/resources/features/test2.json
index acae2a2..0e5c1c6 100644
--- a/featuremodel/feature-support/src/test/resources/features/test2.json
+++ b/featuremodel/feature-support/src/test/resources/features/test2.json
@@ -1,4 +1,5 @@
{
+ "model-version": "1",
"id" : "org.apache.sling/test2/1.1",
"variables": {
--
To stop receiving notification emails like this one, please contact
[email protected].