]> source.dussan.org Git - archiva.git/commitdiff
fix download link in jsp webapp
authorOlivier Lamy <olamy@apache.org>
Wed, 13 Jun 2012 12:16:24 +0000 (12:16 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 13 Jun 2012 12:16:24 +0000 (12:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1349787 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp

index 027aca7de8e7a090dd6091544b5171ec22639975..9f975e46afc5f44837750beb547297a261695ada 100644 (file)
@@ -140,6 +140,17 @@ public class Artifact
      */
     private String size;
 
+    /**
+     * @since 1.4-M3
+     */
+    private String type;
+
+
+    /**
+     * @since 1.4-M3
+     */
+    private String path;
+
 
     public Artifact()
     {
@@ -374,6 +385,26 @@ public class Artifact
         this.size = size;
     }
 
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public String getPath()
+    {
+        return path;
+    }
+
+    public void setPath( String path )
+    {
+        this.path = path;
+    }
+
     @Override
     public String toString()
     {
@@ -400,6 +431,9 @@ public class Artifact
         sb.append( ", classifier='" ).append( classifier ).append( '\'' );
         sb.append( ", packaging='" ).append( packaging ).append( '\'' );
         sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
+        sb.append( ", size='" ).append( size ).append( '\'' );
+        sb.append( ", type='" ).append( type ).append( '\'' );
+        sb.append( ", path='" ).append( path ).append( '\'' );
         sb.append( '}' );
         return sb.toString();
     }
index 8f9f1e1bed6c78b3c92e0d2b2e3311ba6529e74a..4a4065462a207babfd5e51b978ce183b4ee4497c 100644 (file)
@@ -62,7 +62,7 @@ public class ArtifactDownloadInfoBuilder
     public Artifact build()
     {
         ArtifactReference ref = new ArtifactReference();
-        ref.setArtifactId( artifactMetadata.getId() );
+        ref.setArtifactId( artifactMetadata.getProject() );
         ref.setGroupId( artifactMetadata.getNamespace() );
         ref.setVersion( artifactMetadata.getVersion() );
 
@@ -85,7 +85,9 @@ public class ArtifactDownloadInfoBuilder
         artifact.setRepositoryId( artifactMetadata.getRepositoryId() );
         artifact.setClassifier( classifier );
         artifact.setPackaging( type );
+        artifact.setType( type );
         artifact.setFileExtension( extension );
+        artifact.setPath( managedRepositoryContent.toPath( ref ) );
         // TODO: find a reusable formatter for this
         double s = this.artifactMetadata.getSize();
         String symbol = "b";
index 363c2de22740dd66ec34cef0577f6c7ad97aa829..5e09669e9a86c87c75376249916b62476cd78a8b 100644 (file)
@@ -218,6 +218,7 @@ public class ShowArtifactAction
                             l = new ArrayList<Artifact>();
                             this.artifacts.put( artifact.getVersion(), l );
                         }
+
                         ArtifactDownloadInfoBuilder builder = new ArtifactDownloadInfoBuilder().forArtifactMetadata(
                             artifact ).withManagedRepositoryContent(
                             repositoryFactory.getManagedRepositoryContent( repositoryId ) );
index 25a9c471eed2812dd54ece780d03595805133645..d75477921e2d06a17e6537b1801f891cd56f9400 100644 (file)
                   <c:set var="packageName">POM</c:set>
                 </c:when>
                 <%-- These types aren't usually set in the POM yet, so we fudge them for the well known ones --%>
-                <c:when test="${a.type == 'maven-archetype' or a.namespace == 'org.apache.maven.archetypes'}">
+                <c:when test="${a.type == 'maven-archetype' or a.groupId == 'org.apache.maven.archetypes'}">
                   <c:url var="imageUrl" value="/images/download-type-archetype.png"/>
                   <c:set var="packageName">Maven Archetype</c:set>
                 </c:when>
-                <c:when test="${a.type == 'maven-skin' or a.namespace == 'org.apache.maven.skins'}">
+                <c:when test="${a.type == 'maven-skin' or a.groupId == 'org.apache.maven.skins'}">
                   <c:url var="imageUrl" value="/images/download-type-skin.png"/>
                   <c:set var="packageName">Maven Skin</c:set>
                 </c:when>
               </c:choose>
               <c:url var="url" value="/repository/${a.repositoryId}/${a.path}" />
               <tr>
-                <td><a href="${url}" title="Download ${a.id}"><img src="${imageUrl}" alt="" width="24" height="24"/></a></td>
-                <td class="type"><a href="${url}" title="Download ${a.id}">${packageName}</a></td>
+                <td>
+                  <a href="${url}" title="Download ${a.artifactId}"><img src="${imageUrl}" alt="" width="24" height="24"/></a>
+                </td>
+                <td class="type"><a href="${url}" title="Download ${a.artifactId}">${packageName}</a></td>
                 <td class="size">${a.size}</td>
               </tr>
             </c:forEach>