You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2011/08/17 21:05:41 UTC
svn commit: r1158871 - in /maven/indexer/trunk/indexer-core/src:
main/java/org/apache/maven/index/ main/java/org/apache/maven/index/creator/
test/java/org/apache/maven/index/creator/
Author: olamy
Date: Wed Aug 17 19:05:41 2011
New Revision: 1158871
URL: http://svn.apache.org/viewvc?rev=1158871&view=rev
Log:
[MINDEXER-36] index osgi metadatas.
Add support for :
* Bundle-Description
* Bundle-Name
* Bundle-License
* Bundle-DocURL
* Import-Package
Modified:
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java
maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java?rev=1158871&r1=1158870&r2=1158871&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java Wed Aug 17 19:05:41 2011
@@ -244,6 +244,40 @@ public class ArtifactInfo
*/
public String bundleExportService;
+ /**
+ * contains osgi metadata Bundle-Description if available
+ * @since 4.1.2
+ */
+ public String bundleDescription;
+
+ /**
+ * contains osgi metadata Bundle-Name if available
+ * @since 4.1.2
+ */
+ public String bundleName;
+
+ /**
+ * contains osgi metadata Bundle-License if available
+ * @since 4.1.2
+ */
+ public String bundleLicense;
+
+ /**
+ * contains osgi metadata Bundle-DocURL if available
+ * @since 4.1.2
+ */
+ public String bundleDocUrl;
+
+ /**
+ * contains osgi metadata Import-Package if available
+ * @since 4.1.2
+ */
+ public String bundleImportPackage;
+
+
+
+
+
private String uinfo = null;
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java?rev=1158871&r1=1158870&r2=1158871&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java Wed Aug 17 19:05:41 2011
@@ -19,7 +19,7 @@ package org.apache.maven.index;
*/
/**
- * Maven ontology.
+ * OSGI ontology.
*
* @author Olivier Lamy
* @since 4.1.1
@@ -40,4 +40,15 @@ public interface OSGI
Field EXPORT_SERVICE = new Field( null, OSGI_NAMESPACE, "exportService", "Bundle Export-Service" );
+ Field DESCRIPTION = new Field( null, OSGI_NAMESPACE, "bundleDescription", "Bundle-Description" );
+
+ Field NAME = new Field( null, OSGI_NAMESPACE, "bundleName", "Bundle-Name" );
+
+ Field LICENSE = new Field( null, OSGI_NAMESPACE, "bundleLicense", "Bundle-License" );
+
+ Field DOCURL = new Field( null, OSGI_NAMESPACE, "bundleDocUrl", "Bundle-DocURL" );
+
+ Field IMPORT_PACKAGE = new Field( null, OSGI_NAMESPACE, "importPackage", "Import-Package" );
+
+
}
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java?rev=1158871&r1=1158870&r2=1158871&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java Wed Aug 17 19:05:41 2011
@@ -90,10 +90,43 @@ public class OSGIArtifactIndexCreator
new IndexerField( OSGI.EXPORT_SERVICE, IndexerFieldVersion.V4, BES, "Export-Service (indexed, stored)",
Field.Store.YES, Field.Index.ANALYZED );
+
+ private static final String BD = "Bundle-Description";
+
+ public static final IndexerField FLD_BUNDLE_DESCRIPTION =
+ new IndexerField( OSGI.DESCRIPTION, IndexerFieldVersion.V4, BD, "Bundle-Description (indexed, stored)",
+ Field.Store.YES, Field.Index.ANALYZED );
+
+ private static final String BN = "Bundle-Name";
+
+ public static final IndexerField FLD_BUNDLE_NAME =
+ new IndexerField( OSGI.NAME, IndexerFieldVersion.V4, BN, "Bundle-Name (indexed, stored)", Field.Store.YES,
+ Field.Index.ANALYZED );
+
+ private static final String BL = "Bundle-License";
+
+ public static final IndexerField FLD_BUNDLE_LICENSE =
+ new IndexerField( OSGI.LICENSE, IndexerFieldVersion.V4, BL, "Bundle-License (indexed, stored)", Field.Store.YES,
+ Field.Index.ANALYZED );
+
+ private static final String BDU = "Bundle-DocURL";
+
+ public static final IndexerField FLD_BUNDLE_DOCURL =
+ new IndexerField( OSGI.DOCURL, IndexerFieldVersion.V4, BDU, "Bundle-DocURL (indexed, stored)", Field.Store.YES,
+ Field.Index.ANALYZED );
+
+ private static final String BIP = "Import-Package";
+
+ public static final IndexerField FLD_BUNDLE_IMPORT_PACKAGE =
+ new IndexerField( OSGI.IMPORT_PACKAGE, IndexerFieldVersion.V4, BIP, "Import-Package (indexed, stored)",
+ Field.Store.YES, Field.Index.ANALYZED );
+
+
public Collection<IndexerField> getIndexerFields()
{
return Arrays.asList( FLD_BUNDLE_SYMBOLIC_NAME, FLD_BUNDLE_VERSION, FLD_BUNDLE_EXPORT_PACKAGE,
- FLD_BUNDLE_EXPORT_SERVIVE );
+ FLD_BUNDLE_EXPORT_SERVIVE, FLD_BUNDLE_DESCRIPTION, FLD_BUNDLE_NAME, FLD_BUNDLE_LICENSE,
+ FLD_BUNDLE_DOCURL, FLD_BUNDLE_IMPORT_PACKAGE );
}
public OSGIArtifactIndexCreator()
@@ -139,6 +172,30 @@ public class OSGIArtifactIndexCreator
document.add( FLD_BUNDLE_EXPORT_SERVIVE.toField( artifactInfo.bundleExportService ) );
}
+ if ( artifactInfo.bundleDescription != null )
+ {
+ document.add( FLD_BUNDLE_DESCRIPTION.toField( artifactInfo.bundleDescription ) );
+ }
+
+ if ( artifactInfo.bundleName != null )
+ {
+ document.add( FLD_BUNDLE_NAME.toField( artifactInfo.bundleName ) );
+ }
+
+ if ( artifactInfo.bundleLicense != null )
+ {
+ document.add( FLD_BUNDLE_LICENSE.toField( artifactInfo.bundleLicense ) );
+ }
+
+ if ( artifactInfo.bundleDocUrl != null )
+ {
+ document.add( FLD_BUNDLE_DOCURL.toField( artifactInfo.bundleDocUrl ) );
+ }
+
+ if ( artifactInfo.bundleImportPackage != null )
+ {
+ document.add( FLD_BUNDLE_IMPORT_PACKAGE.toField( artifactInfo.bundleImportPackage ) );
+ }
}
public boolean updateArtifactInfo( Document document, ArtifactInfo artifactInfo )
@@ -183,6 +240,59 @@ public class OSGIArtifactIndexCreator
}
+ String bundleDescription = document.get( FLD_BUNDLE_DESCRIPTION.getKey() );
+
+ if ( bundleDescription != null )
+ {
+ artifactInfo.bundleDescription = bundleDescription;
+
+ updated = true;
+
+ }
+
+
+ String bundleName = document.get( FLD_BUNDLE_NAME.getKey() );
+
+ if ( bundleName != null )
+ {
+ artifactInfo.bundleName = bundleName;
+
+ updated = true;
+
+ }
+
+
+ String bundleLicense = document.get( FLD_BUNDLE_LICENSE.getKey() );
+
+ if ( bundleLicense != null )
+ {
+ artifactInfo.bundleLicense = bundleLicense;
+
+ updated = true;
+
+ }
+
+ String bundleDocUrl = document.get( FLD_BUNDLE_DOCURL.getKey() );
+
+ if ( bundleDocUrl != null )
+ {
+ artifactInfo.bundleDocUrl = bundleDocUrl;
+
+ updated = true;
+
+ }
+
+ String bundleImportPackage = document.get( FLD_BUNDLE_IMPORT_PACKAGE.getKey() );
+
+ if ( bundleImportPackage != null )
+ {
+ artifactInfo.bundleImportPackage = bundleImportPackage;
+
+ updated = true;
+
+ }
+
+
return updated;
}
@@ -253,6 +363,61 @@ public class OSGIArtifactIndexCreator
ai.bundleExportService = null;
}
+ attValue = mainAttributes.getValue( BD );
+ if ( StringUtils.isNotBlank( attValue ) )
+ {
+ ai.bundleDescription = attValue;
+ updated = true;
+ }
+ else
+ {
+ ai.bundleDescription = null;
+ }
+
+ attValue = mainAttributes.getValue( BN );
+ if ( StringUtils.isNotBlank( attValue ) )
+ {
+ ai.bundleName = attValue;
+ updated = true;
+ }
+ else
+ {
+ ai.bundleName = null;
+ }
+
+ attValue = mainAttributes.getValue( BL );
+ if ( StringUtils.isNotBlank( attValue ) )
+ {
+ ai.bundleLicense = attValue;
+ updated = true;
+ }
+ else
+ {
+ ai.bundleLicense = null;
+ }
+
+ attValue = mainAttributes.getValue( BDU );
+ if ( StringUtils.isNotBlank( attValue ) )
+ {
+ ai.bundleDocUrl = attValue;
+ updated = true;
+ }
+ else
+ {
+ ai.bundleDocUrl = null;
+ }
+
+ attValue = mainAttributes.getValue( BIP );
+ if ( StringUtils.isNotBlank( attValue ) )
+ {
+ ai.bundleImportPackage = attValue;
+ updated = true;
+ }
+ else
+ {
+ ai.bundleImportPackage = null;
+ }
+
}
}
}
Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java?rev=1158871&r1=1158870&r2=1158871&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java Wed Aug 17 19:05:41 2011
@@ -95,6 +95,17 @@ public class OSGIArtifactIndexCreatorTes
assertEquals(
"org.apache.karaf.features.command.completers;uses:=\"org.apache.karaf.features,org.apache.karaf.shell.console,org.apache.karaf.shell.console.completer\";version=\"2.2.2\",org.apache.karaf.features.command;uses:=\"org.apache.felix.gogo.commands,org.apache.karaf.features,org.apache.karaf.shell.console,org.osgi.framework,org.apache.felix.service.command\";version=\"2.2.2\"",
artifactContext.getArtifactInfo().bundleExportPackage );
+
+ ArtifactInfo ai = artifactContext.getArtifactInfo();
+
+ assertEquals( "This bundle provides the Karaf shell commands to manipulate features.", ai.bundleDescription );
+ assertEquals( "Apache Karaf :: Features :: Command", ai.bundleName );
+ assertEquals( "http://www.apache.org/licenses/LICENSE-2.0.txt", ai.bundleLicense );
+ assertEquals( "http://www.apache.org/", ai.bundleDocUrl );
+
+ assertEquals(
+ "javax.management,javax.management.loading,org.apache.felix.gogo.commands;version=\"[0.6,1)\",org.apache.felix.service.command;status=provisional;version=\"[0.6,1)\",org.apache.karaf.features;version=\"[2.2,3)\",org.apache.karaf.shell.console;version=\"[2.2,3)\",org.apache.karaf.shell.console.completer;version=\"[2.2,3)\",org.osgi.framework;version=\"[1.5,2)\",org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\"",
+ ai.bundleImportPackage );
}
@@ -223,6 +234,16 @@ public class OSGIArtifactIndexCreatorTes
assertEquals( "org.apache.karaf.features.command", ai.bundleSymbolicName );
assertEquals( "2.2.2", ai.bundleVersion );
+ assertEquals( "This bundle provides the Karaf shell commands to manipulate features.",
+ ai.bundleDescription );
+ assertEquals( "Apache Karaf :: Features :: Command", ai.bundleName );
+ assertEquals( "http://www.apache.org/licenses/LICENSE-2.0.txt", ai.bundleLicense );
+ assertEquals( "http://www.apache.org/", ai.bundleDocUrl );
+
+ assertEquals(
+ "javax.management,javax.management.loading,org.apache.felix.gogo.commands;version=\"[0.6,1)\",org.apache.felix.service.command;status=provisional;version=\"[0.6,1)\",org.apache.karaf.features;version=\"[2.2,3)\",org.apache.karaf.shell.console;version=\"[2.2,3)\",org.apache.karaf.shell.console.completer;version=\"[2.2,3)\",org.osgi.framework;version=\"[1.5,2)\",org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\"",
+ ai.bundleImportPackage );
+
}
finally
{
@@ -252,7 +273,7 @@ public class OSGIArtifactIndexCreatorTes
assertEquals( 1, response.getResults().size() );
ArtifactInfo ai = response.getResults().iterator().next();
- System.out.println("ai " + ai );
+ System.out.println( "ai " + ai );
assertEquals( "org.apache.felix", ai.groupId );
assertEquals( "org.apache.felix.bundlerepository", ai.artifactId );