mirror of https://github.com/apache/archiva.git
[MRM-1285][MRM-404] improve appearance of the downloads box and correct handling of snapshots
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@892772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b3f877554f
commit
1f633d5244
|
@ -19,16 +19,26 @@ package org.apache.maven.archiva.web.action;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.Dependency;
|
||||
import org.apache.archiva.metadata.model.MailingList;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionReference;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolver;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
|
||||
/**
|
||||
* Browse the repository.
|
||||
|
@ -48,6 +58,11 @@ public class ShowArtifactAction
|
|||
*/
|
||||
private MetadataResolver metadataResolver;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryContentFactory repositoryFactory;
|
||||
|
||||
/* .\ Exposed Output Objects \.__________________________________ */
|
||||
|
||||
private String groupId;
|
||||
|
@ -72,7 +87,9 @@ public class ShowArtifactAction
|
|||
|
||||
private List<Dependency> dependencies;
|
||||
|
||||
private List<String> snapshotVersions;
|
||||
private Map<String, List<ArtifactDownloadInfo>> artifacts;
|
||||
|
||||
private boolean dependencyTree = false;
|
||||
|
||||
/**
|
||||
* Show the versioned project information tab.
|
||||
|
@ -81,18 +98,16 @@ public class ShowArtifactAction
|
|||
*/
|
||||
public String artifact()
|
||||
{
|
||||
ProjectVersionMetadata versionMetadata = null;
|
||||
artifacts = new HashMap<String, List<ArtifactDownloadInfo>>();
|
||||
|
||||
List<String> repos = getObservableRepos();
|
||||
// In the future, this should be replaced by the repository grouping mechanism, so that we are only making
|
||||
// simple resource requests here and letting the resolver take care of it
|
||||
ProjectVersionMetadata versionMetadata = null;
|
||||
snapshotVersions = new ArrayList<String>();
|
||||
for ( String repoId : getObservableRepos() )
|
||||
for ( String repoId : repos )
|
||||
{
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
// TODO: though we have a simple mapping now, do we want to support paths like /1.0-20090111.123456-1/
|
||||
// again by mapping it to /1.0-SNAPSHOT/? Currently, the individual versions are not supported as we
|
||||
// are only displaying the project's single version.
|
||||
|
||||
// we don't want the implementation being that intelligent - so another resolver to do the
|
||||
// "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
|
||||
versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
|
||||
|
@ -100,9 +115,17 @@ public class ShowArtifactAction
|
|||
{
|
||||
repositoryId = repoId;
|
||||
|
||||
snapshotVersions.addAll(
|
||||
metadataResolver.getArtifactVersions( repoId, groupId, artifactId, versionMetadata.getId() ) );
|
||||
snapshotVersions.remove( version );
|
||||
Collection<ArtifactMetadata> artifacts = metadataResolver.getArtifacts( repoId, groupId, artifactId, version );
|
||||
for ( ArtifactMetadata artifact : artifacts )
|
||||
{
|
||||
List<ArtifactDownloadInfo> l = this.artifacts.get( artifact.getVersion() );
|
||||
if ( l == null )
|
||||
{
|
||||
l = new ArrayList<ArtifactDownloadInfo>();
|
||||
this.artifacts.put( artifact.getVersion(), l );
|
||||
}
|
||||
l.add( new ArtifactDownloadInfo( artifact ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,25 +145,11 @@ public class ShowArtifactAction
|
|||
*/
|
||||
public String dependencies()
|
||||
{
|
||||
ProjectVersionMetadata versionMetadata = null;
|
||||
for ( String repoId : getObservableRepos() )
|
||||
{
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
|
||||
}
|
||||
}
|
||||
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
addActionError( "Artifact not found" );
|
||||
return ERROR;
|
||||
}
|
||||
model = versionMetadata;
|
||||
String result = artifact();
|
||||
|
||||
this.dependencies = model.getDependencies();
|
||||
|
||||
return SUCCESS;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,25 +157,11 @@ public class ShowArtifactAction
|
|||
*/
|
||||
public String mailingLists()
|
||||
{
|
||||
ProjectVersionMetadata versionMetadata = null;
|
||||
for ( String repoId : getObservableRepos() )
|
||||
{
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
|
||||
}
|
||||
}
|
||||
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
addActionError( "Artifact not found" );
|
||||
return ERROR;
|
||||
}
|
||||
model = versionMetadata;
|
||||
String result = artifact();
|
||||
|
||||
this.mailingLists = model.getMailingLists();
|
||||
|
||||
return SUCCESS;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,22 +179,6 @@ public class ShowArtifactAction
|
|||
*/
|
||||
public String dependees()
|
||||
{
|
||||
ProjectVersionMetadata versionMetadata = null;
|
||||
for ( String repoId : getObservableRepos() )
|
||||
{
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
|
||||
}
|
||||
}
|
||||
|
||||
if ( versionMetadata == null )
|
||||
{
|
||||
addActionError( "Artifact not found" );
|
||||
return ERROR;
|
||||
}
|
||||
model = versionMetadata;
|
||||
|
||||
List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
|
||||
// TODO: what if we get duplicates across repositories?
|
||||
for ( String repoId : getObservableRepos() )
|
||||
|
@ -213,7 +192,7 @@ public class ShowArtifactAction
|
|||
// TODO: may need to note on the page that references will be incomplete if the other artifacts are not yet stored in the content repository
|
||||
// (especially in the case of pre-population import)
|
||||
|
||||
return SUCCESS;
|
||||
return artifact();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,6 +206,9 @@ public class ShowArtifactAction
|
|||
// TODO: may need to note on the page that tree will be incomplete if the other artifacts are not yet stored in the content repository
|
||||
// (especially in the case of pre-population import)
|
||||
|
||||
// TODO: a bit ugly, should really be mapping all these results differently now
|
||||
this.dependencyTree = true;
|
||||
|
||||
return artifact();
|
||||
}
|
||||
|
||||
|
@ -309,13 +291,148 @@ public class ShowArtifactAction
|
|||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public List<String> getSnapshotVersions()
|
||||
{
|
||||
return snapshotVersions;
|
||||
}
|
||||
|
||||
public MetadataResolver getMetadataResolver()
|
||||
{
|
||||
return metadataResolver;
|
||||
}
|
||||
|
||||
public Map<String, List<ArtifactDownloadInfo>> getArtifacts()
|
||||
{
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
public Collection<String> getSnapshotVersions()
|
||||
{
|
||||
return artifacts.keySet();
|
||||
}
|
||||
|
||||
public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
|
||||
{
|
||||
this.repositoryFactory = repositoryFactory;
|
||||
}
|
||||
|
||||
public boolean isDependencyTree()
|
||||
{
|
||||
return dependencyTree;
|
||||
}
|
||||
|
||||
// TODO: move this into the artifact metadata itself via facets where necessary
|
||||
public class ArtifactDownloadInfo
|
||||
{
|
||||
private String type;
|
||||
|
||||
private String namespace;
|
||||
|
||||
private String project;
|
||||
|
||||
private String size;
|
||||
|
||||
private String id;
|
||||
|
||||
private String repositoryId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String path;
|
||||
|
||||
public ArtifactDownloadInfo( ArtifactMetadata artifact )
|
||||
{
|
||||
repositoryId = artifact.getRepositoryId();
|
||||
|
||||
// TODO: use metadata resolver capability instead
|
||||
ManagedRepositoryContent repo;
|
||||
try
|
||||
{
|
||||
repo = repositoryFactory.getManagedRepositoryContent( repositoryId );
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
ArtifactReference ref = new ArtifactReference();
|
||||
ref.setArtifactId( artifact.getProject() );
|
||||
ref.setGroupId( artifact.getNamespace() );
|
||||
ref.setVersion( artifact.getVersion() );
|
||||
path = repo.toPath( ref );
|
||||
path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifact.getId();
|
||||
|
||||
try
|
||||
{
|
||||
type = repo.toArtifactReference( path ).getType();
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
namespace = artifact.getNamespace();
|
||||
project = artifact.getProject();
|
||||
|
||||
// TODO: find a reusable formatter for this
|
||||
double s = artifact.getSize();
|
||||
String symbol = "b";
|
||||
if ( s > 1024 )
|
||||
{
|
||||
symbol = "K";
|
||||
s /= 1024;
|
||||
|
||||
if ( s > 1024 )
|
||||
{
|
||||
symbol = "M";
|
||||
s /= 1024;
|
||||
|
||||
if ( s > 1024 )
|
||||
{
|
||||
symbol = "G";
|
||||
s /= 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size = new DecimalFormat( "#,###.##" ).format( s ) + " " + symbol;
|
||||
id = artifact.getId();
|
||||
version = artifact.getVersion();
|
||||
}
|
||||
|
||||
public String getNamespace()
|
||||
{
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
public String getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getRepositoryId()
|
||||
{
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,333 +0,0 @@
|
|||
package org.apache.maven.archiva.web.tags;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolver;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
import org.apache.maven.archiva.repository.RepositoryNotFoundException;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.apache.maven.archiva.security.ArchivaSecurityException;
|
||||
import org.apache.maven.archiva.security.ArchivaXworkUser;
|
||||
import org.apache.maven.archiva.security.UserRepositories;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
public class DownloadArtifact
|
||||
extends Component
|
||||
{
|
||||
private static final String DEFAULT_DOWNLOAD_IMAGE = "download-type-other.png";
|
||||
|
||||
private RepositoryContentFactory repositoryFactory;
|
||||
|
||||
private MetadataResolver metadataResolver;
|
||||
|
||||
private HttpServletRequest req;
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private boolean mini = false;
|
||||
|
||||
private DecimalFormat decimalFormat;
|
||||
|
||||
private static final Map<String, String> DOWNLOAD_IMAGES = new HashMap<String, String>();
|
||||
|
||||
private UserRepositories userRepositories;
|
||||
|
||||
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 );
|
||||
decimalFormat = new DecimalFormat( "#,#00" );
|
||||
this.req = (HttpServletRequest) pageContext.getRequest();
|
||||
try
|
||||
{
|
||||
metadataResolver = (MetadataResolver) PlexusTagUtil.lookup( pageContext, MetadataResolver.class );
|
||||
repositoryFactory =
|
||||
(RepositoryContentFactory) PlexusTagUtil.lookup( pageContext, RepositoryContentFactory.class );
|
||||
userRepositories = (UserRepositories) PlexusTagUtil.lookup( pageContext, UserRepositories.class );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean end( Writer writer, String body )
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
try
|
||||
{
|
||||
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
|
||||
for ( String repoId : getObservableRepos() )
|
||||
{
|
||||
artifacts.addAll( metadataResolver.getArtifacts( repoId, groupId, artifactId, version ) );
|
||||
}
|
||||
|
||||
if ( !artifacts.isEmpty() )
|
||||
{
|
||||
String prefix = req.getContextPath() + "/repository/";
|
||||
|
||||
if ( mini )
|
||||
{
|
||||
// TODO: write 1 line download link for main artifact.
|
||||
}
|
||||
else
|
||||
{
|
||||
appendNormal( sb, prefix, artifacts );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( RepositoryNotFoundException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
writer.write( sb.toString() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new StrutsException( "IOError: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
return super.end( writer, body );
|
||||
}
|
||||
|
||||
private void appendNormal( StringBuffer sb, String prefix, List<ArtifactMetadata> relatedArtifacts )
|
||||
throws RepositoryException
|
||||
{
|
||||
/*
|
||||
* <div class="download">
|
||||
* <div class="hd">
|
||||
* <div class="c"></div>
|
||||
* </div>
|
||||
* <div class="bd">
|
||||
* <div class="c">
|
||||
* <-- main content goes here -->
|
||||
* </div>
|
||||
* </div>
|
||||
* <div class="ft">
|
||||
* <div class="c"></div>
|
||||
* </div>
|
||||
* </div>
|
||||
*/
|
||||
|
||||
sb.append( "<div class=\"download\">" );
|
||||
sb.append( "<div class=\"hd\"><div class=\"c\"></div></div>" );
|
||||
sb.append( "<div class=\"bd\"><div class=\"c\">" );
|
||||
|
||||
// Heading
|
||||
sb.append( "<h2>" );
|
||||
if ( relatedArtifacts.size() > 1 )
|
||||
{
|
||||
sb.append( "Downloads" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "Download" );
|
||||
}
|
||||
sb.append( "</h2>" );
|
||||
|
||||
// Body
|
||||
sb.append( "<p class=\"body\">" );
|
||||
|
||||
sb.append( "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" );
|
||||
for ( ArtifactMetadata artifact : relatedArtifacts )
|
||||
{
|
||||
String repoId = artifact.getRepositoryId();
|
||||
ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId );
|
||||
|
||||
sb.append( "\n<tr>" );
|
||||
|
||||
sb.append( "<td class=\"icon\">" );
|
||||
appendImageLink( sb, prefix + repoId, repo, artifact );
|
||||
sb.append( "</td>" );
|
||||
|
||||
sb.append( "<td class=\"type\">" );
|
||||
appendLink( sb, prefix + repoId, repo, artifact );
|
||||
sb.append( "</td>" );
|
||||
|
||||
sb.append( "<td class=\"size\">" );
|
||||
appendFilesize( sb, artifact );
|
||||
sb.append( "</td>" );
|
||||
|
||||
sb.append( "</tr>" );
|
||||
}
|
||||
sb.append( "</table>" );
|
||||
sb.append( "</p>" );
|
||||
|
||||
sb.append( "</div>" ); // close "downloadbox.bd.c"
|
||||
sb.append( "</div>" ); // close "downloadbox.bd"
|
||||
|
||||
sb.append( "<div class=\"ft\"><div class=\"c\"></div></div>" );
|
||||
sb.append( "</div>" ); // close "download"
|
||||
}
|
||||
|
||||
private void appendImageLink( StringBuffer sb, String prefix, ManagedRepositoryContent repo,
|
||||
ArtifactMetadata artifact )
|
||||
{
|
||||
String path = getPath( repo, artifact );
|
||||
String type = getType( repo, path );
|
||||
String linkText = "<img src=\"" + req.getContextPath() + "/images/" + getDownloadImage( type ) + "\" />";
|
||||
appendLink( sb, prefix, artifact, linkText, path );
|
||||
}
|
||||
|
||||
private String getType( ManagedRepositoryContent repo, String path )
|
||||
{
|
||||
String type = null;
|
||||
try
|
||||
{
|
||||
type = repo.toArtifactReference( path ).getType();
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
e.printStackTrace(); //TODO
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
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, ArtifactMetadata artifact, String linkText,
|
||||
String path )
|
||||
{
|
||||
|
||||
StringBuffer url = new StringBuffer();
|
||||
url.append( prefix );
|
||||
url.append( "/" ).append( path );
|
||||
|
||||
sb.append( "<a href=\"" ).append( StringEscapeUtils.escapeXml( url.toString() ) ).append( "\"" );
|
||||
sb.append( " title=\"" ).append( "Download " ).append( StringEscapeUtils.escapeXml( artifact.getId() ) ).append(
|
||||
"\"" );
|
||||
sb.append( ">" );
|
||||
|
||||
sb.append( linkText );
|
||||
|
||||
sb.append( "</a>" );
|
||||
}
|
||||
|
||||
private static String getPath( ManagedRepositoryContent repo, ArtifactMetadata artifact )
|
||||
{
|
||||
// TODO: use metadata resolver capability instead
|
||||
ArtifactReference ref = new ArtifactReference();
|
||||
ref.setArtifactId( artifact.getProject() );
|
||||
ref.setGroupId( artifact.getNamespace() );
|
||||
ref.setVersion( artifact.getVersion() );
|
||||
String path = repo.toPath( ref );
|
||||
path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifact.getId();
|
||||
return path;
|
||||
}
|
||||
|
||||
private void appendLink( StringBuffer sb, String prefix, ManagedRepositoryContent repo, ArtifactMetadata artifact )
|
||||
{
|
||||
String path = getPath( repo, artifact );
|
||||
String type = getType( repo, path );
|
||||
String linkText = StringUtils.capitalize( type );
|
||||
|
||||
appendLink( sb, prefix, artifact, linkText, path );
|
||||
}
|
||||
|
||||
private void appendFilesize( StringBuffer sb, ArtifactMetadata artifact )
|
||||
{
|
||||
sb.append( decimalFormat.format( artifact.getSize() ) );
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public void setMini( boolean mini )
|
||||
{
|
||||
this.mini = mini;
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Collection<String> getObservableRepos()
|
||||
{
|
||||
try
|
||||
{
|
||||
ActionContext context = ActionContext.getContext();
|
||||
Map session = context.getSession();
|
||||
return userRepositories.getObservableRepositoryIds( ArchivaXworkUser.getActivePrincipal( session ) );
|
||||
}
|
||||
catch ( ArchivaSecurityException e )
|
||||
{
|
||||
e.printStackTrace(); //TODO
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package org.apache.maven.archiva.web.tags;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.views.jsp.ComponentTagSupport;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* DownloadArtifactTag
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DownloadArtifactTag
|
||||
extends ComponentTagSupport
|
||||
{
|
||||
private String groupId_; // stores EL-based groupId property
|
||||
|
||||
private String groupId; // stores the evaluated groupId object.
|
||||
|
||||
private String artifactId_; // stores EL-based artifactId property
|
||||
|
||||
private String artifactId; // stores the evaluated artifactId object.
|
||||
|
||||
private String version_; // stores EL-based version property
|
||||
|
||||
private String version; // stores the evaluated version object.
|
||||
|
||||
private String mini_; // stores EL-based mini property
|
||||
|
||||
private boolean mini; // stores the evaluated mini object.
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack valueStack, HttpServletRequest request, HttpServletResponse response) {
|
||||
return new DownloadArtifact(valueStack, pageContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doEndTag()
|
||||
throws JspException
|
||||
{
|
||||
evaluateExpressions();
|
||||
|
||||
DownloadArtifact download = (DownloadArtifact)component;
|
||||
download.setGroupId( groupId );
|
||||
download.setArtifactId( artifactId );
|
||||
download.setVersion( version );
|
||||
download.setMini( mini );
|
||||
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
private void evaluateExpressions()
|
||||
throws JspException
|
||||
{
|
||||
ExpressionTool exprTool = new ExpressionTool( pageContext, this, "download" );
|
||||
|
||||
// Handle required properties.
|
||||
groupId = exprTool.requiredString( "groupId", groupId_ );
|
||||
artifactId = exprTool.requiredString( "artifactId", artifactId_ );
|
||||
version = exprTool.requiredString( "version", version_ );
|
||||
|
||||
// Handle optional properties
|
||||
mini = exprTool.optionalBoolean( "mini", mini_, false );
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
this.artifactId_ = artifactId;
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
this.groupId_ = groupId;
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
this.version_ = version;
|
||||
}
|
||||
}
|
|
@ -215,7 +215,7 @@
|
|||
</action>
|
||||
|
||||
<action name="showArtifactDependencyTree" class="showArtifactAction" method="dependencyTree">
|
||||
<result>/WEB-INF/jsp/artifact/dependencyTree.jsp</result>
|
||||
<result>/WEB-INF/jsp/showArtifact.jsp</result>
|
||||
</action>
|
||||
|
||||
</package>
|
||||
|
|
|
@ -27,8 +27,4 @@
|
|||
<decorator name="default" page="default.jsp">
|
||||
<pattern>/*</pattern>
|
||||
</decorator>
|
||||
|
||||
<decorator name="artifactDetails" page="artifactDecorator.jsp">
|
||||
<pattern>/*/dependencyTree</pattern>
|
||||
</decorator>
|
||||
</decorators>
|
|
@ -1,28 +0,0 @@
|
|||
<%--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. The ASF licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
--%>
|
||||
|
||||
<%@ taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page" %>
|
||||
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %>
|
||||
|
||||
<archiva:dependency-tree groupId="${groupId}" artifactId="${artifactId}" version="${version}"
|
||||
modelVersion="${model.version}">
|
||||
<my:showArtifactLink groupId="${node.groupId}" artifactId="${node.artifactId}"
|
||||
version="${node.version}"/>
|
||||
</archiva:dependency-tree>
|
|
@ -1,150 +0,0 @@
|
|||
<%--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. The ASF licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
--%>
|
||||
|
||||
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
|
||||
<%@ taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page" %>
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %>
|
||||
|
||||
<page:applyDecorator name="default">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Browse Repository</title>
|
||||
<s:head/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<c:set var="mavenFacet" value="${model.facets['org.apache.archiva.metadata.repository.storage.maven2']}" />
|
||||
<s:set name="model" value="model"/>
|
||||
<c:choose>
|
||||
<c:when test="${facet.packaging == 'maven-plugin'}">
|
||||
<c:url var="imageUrl" value="/images/mavenplugin.gif"/>
|
||||
<c:set var="packageName">Maven Plugin</c:set>
|
||||
</c:when>
|
||||
<c:when test="${facet.packaging == 'pom'}">
|
||||
<c:url var="imageUrl" value="/images/pom.gif"/>
|
||||
<c:set var="packageName">POM</c:set>
|
||||
</c:when>
|
||||
<%-- These types aren't usually set in the POM yet, so we fudge them for the well known ones --%>
|
||||
<c:when test="${facet.packaging == 'maven-archetype' or facet.groupId == 'org.apache.maven.archetypes'}">
|
||||
<c:url var="imageUrl" value="/images/archetype.gif"/>
|
||||
<c:set var="packageName">Maven Archetype</c:set>
|
||||
</c:when>
|
||||
<c:when test="${facet.packaging == 'maven-skin' or facet.groupId == 'org.apache.maven.skins'}">
|
||||
<c:url var="imageUrl" value="/images/skin.gif"/>
|
||||
<c:set var="packageName">Maven Skin</c:set>
|
||||
</c:when>
|
||||
<%-- Must be last so that the above get picked up if possible --%>
|
||||
<c:when test="${facet.packaging == 'jar'}">
|
||||
<c:url var="imageUrl" value="/images/jar.gif"/>
|
||||
<c:set var="packageName">JAR</c:set>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:url var="imageUrl" value="/images/other.gif"/>
|
||||
<c:set var="packageName"></c:set>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<img src="${imageUrl}" width="66" height="66" alt="${packageName}" title="${packageName}" style="float: left"/>
|
||||
|
||||
<h1>
|
||||
<c:choose>
|
||||
<c:when test="${empty (model.name)}">
|
||||
${facet.artifactId}
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
${model.name}
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</h1>
|
||||
|
||||
<div id="contentArea">
|
||||
<div id="tabs">
|
||||
<span>
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifact">
|
||||
<s:param name="groupId" value="%{groupId}"/>
|
||||
<s:param name="artifactId" value="%{artifactId}"/>
|
||||
<s:param name="version" value="%{version}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<my:currentWWUrl url="${url}">Info</my:currentWWUrl>
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifactDependencies">
|
||||
<s:param name="groupId" value="%{groupId}"/>
|
||||
<s:param name="artifactId" value="%{artifactId}"/>
|
||||
<s:param name="version" value="%{version}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<my:currentWWUrl url="${url}">Dependencies</my:currentWWUrl>
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifactDependencyTree">
|
||||
<s:param name="groupId" value="%{groupId}"/>
|
||||
<s:param name="artifactId" value="%{artifactId}"/>
|
||||
<s:param name="version" value="%{version}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<my:currentWWUrl url="${url}">Dependency Tree</my:currentWWUrl>
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifactDependees">
|
||||
<s:param name="groupId" value="%{groupId}"/>
|
||||
<s:param name="artifactId" value="%{artifactId}"/>
|
||||
<s:param name="version" value="%{version}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<my:currentWWUrl url="${url}">Used By</my:currentWWUrl>
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifactMailingLists">
|
||||
<s:param name="groupId" value="%{groupId}"/>
|
||||
<s:param name="artifactId" value="%{artifactId}"/>
|
||||
<s:param name="version" value="%{version}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<my:currentWWUrl url="${url}">Mailing Lists</my:currentWWUrl>
|
||||
<%-- POSTPONED to 1.0-alpha-2
|
||||
<redback:ifAnyAuthorized permissions="archiva-access-reports">
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifactReports">
|
||||
<s:param name="groupId" value="%{groupId}"/>
|
||||
<s:param name="artifactId" value="%{artifactId}"/>
|
||||
<s:param name="version" value="%{version}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<my:currentWWUrl url="${url}">Reports</my:currentWWUrl>
|
||||
</redback:ifAnyAuthorized>
|
||||
--%>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="sidebar3">
|
||||
<archiva:downloadArtifact groupId="${groupId}" artifactId="${artifactId}" version="${version}" />
|
||||
</div>
|
||||
|
||||
<decorator:body />
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</page:applyDecorator>
|
|
@ -91,23 +91,6 @@
|
|||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
<c:if test="${(snapshotVersions != null) && (!empty snapshotVersions)}">
|
||||
<tr>
|
||||
<th>Other Versions</th>
|
||||
<td>
|
||||
<c:forEach items="${snapshotVersions}" var="snapshot">
|
||||
<c:set var="url">
|
||||
<s:url action="showArtifact" namespace="/">
|
||||
<s:param name="groupId" value="%{#attr.mavenFacet.groupId}"/>
|
||||
<s:param name="artifactId" value="%{#attr.mavenFacet.artifactId}"/>
|
||||
<s:param name="version" value="%{#attr.snapshot}"/>
|
||||
</s:url>
|
||||
</c:set>
|
||||
<a href="${url}">${snapshot}</a>
|
||||
</c:forEach>
|
||||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
<%-- TODO: deployment timestamp
|
||||
<tr>
|
||||
<th>Deployment Date</th>
|
||||
|
|
|
@ -17,15 +17,11 @@
|
|||
~ under the License.
|
||||
--%>
|
||||
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %>
|
||||
|
||||
<archiva:dependency-tree groupId="${groupId}" artifactId="${artifactId}" version="${version}" />
|
||||
|
||||
<%--
|
||||
<my:showArtifactLink groupId="${node.artifact.groupId}" artifactId="${node.artifact.artifactId}"
|
||||
version="${node.artifact.version}"/>
|
||||
--%>
|
||||
|
||||
<archiva:dependency-tree groupId="${groupId}" artifactId="${artifactId}" version="${version}"
|
||||
modelVersion="${model.version}">
|
||||
<my:showArtifactLink groupId="${node.groupId}" artifactId="${node.artifactId}"
|
||||
version="${node.version}"/>
|
||||
</archiva:dependency-tree>
|
||||
|
|
|
@ -27,6 +27,14 @@
|
|||
<head>
|
||||
<title>Browse Repository</title>
|
||||
<s:head/>
|
||||
<script type="text/javascript" src="<c:url value='/js/jquery-1.3.2.min.js'/>"></script>
|
||||
<script type="text/javascript" src="<c:url value='/js/jquery-ui-1.7.2.custom.min.js'/>"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("#accordion").accordion({autoHeight:false});
|
||||
});
|
||||
</script>
|
||||
<link rel="stylesheet" href="<c:url value='/css/no-theme/jquery-ui-1.7.2.custom.css'/>" type="text/css" media="all"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -134,8 +142,64 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<div class="sidebar3">
|
||||
<archiva:downloadArtifact groupId="${mavenFacet.groupId}" artifactId="${mavenFacet.artifactId}" version="${model.version}"/>
|
||||
<div id="download">
|
||||
<h2>Download</h2>
|
||||
|
||||
<div id="accordion">
|
||||
<c:forEach items="${snapshotVersions}" var="v">
|
||||
<p><a href="#">${v}</a></p>
|
||||
<div>
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tbody>
|
||||
<c:forEach items="${artifacts[v]}" var="a">
|
||||
<c:choose>
|
||||
<c:when test="${a.type == 'maven-plugin'}">
|
||||
<c:url var="imageUrl" value="/images/download-type-maven-plugin.png"/>
|
||||
<c:set var="packageName">Maven Plugin</c:set>
|
||||
</c:when>
|
||||
<c:when test="${a.type == 'pom'}">
|
||||
<c:url var="imageUrl" value="/images/download-type-pom.png"/>
|
||||
<c:set var="packageName">POM</c:set>
|
||||
</c:when>
|
||||
<%-- These types aren't usually set in the POM yet, so we fudge them for the well known ones --%>
|
||||
<c:when test="${a.type == 'maven-archetype' or a.namespace == 'org.apache.maven.archetypes'}">
|
||||
<c:url var="imageUrl" value="/images/download-type-archetype.png"/>
|
||||
<c:set var="packageName">Maven Archetype</c:set>
|
||||
</c:when>
|
||||
<c:when test="${a.type == 'maven-skin' or a.namespace == 'org.apache.maven.skins'}">
|
||||
<c:url var="imageUrl" value="/images/download-type-skin.png"/>
|
||||
<c:set var="packageName">Maven Skin</c:set>
|
||||
</c:when>
|
||||
<c:when test="${a.type == 'java-source'}">
|
||||
<c:url var="imageUrl" value="/images/download-type-jar.png"/>
|
||||
<c:set var="packageName">Java Sources</c:set>
|
||||
</c:when>
|
||||
<c:when test="${a.type == 'javadoc'}">
|
||||
<c:url var="imageUrl" value="/images/download-type-other.png"/>
|
||||
<c:set var="packageName">JavaDoc Archive</c:set>
|
||||
</c:when>
|
||||
<%-- 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:when>
|
||||
<c:otherwise>
|
||||
<c:url var="imageUrl" value="/images/download-type-other.png"/>
|
||||
<c:set var="packageName">${a.type}</c:set>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<c:url var="url" value="/repository/${a.repositoryId}/${a.path}" />
|
||||
<tr>
|
||||
<td><a href="${url}" title="Download ${a.id}"><img src="${imageUrl}" alt="" width="24" height="24"/></a></td>
|
||||
<td class="type"><a href="${url}" title="Download ${a.id}">${packageName}</a></td>
|
||||
<td class="size">${a.size}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</c:forEach>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%-- TODO: perhaps using ajax? --%>
|
||||
|
@ -145,7 +209,7 @@
|
|||
<c:when test="${dependencies != null}">
|
||||
<%@ include file="/WEB-INF/jsp/include/artifactDependencies.jspf" %>
|
||||
</c:when>
|
||||
<c:when test="${dependencyTree != null}">
|
||||
<c:when test="${dependencyTree}">
|
||||
<%@ include file="/WEB-INF/jsp/include/dependencyTree.jspf" %>
|
||||
</c:when>
|
||||
<c:when test="${dependees != null}">
|
||||
|
|
|
@ -37,47 +37,6 @@
|
|||
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
|
||||
<name>downloadArtifact</name>
|
||||
<tag-class>org.apache.maven.archiva.web.tags.DownloadArtifactTag</tag-class>
|
||||
<body-content>empty</body-content>
|
||||
<description><![CDATA[Render a a set of download links for an artifact]]></description>
|
||||
|
||||
<attribute>
|
||||
<name>groupId</name>
|
||||
<required>true</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
|
||||
<description><![CDATA[The GroupID String]]></description>
|
||||
</attribute>
|
||||
|
||||
<attribute>
|
||||
<name>artifactId</name>
|
||||
<required>true</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
|
||||
<description><![CDATA[The ArtifactID String]]></description>
|
||||
</attribute>
|
||||
|
||||
<attribute>
|
||||
<name>version</name>
|
||||
<required>true</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
|
||||
<description><![CDATA[The Version String]]></description>
|
||||
</attribute>
|
||||
|
||||
<attribute>
|
||||
<name>mini</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
|
||||
<description><![CDATA[Boolean indicating if the download link is to be generated in mini format instead.]]></description>
|
||||
</attribute>
|
||||
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
|
||||
<name>copy-paste-snippet</name>
|
||||
|
|
|
@ -16,118 +16,21 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
.sidebar3 {
|
||||
width: 10em;
|
||||
|
||||
#download {
|
||||
float: right;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#sidebarb {
|
||||
font-size: small;
|
||||
text-align: center;
|
||||
padding: 10px 10px 10px 10px;
|
||||
border: 1px #DFDEDE solid;
|
||||
width: 10em;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
float: right;
|
||||
font-size: small;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px #DFDEDE solid;
|
||||
width: 10em;
|
||||
}
|
||||
|
||||
.download {
|
||||
float: right;
|
||||
font-size: small;
|
||||
font-weight: bold;
|
||||
margin: 15px auto 0px auto;
|
||||
height: auto;
|
||||
width: 150px;
|
||||
min-width: 120px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.download .hd .c,
|
||||
.download .ft .c {
|
||||
font-size: 1px; /* ensure minimum height */
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.download .ft .c {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.download .hd {
|
||||
background: transparent url(../images/download.tl.gif) no-repeat 0px 0px;
|
||||
}
|
||||
|
||||
.download .hd .c {
|
||||
background: transparent url(../images/download.tr.gif) no-repeat right 0px;
|
||||
}
|
||||
|
||||
.download .bd {
|
||||
background: transparent url(../images/download.ml.gif) repeat-y 0px 0px;
|
||||
}
|
||||
|
||||
.download .bd .c {
|
||||
background: transparent url(../images/download.mr.gif) repeat-y right 0px;
|
||||
}
|
||||
|
||||
.download .bd .c .s {
|
||||
margin: 0px 8px 0px 4px;
|
||||
background: #000 url(../images/download.ms.jpg) repeat-x 0px 0px;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.download .ft {
|
||||
background: transparent url(../images/download.bl.gif) no-repeat 0px 0px;
|
||||
}
|
||||
|
||||
.download .ft .c {
|
||||
background: transparent url(../images/download.br.gif) no-repeat right 0px;
|
||||
}
|
||||
|
||||
.download .bd h2 {
|
||||
margin: 0px;
|
||||
text-align: center;
|
||||
border-bottom-width: 0px !important;
|
||||
}
|
||||
|
||||
.download .bd p {
|
||||
margin: 0px;
|
||||
border: 0px;
|
||||
text-align: left;
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.download a {
|
||||
#download a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.download p.body {
|
||||
font-weight: bold;
|
||||
#download td.type {
|
||||
padding-right: 1em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.download table {
|
||||
margin-left: 2px;
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.download .icon {
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.download .type {
|
||||
font-size: 0.9em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.download .size {
|
||||
font-weight: normal;
|
||||
font-size: 0.8em;
|
||||
#download td.size {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class TestMetadataResolver
|
|||
{
|
||||
private Map<String, ProjectVersionMetadata> projectVersions = new HashMap<String, ProjectVersionMetadata>();
|
||||
|
||||
private Map<String, List<String>> artifactVersions = new HashMap<String, List<String>>();
|
||||
private Map<String, List<ArtifactMetadata>> artifacts = new HashMap<String, List<ArtifactMetadata>>();
|
||||
|
||||
private Map<String, List<ProjectVersionReference>> references =
|
||||
new HashMap<String, List<ProjectVersionReference>>();
|
||||
|
@ -66,8 +66,7 @@ public class TestMetadataResolver
|
|||
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
{
|
||||
List<String> versions = artifactVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
|
||||
return ( versions != null ? versions : Collections.<String>emptyList() );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
|
||||
|
@ -123,7 +122,9 @@ public class TestMetadataResolver
|
|||
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
{
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
List<ArtifactMetadata> artifacts =
|
||||
this.artifacts.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
|
||||
return ( artifacts != null ? artifacts : Collections.<ArtifactMetadata>emptyList() );
|
||||
}
|
||||
|
||||
public void setProjectVersion( String repoId, String namespace, String projectId,
|
||||
|
@ -149,10 +150,10 @@ public class TestMetadataResolver
|
|||
versions.add( versionMetadata.getId() );
|
||||
}
|
||||
|
||||
public void setArtifactVersions( String repoId, String namespace, String projectId, String projectVersion,
|
||||
List<String> versions )
|
||||
public void setArtifacts( String repoId, String namespace, String projectId, String projectVersion,
|
||||
List<ArtifactMetadata> artifacts )
|
||||
{
|
||||
artifactVersions.put( createMapKey( repoId, namespace, projectId, projectVersion ), versions );
|
||||
this.artifacts.put( createMapKey( repoId, namespace, projectId, projectVersion ), artifacts );
|
||||
}
|
||||
|
||||
private String createMapKey( String repoId, String namespace, String projectId, String projectVersion )
|
||||
|
|
|
@ -22,13 +22,21 @@ package org.apache.maven.archiva.web.action;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.Dependency;
|
||||
import org.apache.archiva.metadata.model.MailingList;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionReference;
|
||||
import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
|
||||
import org.easymock.MockControl;
|
||||
import org.easymock.classextension.MockClassControl;
|
||||
|
||||
public class ShowArtifactActionTest
|
||||
extends AbstractActionTestCase
|
||||
|
@ -41,13 +49,18 @@ public class ShowArtifactActionTest
|
|||
|
||||
private static final String TEST_TS_SNAPSHOT_VERSION = "1.0-20091120.111111-1";
|
||||
|
||||
private static final List<String> ALL_TEST_SNAPSHOT_VERSIONS =
|
||||
Arrays.asList( TEST_TS_SNAPSHOT_VERSION, "1.0-20091120.222222-2", "1.0-20091123.333333-3" );
|
||||
|
||||
private static final String OTHER_TEST_REPO = "first-repo";
|
||||
|
||||
private ShowArtifactAction action;
|
||||
|
||||
private static final List<ArtifactMetadata> TEST_SNAPSHOT_ARTIFACTS =
|
||||
Arrays.asList( createArtifact( TEST_TS_SNAPSHOT_VERSION ), createArtifact( "1.0-20091120.222222-2" ),
|
||||
createArtifact( "1.0-20091123.333333-3" ) );
|
||||
|
||||
private static final long TEST_SIZE = 12345L;
|
||||
|
||||
private static final String TEST_TYPE = "jar";
|
||||
|
||||
public void testInstantiation()
|
||||
{
|
||||
assertFalse( action == lookup( Action.class, ACTION_HINT ) );
|
||||
|
@ -73,15 +86,15 @@ public class ShowArtifactActionTest
|
|||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertTrue( action.getSnapshotVersions().isEmpty() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetArtifactUniqueSnapshot()
|
||||
{
|
||||
metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
|
||||
createProjectModel( TEST_SNAPSHOT_VERSION ) );
|
||||
metadataResolver.setArtifactVersions( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
|
||||
ALL_TEST_SNAPSHOT_VERSIONS );
|
||||
metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
|
||||
TEST_SNAPSHOT_ARTIFACTS );
|
||||
|
||||
action.setGroupId( TEST_GROUP_ID );
|
||||
action.setArtifactId( TEST_ARTIFACT_ID );
|
||||
|
@ -99,7 +112,7 @@ public class ShowArtifactActionTest
|
|||
|
||||
assertEquals( TEST_REPO, action.getRepositoryId() );
|
||||
|
||||
assertEquals( ALL_TEST_SNAPSHOT_VERSIONS, action.getSnapshotVersions() );
|
||||
assertArtifacts( TEST_SNAPSHOT_ARTIFACTS, action.getArtifacts() );
|
||||
|
||||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
|
@ -109,32 +122,17 @@ public class ShowArtifactActionTest
|
|||
public void testGetArtifactUniqueSnapshotTimestamped()
|
||||
{
|
||||
metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
|
||||
createProjectModel( TEST_TS_SNAPSHOT_VERSION ) );
|
||||
metadataResolver.setArtifactVersions( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_TS_SNAPSHOT_VERSION,
|
||||
ALL_TEST_SNAPSHOT_VERSIONS );
|
||||
createProjectModel( TEST_SNAPSHOT_VERSION ) );
|
||||
metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
|
||||
TEST_SNAPSHOT_ARTIFACTS );
|
||||
|
||||
action.setGroupId( TEST_GROUP_ID );
|
||||
action.setArtifactId( TEST_ARTIFACT_ID );
|
||||
action.setVersion( TEST_TS_SNAPSHOT_VERSION );
|
||||
|
||||
String result = action.artifact();
|
||||
|
||||
assertActionSuccess( action, result );
|
||||
|
||||
assertEquals( TEST_GROUP_ID, action.getGroupId() );
|
||||
assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
|
||||
assertEquals( TEST_TS_SNAPSHOT_VERSION, action.getVersion() );
|
||||
ProjectVersionMetadata model = action.getModel();
|
||||
assertDefaultModel( model, TEST_TS_SNAPSHOT_VERSION );
|
||||
|
||||
assertEquals( TEST_REPO, action.getRepositoryId() );
|
||||
|
||||
assertEquals( Arrays.asList( ALL_TEST_SNAPSHOT_VERSIONS.get( 1 ), ALL_TEST_SNAPSHOT_VERSIONS.get( 2 ) ),
|
||||
action.getSnapshotVersions() );
|
||||
|
||||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertError( result );
|
||||
assertNoOutputFields();
|
||||
}
|
||||
|
||||
public void testGetMissingProject()
|
||||
|
@ -197,7 +195,7 @@ public class ShowArtifactActionTest
|
|||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertTrue( action.getSnapshotVersions().isEmpty() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetArtifactSeenInBothObservableRepo()
|
||||
|
@ -223,7 +221,7 @@ public class ShowArtifactActionTest
|
|||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertTrue( action.getSnapshotVersions().isEmpty() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetArtifactCanOnlyObserveInOneOfTwoRepos()
|
||||
|
@ -249,7 +247,7 @@ public class ShowArtifactActionTest
|
|||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertTrue( action.getSnapshotVersions().isEmpty() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetArtifactNoMavenFacet()
|
||||
|
@ -280,7 +278,7 @@ public class ShowArtifactActionTest
|
|||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertTrue( action.getSnapshotVersions().isEmpty() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetMailingLists()
|
||||
|
@ -305,10 +303,10 @@ public class ShowArtifactActionTest
|
|||
assertMailingList( action.getMailingLists().get( 0 ), "Users List", "users" );
|
||||
assertMailingList( action.getMailingLists().get( 1 ), "Developers List", "dev" );
|
||||
|
||||
assertNull( action.getRepositoryId() );
|
||||
assertEquals( TEST_REPO, action.getRepositoryId() );
|
||||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getSnapshotVersions() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetDependencies()
|
||||
|
@ -333,10 +331,10 @@ public class ShowArtifactActionTest
|
|||
assertDependencyBasic( action.getDependencies().get( 0 ), "artifactId1" );
|
||||
assertDependencyExtended( action.getDependencies().get( 1 ), "artifactId2" );
|
||||
|
||||
assertNull( action.getRepositoryId() );
|
||||
assertEquals( TEST_REPO, action.getRepositoryId() );
|
||||
assertNull( action.getDependees() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertNull( action.getSnapshotVersions() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
public void testGetDependees()
|
||||
|
@ -362,10 +360,45 @@ public class ShowArtifactActionTest
|
|||
assertCoordinate( action.getDependees().get( 0 ), "artifactId1" );
|
||||
assertCoordinate( action.getDependees().get( 1 ), "artifactId2" );
|
||||
|
||||
assertNull( action.getRepositoryId() );
|
||||
assertEquals( TEST_REPO, action.getRepositoryId() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertNull( action.getSnapshotVersions() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
private void assertArtifacts( List<ArtifactMetadata> expectedArtifacts,
|
||||
Map<String, List<ShowArtifactAction.ArtifactDownloadInfo>> artifactMap )
|
||||
{
|
||||
// assuming only one of each version at this point
|
||||
assertEquals( expectedArtifacts.size(), artifactMap.size() );
|
||||
for ( ArtifactMetadata artifact : expectedArtifacts )
|
||||
{
|
||||
assertTrue( artifactMap.containsKey( artifact.getVersion() ) );
|
||||
List<ShowArtifactAction.ArtifactDownloadInfo> list = artifactMap.get( artifact.getVersion() );
|
||||
ShowArtifactAction.ArtifactDownloadInfo actual = list.get( 0 );
|
||||
assertEquals( artifact.getNamespace(), actual.getNamespace() );
|
||||
assertEquals( artifact.getId(), actual.getId() );
|
||||
assertEquals( artifact.getProject(), actual.getProject() );
|
||||
assertEquals( artifact.getRepositoryId(), actual.getRepositoryId() );
|
||||
assertEquals( artifact.getSize(), actual.getSize() );
|
||||
assertEquals( artifact.getVersion(), actual.getVersion() );
|
||||
assertEquals( TEST_TYPE, actual.getType() );
|
||||
assertEquals( TEST_SIZE, actual.getSize() );
|
||||
assertEquals( artifact.getNamespace() + "/" + artifact.getProject() + "/" + TEST_SNAPSHOT_VERSION + "/" +
|
||||
artifact.getId(), actual.getPath() );
|
||||
}
|
||||
}
|
||||
|
||||
private static ArtifactMetadata createArtifact( String version )
|
||||
{
|
||||
ArtifactMetadata metadata = new ArtifactMetadata();
|
||||
metadata.setProject( TEST_ARTIFACT_ID );
|
||||
metadata.setId( TEST_ARTIFACT_ID + "-" + version + ".jar" );
|
||||
metadata.setNamespace( TEST_GROUP_ID );
|
||||
metadata.setRepositoryId( TEST_REPO );
|
||||
metadata.setSize( TEST_SIZE );
|
||||
metadata.setVersion( version );
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private ProjectVersionReference createReference( String projectId )
|
||||
|
@ -452,7 +485,7 @@ public class ShowArtifactActionTest
|
|||
assertNull( action.getDependees() );
|
||||
assertNull( action.getDependencies() );
|
||||
assertNull( action.getMailingLists() );
|
||||
assertTrue( action.getSnapshotVersions().isEmpty() );
|
||||
assertTrue( action.getArtifacts().isEmpty() );
|
||||
}
|
||||
|
||||
private void assertError( String result )
|
||||
|
@ -493,5 +526,17 @@ public class ShowArtifactActionTest
|
|||
super.setUp();
|
||||
action = (ShowArtifactAction) lookup( Action.class, ACTION_HINT );
|
||||
metadataResolver = (TestMetadataResolver) action.getMetadataResolver();
|
||||
MockControl control = MockClassControl.createControl( RepositoryContentFactory.class );
|
||||
RepositoryContentFactory factory = (RepositoryContentFactory) control.getMock();
|
||||
action.setRepositoryFactory( factory );
|
||||
|
||||
ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
|
||||
config.setId( TEST_REPO );
|
||||
config.setLocation( getTestFile( "target/test-repo" ).getAbsolutePath() );
|
||||
ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
|
||||
content.setRepository( config );
|
||||
factory.getManagedRepositoryContent( TEST_REPO );
|
||||
control.setDefaultReturnValue( content );
|
||||
control.replay();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue