mirror of https://github.com/apache/archiva.git
[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:
parent
fad2191ac4
commit
930e9268a0
|
@ -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" )
|
||||||
|
@ -155,7 +154,7 @@ public class ShowArtifactAction
|
||||||
artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
|
artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
|
||||||
|
|
||||||
List<String> repos = getObservableRepos();
|
List<String> repos = getObservableRepos();
|
||||||
|
|
||||||
MetadataResolver metadataResolver = session.getResolver();
|
MetadataResolver metadataResolver = session.getResolver();
|
||||||
for ( String repoId : repos )
|
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
|
// "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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( MetadataResolutionException e )
|
catch ( MetadataResolutionException e )
|
||||||
{
|
{
|
||||||
addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
|
addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
|
||||||
|
|
||||||
// TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer
|
// TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer
|
||||||
versionMetadata = new ProjectVersionMetadata();
|
versionMetadata = new ProjectVersionMetadata();
|
||||||
versionMetadata.setId( version );
|
versionMetadata.setId( version );
|
||||||
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
@ -233,7 +231,7 @@ public class ShowArtifactAction
|
||||||
|
|
||||||
return versionMetadata;
|
return versionMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIncompleteModelWarning( String warningMessage )
|
private void addIncompleteModelWarning( String warningMessage )
|
||||||
{
|
{
|
||||||
addActionError( warningMessage );
|
addActionError( warningMessage );
|
||||||
|
@ -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();
|
||||||
|
@ -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;
|
size = df.format( s ) + " " + symbol;
|
||||||
id = artifact.getId();
|
id = artifact.getId();
|
||||||
version = artifact.getVersion();
|
version = artifact.getVersion();
|
||||||
|
@ -735,5 +736,10 @@ public class ShowArtifactAction
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClassifier()
|
||||||
|
{
|
||||||
|
return classifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: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: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"/>
|
||||||
|
|
Loading…
Reference in New Issue