SLING-8121 Rename feature 'include' to 'prototype'
diff --git a/src/main/java/org/apache/sling/feature/io/json/FeatureJSONReader.java b/src/main/java/org/apache/sling/feature/io/json/FeatureJSONReader.java
index 8cdeb0b..54757af 100644
--- a/src/main/java/org/apache/sling/feature/io/json/FeatureJSONReader.java
+++ b/src/main/java/org/apache/sling/feature/io/json/FeatureJSONReader.java
@@ -107,7 +107,7 @@
this.readCapabilities(map, feature.getCapabilities());
this.readRequirements(map, feature.getRequirements());
- feature.setInclude(this.readInclude(map));
+ feature.setPrototype(this.readPrototype(map));
this.readExtensions(map,
JSONConstants.FEATURE_KNOWN_PROPERTIES,
diff --git a/src/main/java/org/apache/sling/feature/io/json/FeatureJSONWriter.java b/src/main/java/org/apache/sling/feature/io/json/FeatureJSONWriter.java
index c2f8cd5..2c7af7c 100644
--- a/src/main/java/org/apache/sling/feature/io/json/FeatureJSONWriter.java
+++ b/src/main/java/org/apache/sling/feature/io/json/FeatureJSONWriter.java
@@ -71,8 +71,8 @@
// variables
writeVariables(generator, feature.getVariables());
- // include
- writeInclude(generator, feature.getInclude());
+ // prototype
+ writePrototype(generator, feature.getPrototype());
// requirements
writeRequirements(generator, feature.getRequirements());
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONConstants.java b/src/main/java/org/apache/sling/feature/io/json/JSONConstants.java
index 196dfed..9d665fb 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONConstants.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONConstants.java
@@ -33,7 +33,7 @@
static final String FEATURE_CONFIGURATIONS = "configurations";
- static final String FEATURE_INCLUDE = "include";
+ static final String FEATURE_PROTOTYPE = "prototype";
static final String FEATURE_REQUIREMENTS = "requirements";
@@ -59,7 +59,7 @@
FEATURE_BUNDLES,
FEATURE_FRAMEWORK_PROPERTIES,
FEATURE_CONFIGURATIONS,
- FEATURE_INCLUDE,
+ FEATURE_PROTOTYPE,
FEATURE_REQUIREMENTS,
FEATURE_CAPABILITIES,
FEATURE_TITLE,
@@ -75,9 +75,9 @@
Configuration.PROP_ARTIFACT_ID,
FEATURE_CONFIGURATIONS);
- static final String INCLUDE_REMOVALS = "removals";
+ static final String PROTOTYPE_REMOVALS = "removals";
- static final String INCLUDE_EXTENSION_REMOVALS = "extensions";
+ static final String PROTOTYPE_EXTENSION_REMOVALS = "extensions";
static final String REQCAP_NAMESPACE = "namespace";
static final String REQCAP_ATTRIBUTES = "attributes";
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
index e063c39..e4051f0 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
@@ -30,7 +30,7 @@
import org.apache.sling.feature.Extension;
import org.apache.sling.feature.ExtensionType;
import org.apache.sling.feature.Extensions;
-import org.apache.sling.feature.Include;
+import org.apache.sling.feature.Prototype;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
@@ -279,7 +279,7 @@
for(final Config c : configs) {
final Configuration config = new Configuration(c.getPid());
-
+
final Enumeration<String> keyEnum = c.getProperties().keys();
while ( keyEnum.hasMoreElements() ) {
final String key = keyEnum.nextElement();
@@ -487,87 +487,87 @@
}
}
- protected Include readInclude(final Map<String, Object> map) throws IOException {
- if ( map.containsKey(JSONConstants.FEATURE_INCLUDE)) {
- final Object includeObj = map.get(JSONConstants.FEATURE_INCLUDE);
- checkType(JSONConstants.FEATURE_INCLUDE, includeObj, Map.class, String.class);
+ protected Prototype readPrototype(final Map<String, Object> map) throws IOException {
+ if ( map.containsKey(JSONConstants.FEATURE_PROTOTYPE)) {
+ final Object prototypeObj = map.get(JSONConstants.FEATURE_PROTOTYPE);
+ checkType(JSONConstants.FEATURE_PROTOTYPE, prototypeObj, Map.class, String.class);
- final Include include;
- if ( includeObj instanceof String ) {
- final ArtifactId id = ArtifactId.parse(includeObj.toString());
- include = new Include(id);
+ final Prototype prototype;
+ if ( prototypeObj instanceof String ) {
+ final ArtifactId id = ArtifactId.parse(prototypeObj.toString());
+ prototype = new Prototype(id);
} else {
@SuppressWarnings("unchecked")
- final Map<String, Object> obj = (Map<String, Object>) includeObj;
+ final Map<String, Object> obj = (Map<String, Object>) prototypeObj;
if ( !obj.containsKey(JSONConstants.ARTIFACT_ID) ) {
- throw new IOException(exceptionPrefix + " include is missing required artifact id");
+ throw new IOException(exceptionPrefix + " prototype is missing required artifact id");
}
- checkType("Include " + JSONConstants.ARTIFACT_ID, obj.get(JSONConstants.ARTIFACT_ID), String.class);
+ checkType("Prototype " + JSONConstants.ARTIFACT_ID, obj.get(JSONConstants.ARTIFACT_ID), String.class);
final ArtifactId id = ArtifactId.parse(obj.get(JSONConstants.ARTIFACT_ID).toString());
- include = new Include(id);
+ prototype = new Prototype(id);
- if ( obj.containsKey(JSONConstants.INCLUDE_REMOVALS) ) {
- checkType("Include removals", obj.get(JSONConstants.INCLUDE_REMOVALS), Map.class);
+ if ( obj.containsKey(JSONConstants.PROTOTYPE_REMOVALS) ) {
+ checkType("Prototype removals", obj.get(JSONConstants.PROTOTYPE_REMOVALS), Map.class);
@SuppressWarnings("unchecked")
- final Map<String, Object> removalObj = (Map<String, Object>) obj.get(JSONConstants.INCLUDE_REMOVALS);
+ final Map<String, Object> removalObj = (Map<String, Object>) obj.get(JSONConstants.PROTOTYPE_REMOVALS);
if ( removalObj.containsKey(JSONConstants.FEATURE_BUNDLES) ) {
- checkType("Include removal bundles", removalObj.get(JSONConstants.FEATURE_BUNDLES), List.class);
+ checkType("Prototype removal bundles", removalObj.get(JSONConstants.FEATURE_BUNDLES), List.class);
@SuppressWarnings("unchecked")
final List<Object> list = (List<Object>)removalObj.get(JSONConstants.FEATURE_BUNDLES);
for(final Object val : list) {
- checkType("Include removal bundles", val, String.class);
+ checkType("Prototype removal bundles", val, String.class);
if ( val.toString().startsWith("#")) {
continue;
}
- include.getBundleRemovals().add(ArtifactId.parse(val.toString()));
+ prototype.getBundleRemovals().add(ArtifactId.parse(val.toString()));
}
}
if ( removalObj.containsKey(JSONConstants.FEATURE_CONFIGURATIONS) ) {
- checkType("Include removal configuration", removalObj.get(JSONConstants.FEATURE_CONFIGURATIONS), List.class);
+ checkType("Prototype removal configuration", removalObj.get(JSONConstants.FEATURE_CONFIGURATIONS), List.class);
@SuppressWarnings("unchecked")
final List<Object> list = (List<Object>)removalObj.get(JSONConstants.FEATURE_CONFIGURATIONS);
for(final Object val : list) {
- checkType("Include removal configuration", val, String.class);
- include.getConfigurationRemovals().add(val.toString());
+ checkType("Prototype removal configuration", val, String.class);
+ prototype.getConfigurationRemovals().add(val.toString());
}
}
if ( removalObj.containsKey(JSONConstants.FEATURE_FRAMEWORK_PROPERTIES) ) {
- checkType("Include removal framework properties", removalObj.get(JSONConstants.FEATURE_FRAMEWORK_PROPERTIES), List.class);
+ checkType("Prototype removal framework properties", removalObj.get(JSONConstants.FEATURE_FRAMEWORK_PROPERTIES), List.class);
@SuppressWarnings("unchecked")
final List<Object> list = (List<Object>)removalObj.get(JSONConstants.FEATURE_FRAMEWORK_PROPERTIES);
for(final Object val : list) {
- checkType("Include removal framework properties", val, String.class);
- include.getFrameworkPropertiesRemovals().add(val.toString());
+ checkType("Prototype removal framework properties", val, String.class);
+ prototype.getFrameworkPropertiesRemovals().add(val.toString());
}
}
- if ( removalObj.containsKey(JSONConstants.INCLUDE_EXTENSION_REMOVALS) ) {
- checkType("Include removal extensions", removalObj.get(JSONConstants.INCLUDE_EXTENSION_REMOVALS), List.class);
+ if ( removalObj.containsKey(JSONConstants.PROTOTYPE_EXTENSION_REMOVALS) ) {
+ checkType("Prototype removal extensions", removalObj.get(JSONConstants.PROTOTYPE_EXTENSION_REMOVALS), List.class);
@SuppressWarnings("unchecked")
- final List<Object> list = (List<Object>)removalObj.get(JSONConstants.INCLUDE_EXTENSION_REMOVALS);
+ final List<Object> list = (List<Object>)removalObj.get(JSONConstants.PROTOTYPE_EXTENSION_REMOVALS);
for(final Object val : list) {
- checkType("Include removal extension", val, String.class, Map.class);
+ checkType("Prototype removal extension", val, String.class, Map.class);
if ( val instanceof String ) {
if ( val.toString().startsWith("#")) {
continue;
}
- include.getExtensionRemovals().add(val.toString());
+ prototype.getExtensionRemovals().add(val.toString());
} else {
@SuppressWarnings("unchecked")
final Map<String, Object> removalMap = (Map<String, Object>)val;
final Object nameObj = removalMap.get("name");
- checkType("Include removal extension", nameObj, String.class);
+ checkType("Prototype removal extension", nameObj, String.class);
if ( removalMap.containsKey("artifacts") ) {
- checkType("Include removal extension artifacts", removalMap.get("artifacts"), List.class);
+ checkType("Prototype removal extension artifacts", removalMap.get("artifacts"), List.class);
@SuppressWarnings("unchecked")
final List<Object> artifactList = (List<Object>)removalMap.get("artifacts");
final List<ArtifactId> ids = new ArrayList<>();
for(final Object aid : artifactList) {
- checkType("Include removal extension artifact", aid, String.class);
+ checkType("Prototype removal extension artifact", aid, String.class);
ids.add(ArtifactId.parse(aid.toString()));
}
- include.getArtifactExtensionRemovals().put(nameObj.toString(), ids);
+ prototype.getArtifactExtensionRemovals().put(nameObj.toString(), ids);
} else {
- include.getExtensionRemovals().add(nameObj.toString());
+ prototype.getExtensionRemovals().add(nameObj.toString());
}
}
}
@@ -575,7 +575,7 @@
}
}
- return include;
+ return prototype;
}
return null;
}
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java b/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
index 969ef62..1988595 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
@@ -37,7 +37,7 @@
import org.apache.sling.feature.Configurations;
import org.apache.sling.feature.Extension;
import org.apache.sling.feature.ExtensionType;
-import org.apache.sling.feature.Include;
+import org.apache.sling.feature.Prototype;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
@@ -270,7 +270,7 @@
}
}
- protected void writeInclude(final JsonGenerator generator, final Include inc) {
+ protected void writePrototype(final JsonGenerator generator, final Prototype inc) {
if (inc == null) {
return;
}
@@ -280,16 +280,16 @@
&& inc.getConfigurationRemovals().isEmpty()
&& inc.getFrameworkPropertiesRemovals().isEmpty() ) {
- generator.write(JSONConstants.FEATURE_INCLUDE, inc.getId().toMvnId());
+ generator.write(JSONConstants.FEATURE_PROTOTYPE, inc.getId().toMvnId());
} else {
- generator.writeStartObject(JSONConstants.FEATURE_INCLUDE);
+ generator.writeStartObject(JSONConstants.FEATURE_PROTOTYPE);
writeProperty(generator, JSONConstants.ARTIFACT_ID, inc.getId().toMvnId());
- generator.writeStartObject(JSONConstants.INCLUDE_REMOVALS);
+ generator.writeStartObject(JSONConstants.PROTOTYPE_REMOVALS);
if ( !inc.getArtifactExtensionRemovals().isEmpty()
|| inc.getExtensionRemovals().isEmpty() ) {
- generator.writeStartArray(JSONConstants.INCLUDE_EXTENSION_REMOVALS);
+ generator.writeStartArray(JSONConstants.PROTOTYPE_EXTENSION_REMOVALS);
for(final String id : inc.getExtensionRemovals()) {
generator.write(id);
diff --git a/src/main/resources/META-INF/feature/Feature-1.0.0.schema.json b/src/main/resources/META-INF/feature/Feature-1.0.0.schema.json
index 21067b6..9021482 100644
--- a/src/main/resources/META-INF/feature/Feature-1.0.0.schema.json
+++ b/src/main/resources/META-INF/feature/Feature-1.0.0.schema.json
@@ -58,8 +58,8 @@
}
}
},
- "include": {
- "$ref": "#/definitions/Include"
+ "prototype": {
+ "$ref": "#/definitions/Prototype"
},
"requirements": {
" type": "array",
@@ -143,8 +143,8 @@
}
}
},
- "Include": {
- "$id": "#Include",
+ "Prototype": {
+ "$id": "#Prototype",
"type": "object",
"properties": {
"id": {
diff --git a/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java b/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
index 011778a..4d3feca 100644
--- a/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
+++ b/src/test/java/org/apache/sling/feature/io/json/FeatureJSONWriterTest.java
@@ -81,9 +81,9 @@
ArtifactsExtensions.testReadArtifactsExtensions(rf);
}
- @Test public void testIncludeWriteRead() throws Exception {
+ @Test public void testPrototypeWriteRead() throws Exception {
final Feature f = U.readFeature("test");
- assertNotNull(f.getInclude());
+ assertNotNull(f.getPrototype());
final Feature rf;
try ( final StringWriter writer = new StringWriter() ) {
@@ -92,7 +92,7 @@
rf = FeatureJSONReader.read(reader, null);
}
}
- assertEquals(f.getInclude().getId(), rf.getInclude().getId());
+ assertEquals(f.getPrototype().getId(), rf.getPrototype().getId());
}
@Test public void testRepoInitWrite() throws Exception {
diff --git a/src/test/resources/features/test.json b/src/test/resources/features/test.json
index d5d10df..42d4c4d 100644
--- a/src/test/resources/features/test.json
+++ b/src/test/resources/features/test.json
@@ -2,7 +2,7 @@
"id" : "org.apache.sling/test-feature/1.1",
"description": "The feature description",
- "include" :
+ "prototype" :
{
"id" : "org.apache.sling/sling/9",
"removals" : {