mirror of
https://github.com/apache/archiva.git
synced 2025-02-28 21:49:10 +00:00
[MRM-345]: Browsing shows no information.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@538642 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba721ad3cc
commit
6c1ebee773
@ -69,7 +69,7 @@ public BrowsingResults selectArtifactId( String groupId, String artifactId )
|
||||
|
||||
// results.setGroupIds( groups );
|
||||
// results.setArtifacts( artifacts );
|
||||
results.setArtifacts( versions );
|
||||
results.setVersions( versions );
|
||||
|
||||
return results;
|
||||
}
|
||||
|
@ -48,12 +48,14 @@ public class BrowseAction
|
||||
|
||||
public String browse()
|
||||
{
|
||||
getLogger().info( ".browse()" );
|
||||
this.results = repoBrowsing.getRoot();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String browseGroup()
|
||||
{
|
||||
getLogger().info( ".browseGroup( " + groupId + " )" );
|
||||
if ( StringUtils.isEmpty( groupId ) )
|
||||
{
|
||||
// TODO: i18n
|
||||
@ -67,6 +69,7 @@ public String browseGroup()
|
||||
|
||||
public String browseArtifact()
|
||||
{
|
||||
getLogger().info( ".browseArtifact( " + groupId + "," + artifactId + " )" );
|
||||
if ( StringUtils.isEmpty( groupId ) )
|
||||
{
|
||||
// TODO: i18n
|
||||
|
@ -22,10 +22,13 @@
|
||||
import com.opensymphony.webwork.dispatcher.mapper.ActionMapping;
|
||||
import com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Map alternate URLs to specific actions. Used for the repository browser and the proxy.
|
||||
*
|
||||
@ -34,53 +37,37 @@
|
||||
public class RepositoryActionMapper
|
||||
extends DefaultActionMapper
|
||||
{
|
||||
private static final String BROWSE_PREFIX = "/browse/";
|
||||
private static final String ACTION_BROWSE = "browse";
|
||||
|
||||
private static final String PROXY_PREFIX = "/proxy/";
|
||||
private static final String ACTION_BROWSE_ARTIFACT = "browseArtifact";
|
||||
|
||||
public String getUriFromActionMapping( ActionMapping actionMapping )
|
||||
{
|
||||
Map params = actionMapping.getParams();
|
||||
if ( "browseGroup".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" );
|
||||
}
|
||||
else if ( "browseArtifact".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" );
|
||||
}
|
||||
else if ( "showArtifact".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" ) + "/" +
|
||||
params.remove( "version" );
|
||||
}
|
||||
else if ( "showArtifactDependencies".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" ) + "/" +
|
||||
params.remove( "version" ) + "/dependencies";
|
||||
}
|
||||
else if ( "showArtifactMailingLists".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" ) + "/" +
|
||||
params.remove( "version" ) + "/mailingLists";
|
||||
}
|
||||
else if ( "showArtifactDependees".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" ) + "/" +
|
||||
params.remove( "version" ) + "/usedby";
|
||||
}
|
||||
else if ( "showArtifactDependencyTree".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" ) + "/" +
|
||||
params.remove( "version" ) + "/dependencyTree";
|
||||
}
|
||||
else if ( "proxy".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return PROXY_PREFIX + params.remove( "path" );
|
||||
}
|
||||
private static final String ACTION_BROWSE_GROUP = "browseGroup";
|
||||
|
||||
return super.getUriFromActionMapping( actionMapping );
|
||||
}
|
||||
private static final String ACTION_SHOW_ARTIFACT = "showArtifact";
|
||||
|
||||
private static final String ACTION_SHOW_ARTIFACT_DEPENDEES = "showArtifactDependees";
|
||||
|
||||
private static final String ACTION_SHOW_ARTIFACT_DEPENDENCIES = "showArtifactDependencies";
|
||||
|
||||
private static final String ACTION_SHOW_ARTIFACT_DEPENDENCY_TREE = "showArtifactDependencyTree";
|
||||
|
||||
private static final String ACTION_SHOW_ARTIFACT_MAILING_LISTS = "showArtifactMailingLists";
|
||||
|
||||
private static final String BROWSE_PREFIX = "/browse";
|
||||
|
||||
private static final String METHOD_DEPENDENCIES = "dependencies";
|
||||
|
||||
private static final String METHOD_DEPENDENCY_TREE = "dependencyTree";
|
||||
|
||||
private static final String METHOD_MAILING_LISTS = "mailingLists";
|
||||
|
||||
private static final String METHOD_USEDBY = "usedby";
|
||||
|
||||
private static final String PARAM_ARTIFACT_ID = "artifactId";
|
||||
|
||||
private static final String PARAM_GROUP_ID = "groupId";
|
||||
|
||||
private static final String PARAM_VERSION = "version";
|
||||
|
||||
public ActionMapping getMapping( HttpServletRequest httpServletRequest )
|
||||
{
|
||||
@ -88,70 +75,134 @@ public ActionMapping getMapping( HttpServletRequest httpServletRequest )
|
||||
if ( path.startsWith( BROWSE_PREFIX ) )
|
||||
{
|
||||
path = path.substring( BROWSE_PREFIX.length() );
|
||||
if ( path.length() == 0 )
|
||||
if ( StringUtils.isBlank( path ) ||
|
||||
StringUtils.equals( path, "/" ) ||
|
||||
StringUtils.equals( path, ".action" ) )
|
||||
{
|
||||
return new ActionMapping( "browse", "/", "", null );
|
||||
// Return "root" browse.
|
||||
return new ActionMapping( ACTION_BROWSE, "/", "", null );
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] parts = path.split( "/" );
|
||||
if ( parts.length == 1 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
return new ActionMapping( "browseGroup", "/", "", params );
|
||||
}
|
||||
else if ( parts.length == 2 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
params.put( "artifactId", parts[1] );
|
||||
return new ActionMapping( "browseArtifact", "/", "", params );
|
||||
}
|
||||
else if ( parts.length == 3 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
params.put( "artifactId", parts[1] );
|
||||
params.put( "version", parts[2] );
|
||||
return new ActionMapping( "showArtifact", "/", "", params );
|
||||
}
|
||||
else if ( parts.length == 4 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
params.put( "artifactId", parts[1] );
|
||||
params.put( "version", parts[2] );
|
||||
Map params = new HashMap();
|
||||
|
||||
if ( "dependencies".equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( "showArtifactDependencies", "/", "", params );
|
||||
}
|
||||
else if ( "mailingLists".equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( "showArtifactMailingLists", "/", "", params );
|
||||
}
|
||||
else if ( "usedby".equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( "showArtifactDependees", "/", "", params );
|
||||
}
|
||||
else if ( "dependencyTree".equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( "showArtifactDependencyTree", "/", "", params );
|
||||
}
|
||||
if ( path.charAt( 0 ) == '/' )
|
||||
{
|
||||
path = path.substring( 1 );
|
||||
}
|
||||
|
||||
String[] parts = path.split( "/" );
|
||||
switch ( parts.length )
|
||||
{
|
||||
case 1:
|
||||
params.put( PARAM_GROUP_ID, parts[0] );
|
||||
return new ActionMapping( ACTION_BROWSE_GROUP, "/", "", params );
|
||||
|
||||
case 2:
|
||||
params.put( PARAM_GROUP_ID, parts[0] );
|
||||
params.put( PARAM_ARTIFACT_ID, parts[1] );
|
||||
return new ActionMapping( ACTION_BROWSE_ARTIFACT, "/", "", params );
|
||||
|
||||
case 3:
|
||||
params.put( PARAM_GROUP_ID, parts[0] );
|
||||
params.put( PARAM_ARTIFACT_ID, parts[1] );
|
||||
params.put( PARAM_VERSION, parts[2] );
|
||||
return new ActionMapping( ACTION_SHOW_ARTIFACT, "/", "", params );
|
||||
|
||||
case 4:
|
||||
params.put( PARAM_GROUP_ID, parts[0] );
|
||||
params.put( PARAM_ARTIFACT_ID, parts[1] );
|
||||
params.put( PARAM_VERSION, parts[2] );
|
||||
|
||||
if ( METHOD_DEPENDENCIES.equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( ACTION_SHOW_ARTIFACT_DEPENDENCIES, "/", "", params );
|
||||
}
|
||||
else if ( METHOD_MAILING_LISTS.equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( ACTION_SHOW_ARTIFACT_MAILING_LISTS, "/", "", params );
|
||||
}
|
||||
else if ( METHOD_USEDBY.equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( ACTION_SHOW_ARTIFACT_DEPENDEES, "/", "", params );
|
||||
}
|
||||
else if ( METHOD_DEPENDENCY_TREE.equals( parts[3] ) )
|
||||
{
|
||||
return new ActionMapping( ACTION_SHOW_ARTIFACT_DEPENDENCY_TREE, "/", "", params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( path.startsWith( PROXY_PREFIX ) )
|
||||
{
|
||||
// retain the leading /
|
||||
path = path.substring( PROXY_PREFIX.length() - 1 );
|
||||
|
||||
Map params = new HashMap();
|
||||
params.put( "path", path );
|
||||
return new ActionMapping( "proxy", "/", "", params );
|
||||
}
|
||||
|
||||
return super.getMapping( httpServletRequest );
|
||||
}
|
||||
|
||||
public String getUriFromActionMapping( ActionMapping actionMapping )
|
||||
{
|
||||
Map params = actionMapping.getParams();
|
||||
if ( ACTION_BROWSE.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX;
|
||||
}
|
||||
else if ( ACTION_BROWSE_GROUP.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, false, false, null );
|
||||
}
|
||||
else if ( ACTION_BROWSE_ARTIFACT.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, true, false, null );
|
||||
}
|
||||
else if ( ACTION_SHOW_ARTIFACT.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, true, true, null );
|
||||
}
|
||||
else if ( ACTION_SHOW_ARTIFACT_DEPENDENCIES.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, true, true, METHOD_DEPENDENCIES );
|
||||
}
|
||||
else if ( ACTION_SHOW_ARTIFACT_MAILING_LISTS.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, true, true, METHOD_MAILING_LISTS );
|
||||
}
|
||||
else if ( ACTION_SHOW_ARTIFACT_DEPENDEES.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, true, true, METHOD_USEDBY );
|
||||
}
|
||||
else if ( ACTION_SHOW_ARTIFACT_DEPENDENCY_TREE.equals( actionMapping.getName() ) )
|
||||
{
|
||||
return toUri( params, true, true, METHOD_DEPENDENCY_TREE );
|
||||
}
|
||||
|
||||
return super.getUriFromActionMapping( actionMapping );
|
||||
}
|
||||
|
||||
private String toUri( Map params, boolean artifactId, boolean version, String method )
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append( BROWSE_PREFIX );
|
||||
buf.append( '/' );
|
||||
buf.append( params.remove( PARAM_GROUP_ID ) );
|
||||
|
||||
if ( artifactId )
|
||||
{
|
||||
buf.append( '/' );
|
||||
buf.append( params.remove( PARAM_ARTIFACT_ID ) );
|
||||
|
||||
if ( version )
|
||||
{
|
||||
buf.append( '/' );
|
||||
buf.append( params.remove( PARAM_VERSION ) );
|
||||
|
||||
if ( StringUtils.isNotBlank( method ) )
|
||||
{
|
||||
buf.append( '/' );
|
||||
buf.append( method );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
@ -182,11 +182,11 @@
|
||||
</action>
|
||||
|
||||
<action name="browseGroup" class="browseAction" method="browseGroup">
|
||||
<result>/WEB-INF/jsp/browseGroup.jsp</result>
|
||||
<result>/WEB-INF/jsp/browse.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="browseArtifact" class="browseAction" method="browseArtifact">
|
||||
<result>/WEB-INF/jsp/browseArtifact.jsp</result>
|
||||
<result>/WEB-INF/jsp/browse.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="showArtifact" class="showArtifactAction" method="artifact">
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
<%@ taglib prefix="ww" uri="/webwork" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
|
||||
<html>
|
||||
@ -32,49 +33,66 @@
|
||||
<h1>Browse Repository</h1>
|
||||
|
||||
<div id="contentArea">
|
||||
<div id="nameColumn">
|
||||
<h2>Groups</h2>
|
||||
<ul>
|
||||
<ww:set name="groups" value="groups"/>
|
||||
<c:forEach items="${groups}" var="groupId">
|
||||
<c:set var="url">
|
||||
<ww:url action="browseGroup" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${groupId}'}"/>
|
||||
</ww:url>
|
||||
</c:set>
|
||||
<li><a href="${url}">${groupId}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<%-- TODO: later, when supported in metadata
|
||||
<div id="categoryColumn">
|
||||
<h2>Category</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#">Java</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#">Ruby</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2>Labels</h2>
|
||||
|
||||
<div id="labels">
|
||||
<c:if test="${not empty results.selectedGroupId}">
|
||||
<p>
|
||||
<a href="#">jdo</a>
|
||||
<a href="#">j2ee</a>
|
||||
<a href="#">maven</a>
|
||||
<archiva:groupIdLink var="${results.selectedGroupId}" includeTop="true" />
|
||||
<c:if test="${not empty results.selectedArtifactId}">
|
||||
<strong>${artifactId}</strong>
|
||||
</c:if>
|
||||
</p>
|
||||
</div>
|
||||
--%>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${not empty results.groupIds}">
|
||||
<div id="nameColumn">
|
||||
<h2>Groups</h2>
|
||||
<ul>
|
||||
<c:forEach items="${results.groupIds}" var="groupId">
|
||||
<c:set var="url">
|
||||
<ww:url action="browseGroup" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${groupId}'}"/>
|
||||
</ww:url>
|
||||
</c:set>
|
||||
<li><a href="${url}">${groupId}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${not empty results.artifacts}">
|
||||
<div id="nameColumn">
|
||||
<h2>Artifacts</h2>
|
||||
<ul>
|
||||
<c:forEach items="${results.artifacts}" var="artifactId">
|
||||
<c:set var="url">
|
||||
<ww:url action="browseArtifact" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${results.selectedGroupId}'}"/>
|
||||
<ww:param name="artifactId" value="%{'${artifactId}'}"/>
|
||||
</ww:url>
|
||||
</c:set>
|
||||
<li><a href="${url}">${artifactId}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${not empty results.versions}">
|
||||
<div id="nameColumn">
|
||||
<h2>Versions</h2>
|
||||
<ul>
|
||||
<c:forEach items="${results.versions}" var="version">
|
||||
<c:set var="url">
|
||||
<ww:url action="showArtifact" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${results.selectedGroupId}'}"/>
|
||||
<ww:param name="artifactId" value="%{'${results.selectedArtifactId}'}"/>
|
||||
<ww:param name="version" value="%{'${version}'}"/>
|
||||
</ww:url>
|
||||
</c:set>
|
||||
<li><a href="${url}">${version}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
@ -32,31 +32,46 @@
|
||||
<h1>Browse Repository</h1>
|
||||
|
||||
<div id="contentArea">
|
||||
<div id="nameColumn">
|
||||
<p>
|
||||
<archiva:groupIdLink var="${groupId}" includeTop="true" />
|
||||
</p>
|
||||
<p>
|
||||
<archiva:groupIdLink var="${results.selectedGroupId}" includeTop="true" />
|
||||
</p>
|
||||
|
||||
<ww:set name="groups" value="groups"/>
|
||||
<c:if test="${!empty(groups)}">
|
||||
<h2>Groups</h2>
|
||||
<div id="nameColumn">
|
||||
<h2>Groups</h2>
|
||||
<ul>
|
||||
<c:forEach items="${results.groupIds}" var="groupId">
|
||||
<c:set var="url">
|
||||
<ww:url action="browseGroup" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${groupId}'}"/>
|
||||
</ww:url>
|
||||
</c:set>
|
||||
<li><a href="${url}">${groupId}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<c:if test="${not empty results.versions}">
|
||||
<div id="nameColumn">
|
||||
<h2>Versions</h2>
|
||||
<ul>
|
||||
<c:forEach items="${groups}" var="groupId">
|
||||
<c:forEach items="${results.versions}" var="version">
|
||||
<c:set var="url">
|
||||
<ww:url action="browseGroup" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${groupId}'}"/>
|
||||
<ww:url action="browseVersion" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${results.selectedGroupId}'}"/>
|
||||
<ww:param name="version" value="%{'${version}'}"/>
|
||||
</ww:url>
|
||||
</c:set>
|
||||
<li><a href="${url}">${groupId}/</a></li>
|
||||
<li><a href="${url}">${version}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</c:if>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<ww:set name="artifactIds" value="artifactIds"/>
|
||||
<c:if test="${!empty(artifactIds)}">
|
||||
<c:if test="${not empty results.artifacts}">
|
||||
<div id="nameColumn">
|
||||
<h2>Artifacts</h2>
|
||||
<ul>
|
||||
<c:forEach items="${artifactIds}" var="artifactId">
|
||||
<c:forEach items="${results.artifacts}" var="artifactId">
|
||||
<c:set var="url">
|
||||
<ww:url action="browseArtifact" namespace="/">
|
||||
<ww:param name="groupId" value="%{'${groupId}'}"/>
|
||||
@ -66,8 +81,10 @@
|
||||
<li><a href="${url}">${artifactId}/</a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user