]> source.dussan.org Git - archiva.git/commitdiff
if classifier from the search we must download the artifact with this classifier
authorOlivier Lamy <olamy@apache.org>
Tue, 18 Dec 2012 14:20:31 +0000 (14:20 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 18 Dec 2012 14:20:31 +0000 (14:20 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1423442 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js

index cbd7845178438b83037a40c27808cae3d9255123..5cd0f50b9a11207a2029dd8495f8410e6885d4a8 100644 (file)
@@ -45,61 +45,59 @@ import java.util.List;
  * @author Olivier Lamy
  * @since 1.4-M3
  */
-@Path ("/browseService/")
+@Path("/browseService/")
 public interface BrowseService
 {
-    @Path ("rootGroups")
+    @Path("rootGroups")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    BrowseResult getRootGroups( @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    BrowseResult getRootGroups( @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
     /**
-     * @param groupId groupId to browse
+     * @param groupId      groupId to browse
      * @param repositoryId optionnal (repository to browse if <code>null</code> all available user repositories are used)
      */
-    @Path ("browseGroupId/{groupId}")
+    @Path("browseGroupId/{groupId}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    BrowseResult browseGroupId( @PathParam ("groupId") String groupId,
-                                @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    BrowseResult browseGroupId( @PathParam("groupId") String groupId, @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("versionsList/{g}/{a}")
+    @Path("versionsList/{g}/{a}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    VersionsList getVersionsList( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                                  @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    VersionsList getVersionsList( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                  @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("projectVersionMetadata/{g}/{a}")
+    @Path("projectVersionMetadata/{g}/{a}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    ProjectVersionMetadata getProjectVersionMetadata( @PathParam ("g") String groupId,
-                                                      @PathParam ("a") String artifactId,
-                                                      @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    ProjectVersionMetadata getProjectVersionMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                                      @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("projectVersionMetadata/{g}/{a}/{v}")
+    @Path("projectVersionMetadata/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    ProjectVersionMetadata getProjectMetadata( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                                               @PathParam ("v") String version,
-                                               @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    ProjectVersionMetadata getProjectMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                               @PathParam("v") String version,
+                                               @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
     /**
      * @return List of managed repositories current user can read
      */
-    @Path ("userRepositories")
+    @Path("userRepositories")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
     List<ManagedRepository> getUserRepositories()
         throws ArchivaRestServiceException;
 
@@ -107,115 +105,130 @@ public interface BrowseService
      * return the dependency Tree for an artifacts
      * <b>the List result has only one entry</b>
      */
-    @Path ("treeEntries/{g}/{a}/{v}")
+    @Path("treeEntries/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    List<TreeEntry> getTreeEntries( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                                    @PathParam ("v") String version, @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    List<TreeEntry> getTreeEntries( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                    @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
     /**
      * List of artifacts using the artifact passed in parameter.
      */
-    @Path ("dependees/{g}/{a}/{v}")
+    @Path("dependees/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    List<Artifact> getDependees( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                                 @PathParam ("v") String version, @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    List<Artifact> getDependees( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                 @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("metadatas/{g}/{a}/{v}")
+    @Path("metadatas/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    List<Entry> getMetadatas( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                              @PathParam ("v") String version, @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    List<Entry> getMetadatas( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                              @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("metadata/{g}/{a}/{v}/{key}/{value}")
+    @Path("metadata/{g}/{a}/{v}/{key}/{value}")
     @PUT
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = false, noRestriction = false, permissions = "archiva-add-metadata")
-    Boolean addMetadata( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                         @PathParam ("v") String version, @PathParam ("key") String key,
-                         @PathParam ("value") String value, @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata")
+    Boolean addMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                         @PathParam("v") String version, @PathParam("key") String key, @PathParam("value") String value,
+                         @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("metadata/{g}/{a}/{v}/{key}")
+    @Path("metadata/{g}/{a}/{v}/{key}")
     @DELETE
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = false, noRestriction = false, permissions = "archiva-add-metadata")
-    Boolean deleteMetadata( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                            @PathParam ("v") String version, @PathParam ("key") String key,
-                            @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata")
+    Boolean deleteMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                            @PathParam("v") String version, @PathParam("key") String key,
+                            @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path( "importMetadata" )
+    @Path("importMetadata")
     @POST
-    @RedbackAuthorization( noPermission = false, noRestriction = false, permissions = "archiva-add-metadata")
-    Boolean importMetadata( MetadataAddRequest metadataAddRequest, @QueryParam ("repository") String repository )
+    @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata")
+    Boolean importMetadata( MetadataAddRequest metadataAddRequest, @QueryParam("repository") String repository )
         throws ArchivaRestServiceException;
 
-    @Path ("artifactContentEntries/{g}/{a}/{v}")
+    @Path("artifactContentEntries/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    List<ArtifactContentEntry> getArtifactContentEntries( @PathParam ("g") String groupId,
-                                                          @PathParam ("a") String artifactId,
-                                                          @PathParam ("v") String version,
-                                                          @QueryParam ("c") String classifier,
-                                                          @QueryParam ("t") String type, @QueryParam ("p") String path,
-                                                          @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    List<ArtifactContentEntry> getArtifactContentEntries( @PathParam("g") String groupId,
+                                                          @PathParam("a") String artifactId,
+                                                          @PathParam("v") String version,
+                                                          @QueryParam("c") String classifier,
+                                                          @QueryParam("t") String type, @QueryParam("p") String path,
+                                                          @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ("artifactDownloadInfos/{g}/{a}/{v}")
+    @Path("artifactDownloadInfos/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    List<Artifact> getArtifactDownloadInfos( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                                             @PathParam ("v") String version,
-                                             @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    List<Artifact> getArtifactDownloadInfos( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                             @PathParam("v") String version,
+                                             @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
     /**
      * if path is empty content of the file is returned (for pom view)
      */
-    @Path ("artifactContentText/{g}/{a}/{v}")
+    @Path("artifactContentText/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    ArtifactContent getArtifactContentText( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                                            @PathParam ("v") String version, @QueryParam ("c") String classifier,
-                                            @QueryParam ("t") String type, @QueryParam ("p") String path,
-                                            @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    ArtifactContent getArtifactContentText( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                                            @PathParam("v") String version, @QueryParam("c") String classifier,
+                                            @QueryParam("t") String type, @QueryParam("p") String path,
+                                            @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
     /**
      * verify if an artifact is available locally if not download from proxies will be try
+     *
      * @since 1.4-M3
      */
-    @Path ("artifactAvailable/{g}/{a}/{v}")
+    @Path("artifactAvailable/{g}/{a}/{v}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    Boolean artifactAvailable( @PathParam ("g") String groupId, @PathParam ("a") String artifactId,
-                               @PathParam ("v") String version, @QueryParam ("repositoryId") String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    Boolean artifactAvailable( @PathParam("g") String groupId, @PathParam("a") String artifactId,
+                               @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
     /**
+     * verify if an artifact is available locally if not download from proxies will be try
      *
+     * @since 1.4-M4
+     */
+    @Path( "artifactAvailable/{g}/{a}/{v}/{c}" )
+    @GET
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    @RedbackAuthorization( noPermission = true, noRestriction = true )
+    Boolean artifactAvailable( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId,
+                               @PathParam( "v" ) String version, @PathParam( "c" ) String classifier,
+                               @QueryParam( "repositoryId" ) String repositoryId )
+        throws ArchivaRestServiceException;
+
+    /**
      * return List of all artifacts from this repository
+     *
      * @param repositoryId
      * @return
      * @throws ArchivaRestServiceException
      * @since 1.4-M3
      */
-    @Path ("artifacts/{r}")
+    @Path("artifacts/{r}")
     @GET
-    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @RedbackAuthorization (noPermission = true, noRestriction = true)
-    List<Artifact> getArtifacts( @PathParam ( "r" ) String repositoryId )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(noPermission = true, noRestriction = true)
+    List<Artifact> getArtifacts( @PathParam("r") String repositoryId )
         throws ArchivaRestServiceException;
 }
index 36e4ae17ad0e241d558125ea167aa7ea3b3e2dab..a9638b60f87d0667cc18c6dc56388b5cfac53ce3 100644 (file)
@@ -62,6 +62,8 @@ import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 import java.io.File;
 import java.io.IOException;
@@ -771,7 +773,8 @@ public class DefaultBrowseService
         return new ArtifactContent();
     }
 
-    public Boolean artifactAvailable( String groupId, String artifactId, String version, String repositoryId )
+    public Boolean artifactAvailable( String groupId, String artifactId, String version, String classifier,
+                                      String repositoryId )
         throws ArchivaRestServiceException
     {
         List<String> selectedRepos = getSelectedRepos( repositoryId );
@@ -793,8 +796,10 @@ public class DefaultBrowseService
                 ManagedRepositoryContent managedRepositoryContent =
                     repositoryContentFactory.getManagedRepositoryContent( repoId );
                 // FIXME default to jar which can be wrong for war zip etc....
-                ArchivaArtifact archivaArtifact =
-                    new ArchivaArtifact( groupId, artifactId, version, "", "jar", repoId );
+                ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version,
+                                                                       StringUtils.isEmpty( classifier )
+                                                                           ? ""
+                                                                           : classifier, "jar", repoId );
                 File file = managedRepositoryContent.toFile( archivaArtifact );
 
                 if ( file != null && file.exists() )
@@ -831,6 +836,12 @@ public class DefaultBrowseService
         return false;
     }
 
+    public Boolean artifactAvailable( String groupId, String artifactId, String version, String repositoryId )
+        throws ArchivaRestServiceException
+    {
+        return artifactAvailable( groupId, artifactId, version, null, repositoryId );
+    }
+
     public List<Artifact> getArtifacts( String repositoryId )
         throws ArchivaRestServiceException
     {
index 1dc4a36e5993f27c1d8cddf72a8a4b16f2d6175a..1f18d839841bd8b7cf3d1d98dc177895defd5ec5 100644 (file)
@@ -350,7 +350,8 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
           goToBrowseArtifactDetail(groupId,artifactId,repositoryId);//,null,null);
         });
 
-        var checkArtifactDetailContent=function(groupId,artifactId,version,repositoryId,tabToActivate,idContentToCheck,contentDisplayFn){
+
+        var checkArtifactDetailContent=function(groupId,artifactId,version,repositoryId,tabToActivate,idContentToCheck,contentDisplayFn,classifier){
           self.activeMenuId("browse");
           // no need to recalculate all stuff just activate the tab
           var htmlId = idContentToCheck?idContentToCheck:"browse_artifact_detail";
@@ -369,6 +370,10 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
 
           var artifactAvailableUrl="restServices/archivaServices/browseService/artifactAvailable/"+encodeURIComponent(groupId)+"/"+encodeURIComponent(artifactId);
           artifactAvailableUrl+="/"+encodeURIComponent(version);
+          if(classifier){
+            artifactAvailableUrl+="/"+encodeURIComponent(classifier);
+          }
+
           var selectedRepo=getSelectedBrowsingRepository();
           if (selectedRepo){
             artifactAvailableUrl+="?repositoryId="+encodeURIComponent(selectedRepo);
@@ -412,6 +417,24 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
           checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-info-content-a");
         });
 
+        this.get('#artifact/:groupId/:artifactId/:version/:classifier',function(context){
+          var groupId= this.params.groupId;
+          var artifactId= this.params.artifactId;
+          var version= this.params.version;
+          var classifier= this.params.classifier;
+          checkArtifactDetailContent(groupId,artifactId,version,null,"artifact-details-info-content-a",null,null,classifier);
+        });
+
+        this.get('#artifact~:repositoryId/:groupId/:artifactId/:version/:classifier',function(context){
+
+          var repositoryId = this.params.repositoryId;
+          var groupId= this.params.groupId;
+          var artifactId= this.params.artifactId;
+          var version= this.params.version;
+          var classifier= this.params.classifier;
+          checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-info-content-a",null,null,classifier);
+        });
+
         this.get('#artifact-dependencies/:groupId/:artifactId/:version',function(context){
 
           var repositoryId = this.params.repositoryId;
@@ -423,6 +446,16 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
 
         });
 
+        this.get('#artifact-dependencies/:groupId/:artifactId/:version',function(context){
+
+          var repositoryId = this.params.repositoryId;
+          var groupId= this.params.groupId;
+          var artifactId= this.params.artifactId;
+          var version= this.params.version;
+          checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependencies-content-a");
+
+        });
+
         this.get('#artifact-dependencies~:repositoryId/:groupId/:artifactId/:version',function(context){
 
           var repositoryId = this.params.repositoryId;
index 01cbac7c2d0c28381883404f1519c25aaaa9a27f..1ae512a97b633906aa284945cbc2ef6154390550 100644 (file)
@@ -964,6 +964,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
    * @param artifactId
    * @param parentBrowseViewModel
    * @param restUrl
+   * @param repositoryId
    */
   displayArtifactDetail=function(groupId,artifactId,parentBrowseViewModel,restUrl,repositoryId){
     $.log("displayArtifactDetail:"+groupId+":"+artifactId);
@@ -1758,6 +1759,10 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
       }
       location+="/"+artifact.groupId+"/"+artifact.artifactId+"/"+artifact.version;
 
+      if(artifact.classifier){
+        location+="/"+artifact.classifier;
+      }
+
       window.sammyArchivaApplication.setLocation(location);
     }
   }