[MRM-1543] artifact display doesn't show eventual classifiers

display classifier in the download box

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1188914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-10-25 21:16:30 +00:00
parent fad2191ac4
commit 930e9268a0
2 changed files with 34 additions and 23 deletions

View 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.MetadataResolver;
import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet; 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.model.ArtifactReference;
import org.apache.archiva.reports.RepositoryProblemFacet;
import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.RepositoryException;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import javax.inject.Inject;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,13 +55,11 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.inject.Inject;
/** /**
* Browse the repository. * Browse the repository.
* * <p/>
* TODO change name to ShowVersionedAction to conform to terminology. * TODO change name to ShowVersionedAction to conform to terminology.
*
*/ */
@SuppressWarnings( "serial" ) @SuppressWarnings( "serial" )
@Controller( "showArtifactAction" ) @Controller( "showArtifactAction" )
@ -165,14 +164,15 @@ public class ShowArtifactAction
// "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
try try
{ {
versionMetadata = metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId, versionMetadata =
version ); metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId, version );
if ( versionMetadata != null ) if ( versionMetadata != null )
{ {
MetadataFacet repoProbFacet; 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 //set metadata to complete so that no additional 'Artifact metadata is incomplete' warning is logged
versionMetadata.setIncomplete( false ); versionMetadata.setIncomplete( false );
} }
@ -194,10 +194,8 @@ public class ShowArtifactAction
List<ArtifactMetadata> artifacts; List<ArtifactMetadata> artifacts;
try try
{ {
artifacts = new ArrayList<ArtifactMetadata>( metadataResolver.resolveArtifacts( session, repoId, artifacts = new ArrayList<ArtifactMetadata>(
groupId, metadataResolver.resolveArtifacts( session, repoId, groupId, artifactId, version ) );
artifactId,
version ) );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
{ {
@ -289,8 +287,9 @@ public class ShowArtifactAction
for ( String repoId : getObservableRepos() ) for ( String repoId : getObservableRepos() )
{ {
// TODO: what about if we want to see this irrespective of version? // TODO: what about if we want to see this irrespective of version?
references.addAll( metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId, references.addAll(
artifactId, version ) ); metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId, artifactId,
version ) );
} }
} }
finally finally
@ -633,6 +632,8 @@ public class ShowArtifactAction
private String path; private String path;
private String classifier;
public ArtifactDownloadInfo( ArtifactMetadata artifact ) public ArtifactDownloadInfo( ArtifactMetadata artifact )
{ {
repositoryId = artifact.getRepositoryId(); repositoryId = artifact.getRepositoryId();
@ -662,9 +663,9 @@ public class ShowArtifactAction
MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID ); MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
if ( facet != null ) if ( facet != null )
{ {
type = facet.getType(); this.type = facet.getType();
this.classifier = facet.getClassifier();
} }
this.type = type;
namespace = artifact.getNamespace(); namespace = artifact.getNamespace();
project = artifact.getProject(); project = artifact.getProject();
@ -735,5 +736,10 @@ public class ShowArtifactAction
{ {
return path; return path;
} }
public String getClassifier()
{
return classifier;
}
} }
} }

View File

@ -195,7 +195,12 @@
<%-- Must be last so that the above get picked up if possible --%> <%-- Must be last so that the above get picked up if possible --%>
<c:when test="${a.type == 'jar'}"> <c:when test="${a.type == 'jar'}">
<c:url var="imageUrl" value="/images/download-type-jar.png"/> <c:url var="imageUrl" value="/images/download-type-jar.png"/>
<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:set var="packageName">JAR</c:set>
</c:if>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<c:url var="imageUrl" value="/images/download-type-other.png"/> <c:url var="imageUrl" value="/images/download-type-other.png"/>