if (contextPath == null) {
// the bundle is not a web bundle
continue;
}
WebBundle webBundle = new WebBundle();
contextPath.trim();
// get the bundle name
String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
// if there is no name, then default to symbolic name
name = (name == null) ? bundle.getSymbolicName() : name;
// if there is no symbolic name, resort to location
name = (name == null) ? bundle.getLocation() : name;
// get the bundle version
String version = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
name = ((version != null)) ? name + " (" + version + ")" : name;
long bundleId = bundle.getBundleId();
int level = bundle.adapt(BundleStartLevel.class).getStartLevel();
if (!contextPath.startsWith("/")) {
contextPath = "/" + contextPath;
}
webBundle.setBundleId(bundleId);
webBundle.setName(name);
webBundle.setContextPath(contextPath);
webBundle.setLevel(level);
webBundle.setState(getStateString(bundle));
webBundle.setWebState(state(bundle.getBundleId()));
webBundles.add(webBundle);
}
}