mirror of https://github.com/apache/archiva.git
PR: MRM-74
Submitted by: Nick Gonzalez Applied patch for browse user interface and applied code formatting git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@380051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2448efd5a0
commit
69e3cfc270
|
@ -19,6 +19,10 @@
|
|||
<groupId>org.apache.maven.repository</groupId>
|
||||
<artifactId>maven-repository-indexer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.repository</groupId>
|
||||
<artifactId>maven-repository-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.repository</groupId>
|
||||
<artifactId>maven-repository-artifact-applet</artifactId>
|
||||
|
@ -38,8 +42,8 @@
|
|||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty6-plugin</artifactId>
|
||||
<configuration>
|
||||
<webAppSourceDirectory>${basedir}/target/${artifactId}</webAppSourceDirectory >
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
<contextPath>/</contextPath>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
package org.apache.maven.repository.manager.web.action;
|
||||
|
||||
import com.opensymphony.xwork.Action;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* TODO: Description.
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.RepositoryBrowseAction"
|
||||
*/
|
||||
public class RepositoryBrowseAction
|
||||
implements Action
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement role-hint="default"
|
||||
*/
|
||||
private ArtifactDiscoverer discoverer;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArtifactRepositoryFactory repositoryFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="default"
|
||||
*/
|
||||
private ArtifactRepositoryLayout layout;
|
||||
|
||||
private String group;
|
||||
|
||||
private TreeMap artifactMap;
|
||||
|
||||
private String folder;
|
||||
|
||||
private int idx;
|
||||
|
||||
public String execute()
|
||||
throws Exception
|
||||
{
|
||||
String path = "E:/jeprox/maven-repository-manager/trunk/maven-repository-discovery/src/test/repository";
|
||||
|
||||
ArtifactRepository repository =
|
||||
repositoryFactory.createArtifactRepository( "discoveryRepo", "file://" + path, layout, null, null );
|
||||
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
|
||||
Iterator iterator = artifacts.iterator();
|
||||
|
||||
artifactMap = new TreeMap();
|
||||
|
||||
String groupId;
|
||||
|
||||
while ( iterator.hasNext() )
|
||||
{
|
||||
Artifact artifact = (Artifact) iterator.next();
|
||||
|
||||
groupId = artifact.getGroupId();
|
||||
|
||||
String key = groupId.replace( '.', '/' ) + "/" + artifact.getArtifactId() + "/" + artifact.getVersion();
|
||||
|
||||
ArrayList artifactList;
|
||||
|
||||
if ( artifactMap.containsKey( key ) )
|
||||
{
|
||||
artifactList = (ArrayList) artifactMap.get( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
artifactList = new ArrayList();
|
||||
}
|
||||
|
||||
artifactList.add( artifact );
|
||||
|
||||
Collections.sort( artifactList );
|
||||
|
||||
artifactMap.put( key, artifactList );
|
||||
}
|
||||
|
||||
//set the index for folder level to be displayed
|
||||
setIdx( 1 );
|
||||
|
||||
setFolder( "" );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String doEdit()
|
||||
throws Exception
|
||||
{
|
||||
setIdx( getIdx() + 1 );
|
||||
|
||||
//set folder to "" if we are at the root directory
|
||||
if ( getIdx() == 1 )
|
||||
{
|
||||
setFolder( "" );
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public TreeMap getArtifactMap()
|
||||
{
|
||||
return artifactMap;
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup( String group )
|
||||
{
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getFolder()
|
||||
{
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder( String folder )
|
||||
{
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public int getIdx()
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
|
||||
public void setIdx( int index )
|
||||
{
|
||||
this.idx = index;
|
||||
}
|
||||
|
||||
}
|
|
@ -35,6 +35,11 @@
|
|||
<result name="success" type="dispatcher">/WEB-INF/jsp/results.jsp</result>
|
||||
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="browse" class="org.apache.maven.repository.manager.web.action.RepositoryBrowseAction">
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/browse.jsp</result>
|
||||
<result name="error" type="dispatcher">/WEB-INF/jsp/browse.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
</xwork>
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<%@ taglib uri="webwork" prefix="ww" %>
|
||||
<%@page import="java.util.*"%>
|
||||
<html>
|
||||
<head>
|
||||
<title>Repository Browser</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3><a href="<ww:url value="browse!edit.action"><ww:param name="idx" value="0"/></ww:url>">basedir</a> /
|
||||
<ww:set name="previousFolder" value="''"/>
|
||||
<ww:set name="counter" value="0"/>
|
||||
<ww:if test="folder != ''">
|
||||
<ww:set name="folderHeader" value="folder.split('/')"/>
|
||||
<ww:iterator value="#folderHeader">
|
||||
<ww:set name="counter" value="#counter + 1"/>
|
||||
<ww:if test="#previousFolder == ''">
|
||||
<ww:set name="previousFolder" value="top"/>
|
||||
</ww:if>
|
||||
<ww:else>
|
||||
<ww:set name="previousFolder" value="#previousFolder + '/' + top"/>
|
||||
</ww:else>
|
||||
<ww:if test="idx > (#counter + 1)"><a href="<ww:url value="browse!edit.action"><ww:param name="idx"><ww:property value="#counter"/></ww:param><ww:param name="folder"></ww:param></ww:url>"></ww:if><ww:property/></a> /
|
||||
</ww:iterator>
|
||||
</ww:if>
|
||||
</h3>
|
||||
<br/>
|
||||
|
||||
<ww:set name="previousFolder" value="'the previous folder'"/>
|
||||
<ww:set name="in" value="idx" scope="page"/>
|
||||
<ww:iterator value="artifactMap.keySet().iterator()">
|
||||
<ww:set name="groupName" value="top"/>
|
||||
<ww:if test="idx == 1 || (folder != '' and #groupName.startsWith(folder))">
|
||||
<%
|
||||
int ctr = 1;
|
||||
%>
|
||||
<ww:set name="groupFolder" value="#groupName.split('/')"/>
|
||||
<ww:iterator value="#groupFolder">
|
||||
<%
|
||||
if (ctr == ((Integer)pageContext.getAttribute("in")).intValue()) {%>
|
||||
<ww:if test="top != #previousFolder">
|
||||
<ww:set name="previousFolder" value="top"/>
|
||||
<a href="<ww:url value="browse!edit.action"><ww:param name="folder"><ww:property value="folder"/><ww:if test="folder != ''">/</ww:if><ww:property/></ww:param><ww:param name="idx" value="idx"/></ww:url>"">
|
||||
<ww:property/>/
|
||||
</a><br>
|
||||
</ww:if>
|
||||
<%
|
||||
}
|
||||
ctr++;
|
||||
%>
|
||||
</ww:iterator>
|
||||
</ww:if>
|
||||
</ww:iterator>
|
||||
|
||||
<ww:if test="folder != ''">
|
||||
<ww:set name="previousFolder" value="''"/>
|
||||
<ww:set name="artifactList" value="artifactMap.get(folder)"/>
|
||||
<ww:iterator value="#artifactList">
|
||||
<table border="1">
|
||||
<tr align="left">
|
||||
<th>Group ID</th>
|
||||
<td><ww:property value="groupId"/></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<th>Artifact ID</th>
|
||||
<td><ww:property value="artifactId"/></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<th>Version</th>
|
||||
<td><ww:property value="version"/></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<th>Derivatives</th>
|
||||
<td><ww:property value="groupId"/></td>
|
||||
</tr>
|
||||
<tr align="left">
|
||||
<th>Parent</th>
|
||||
<td><ww:property value="folder"/></td>
|
||||
</tr>
|
||||
</table><br/>
|
||||
</ww:iterator>
|
||||
</ww:if>
|
||||
</body>
|
||||
</html>
|
|
@ -30,4 +30,9 @@
|
|||
<welcome-file-list>
|
||||
<welcome-file>index.action</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<taglib>
|
||||
<taglib-uri>webwork</taglib-uri>
|
||||
<taglib-location>/WEB-INF/lib/webwork-2.1.7.jar</taglib-location>
|
||||
</taglib>
|
||||
</web-app>
|
||||
|
|
Loading…
Reference in New Issue