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 2022/02/23 06:22:49 UTC
[sling-org-apache-sling-feature] branch master updated: SLING-11159 : Add additional metadata from OSGi feature
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-org-apache-sling-feature.git
The following commit(s) were added to refs/heads/master by this push:
new ded8124 SLING-11159 : Add additional metadata from OSGi feature
ded8124 is described below
commit ded8124c50d75b92715b488eb944d027a9cff839
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Feb 23 07:22:42 2022 +0100
SLING-11159 : Add additional metadata from OSGi feature
---
.gitignore | 1 +
.../java/org/apache/sling/feature/Feature.java | 68 ++++++++++++++++++++++
.../sling/feature/io/json/FeatureJSONReader.java | 11 +++-
.../sling/feature/io/json/FeatureJSONWriter.java | 7 ++-
.../sling/feature/io/json/JSONConstants.java | 11 +++-
.../org/apache/sling/feature/package-info.java | 2 +-
6 files changed, 96 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5b783ed..38f5ca4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ maven-eclipse.xml
.vlt
.DS_Store
jcr.log
+.vscode
atlassian-ide-plugin.xml
diff --git a/src/main/java/org/apache/sling/feature/Feature.java b/src/main/java/org/apache/sling/feature/Feature.java
index 05f586e..8a4f5f5 100644
--- a/src/main/java/org/apache/sling/feature/Feature.java
+++ b/src/main/java/org/apache/sling/feature/Feature.java
@@ -87,6 +87,24 @@ public class Feature implements Comparable<Feature> {
/** The optional prototype. */
private Prototype prototype;
+ /**
+ * The optional categories
+ * @since 1.9
+ */
+ private final List<String> categories = new ArrayList<>();
+
+ /**
+ * Optional document URL
+ * @since 1.9
+ */
+ private String docURL;
+
+ /**
+ * Optional scm info
+ * @since 1.9
+ */
+ private String scmInfo;
+
/**
* Construct a new feature.
* @param id The id of the feature.
@@ -384,6 +402,53 @@ public class Feature implements Comparable<Feature> {
}
/**
+ * Get the list of categories
+ * @return The modifiable list, might be empty
+ * @since 1.9
+ */
+ public List<String> getCategories() {
+ return this.categories;
+ }
+
+ /**
+ * Get the optional document URL
+ * @return The document URL or {@code null}
+ * @since 1.9
+ */
+ public String getDocURL() {
+ return this.docURL;
+ }
+
+ /**
+ * Set the document URL
+ * @param url The url
+ * @since 1.9
+ */
+ public void setDocURL(final String url) {
+ this.docURL = url;
+ }
+
+ /**
+ * Get the SCM information relating to the feature. The syntax of the value follows the Bundle-SCM
+ * format. See the 'Bundle Manifest Headers' section in the OSGi Core specification.
+ * @return The SCM information or {@code null}
+ * @since 1.9
+ */
+ public String getSCMInfo() {
+ return this.scmInfo;
+ }
+
+ /**
+ * Set the SCM information
+ * @param info The SCM information
+ * @see #getSCMInfo()
+ * @since 1.9
+ */
+ public void setSCMInfo(final String info) {
+ this.scmInfo = info;
+ }
+
+ /**
* Create a copy of the feature
* @return A copy of the feature
*/
@@ -410,6 +475,9 @@ public class Feature implements Comparable<Feature> {
result.setAssembled(this.isAssembled());
result.setFinal(this.isFinal());
result.setComplete(this.isComplete());
+ result.getCategories().addAll(this.getCategories());
+ result.setDocURL(this.getDocURL());
+ result.setSCMInfo(this.getSCMInfo());
// variables
result.getVariables().putAll(this.getVariables());
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 6eb0421..bfb8083 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
@@ -691,11 +691,20 @@ public class FeatureJSONReader {
this.feature.setComplete(checkTypeBoolean(JSONConstants.FEATURE_COMPLETE, json.get(JSONConstants.FEATURE_COMPLETE)));
}
- // title, description, vendor and license
+ // title, description, vendor and license, docURL, scmInfo
this.feature.setTitle(getProperty(json, JSONConstants.FEATURE_TITLE));
this.feature.setDescription(getProperty(json, JSONConstants.FEATURE_DESCRIPTION));
this.feature.setVendor(getProperty(json, JSONConstants.FEATURE_VENDOR));
this.feature.setLicense(getProperty(json, JSONConstants.FEATURE_LICENSE));
+ this.feature.setDocURL(getProperty(json, JSONConstants.FEATURE_DOC_URL));
+ this.feature.setSCMInfo(getProperty(json, JSONConstants.FEATURE_SCM_INFO));
+
+ // categories
+ if ( json.containsKey(JSONConstants.FEATURE_CATEGORIES) ) {
+ for(final JsonValue val : checkTypeArray(JSONConstants.FEATURE_CATEGORIES, json.get(JSONConstants.FEATURE_CATEGORIES))) {
+ this.feature.getCategories().add(checkTypeString("Categories", val));
+ }
+ }
this.readVariables(json, feature.getVariables());
this.readBundles(json, feature.getBundles(), feature.getConfigurations());
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 428ba8f..cab70c4 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
@@ -376,11 +376,16 @@ public class FeatureJSONWriter {
generator.write(JSONConstants.FEATURE_COMPLETE, true);
}
- // title, description, vendor, license
+ // title, description, vendor, license, docURL, scmInfo
writeProperty(generator, JSONConstants.FEATURE_TITLE, feature.getTitle());
writeProperty(generator, JSONConstants.FEATURE_DESCRIPTION, feature.getDescription());
writeProperty(generator, JSONConstants.FEATURE_VENDOR, feature.getVendor());
writeProperty(generator, JSONConstants.FEATURE_LICENSE, feature.getLicense());
+ writeProperty(generator, JSONConstants.FEATURE_DOC_URL, feature.getDocURL());
+ writeProperty(generator, JSONConstants.FEATURE_SCM_INFO, feature.getSCMInfo());
+
+ // categories
+ writeList(generator, JSONConstants.FEATURE_CATEGORIES, feature.getCategories());
// variables
writeVariables(generator, feature.getVariables());
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 c48c9c1..e1e89ab 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
@@ -53,6 +53,12 @@ public abstract class JSONConstants {
static final String FEATURE_MODEL_VERSION = "model-version";
+ static final String FEATURE_CATEGORIES = "categories";
+
+ static final String FEATURE_DOC_URL = "doc-url";
+
+ static final String FEATURE_SCM_INFO = "scm-info";
+
static final List<String> FEATURE_KNOWN_PROPERTIES = Arrays.asList(FEATURE_ID,
FEATURE_MODEL_VERSION,
FEATURE_VARIABLES,
@@ -67,7 +73,10 @@ public abstract class JSONConstants {
FEATURE_VENDOR,
FEATURE_FINAL,
FEATURE_COMPLETE,
- FEATURE_LICENSE);
+ FEATURE_LICENSE,
+ FEATURE_CATEGORIES,
+ FEATURE_DOC_URL,
+ FEATURE_SCM_INFO);
static final String ARTIFACT_ID = "id";
diff --git a/src/main/java/org/apache/sling/feature/package-info.java b/src/main/java/org/apache/sling/feature/package-info.java
index a9a3f0f..62be58d 100644
--- a/src/main/java/org/apache/sling/feature/package-info.java
+++ b/src/main/java/org/apache/sling/feature/package-info.java
@@ -17,7 +17,7 @@
* under the License.
*/
-@org.osgi.annotation.versioning.Version("1.8.0")
+@org.osgi.annotation.versioning.Version("1.9.0")
package org.apache.sling.feature;