From 3332083d45ef4dfb9c1eeabf0239057c714fb269 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 5 Mar 2012 15:52:56 +0000 Subject: [PATCH] add search for osgi: Import-Package and Require-Bundle are now searchable git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1297102 13f79535-47bb-0310-9956-ffa450edef68 --- .../indexer/search/NexusRepositorySearch.java | 14 +++++++ .../archiva/indexer/search/SearchFields.java | 20 ++++++++++ .../archiva/rest/api/model/SearchRequest.java | 40 ++++++++++++++++++- .../apache/archiva/i18n/default.properties | 2 + .../src/main/webapp/js/archiva/search.js | 4 ++ .../webapp/js/archiva/templates/search.html | 14 +++++++ 6 files changed, 93 insertions(+), 1 deletion(-) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java index 58cfea4cf..3d84602ae 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java @@ -223,6 +223,20 @@ public class NexusRepositorySearch Occur.MUST ); } + if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) ) + { + q.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE, + new StringSearchExpression( searchFields.getBundleImportPackage() ) ), + Occur.MUST ); + } + + if ( StringUtils.isNotBlank( searchFields.getBundleRequireBundle() ) ) + { + q.add( indexer.constructQuery( OSGI.REQUIRE_BUNDLE, + new StringSearchExpression( searchFields.getBundleRequireBundle() ) ), + Occur.MUST ); + } + if ( StringUtils.isNotBlank( searchFields.getClassifier() ) ) { q.add( diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java index d7d00093b..cd34f701e 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java @@ -97,8 +97,17 @@ public class SearchFields */ private String bundleExportService; + + /** + * contains osgi metadata Require-Bundle if available + * + * @since 1.4-M3 + */ + private String bundleRequireBundle; + /** * not return artifact with file extension pom + * * @since 1.4-M2 */ private boolean includePomArtifacts = false; @@ -262,6 +271,16 @@ public class SearchFields this.includePomArtifacts = includePomArtifacts; } + public String getBundleRequireBundle() + { + return bundleRequireBundle; + } + + public void setBundleRequireBundle( String bundleRequireBundle ) + { + this.bundleRequireBundle = bundleRequireBundle; + } + @Override public String toString() { @@ -279,6 +298,7 @@ public class SearchFields sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); sb.append( ", classifier='" ).append( classifier ).append( '\'' ); sb.append( '}' ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/SearchRequest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/SearchRequest.java index 6d82b5b44..b391650e2 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/SearchRequest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/SearchRequest.java @@ -28,7 +28,7 @@ public class SearchRequest /** * @since 1.4-M3 - * to be able to search with a query on selected repositories + * to be able to search with a query on selected repositories */ private String queryTerms; @@ -91,10 +91,26 @@ public class SearchRequest */ private String bundleExportService; + /** + * contains osgi metadata Import-Package if available + * + * @since 1.4-M3 + */ + private String bundleImportPackage; + + + /** + * contains osgi metadata Require-Bundle if available + * + * @since 1.4-M3 + */ + private String bundleRequireBundle; + private String classifier; /** * not return artifact with file extension pom + * * @since 1.4-M2 */ private boolean includePomArtifacts = false; @@ -246,6 +262,26 @@ public class SearchRequest this.queryTerms = queryTerms; } + public String getBundleImportPackage() + { + return bundleImportPackage; + } + + public void setBundleImportPackage( String bundleImportPackage ) + { + this.bundleImportPackage = bundleImportPackage; + } + + public String getBundleRequireBundle() + { + return bundleRequireBundle; + } + + public void setBundleRequireBundle( String bundleRequireBundle ) + { + this.bundleRequireBundle = bundleRequireBundle; + } + @Override public String toString() { @@ -262,6 +298,8 @@ public class SearchRequest sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); + sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); sb.append( ", classifier='" ).append( classifier ).append( '\'' ); sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); sb.append( '}' ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 9d53f29d7..19dc750d4 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -236,6 +236,8 @@ search.artifact.search.form.query.bundleSymbolicName=Symbolic Name search.artifact.search.form.query.bundleVersion=Bundle Version search.artifact.search.form.query.bundleExportPackage=Export Package search.artifact.search.form.query.bundleExportService=Export Service +search.artifact.search.form.query.bundleImportPackage=Import Package +search.artifact.search.form.query.bundleRequireBundle=Require Bundle #login login.username.placehoder=Username diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index 19b07c23f..9f372f277 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -652,6 +652,10 @@ $(function() { //private String bundleExportService; this.bundleExportService=ko.observable(); + this.bundleImportPackage=ko.observable(); + + this.bundleRequireBundle=ko.observable(); + //private String classifier; this.classifier=ko.observable(); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html index 04941d1d7..4405a214d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html @@ -302,6 +302,20 @@ data-bind="value: searchRequest().bundleExportService"/> +
+ +
+ +
+
+
+ +
+ +
+
-- 2.39.5