mirror of https://github.com/apache/archiva.git
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
This commit is contained in:
parent
6eb766e9d9
commit
988f8b45f3
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue