+ /** Read the OSGi {@link NameVersion} */
+ public static NameVersion readNameVersion(Manifest manifest) {
+ BasicNameVersion nameVersion = new BasicNameVersion();
+ nameVersion.setName(manifest.getMainAttributes().getValue(
+ Constants.BUNDLE_SYMBOLICNAME));
+
+ // Skip additional specs such as
+ // ; singleton:=true
+ if (nameVersion.getName().indexOf(';') > -1) {
+ nameVersion
+ .setName(new StringTokenizer(nameVersion.getName(), " ;")
+ .nextToken());
+ }
+
+ nameVersion.setVersion(manifest.getMainAttributes().getValue(
+ Constants.BUNDLE_VERSION));
+
+ return nameVersion;
+ }
+
+ /*
+ * DATA MODEL
+ */
+ /** The artifact described by this node */
+ public static Artifact asArtifact(Node node) throws RepositoryException {
+ if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+ // FIXME update data model to store packaging at this level
+ String extension = "jar";
+ return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
+ .getString(),
+ node.getProperty(SLC_ARTIFACT_ID).getString(), extension,
+ node.getProperty(SLC_ARTIFACT_VERSION).getString());
+ } else if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+ return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
+ .getString(),
+ node.getProperty(SLC_ARTIFACT_ID).getString(), node
+ .getProperty(SLC_ARTIFACT_CLASSIFIER).getString(),
+ node.getProperty(SLC_ARTIFACT_EXTENSION).getString(), node
+ .getProperty(SLC_ARTIFACT_VERSION).getString());
+ } else {
+ throw new SlcException("Unsupported node type for " + node);
+ }
+ }
+