@XmlRootElement( name = "searchRequest" )
public class SearchRequest
{
+
+ /**
+ * @since 1.4-M3
+ * to be able to search with a query on selected repositories
+ */
+ private String queryTerms;
+
/**
* groupId
*/
this.includePomArtifacts = includePomArtifacts;
}
+ public String getQueryTerms()
+ {
+ return queryTerms;
+ }
+
+ public void setQueryTerms( String queryTerms )
+ {
+ this.queryTerms = queryTerms;
+ }
+
@Override
public String toString()
{
final StringBuilder sb = new StringBuilder();
sb.append( "SearchRequest" );
- sb.append( "{groupId='" ).append( groupId ).append( '\'' );
+ sb.append( "{queryTerms='" ).append( queryTerms ).append( '\'' );
+ sb.append( ", groupId='" ).append( groupId ).append( '\'' );
sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
sb.append( ", version='" ).append( version ).append( '\'' );
sb.append( ", packaging='" ).append( packaging ).append( '\'' );
List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
throws ArchivaRestServiceException;
- @Path( "getArtifactVersions" )
- @GET
+ @Path( "quickSearch" )
+ @POST
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noPermission = true, noRestriction = true )
/**
- * <b>search will be apply on all repositories the current user has karma</b>
+ * <b>if not repositories in SearchRequest: search will be apply on all repositories the current user has karma</b>
*/
- List<Artifact> getArtifactVersions( @QueryParam( "groupId" ) String groupId,
- @QueryParam( "artifactId" ) String artifactId,
- @QueryParam( "packaging" ) String packaging )
+ List<Artifact> quickSearchWithRepositories( SearchRequest searchRequest )
throws ArchivaRestServiceException;
@Path( "searchArtifacts" )
List<Artifact> searchArtifacts( SearchRequest searchRequest )
throws ArchivaRestServiceException;
+ @Path( "getArtifactVersions" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
+ /**
+ * <b>search will be apply on all repositories the current user has karma</b>
+ */
+ List<Artifact> getArtifactVersions( @QueryParam( "groupId" ) String groupId,
+ @QueryParam( "artifactId" ) String artifactId,
+ @QueryParam( "packaging" ) String packaging )
+ throws ArchivaRestServiceException;
+
+
@Path( "getAllGroupIds" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noPermission = true, noRestriction = true )
+ /**
+ * @since 1.4-M3
+ */
StringList getObservablesRepoIds()
throws ArchivaRestServiceException;
}
}
+ public List<Artifact> quickSearchWithRepositories( SearchRequest searchRequest )
+ throws ArchivaRestServiceException
+ {
+ String queryString = searchRequest.getQueryTerms();
+ if ( StringUtils.isBlank( queryString ) )
+ {
+ return Collections.emptyList();
+ }
+ List<String> repositories = searchRequest.getRepositories();
+ if ( repositories == null || repositories.isEmpty() )
+ {
+ repositories = getObservableRepos();
+ }
+ SearchResultLimits limits = new SearchResultLimits( 0 );
+ try
+ {
+ SearchResults searchResults = repositorySearch.search( getPrincipal(), repositories, queryString, limits,
+ Collections.<String>emptyList() );
+ return getArtifacts( searchResults );
+
+ }
+ catch ( RepositorySearchException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new ArchivaRestServiceException( e.getMessage() );
+ }
+ }
+
public List<Artifact> getArtifactVersions( String groupId, String artifactId, String packaging )
throws ArchivaRestServiceException
{