if (log.isDebugEnabled())
log.debug("Wrapping " + uri);
if (log.isDebugEnabled())
log.debug("Wrapping " + uri);
+ boolean nothingWasDone = true;
Node distNode = osgiFactory.getDist(distSession, uri);
zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
Node distNode = osgiFactory.getDist(distSession, uri);
zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
wrapper.getName(), wrapper.getVersion());
byte[] pdeSource = RepoUtils.packageAsPdeSource(zin,
bundleNv);
wrapper.getName(), wrapper.getVersion());
byte[] pdeSource = RepoUtils.packageAsPdeSource(zin,
bundleNv);
+ Artifact sourcesArtifact = new DefaultArtifact(
+ wrapper.getCategory(), wrapper.getName()
+ + ".source", "jar",
+ wrapper.getVersion());
Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(
Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(
- javaSession.getRootNode(),
- new DefaultArtifact(wrapper.getCategory(),
- wrapper.getName() + ".source", "jar",
- wrapper.getVersion()), pdeSource);
+ javaSession.getRootNode(), sourcesArtifact,
+ pdeSource);
osgiFactory.indexNode(pdeSourceNode);
pdeSourceNode.getSession().save();
osgiFactory.indexNode(pdeSourceNode);
pdeSourceNode.getSession().save();
+ if (log.isDebugEnabled())
+ log.debug("Added sources " + sourcesArtifact
+ + " for bundle " + wrapper.getArtifact()
+ + "from " + name + " in binary archive.");
} else if (baseName.endsWith(".source")) {
// TODO Eclipse source already available
}
} else if (baseName.endsWith(".source")) {
// TODO Eclipse source already available
}
if (wrappers.containsKey(name)) {
BndWrapper wrapper = (BndWrapper) wrappers.get(name);
// we must copy since the stream is closed by BND
if (wrappers.containsKey(name)) {
BndWrapper wrapper = (BndWrapper) wrappers.get(name);
// we must copy since the stream is closed by BND
- byte[] sourceJarBytes = IOUtils.toByteArray(zin);
+ byte[] origJarBytes = IOUtils.toByteArray(zin);
Artifact artifact = wrapZipEntry(javaSession, zentry,
Artifact artifact = wrapZipEntry(javaSession, zentry,
- sourceJarBytes, wrapper);
+ origJarBytes, wrapper);
+ nothingWasDone = false;
addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
} else {
for (String wrapperKey : wrappers.keySet())
addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
} else {
for (String wrapperKey : wrappers.keySet())
BndWrapper wrapper = (BndWrapper) wrappers
.get(wrapperKey);
// we must copy since the stream is closed by BND
BndWrapper wrapper = (BndWrapper) wrappers
.get(wrapperKey);
// we must copy since the stream is closed by BND
- byte[] sourceJarBytes = IOUtils.toByteArray(zin);
+ byte[] origJarBytes = IOUtils.toByteArray(zin);
Artifact artifact = wrapZipEntry(javaSession,
Artifact artifact = wrapZipEntry(javaSession,
- zentry, sourceJarBytes, wrapper);
+ zentry, origJarBytes, wrapper);
+ nothingWasDone = false;
addArtifactToIndex(binaries, wrapper.getGroupId(),
artifact);
continue entries;
addArtifactToIndex(binaries, wrapper.getGroupId(),
artifact);
continue entries;
log.warn("Skipped non identified " + zentry);
continue entries;
}
log.warn("Skipped non identified " + zentry);
continue entries;
}
+ nothingWasDone = false;
if (artifact.getArtifactId().endsWith(".source"))
addArtifactToIndex(sources, groupId, artifact);
else
if (artifact.getArtifactId().endsWith(".source"))
addArtifactToIndex(sources, groupId, artifact);
else
+ if (nothingWasDone)
+ throw new SlcException("Nothing was done");
+
// FIXME Fail if not all wrappers matched
} catch (Exception e) {
throw new SlcException("Cannot wrap distribution " + uri, e);
// FIXME Fail if not all wrappers matched
} catch (Exception e) {
throw new SlcException("Cannot wrap distribution " + uri, e);
}
protected Artifact wrapZipEntry(Session javaSession, ZipEntry zentry,
}
protected Artifact wrapZipEntry(Session javaSession, ZipEntry zentry,
- byte[] sourceJarBytes, BndWrapper wrapper)
- throws RepositoryException {
+ byte[] origJarBytes, BndWrapper wrapper) throws RepositoryException {
ByteArrayOutputStream out = null;
ByteArrayInputStream in = null;
Node newJarNode;
Jar jar = null;
try {
out = new ByteArrayOutputStream((int) zentry.getSize());
ByteArrayOutputStream out = null;
ByteArrayInputStream in = null;
Node newJarNode;
Jar jar = null;
try {
out = new ByteArrayOutputStream((int) zentry.getSize());
- in = new ByteArrayInputStream(sourceJarBytes);
+ in = new ByteArrayInputStream(origJarBytes);
wrapper.wrapJar(in, out);
Artifact artifact = wrapper.getArtifact();
wrapper.wrapJar(in, out);
Artifact artifact = wrapper.getArtifact();
}
protected void addSource(Session javaSession, Artifact artifact,
}
protected void addSource(Session javaSession, Artifact artifact,
+ byte[] binaryJarBytes) {
InputStream in = null;
ByteArrayOutputStream out = null;
Jar jar = null;
try {
InputStream in = null;
ByteArrayOutputStream out = null;
Jar jar = null;
try {
- in = new ByteArrayInputStream(jarBytes);
+ in = new ByteArrayInputStream(binaryJarBytes);
jar = new Jar(null, in);
List<String> packages = jar.getPackages();
jar = new Jar(null, in);
List<String> packages = jar.getPackages();
if (log.isDebugEnabled())
log.debug("Added sources " + sourcesArtifact + " for bundle "
if (log.isDebugEnabled())
log.debug("Added sources " + sourcesArtifact + " for bundle "
+ + artifact + "from source provider " + sourcesProvider);
} catch (Exception e) {
throw new SlcException("Cannot get sources for " + artifact, e);
} finally {
} catch (Exception e) {
throw new SlcException("Cannot get sources for " + artifact, e);
} finally {
}
protected Artifact importZipEntry(Session javaSession, ZipEntry zentry,
}
protected Artifact importZipEntry(Session javaSession, ZipEntry zentry,
- byte[] jarBytes, String groupId) throws RepositoryException {
+ byte[] binaryJarBytes, String groupId) throws RepositoryException {
ByteArrayInputStream in = null;
Node newJarNode;
try {
ByteArrayInputStream in = null;
Node newJarNode;
try {
- in = new ByteArrayInputStream(jarBytes);
+ in = new ByteArrayInputStream(binaryJarBytes);
NameVersion nameVersion = RepoUtils.readNameVersion(in);
if (nameVersion == null) {
return null;
NameVersion nameVersion = RepoUtils.readNameVersion(in);
if (nameVersion == null) {
return null;
Artifact artifact = new DefaultArtifact(groupId,
nameVersion.getName(), "jar", nameVersion.getVersion());
newJarNode = RepoUtils.copyBytesAsArtifact(
Artifact artifact = new DefaultArtifact(groupId,
nameVersion.getName(), "jar", nameVersion.getVersion());
newJarNode = RepoUtils.copyBytesAsArtifact(
- javaSession.getRootNode(), artifact, jarBytes);
+ javaSession.getRootNode(), artifact, binaryJarBytes);
osgiFactory.indexNode(newJarNode);
newJarNode.getSession().save();
if (log.isDebugEnabled())
osgiFactory.indexNode(newJarNode);
newJarNode.getSession().save();
if (log.isDebugEnabled())
+ newJarNode.getPath());
if (sourcesProvider != null)
+ newJarNode.getPath());
if (sourcesProvider != null)
- addSource(javaSession, artifact, jarBytes);
+ addSource(javaSession, artifact, binaryJarBytes);
return artifact;
} finally {
return artifact;
} finally {
}
public void setBeanName(String name) {
}
public void setBeanName(String name) {
+ if (this.name == null) {
+ this.name = name;
+ } else {
+ log.warn("Using explicitely set name " + this.name
+ + " and not bean name " + name);
+ }
}
public String getGroupId() {
}
public String getGroupId() {