You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:57:03 UTC
[sling-org-apache-sling-provisioning-model] 07/34: Fully support
Apach Felix config file format. Move from properties to getter and setter
methods
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git
commit 470e4bc472132ad0f6515e9573177d3098ddedcd
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Sep 24 08:26:19 2014 +0000
Fully support Apach Felix config file format. Move from properties to getter and setter methods
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/slingstart-model@1627253 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/sling/slingstart/model/SSMArtifact.java | 66 ++++++++++++----------
.../sling/slingstart/model/SSMStartLevel.java | 5 +-
.../slingstart/model/xml/XMLSSMModelReader.java | 11 ++--
3 files changed, 44 insertions(+), 38 deletions(-)
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java b/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java
index a26cdab..e84485b 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMArtifact.java
@@ -21,11 +21,30 @@ package org.apache.sling.slingstart.model;
*/
public class SSMArtifact {
- public String groupId;
- public String artifactId;
- public String version;
- public String classifier;
- public String type;
+ public final String groupId;
+ public final String artifactId;
+ public final String version;
+ public final String classifier;
+ public final String type;
+
+ public SSMArtifact(final String gId, final String aId, final String version,
+ final String classifier, final String type) {
+ this.groupId = (gId != null ? gId.trim() : null);
+ this.artifactId = (aId != null ? aId.trim() : null);
+ this.version = (version != null ? version.trim() : null);
+ final String trimmedType = (type != null ? type.trim() : null);
+ if ( "bundle".equals(trimmedType) || trimmedType == null || trimmedType.isEmpty() ) {
+ this.type = "jar";
+ } else {
+ this.type = trimmedType;
+ }
+ final String trimmedClassifier = (classifier != null ? classifier.trim() : null);
+ if ( trimmedClassifier != null && trimmedClassifier.isEmpty() ) {
+ this.classifier = null;
+ } else {
+ this.classifier = trimmedClassifier;
+ }
+ }
public String getRepositoryPath() {
final StringBuilder sb = new StringBuilder();
@@ -60,13 +79,6 @@ public class SSMArtifact {
* @throws IllegalStateException
*/
public void validate() {
- // trim values first
- if ( groupId != null ) groupId = groupId.trim();
- if ( artifactId != null ) artifactId = artifactId.trim();
- if ( version != null ) version = version.trim();
- if ( type != null ) type = type.trim();
- if ( classifier != null ) classifier = classifier.trim();
-
// check/correct values
if ( groupId == null || groupId.isEmpty() ) {
throw new IllegalStateException(this + " : groupId");
@@ -77,15 +89,9 @@ public class SSMArtifact {
if ( version == null || version.isEmpty() ) {
throw new IllegalStateException(this + " : version");
}
- if ( "bundle".equals(type) || type == null || type.isEmpty() ) {
- type = "jar";
- }
if ( type == null || type.isEmpty() ) {
throw new IllegalStateException(this + " : type");
}
- if ( classifier != null && classifier.isEmpty() ) {
- classifier = null;
- }
}
public static SSMArtifact fromMvnUrl(final String url) {
@@ -94,7 +100,11 @@ public class SSMArtifact {
// ignore repository url
int pos = content.indexOf('!');
final String coordinates = (pos == -1 ? content : content.substring(pos + 1));
- final SSMArtifact ad = new SSMArtifact();
+ String gId = null;
+ String aId = null;
+ String version = null;
+ String type = null;
+ String classifier = null;
int part = 0;
String value = coordinates;
while ( value != null ) {
@@ -113,25 +123,23 @@ public class SSMArtifact {
}
if ( current != null ) {
if ( part == 0 ) {
- ad.groupId = current;
+ gId = current;
} else if ( part == 1 ) {
- ad.artifactId = current;
+ aId = current;
} else if ( part == 2 ) {
- ad.version = current;
+ version = current;
} else if ( part == 3 ) {
- ad.type = current;
+ type = current;
} else if ( part == 4 ) {
- ad.classifier = current;
+ classifier = current;
}
}
part++;
}
- if ( ad.version == null ) {
- ad.version = "LATEST";
- }
- if ( ad.type == null || ad.type.length() == 0 || ad.type.equals("bundle") ) {
- ad.type = "jar";
+ if ( version == null ) {
+ version = "LATEST";
}
+ final SSMArtifact ad = new SSMArtifact(gId, aId, version, classifier, type);
return ad;
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java b/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java
index 98899a9..57f0de1 100644
--- a/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java
+++ b/src/main/java/org/apache/sling/slingstart/model/SSMStartLevel.java
@@ -73,10 +73,9 @@ public class SSMStartLevel implements Comparable<SSMStartLevel> {
for(final SSMArtifact a : other.artifacts) {
final SSMArtifact found = this.search(a);
if ( found != null ) {
- found.version = a.version;
- } else {
- this.artifacts.add(a);
+ this.artifacts.remove(found);
}
+ this.artifacts.add(a);
}
}
diff --git a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
index c923044..609661d 100644
--- a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
+++ b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
@@ -152,13 +152,12 @@ public class XMLSSMModelReader {
}
this.startLevel = level;
} else if ( this.mode == MODE.ARTIFACT || this.mode == MODE.FEATURE_ARTIFACT || this.mode == MODE.STARTLEVEL_ARTIFACT || this.mode == MODE.FEATURE_STARTLEVEL_ARTIFACT) {
- final SSMArtifact artifact = new SSMArtifact();
+ final SSMArtifact artifact = new SSMArtifact(atts.getValue("groupId"),
+ atts.getValue("artifactId"),
+ atts.getValue("version"),
+ atts.getValue("classifier"),
+ atts.getValue("type"));
this.feature.getOrCreateStartLevel(this.startLevel).artifacts.add(artifact);
- artifact.groupId = atts.getValue("groupId");
- artifact.artifactId = atts.getValue("artifactId");
- artifact.version = atts.getValue("version");
- artifact.type = atts.getValue("type");
- artifact.classifier = atts.getValue("classifier");
} else if ( this.mode == MODE.CONFIGURATION || this.mode == MODE.FEATURE_CONFIGURATION) {
this.configuration = this.feature.getOrCreateConfiguration(atts.getValue("pid"), atts.getValue("factory"));
this.text = new StringBuilder();
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.