diff options
author | Olivier Lamy <olamy@apache.org> | 2011-11-17 21:29:44 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-11-17 21:29:44 +0000 |
commit | 988f8b45f3ae4c2e2d99e38c64e1d2ef5273d37f (patch) | |
tree | d4b292e28d1350b964b71d655fb46dc864c06a5f | |
parent | 6eb766e9d96a71fe8c6be5cd5caf6b83078f2c5f (diff) | |
download | archiva-988f8b45f3ae4c2e2d99e38c64e1d2ef5273d37f.tar.gz archiva-988f8b45f3ae4c2e2d99e38c64e1d2ef5273d37f.zip |
includePom in index search results configurable: false by default
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1203376 13f79535-47bb-0310-9956-ffa450edef68
7 files changed, 83 insertions, 34 deletions
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 1f1b1c798..81b76ee5f 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 @@ -124,7 +124,7 @@ public class NexusRepositorySearch // we retun only artifacts without classifier in quick search, olamy cannot find a way to say with this field empty // FIXME cannot find a way currently to setup this in constructQuery !!! - return search( limits, q, indexingContextIds, NoClassifierArtifactInfoFiler.LIST, principal, selectedRepos ); + return search( limits, q, indexingContextIds, NoClassifierArtifactInfoFiler.LIST, selectedRepos, false ); } @@ -235,13 +235,13 @@ public class NexusRepositorySearch throw new RepositorySearchException( "No search fields set." ); } - return search( limits, q, indexingContextIds, Collections.<ArtifactInfoFiler>emptyList(), principal, - searchFields.getRepositories() ); + return search( limits, q, indexingContextIds, Collections.<ArtifactInfoFiler>emptyList(), + searchFields.getRepositories(), searchFields.isIncludePomArtifacts() ); } private SearchResults search( SearchResultLimits limits, BooleanQuery q, List<String> indexingContextIds, - List<? extends ArtifactInfoFiler> filters, String principal, - List<String> selectedRepos ) + List<? extends ArtifactInfoFiler> filters, + List<String> selectedRepos, boolean includePoms) throws RepositorySearchException { @@ -259,7 +259,7 @@ public class NexusRepositorySearch return results; } - return convertToSearchResults( response, limits, filters, principal, selectedRepos ); + return convertToSearchResults( response, limits, filters, selectedRepos, includePoms ); } catch ( IOException e ) { @@ -449,7 +449,7 @@ public class NexusRepositorySearch private SearchResults convertToSearchResults( FlatSearchResponse response, SearchResultLimits limits, List<? extends ArtifactInfoFiler> artifactInfoFilers, - String principal, List<String> selectedRepos ) + List<String>selectedRepos, boolean includePoms) throws RepositoryAdminException { SearchResults results = new SearchResults(); @@ -457,7 +457,7 @@ public class NexusRepositorySearch for ( ArtifactInfo artifactInfo : artifactInfos ) { - if ( StringUtils.equalsIgnoreCase( "pom", artifactInfo.fextension ) ) + if ( StringUtils.equalsIgnoreCase( "pom", artifactInfo.fextension ) && !includePoms ) { continue; } @@ -500,6 +500,7 @@ public class NexusRepositorySearch hit.setPrefix( artifactInfo.prefix ); hit.setPackaging( artifactInfo.packaging ); hit.setClassifier( artifactInfo.classifier ); + hit.setFileExtension( artifactInfo.fextension ); hit.setUrl( getBaseUrl( artifactInfo, selectedRepos ) ); } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java index e2a541e00..4879ee353 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java @@ -29,7 +29,7 @@ import java.util.Set; public interface RepositorySearch { /** - * Quick search. + * Quick search by won't return artifact with file extension pom * * @param principal * @param selectedRepos 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 ca99d6b80..d7d00093b 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,6 +97,12 @@ public class SearchFields */ private String bundleExportService; + /** + * not return artifact with file extension pom + * @since 1.4-M2 + */ + private boolean includePomArtifacts = false; + private String classifier; public SearchFields() @@ -246,6 +252,16 @@ public class SearchFields this.bundleName = bundleName; } + public boolean isIncludePomArtifacts() + { + return includePomArtifacts; + } + + public void setIncludePomArtifacts( boolean includePomArtifacts ) + { + this.includePomArtifacts = includePomArtifacts; + } + @Override public String toString() { @@ -263,6 +279,7 @@ public class SearchFields sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); sb.append( ", classifier='" ).append( classifier ).append( '\'' ); sb.append( '}' ); return sb.toString(); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java index 8a2a76c97..7eac34c14 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java @@ -129,6 +129,12 @@ public class SearchResultHit private String classifier; + /** + * file extension of the search result + * @since 1.4-M2 + */ + private String fileExtension; + public String getContext() { return context; @@ -344,6 +350,16 @@ public class SearchResultHit this.classifier = classifier; } + public String getFileExtension() + { + return fileExtension; + } + + public void setFileExtension( String fileExtension ) + { + this.fileExtension = fileExtension; + } + @Override public String toString() { @@ -369,6 +385,7 @@ public class SearchResultHit sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); sb.append( ", classifier='" ).append( classifier ).append( '\'' ); + sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java index bcb5fa436..e4e403267 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java @@ -127,6 +127,12 @@ public class Artifact private String packaging; + /** + * file extension of the search result + * @since 1.4-M2 + */ + private String fileExtension; + public Artifact() { @@ -334,6 +340,15 @@ public class Artifact this.packaging = packaging; } + public String getFileExtension() + { + return fileExtension; + } + + public void setFileExtension( String fileExtension ) + { + this.fileExtension = fileExtension; + } @Override public String toString() @@ -360,6 +375,7 @@ public class Artifact sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); sb.append( ", classifier='" ).append( classifier ).append( '\'' ); sb.append( ", packaging='" ).append( packaging ).append( '\'' ); + sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' ); sb.append( '}' ); return sb.toString(); } 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 f71743a0f..93744e05d 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 @@ -86,6 +86,12 @@ public class SearchRequest private String classifier; + /** + * not return artifact with file extension pom + * @since 1.4-M2 + */ + private boolean includePomArtifacts = false; + public SearchRequest() { // no op @@ -213,6 +219,16 @@ public class SearchRequest this.classifier = classifier; } + public boolean isIncludePomArtifacts() + { + return includePomArtifacts; + } + + public void setIncludePomArtifacts( boolean includePomArtifacts ) + { + this.includePomArtifacts = includePomArtifacts; + } + @Override public String toString() { @@ -229,6 +245,7 @@ public class SearchRequest sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); sb.append( ", classifier='" ).append( classifier ).append( '\'' ); + sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java index ffb279901..9ba9014e8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java @@ -229,31 +229,6 @@ public class DefaultSearchService { for ( String version : hit.getVersions() ) { - /* - Artifact versionned = new Artifact( ); - versionned.setArtifactId( hit.getArtifactId()); - versionned.setGroupId( hit.getGroupId() ); - versionned.setRepositoryId(hit.getRepositoryId() ); - - - versionned.setBundleExportPackage( hit.getBundleExportPackage() ); - versionned.setBundleExportService( hit.getBundleExportService()); - versionned.setBundleSymbolicName(hit.getBundleSymbolicName() ); - versionned.setBundleVersion( artifactInfo.bundleVersion ); - versionned.setBundleDescription( artifactInfo.bundleDescription ); - versionned.setBundleDocUrl( artifactInfo.bundleDocUrl ); - - versionned.setBundleRequireBundle( artifactInfo.bundleRequireBundle ); - versionned.setBundleImportPackage( artifactInfo.bundleImportPackage ); - versionned.setBundleLicense( artifactInfo.bundleLicense ); - versionned.setBundleName( artifactInfo.bundleName ); - versionned.setContext( artifactInfo.context ); - versionned.setGoals( artifactInfo.goals ); - versionned.setPrefix( artifactInfo.prefix ); - // sure ?? - versionned.setUrl( artifactInfo.remoteUrl ); - */ - // FIXME archiva url ?? Artifact versionned = new BeanReplicator().replicateBean( hit, Artifact.class ); @@ -271,6 +246,12 @@ public class DefaultSearchService return artifacts; } + /** + * TODO add a configuration mechanism to have configured the base archiva url + * @param httpContext + * @param artifact + * @return + */ private String getArtifactUrl( HttpContext httpContext, Artifact artifact ) { if ( httpContext == null ) |