From 235030c2bdc5a4e6218c5137ace6ec982cd9f066 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 13 Jun 2012 12:16:24 +0000 Subject: [PATCH] fix download link in jsp webapp git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1349787 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/rest/api/model/Artifact.java | 34 +++++++++++++++++++ .../utils/ArtifactDownloadInfoBuilder.java | 4 ++- .../web/action/ShowArtifactAction.java | 1 + .../main/webapp/WEB-INF/jsp/showArtifact.jsp | 10 +++--- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java index 027aca7de..9f975e46a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java @@ -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(); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java index 8f9f1e1be..4a4065462 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java @@ -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"; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java index 363c2de22..5e09669e9 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java @@ -218,6 +218,7 @@ public class ShowArtifactAction l = new ArrayList(); this.artifacts.put( artifact.getVersion(), l ); } + ArtifactDownloadInfoBuilder builder = new ArtifactDownloadInfoBuilder().forArtifactMetadata( artifact ).withManagedRepositoryContent( repositoryFactory.getManagedRepositoryContent( repositoryId ) ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp index 25a9c471e..d75477921 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp @@ -171,11 +171,11 @@ POM <%-- These types aren't usually set in the POM yet, so we fudge them for the well known ones --%> - + Maven Archetype - + Maven Skin @@ -209,8 +209,10 @@ - - ${packageName} + + + + ${packageName} ${a.size} -- 2.39.5