Properly deal with items imported multiple times
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 7 Feb 2015 18:15:30 +0000 (18:15 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 7 Feb 2015 18:15:30 +0000 (18:15 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@7756 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ArchiveWrapper.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/BndWrapper.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ProcessDistribution.java

index 768cbbde392ea03ddd80dd19f91de2d9e4538390..29fa8f14d8dba8790cb631241307d924c3eaeb3e 100644 (file)
@@ -109,7 +109,8 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
                        ZipEntry zentry = null;
                        entries: while ((zentry = zin.getNextEntry()) != null) {
                                String name = zentry.getName();
-                               // log.debug(name);
+                               if (log.isTraceEnabled())
+                                       log.trace("Zip entry " + name);
                                for (String exclude : excludes)
                                        if (pathMatcher.match(exclude, name))
                                                continue entries;
@@ -118,6 +119,11 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
                                        if (pathMatcher.match(include, name)) {
                                                String groupId = includes.get(include);
                                                JarInputStream jis = new JarInputStream(zin);
+                                               if (jis.getManifest() == null) {
+                                                       log.warn("No MANIFEST in entry " + name
+                                                                       + ", skipping...");
+                                                       continue entries;
+                                               }
                                                NameVersion nv = RepoUtils.readNameVersion(jis
                                                                .getManifest());
                                                if (nv != null) {
@@ -127,6 +133,8 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
                                                                        groupId, nv.getName(), nv.getVersion(),
                                                                        this);
                                                        nvs.add(cnv);
+                                                       // no need to process further includes
+                                                       continue entries;
                                                }
                                        }
                                }
@@ -248,6 +256,8 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
                                                                addArtifactToIndex(sources, groupId, artifact);
                                                        else
                                                                addArtifactToIndex(binaries, groupId, artifact);
+                                                       // no need to process this entry further
+                                                       continue entries;
                                                }
                                        }
                                }
@@ -356,6 +366,7 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
                        in = new ByteArrayInputStream(binaryJarBytes);
                        NameVersion nameVersion = RepoUtils.readNameVersion(in);
                        if (nameVersion == null) {
+                               log.warn("Cannot identify " + zentry.getName());
                                return null;
                        }
                        Artifact artifact = new DefaultArtifact(groupId,
index 7b75b903d4609df31054fc876042ad05c8c4a767..fce521181686c1cf604e3383ae2a675c9bc39fe4 100644 (file)
@@ -54,7 +54,7 @@ public class BndWrapper implements Constants, CategorizedNameVersion,
                                                .getValue(BUNDLE_SYMBOLICNAME);
                                if (sourceSymbolicName != null
                                                && !sourceSymbolicName.equals(name))
-                                       log.warn("The new symbolic name ("
+                                       log.info("The new symbolic name ("
                                                        + name
                                                        + ") is not consistant with the wrapped bundle symbolic name ("
                                                        + sourceSymbolicName + ")");
index 9ea467d773d9d5a507ad6e60b835d9cc6c49b7fa..d16a797420f7f39c71d5887bd76485134be1b614 100644 (file)
@@ -9,6 +9,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.DefaultNameVersion;
 import org.argeo.slc.NameVersion;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.repo.ArgeoOsgiDistribution;
@@ -33,6 +34,17 @@ public class ProcessDistribution implements Runnable {
                                        .nameVersions(); it.hasNext();)
                                processNameVersion(javaSession, it.next());
 
+                       // Check sources
+                       for (Iterator<? extends NameVersion> it = osgiDistribution
+                                       .nameVersions(); it.hasNext();) {
+                               CategorizedNameVersion nv = (CategorizedNameVersion) it.next();
+                               Artifact artifact = new DefaultArtifact(nv.getCategory(),
+                                               nv.getName() + ".source", "jar", nv.getVersion());
+                               String path = MavenConventionsUtils.artifactPath("/", artifact);
+                               if (!javaSession.itemExists(path))
+                                       log.warn("No source available for " + nv);
+                       }
+
                        // explicitly create the corresponding modular distribution as we
                        // have here all necessary info.
                        ModularDistributionFactory mdf = new ModularDistributionFactory(