From 13c799574c26123f1d469acfa242893d34002bfa Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 29 Jul 2008 02:48:33 +0000 Subject: [PATCH] [MRM-892] -instead of using different keywords like 'class:', 'package:' or 'method', just use one keyword for all which is 'bytecode:', user can just use the filtered search for specifics once it is implemented git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@680606 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/IndexJavaPublicMethodsConsumer.java | 2 +- .../archiva/indexer/search/SearchResults.java | 3 ++- .../maven/archiva/web/action/SearchAction.java | 15 ++++++--------- .../WEB-INF/jsp/include/quickSearchForm.jspf | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexJavaPublicMethodsConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexJavaPublicMethodsConsumer.java index 022853a3d..dd0ded398 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexJavaPublicMethodsConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexJavaPublicMethodsConsumer.java @@ -148,7 +148,7 @@ public class IndexJavaPublicMethodsConsumer bytecodeRecord.setFiles( files ); bytecodeRecord.setMethods( mapOfClassesAndMethods.get( METHODS ) ); bytecodeRecord.setArtifact( artifact ); - bytecodeRecord.setRepositoryId( artifact.getModel().getRepositoryId() ); + bytecodeRecord.setRepositoryId( repoContent.getId() ); bytecodeIndex.modifyRecord( bytecodeRecord ); } } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java index 6110374a1..c82097467 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java @@ -81,7 +81,8 @@ public class SearchResults { hit = new SearchResultHit(); } - + + hit.setRepositoryId( bytecode.getRepositoryId() ); hit.addArtifact( bytecode.getArtifact() ); hit.setContext( null ); // TODO: provide context on why this is a valuable hit. diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index b2bda65fe..39c3bb361 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -91,7 +91,7 @@ public class SearchAction private static final String COMPLETE_QUERY_STRING_SEPARATOR = ";"; - private static final String[] BYTECODE_KEYWORDS = new String[] { "class:", "package:", "method:" }; + private static final String BYTECODE_KEYWORD = "bytecode:"; public String quickSearch() throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException @@ -114,7 +114,7 @@ public class SearchAction if( isBytecodeSearch( q ) ) { - results = crossRepoSearch.searchForBytecode( getPrincipal(), selectedRepos, removeKeywords( q ), limits ); + results = crossRepoSearch.searchForBytecode( getPrincipal(), selectedRepos, removeKeyword( q ), limits ); } else { @@ -322,21 +322,18 @@ public class SearchAction private boolean isBytecodeSearch( String queryString ) { - if( queryString.startsWith( BYTECODE_KEYWORDS[0] ) || queryString.startsWith( BYTECODE_KEYWORDS[1] ) || - queryString.startsWith( BYTECODE_KEYWORDS[2] ) ) + if( queryString.startsWith( BYTECODE_KEYWORD ) ) { - return true; + return true; } return false; } - private String removeKeywords( String queryString ) + private String removeKeyword( String queryString ) { String qString = StringUtils.uncapitalize( queryString ); - qString = StringUtils.removeStart( queryString, BYTECODE_KEYWORDS[0] ); - qString = StringUtils.removeStart( qString, BYTECODE_KEYWORDS[1] ); - qString = StringUtils.removeStart( qString, BYTECODE_KEYWORDS[2] ); + qString= StringUtils.remove( queryString, BYTECODE_KEYWORD ); return qString; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf index b37f28cac..14693aa87 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf @@ -33,8 +33,8 @@

Enter your search terms. A variety of data will be searched for your keywords.
- To search for java classes, packages or methods, append the keywords "class:", - "package:" or "method:" before your query. Example, class:MyClass + To search for java classes, packages or methods, append the keyword "bytecode:" + to your query. Example, bytecode:MyClass or bytecode:myMethod

\ No newline at end of file -- 2.39.5