X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.repo%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Frepo%2FJarFileIndexer.java;h=80c750407a70c23343390db139aad1066fcc4941;hb=604aac63035b30549b51a7030f49e0bf83c558f5;hp=6ab3c529dd84a4b237a3556bb16c6c2bc2de5e6c;hpb=74904a755b5b344238eafa798419b80c5e74f7ed;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/JarFileIndexer.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/JarFileIndexer.java index 6ab3c529d..80c750407 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/JarFileIndexer.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/JarFileIndexer.java @@ -18,6 +18,7 @@ package org.argeo.slc.repo; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; @@ -47,7 +48,7 @@ import org.osgi.framework.Version; * Indexes jar file, currently supports standard J2SE and OSGi metadata (both * from MANIFEST) */ -public class JarFileIndexer implements NodeIndexer { +public class JarFileIndexer implements NodeIndexer, SlcNames { private final static Log log = LogFactory.getLog(JarFileIndexer.class); public Boolean support(String path) { @@ -78,13 +79,27 @@ public class JarFileIndexer implements NodeIndexer { log.error(fileNode + " has no MANIFEST"); return; } + bo = new ByteArrayOutputStream(); manifest.write(bo); - bi = new ByteArrayInputStream(bo.toByteArray()); + byte[] newManifest = bo.toByteArray(); + if (fileNode.hasProperty(SLC_MANIFEST)) { + byte[] storedManifest = JcrUtils.getBinaryAsBytes(fileNode + .getProperty(SLC_MANIFEST)); + if (Arrays.equals(newManifest, storedManifest)) { + if (log.isTraceEnabled()) + log.trace("Manifest not changed, doing nothing " + + fileNode); + return; + } + } + + bi = new ByteArrayInputStream(newManifest); manifestBinary = jcrSession.getValueFactory().createBinary(bi); // standard jar file fileNode.addMixin(SlcTypes.SLC_JAR_FILE); + fileNode.setProperty(SlcNames.SLC_MANIFEST, manifestBinary); Attributes attrs = manifest.getMainAttributes(); if (log.isTraceEnabled()) @@ -116,6 +131,7 @@ public class JarFileIndexer implements NodeIndexer { if (log.isTraceEnabled()) log.trace("Indexed JAR file " + fileNode); } + } catch (Exception e) { throw new SlcException("Cannot index jar " + fileNode, e); } finally { @@ -352,9 +368,11 @@ public class JarFileIndexer implements NodeIndexer { boolean in = false; for (char c : str.toCharArray()) { if (c == ',') { - if (!in) { + if (!in) {// new package res.add(curr.toString()); curr = new StringBuffer(""); + } else {// a ',' within " " + curr.append(c); } } else if (c == '\"') { in = !in;