]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1096] [MRM-989] fix plugin download type, add default for other types such as...
authorBrett Porter <brett@apache.org>
Sat, 21 Mar 2009 07:20:09 +0000 (07:20 +0000)
committerBrett Porter <brett@apache.org>
Sat, 21 Mar 2009 07:20:09 +0000 (07:20 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@756883 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DownloadArtifact.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-archetype.png [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-jar.png
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-java-source.png [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-maven-plugin.png [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-other.png [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-pom.png
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-skin.png [new file with mode: 0644]

index f3eac71111f1b1d8ed233cec2cc1cd00efa79df5..23dcadd847317cb50142186fc3827b21d37f920f 100644 (file)
@@ -40,7 +40,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
 import java.io.IOException;
 import java.io.Writer;
 import java.text.DecimalFormat;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -56,6 +58,8 @@ import javax.servlet.jsp.PageContext;
 public class DownloadArtifact
     extends Component
 {
+    private static final String DEFAULT_DOWNLOAD_IMAGE = "download-type-other.png";
+
     /**
      * @plexus.requirement role-hint="jdo"
      */
@@ -81,6 +85,18 @@ public class DownloadArtifact
 
     private DecimalFormat decimalFormat;
 
+    private static final Map<String, String> DOWNLOAD_IMAGES = new HashMap<String,String>();
+
+    static
+    {
+        DOWNLOAD_IMAGES.put( "jar", "download-type-jar.png" );
+        DOWNLOAD_IMAGES.put( "java-source", "download-type-jar.png" );
+        DOWNLOAD_IMAGES.put( "pom", "download-type-pom.png" );
+        DOWNLOAD_IMAGES.put( "maven-plugin", "download-type-maven-plugin.png" );
+        DOWNLOAD_IMAGES.put( "maven-archetype", "download-type-archetype.png" );
+        DOWNLOAD_IMAGES.put( "maven-skin", "download-type-skin.png" );
+    }
+    
     public DownloadArtifact( ValueStack stack, PageContext pageContext )
     {
         super( stack );
@@ -238,10 +254,16 @@ public class DownloadArtifact
                                   ArchivaArtifact artifact )
     {
         String type = artifact.getType();
-        String linkText = "<img src=\"" + req.getContextPath() + "/images/download-type-" + type + ".png\" />";
+        String linkText = "<img src=\"" + req.getContextPath() + "/images/" + getDownloadImage( type ) + "\" />";
         appendLink( sb, prefix, repo, artifact, linkText );
     }
 
+    private String getDownloadImage( String type )
+    {
+        String name = DOWNLOAD_IMAGES.get( type );
+        return name != null ? name : DEFAULT_DOWNLOAD_IMAGE;
+    }
+
     private static void appendLink( StringBuffer sb, String prefix, ManagedRepositoryContent repo,
                                     ArchivaArtifact artifact, String linkText )
     {
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-archetype.png b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-archetype.png
new file mode 100644 (file)
index 0000000..c0a19da
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-archetype.png differ
index 146e1fd8f47287f1f29443fc90942f77e9b0c478..6eb48831dd8dfc218fa65af19910202575aadcd2 100644 (file)
Binary files a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-jar.png and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-jar.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-java-source.png b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-java-source.png
deleted file mode 100644 (file)
index 9660957..0000000
Binary files a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-java-source.png and /dev/null differ
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-maven-plugin.png b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-maven-plugin.png
new file mode 100644 (file)
index 0000000..3f27ddb
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-maven-plugin.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-other.png b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-other.png
new file mode 100644 (file)
index 0000000..cb268e0
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-other.png differ
index d0e4c12bf701ce436233f4ffa7d627f0beba015a..7ed1db58311e6c07f38ec922e08182907637a3b8 100644 (file)
Binary files a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-pom.png and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-pom.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-skin.png b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-skin.png
new file mode 100644 (file)
index 0000000..0671e09
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/images/download-type-skin.png differ