if ( StringUtils.isNotBlank( searchFields.getVersion() ) )
{
- q.add( indexer.constructQuery( MAVEN.VERSION, searchFields.isExactSearch() ? new SourcedSearchExpression(
- searchFields.getVersion() ) : new SourcedSearchExpression( searchFields.getVersion() ) ), Occur.MUST );
+ q.add( indexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
+ searchFields.getVersion( ) ) ), Occur.MUST );
}
if ( StringUtils.isNotBlank( searchFields.getPackaging() ) )
import org.apache.archiva.rest.api.model.SearchRequest;
import org.apache.archiva.rest.api.model.StringList;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
throws ArchivaRestServiceException;
*/
-
+ /**
+ * Returns a redirect to a artifact file, that matches given search parameter
+ * @param repositoryId The repository id (optional)
+ * @param groupId The search pattern for the group id of the artifact (required)
+ * @param artifactId The search pattern for the artifact id of the artifact (required)
+ * @param version The search pattern for the version of the artifact (required)
+ * LATEST returns the latest version of the artifact.
+ * @param packaging the packaging
+ * @param classifier the artifact classifier
+ * @param literalVersion true, if the version string should be treated literally, which means
+ * LATEST search for versions with LATEST in the version string.
+ * false, is default and treats v=LATEST special
+ * @return the redirect response, if a artifact was found
+ * @throws ArchivaRestServiceException
+ */
@GET
@Path( "/artifact" )
@Produces( "text/html" )
@QueryParam( "a" ) String artifactId, //
@QueryParam( "v" ) String version, //
@QueryParam( "p" ) String packaging, //
- @QueryParam( "c" ) String classifier )
+ @QueryParam( "c" ) String classifier,
+ @DefaultValue( "false" )
+ @QueryParam( "literalVersion" ) Boolean literalVersion)
throws ArchivaRestServiceException;
@Override
public Response redirectToArtifactFile( String repositoryId, String groupId, String artifactId, String version,
- String packaging, String classifier )
+ String packaging, String classifier, Boolean literalVersion )
throws ArchivaRestServiceException
{
try
searchField.setGroupId( groupId );
searchField.setArtifactId( artifactId );
searchField.setPackaging( StringUtils.isBlank( packaging ) ? "jar" : packaging );
- if ( !StringUtils.equals( version, LATEST_KEYWORD ) )
+ if ( literalVersion.booleanValue() || !StringUtils.equals( version, LATEST_KEYWORD ) )
{
searchField.setVersion( version );
}
{
Response response =
getSearchService().redirectToArtifactFile( null, "org.apache.archiva", "archiva-test", "1.0", null,
- null );
+ null, Boolean.FALSE );
}
catch ( RedirectionException e )
{
Response response =
getSearchService().redirectToArtifactFile( null, "org.apache.archiva", "archiva-test", "LATEST", null,
- null );
+ null , Boolean.FALSE);
}
catch ( RedirectionException e )
{
Response response =
getSearchService().redirectToArtifactFile( null, "org.apache.archiva.beer", "archiva-wine", "LATEST",
- null, null );
+ null, null, Boolean.FALSE );
Assert.assertEquals( Response.Status.NO_CONTENT.getStatusCode(), response.getStatus() );