- manifestBinary = fileNode.getProperty(RepoNames.SLC_MANIFEST)
- .getBinary();
- manifestIn = manifestBinary.getStream();
- Manifest manifest = new Manifest(manifestIn);
- Attributes attrs = manifest.getMainAttributes();
-
- if (log.isTraceEnabled())
- for (Object key : attrs.keySet())
- log.trace(key + ": " + attrs.getValue(key.toString()));
-
- if (!attrs.containsKey(new Name(Constants.BUNDLE_SYMBOLICNAME))) {
- log.warn(fileNode + " is not an OSGi bundle");
- return;// not an osgi bundle
- }
-
- fileNode.addMixin(RepoTypes.SLC_BUNDLE_ARTIFACT);
-
- // symbolic name
- String symbolicName = attrs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- // make sure there is no directive
- symbolicName = symbolicName.split(";")[0];
- fileNode.setProperty(RepoNames.SLC_SYMBOLIC_NAME, symbolicName);
-
- // direct mapping
- addAttr(Constants.BUNDLE_SYMBOLICNAME, fileNode, attrs);
- addAttr(Constants.BUNDLE_NAME, fileNode, attrs);
- addAttr(Constants.BUNDLE_DESCRIPTION, fileNode, attrs);
- addAttr(Constants.BUNDLE_MANIFESTVERSION, fileNode, attrs);
- addAttr(Constants.BUNDLE_CATEGORY, fileNode, attrs);
- addAttr(Constants.BUNDLE_ACTIVATIONPOLICY, fileNode, attrs);
- addAttr(Constants.BUNDLE_COPYRIGHT, fileNode, attrs);
- addAttr(Constants.BUNDLE_VENDOR, fileNode, attrs);
- addAttr("Bundle-License", fileNode, attrs);
- addAttr(Constants.BUNDLE_DOCURL, fileNode, attrs);
- addAttr(Constants.BUNDLE_CONTACTADDRESS, fileNode, attrs);
- addAttr(Constants.BUNDLE_ACTIVATOR, fileNode, attrs);
- addAttr(Constants.BUNDLE_UPDATELOCATION, fileNode, attrs);
- addAttr(Constants.BUNDLE_LOCALIZATION, fileNode, attrs);
-
- // required execution environment
- if (attrs.containsKey(new Name(
- Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)))
- fileNode.setProperty(
- RepoNames.SLC_
- + Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT,
- attrs.getValue(
- Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)
- .split(","));
-
- // bundle classpath
- if (attrs.containsKey(new Name(Constants.BUNDLE_CLASSPATH)))
- fileNode.setProperty(RepoNames.SLC_
- + Constants.BUNDLE_CLASSPATH,
- attrs.getValue(Constants.BUNDLE_CLASSPATH).split(","));
-
- // version
- Version version = new Version(
- attrs.getValue(Constants.BUNDLE_VERSION));
- fileNode.setProperty(RepoNames.SLC_BUNDLE_VERSION,
- version.toString());
- cleanSubNodes(fileNode, RepoNames.SLC_ + Constants.BUNDLE_VERSION);
- Node bundleVersionNode = fileNode.addNode(RepoNames.SLC_
- + Constants.BUNDLE_VERSION, RepoTypes.SLC_OSGI_VERSION);
- mapOsgiVersion(version, bundleVersionNode);
-
- // fragment
- cleanSubNodes(fileNode, RepoNames.SLC_ + Constants.FRAGMENT_HOST);
- if (attrs.containsKey(new Name(Constants.FRAGMENT_HOST))) {
- String fragmentHost = attrs.getValue(Constants.FRAGMENT_HOST);
- String[] tokens = fragmentHost.split(";");
- Node node = fileNode.addNode(RepoNames.SLC_
- + Constants.FRAGMENT_HOST, RepoTypes.SLC_FRAGMENT_HOST);
- node.setProperty(RepoNames.SLC_SYMBOLIC_NAME, tokens[0]);
- for (int i = 1; i < tokens.length; i++) {
- if (tokens[i]
- .startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
- node.setProperty(RepoNames.SLC_BUNDLE_VERSION,
- attributeValue(tokens[i]));
- }
- }
- }
-
- // imported packages
- cleanSubNodes(fileNode, RepoNames.SLC_ + Constants.IMPORT_PACKAGE);
- if (attrs.containsKey(new Name(Constants.IMPORT_PACKAGE))) {
- String importPackages = attrs
- .getValue(Constants.IMPORT_PACKAGE);
- List<String> packages = parsePackages(importPackages);
- for (String pkg : packages) {
- String[] tokens = pkg.split(";");
- Node node = fileNode.addNode(RepoNames.SLC_
- + Constants.IMPORT_PACKAGE,
- RepoTypes.SLC_IMPORTED_PACKAGE);
- node.setProperty(RepoNames.SLC_NAME, tokens[0]);
- for (int i = 1; i < tokens.length; i++) {
- if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
- node.setProperty(RepoNames.SLC_VERSION,
- attributeValue(tokens[i]));
- } else if (tokens[i]
- .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
- node.setProperty(
- RepoNames.SLC_OPTIONAL,
- directiveValue(tokens[i]).equals(
- Constants.RESOLUTION_OPTIONAL));
- }
- }
- }
- }
-
- // dynamic import package
- cleanSubNodes(fileNode, RepoNames.SLC_
- + Constants.DYNAMICIMPORT_PACKAGE);
- if (attrs.containsKey(new Name(Constants.DYNAMICIMPORT_PACKAGE))) {
- String importPackages = attrs
- .getValue(Constants.DYNAMICIMPORT_PACKAGE);
- List<String> packages = parsePackages(importPackages);
- for (String pkg : packages) {
- String[] tokens = pkg.split(";");
- Node node = fileNode.addNode(RepoNames.SLC_
- + Constants.DYNAMICIMPORT_PACKAGE,
- RepoTypes.SLC_DYNAMIC_IMPORTED_PACKAGE);
- node.setProperty(RepoNames.SLC_NAME, tokens[0]);
- for (int i = 1; i < tokens.length; i++) {
- if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
- node.setProperty(RepoNames.SLC_VERSION,
- attributeValue(tokens[i]));
- }
- }
- }
- }
-
- // exported packages
- cleanSubNodes(fileNode, RepoNames.SLC_ + Constants.EXPORT_PACKAGE);
- if (attrs.containsKey(new Name(Constants.EXPORT_PACKAGE))) {
- String exportPackages = attrs
- .getValue(Constants.EXPORT_PACKAGE);
- List<String> packages = parsePackages(exportPackages);
- for (String pkg : packages) {
- String[] tokens = pkg.split(";");
- Node node = fileNode.addNode(RepoNames.SLC_
- + Constants.EXPORT_PACKAGE,
- RepoTypes.SLC_EXPORTED_PACKAGE);
- node.setProperty(RepoNames.SLC_NAME, tokens[0]);
- // TODO: are these cleans really necessary?
- cleanSubNodes(node, RepoNames.SLC_USES);
- cleanSubNodes(node, RepoNames.SLC_VERSION);
- for (int i = 1; i < tokens.length; i++) {
- if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
- String versionStr = attributeValue(tokens[i]);
- Node versionNode = node.addNode(
- RepoNames.SLC_VERSION,
- RepoTypes.SLC_OSGI_VERSION);
- mapOsgiVersion(new Version(versionStr), versionNode);
- } else if (tokens[i]
- .startsWith(Constants.USES_DIRECTIVE)) {
- String usedPackages = directiveValue(tokens[i]);
- // log.debug("uses='" + usedPackages + "'");
- for (String usedPackage : usedPackages.split(",")) {
- // log.debug("usedPackage='" + usedPackage +
- // "'");
- Node usesNode = node.addNode(
- RepoNames.SLC_USES,
- RepoTypes.SLC_JAVA_PACKAGE);
- usesNode.setProperty(RepoNames.SLC_NAME,
- usedPackage);
- }
- }
- }
- }