]> source.dussan.org Git - archiva.git/commitdiff
add more OSGI search fields
authorOlivier Lamy <olamy@apache.org>
Fri, 16 Sep 2011 15:24:54 +0000 (15:24 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 16 Sep 2011 15:24:54 +0000 (15:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171622 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java

index b72d3753355bd39eb0056e56e44971ec7fb6ec1f..fb5986f56f8fc517d8e4f60ae74e7ea2c9d9f82f 100644 (file)
@@ -186,11 +186,24 @@ public class NexusRepositorySearch
 
         if ( StringUtils.isNotBlank( searchFields.getBundleExportService() ) )
         {
-            q.add( indexer.constructQuery( OSGI.SYMBOLIC_NAME,
+            q.add( indexer.constructQuery( OSGI.EXPORT_SERVICE,
                                            new StringSearchExpression( searchFields.getBundleExportService() ) ),
                    Occur.MUST );
         }
 
+        if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) )
+        {
+            q.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE,
+                                           new StringSearchExpression( searchFields.getBundleImportPackage() ) ),
+                   Occur.MUST );
+        }
+
+        if ( StringUtils.isNotBlank( searchFields.getBundleName() ) )
+        {
+            q.add( indexer.constructQuery( OSGI.NAME, new StringSearchExpression( searchFields.getBundleName() ) ),
+                   Occur.MUST );
+        }
+
         if ( StringUtils.isNotBlank( searchFields.getClassifier() ) )
         {
             q.add(
index 74c5e38ce2c2719dd6a5707c7a5a767015ff27d3..ba1ce7eec4bc5fedb34f495b0f9319faaeda393c 100644 (file)
@@ -76,6 +76,20 @@ public class SearchFields
      */
     private String bundleExportPackage;
 
+    /**
+     * contains osgi metadata import package if available
+     *
+     * @since 1.4
+     */
+    private String bundleImportPackage;
+
+    /**
+     * contains osgi metadata name if available
+     *
+     * @since 1.4
+     */
+    private String bundleName;
+
     /**
      * contains osgi metadata Export-Service if available
      *
@@ -212,6 +226,26 @@ public class SearchFields
         this.classifier = classifier;
     }
 
+    public String getBundleImportPackage()
+    {
+        return bundleImportPackage;
+    }
+
+    public void setBundleImportPackage( String bundleImportPackage )
+    {
+        this.bundleImportPackage = bundleImportPackage;
+    }
+
+    public String getBundleName()
+    {
+        return bundleName;
+    }
+
+    public void setBundleImportName( String bundleName )
+    {
+        this.bundleName = bundleName;
+    }
+
     @Override
     public String toString()
     {
@@ -226,6 +260,8 @@ public class SearchFields
         sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
         sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
         sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
+        sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
+        sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
         sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
         sb.append( ", classifier='" ).append( classifier ).append( '\'' );
         sb.append( '}' );
index 0c331474ea3fa87a1c62cd95b4976af242fc22b4..ca04f297ce34ba78fcd95f6a259e2661b862e3de 100644 (file)
@@ -53,7 +53,10 @@ public class SearchServiceTest
 
         SearchService searchService = getSearchService( authorizationHeader );
 
+        // START SNIPPET: quick-search
         List<Artifact> artifacts = searchService.quickSearch( "commons-logging" );
+        // return all artifacts with groupId OR artifactId
+        // START SNIPPET: quick-search
 
         assertNotNull( artifacts );
         assertTrue( " not 6 results for commons-logging search but " + artifacts.size() + ":" + artifacts,