X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=inline;f=runtime%2Forg.argeo.slc.repo%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Frepo%2Fosgi%2FNormalizeGroup.java;h=99f31bb0414ae047c913ed7c6641ae1e09f60bee;hb=399702cec859f48ec171c30d268c55eb632d472a;hp=0d1eded0847b9b7131cd4bd7db42e3c5f6e28efa;hpb=74b4eb4af83276d7850177cc43ff001ac633262c;p=gpl%2Fargeo-slc.git
diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java
index 0d1eded08..99f31bb04 100644
--- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java
+++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.jcr.Node;
@@ -49,7 +50,11 @@ import org.sonatype.aether.util.artifact.DefaultArtifact;
/**
* Make sure that all JCR metadata and Maven metadata are consistent for this
* group of OSGi bundles.
+ *
+ * The job is now done via the various {@code NodeIndexer} of the
+ * WorkspaceManager. TODO import dependencies in the workspace.
*/
+@Deprecated
public class NormalizeGroup implements Runnable, SlcNames {
private final static Log log = LogFactory.getLog(NormalizeGroup.class);
@@ -178,8 +183,9 @@ public class NormalizeGroup implements Runnable, SlcNames {
version = allArtifactsHighestVersion.getProperty(
SLC_ARTIFACT_VERSION).getString();
else
- throw new SlcException("Group version " + version
- + " is empty.");
+ version = "0.0";
+ // throw new SlcException("Group version " + version
+ // + " is empty.");
int bundleCount = symbolicNamesToNodes.size();
if (log.isDebugEnabled())
@@ -215,7 +221,46 @@ public class NormalizeGroup implements Runnable, SlcNames {
String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
.getString();
String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
- return new Version(cleanVersion);
+ Version osgiVersion = null;
+ // log invalid version value to enable tracking them
+ try {
+ osgiVersion = new Version(cleanVersion);
+ } catch (IllegalArgumentException e) {
+ log.error("Version string " + cleanVersion + " is invalid ");
+ String twickedVersion = twickInvalidVersion(cleanVersion);
+ osgiVersion = new Version(twickedVersion);
+ log.error("Using " + twickedVersion + " instead");
+ // throw e;
+ }
+ return osgiVersion;
+ }
+
+ private String twickInvalidVersion(String tmpVersion) {
+ String[] tokens = tmpVersion.split("\\.");
+ if (tokens.length == 3 && tokens[2].lastIndexOf("-") > 0) {
+ String newSuffix = tokens[2].replaceFirst("-", ".");
+ tmpVersion = tmpVersion.replaceFirst(tokens[2], newSuffix);
+ } else if (tokens.length > 4) {
+ // FIXME manually remove other "."
+ StringTokenizer st = new StringTokenizer(tmpVersion, ".", true);
+ StringBuilder builder = new StringBuilder();
+ // Major
+ builder.append(st.nextToken()).append(st.nextToken());
+ // Minor
+ builder.append(st.nextToken()).append(st.nextToken());
+ // Micro
+ builder.append(st.nextToken()).append(st.nextToken());
+ // Qualifier
+ builder.append(st.nextToken());
+ while (st.hasMoreTokens()) {
+ // consume delimiter
+ st.nextToken();
+ if (st.hasMoreTokens())
+ builder.append("-").append(st.nextToken());
+ }
+ tmpVersion = builder.toString();
+ }
+ return tmpVersion;
}
private Artifact writeIndex(Session session, String artifactId,
@@ -243,12 +288,8 @@ public class NormalizeGroup implements Runnable, SlcNames {
protected void preProcessBundleArtifact(Node bundleNode)
throws RepositoryException {
- // we assume nodes are already indexed
- // artifactIndexer.index(bundleNode);
- // jarFileIndexer.index(bundleNode);
String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
-
if (symbolicName.endsWith(".source")) {
// TODO make a shared node with classifier 'sources'?
String bundleName = RepoUtils
@@ -313,7 +354,6 @@ public class NormalizeGroup implements Runnable, SlcNames {
p.append("4.0.0");
// Artifact
- // p.append("org.argeoparent1.2.0\n");
p.append("").append(JcrUtils.get(n, SLC_GROUP_ID))
.append("\n");
p.append("").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
@@ -428,6 +468,7 @@ public class NormalizeGroup implements Runnable, SlcNames {
return p.toString();
}
+ /* DEPENDENCY INJECTION */
public void setRepository(Repository repository) {
this.repository = repository;
}