]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1543] artifact display doesn't show eventual classifiers
authorOlivier Lamy <olamy@apache.org>
Tue, 25 Oct 2011 21:16:30 +0000 (21:16 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 25 Oct 2011 21:16:30 +0000 (21:16 +0000)
display classifier in the download box

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1188914 13f79535-47bb-0310-9956-ffa450edef68

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 92d2cea539f5bbb6586d66e2f89511e72a547129..cb9ef9ee592cab4ecc4c6d54e35bca25b21c323d 100644 (file)
@@ -33,16 +33,17 @@ import org.apache.archiva.metadata.repository.MetadataResolutionException;
 import org.apache.archiva.metadata.repository.MetadataResolver;
 import org.apache.archiva.metadata.repository.RepositorySession;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
-import org.apache.archiva.reports.RepositoryProblemFacet;
-import org.apache.commons.lang.StringUtils;
 import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.reports.RepositoryProblemFacet;
 import org.apache.archiva.repository.ManagedRepositoryContent;
 import org.apache.archiva.repository.RepositoryContentFactory;
 import org.apache.archiva.repository.RepositoryException;
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
+import javax.inject.Inject;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.ArrayList;
@@ -54,13 +55,11 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import javax.inject.Inject;
 
 /**
  * Browse the repository.
- *
+ * <p/>
  * TODO change name to ShowVersionedAction to conform to terminology.
- *
  */
 @SuppressWarnings( "serial" )
 @Controller( "showArtifactAction" )
@@ -155,7 +154,7 @@ public class ShowArtifactAction
         artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
 
         List<String> repos = getObservableRepos();
-        
+
         MetadataResolver metadataResolver = session.getResolver();
         for ( String repoId : repos )
         {
@@ -165,24 +164,25 @@ public class ShowArtifactAction
                 // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
                 try
                 {
-                    versionMetadata = metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId,
-                                                                              version );
+                    versionMetadata =
+                        metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId, version );
                     if ( versionMetadata != null )
                     {
                         MetadataFacet repoProbFacet;
-                        if ( (repoProbFacet = versionMetadata.getFacet( RepositoryProblemFacet.FACET_ID ) ) != null )
+                        if ( ( repoProbFacet = versionMetadata.getFacet( RepositoryProblemFacet.FACET_ID ) ) != null )
                         {
-                            addIncompleteModelWarning( "Artifact metadata is incomplete: " + ( ( RepositoryProblemFacet) repoProbFacet ).getProblem() );
+                            addIncompleteModelWarning( "Artifact metadata is incomplete: "
+                                                           + ( (RepositoryProblemFacet) repoProbFacet ).getProblem() );
                             //set metadata to complete so that no additional 'Artifact metadata is incomplete' warning is logged
                             versionMetadata.setIncomplete( false );
                         }
                     }
-                    
+
                 }
                 catch ( MetadataResolutionException e )
                 {
                     addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
-                    
+
                     // TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer
                     versionMetadata = new ProjectVersionMetadata();
                     versionMetadata.setId( version );
@@ -194,10 +194,8 @@ public class ShowArtifactAction
                     List<ArtifactMetadata> artifacts;
                     try
                     {
-                        artifacts = new ArrayList<ArtifactMetadata>( metadataResolver.resolveArtifacts( session, repoId,
-                                                                                                        groupId,
-                                                                                                        artifactId,
-                                                                                                        version ) );
+                        artifacts = new ArrayList<ArtifactMetadata>(
+                            metadataResolver.resolveArtifacts( session, repoId, groupId, artifactId, version ) );
                     }
                     catch ( MetadataResolutionException e )
                     {
@@ -233,7 +231,7 @@ public class ShowArtifactAction
 
         return versionMetadata;
     }
-    
+
     private void addIncompleteModelWarning( String warningMessage )
     {
         addActionError( warningMessage );
@@ -289,8 +287,9 @@ public class ShowArtifactAction
             for ( String repoId : getObservableRepos() )
             {
                 // TODO: what about if we want to see this irrespective of version?
-                references.addAll( metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId,
-                                                                              artifactId, version ) );
+                references.addAll(
+                    metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId, artifactId,
+                                                               version ) );
             }
         }
         finally
@@ -633,6 +632,8 @@ public class ShowArtifactAction
 
         private String path;
 
+        private String classifier;
+
         public ArtifactDownloadInfo( ArtifactMetadata artifact )
         {
             repositoryId = artifact.getRepositoryId();
@@ -662,9 +663,9 @@ public class ShowArtifactAction
             MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
             if ( facet != null )
             {
-                type = facet.getType();
+                this.type = facet.getType();
+                this.classifier = facet.getClassifier();
             }
-            this.type = type;
 
             namespace = artifact.getNamespace();
             project = artifact.getProject();
@@ -690,7 +691,7 @@ public class ShowArtifactAction
                 }
             }
 
-            DecimalFormat df = new DecimalFormat( "#,###.##", new DecimalFormatSymbols( Locale.US) );
+            DecimalFormat df = new DecimalFormat( "#,###.##", new DecimalFormatSymbols( Locale.US ) );
             size = df.format( s ) + " " + symbol;
             id = artifact.getId();
             version = artifact.getVersion();
@@ -735,5 +736,10 @@ public class ShowArtifactAction
         {
             return path;
         }
+
+        public String getClassifier()
+        {
+            return classifier;
+        }
     }
 }
index b5e4799843a4065ce75e6d0f8189f2f55f827411..cb8d7975b0e0a0e07fdd3975f7db3ab970a108e1 100644 (file)
                 <%-- Must be last so that the above get picked up if possible --%>
                 <c:when test="${a.type == 'jar'}">
                   <c:url var="imageUrl" value="/images/download-type-jar.png"/>
-                  <c:set var="packageName">JAR</c:set>
+                  <c:if test="${a.classifier != null}">
+                    <c:set var="packageName">JAR - <c:out value="${a.classifier}"/></c:set>
+                  </c:if>
+                  <c:if test="${a.classifier == null}">
+                    <c:set var="packageName">JAR</c:set>
+                  </c:if>
                 </c:when>
                 <c:otherwise>
                   <c:url var="imageUrl" value="/images/download-type-other.png"/>