From: Brett Porter Date: Mon, 9 Mar 2009 15:14:47 +0000 (+0000) Subject: [MRM-1081] fix download tag in light of multiple repositories offering the same artifact X-Git-Tag: archiva-1.2~80 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1216a8534abf5790bda3091c38ecb281ca51cf89;p=archiva.git [MRM-1081] fix download tag in light of multiple repositories offering the same artifact git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@751702 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java index 973a7c21e..f3eac7111 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java @@ -111,18 +111,15 @@ public class DownloadArtifact if ( relatedArtifacts != null && relatedArtifacts.size() > 0 ) { - String repoId = ( (ArchivaArtifact) relatedArtifacts.get( 0 ) ).getModel().getRepositoryId(); - ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId ); - - String prefix = req.getContextPath() + "/repository/" + repoId; + String prefix = req.getContextPath() + "/repository/"; if ( mini ) { - appendMini( sb, prefix, repo, relatedArtifacts ); + appendMini( sb, prefix, relatedArtifacts ); } else { - appendNormal( sb, prefix, repo, relatedArtifacts ); + appendNormal( sb, prefix, relatedArtifacts ); } } } @@ -162,14 +159,13 @@ public class DownloadArtifact /* do nothing */ } - private void appendMini( StringBuffer sb, String prefix, ManagedRepositoryContent repo, - List relatedArtifacts ) + private void appendMini( StringBuffer sb, String prefix, List relatedArtifacts ) { // TODO: write 1 line download link for main artifact. } - private void appendNormal( StringBuffer sb, String prefix, ManagedRepositoryContent repo, - List relatedArtifacts ) + private void appendNormal( StringBuffer sb, String prefix, List relatedArtifacts ) + throws RepositoryNotFoundException, RepositoryException { /* *
@@ -209,14 +205,17 @@ public class DownloadArtifact sb.append( "" ); for ( ArchivaArtifact artifact : relatedArtifacts ) { + String repoId = artifact.getModel().getRepositoryId(); + ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId ); + sb.append( "\n" ); sb.append( "" ); sb.append( "" ); sb.append( "
" ); - appendImageLink( sb, prefix, repo, artifact ); + appendImageLink( sb, prefix + repoId, repo, artifact ); sb.append( "" ); - appendLink( sb, prefix, repo, artifact ); + appendLink( sb, prefix + repoId, repo, artifact ); sb.append( "" );