in upgrade/src/main/java/org/apache/sling/upgrade/BundleEntry.java [50:94]
public BundleEntry(JarEntry entry, InputStream is, BundleContext bundleContext) throws IOException {
super(entry, is);
String[] segments = entry.getName().split("\\/");
String startStr = segments[2];
if (segments[1].contains(".")) {
runmode = StringUtils.substringAfter(segments[1], ".");
} else {
runmode = null;
}
start = Integer.parseInt(startStr, 10);
log.debug("Loaded start level {}", start);
try (JarInputStream bundleIs = new JarInputStream(new ByteArrayInputStream(this.getContents()))) {
Manifest manifest = bundleIs.getManifest();
Attributes attributes = manifest.getMainAttributes();
if (attributes.getValue(BUNDLE_SYMBOLIC_NAME).contains(";")) {
symbolicName = StringUtils.substringBefore(attributes.getValue(BUNDLE_SYMBOLIC_NAME), ";");
} else {
symbolicName = attributes.getValue(BUNDLE_SYMBOLIC_NAME);
}
log.debug("Loaded symbolic name: {}", symbolicName);
version = new Version(attributes.getValue("Bundle-Version"));
log.debug("Loaded version: {}", version);
}
Bundle currentBundle = null;
for (Bundle b : bundleContext.getBundles()) {
if (b.getSymbolicName().equals(this.symbolicName)) {
currentBundle = b;
}
}
if (currentBundle != null) {
installed = true;
if (currentBundle.getVersion().compareTo(version) < 0) {
updated = true;
} else {
updated = false;
}
} else {
installed = false;
updated = true;
}
}