[MRM-1501] search on artifacts with OSGI Metadatas fields

modify SearchResultSearchResultHitSearchResultHit to return osgi metadata

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1158023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-08-15 21:28:13 +00:00
parent c1abddcaf9
commit 7a354f09ed
3 changed files with 80 additions and 2 deletions

View File

@ -322,6 +322,10 @@ public class NexusRepositorySearch
//hit.setRepositoryId( artifactInfo.repository ); //hit.setRepositoryId( artifactInfo.repository );
hit.setUrl( artifactInfo.repository + "/" + artifactInfo.fname ); hit.setUrl( artifactInfo.repository + "/" + artifactInfo.fname );
hit.addVersion( artifactInfo.version ); hit.addVersion( artifactInfo.version );
hit.setBundleExportPackage( artifactInfo.bundleExportPackage );
hit.setBundleExportService( artifactInfo.bundleExportService );
hit.setBundleSymbolicName( artifactInfo.bundleSymbolicName );
hit.setBundleVersion( artifactInfo.bundleVersion );
} }
results.addHit( id, hit ); results.addHit( id, hit );

View File

@ -48,6 +48,35 @@ public class SearchResultHit
private List<String> versions = new ArrayList<String>(); private List<String> versions = new ArrayList<String>();
/**
* contains osgi metadata Bundle-Version if available
*
* @since 1.4
*/
private String bundleVersion;
/**
* contains osgi metadata Bundle-SymbolicName if available
*
* @since 1.4
*/
private String bundleSymbolicName;
/**
* contains osgi metadata Export-Package if available
*
* @since 1.4
*/
private String bundleExportPackage;
/**
* contains osgi metadata Export-Service if available
*
* @since 1.4
*/
private String bundleExportService;
public String getContext() public String getContext()
{ {
return context; return context;
@ -128,6 +157,46 @@ public class SearchResultHit
versions.add( version ); versions.add( version );
} }
public String getBundleVersion()
{
return bundleVersion;
}
public void setBundleVersion( String bundleVersion )
{
this.bundleVersion = bundleVersion;
}
public String getBundleSymbolicName()
{
return bundleSymbolicName;
}
public void setBundleSymbolicName( String bundleSymbolicName )
{
this.bundleSymbolicName = bundleSymbolicName;
}
public String getBundleExportPackage()
{
return bundleExportPackage;
}
public void setBundleExportPackage( String bundleExportPackage )
{
this.bundleExportPackage = bundleExportPackage;
}
public String getBundleExportService()
{
return bundleExportService;
}
public void setBundleExportService( String bundleExportService )
{
this.bundleExportService = bundleExportService;
}
@Override @Override
public String toString() public String toString()
{ {

View File

@ -19,7 +19,6 @@ package org.apache.archiva.indexer.search;
* under the License. * under the License.
*/ */
import junit.framework.TestCase;
import org.junit.Test; import org.junit.Test;
import java.io.File; import java.io.File;
@ -48,7 +47,7 @@ public class NexusRepositorySearchOSGITest
archivaConfigControl.replay(); archivaConfigControl.replay();
SearchFields searchFields = new SearchFields( ); SearchFields searchFields = new SearchFields();
searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" ); searchFields.setBundleSymbolicName( "org.apache.felix.bundlerepository" );
searchFields.setBundleVersion( "1.6.6" ); searchFields.setBundleVersion( "1.6.6" );
searchFields.setRepositories( selectedRepos ); searchFields.setRepositories( selectedRepos );
@ -65,6 +64,12 @@ public class NexusRepositorySearchOSGITest
assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() ); assertEquals( "org.apache.felix.bundlerepository", hit.getArtifactId() );
assertEquals( "1.6.6", hit.getVersions().get( 0 ) ); assertEquals( "1.6.6", hit.getVersions().get( 0 ) );
assertEquals( "org.apache.felix.bundlerepository;uses:=\"org.osgi.framework\";version=\"2.0\"",
hit.getBundleExportPackage() );
assertEquals( "org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin",
hit.getBundleExportService() );
assertEquals( "org.apache.felix.bundlerepository", hit.getBundleSymbolicName() );
assertEquals( "1.6.6", hit.getBundleVersion() );
} }
} }