<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>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty6-plugin</artifactId>
<configuration>
+ <webAppSourceDirectory>${basedir}/target/${artifactId}</webAppSourceDirectory >
<scanIntervalSeconds>10</scanIntervalSeconds>
- <contextPath>/</contextPath>
</configuration>
</plugin>
<plugin>
--- /dev/null
+package org.apache.maven.repository.manager.web.action;\r
+\r
+import com.opensymphony.xwork.Action;\r
+import org.apache.maven.artifact.Artifact;\r
+import org.apache.maven.artifact.repository.ArtifactRepository;\r
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
+import org.apache.maven.repository.discovery.ArtifactDiscoverer;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.TreeMap;\r
+\r
+/**\r
+ * TODO: Description.\r
+ *\r
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.RepositoryBrowseAction"\r
+ */\r
+public class RepositoryBrowseAction\r
+ implements Action\r
+{\r
+ /**\r
+ * @plexus.requirement role-hint="default"\r
+ */\r
+ private ArtifactDiscoverer discoverer;\r
+\r
+ /**\r
+ * @plexus.requirement\r
+ */\r
+ private ArtifactRepositoryFactory repositoryFactory;\r
+\r
+ /**\r
+ * @plexus.requirement role-hint="default"\r
+ */\r
+ private ArtifactRepositoryLayout layout;\r
+\r
+ private String group;\r
+\r
+ private TreeMap artifactMap;\r
+\r
+ private String folder;\r
+\r
+ private int idx;\r
+\r
+ public String execute()\r
+ throws Exception\r
+ {\r
+ String path = "E:/jeprox/maven-repository-manager/trunk/maven-repository-discovery/src/test/repository";\r
+\r
+ ArtifactRepository repository =\r
+ repositoryFactory.createArtifactRepository( "discoveryRepo", "file://" + path, layout, null, null );\r
+\r
+ List artifacts = discoverer.discoverArtifacts( repository, null, true );\r
+\r
+ Iterator iterator = artifacts.iterator();\r
+\r
+ artifactMap = new TreeMap();\r
+\r
+ String groupId;\r
+\r
+ while ( iterator.hasNext() )\r
+ {\r
+ Artifact artifact = (Artifact) iterator.next();\r
+\r
+ groupId = artifact.getGroupId();\r
+\r
+ String key = groupId.replace( '.', '/' ) + "/" + artifact.getArtifactId() + "/" + artifact.getVersion();\r
+\r
+ ArrayList artifactList;\r
+\r
+ if ( artifactMap.containsKey( key ) )\r
+ {\r
+ artifactList = (ArrayList) artifactMap.get( key );\r
+ }\r
+ else\r
+ {\r
+ artifactList = new ArrayList();\r
+ }\r
+\r
+ artifactList.add( artifact );\r
+\r
+ Collections.sort( artifactList );\r
+\r
+ artifactMap.put( key, artifactList );\r
+ }\r
+\r
+ //set the index for folder level to be displayed\r
+ setIdx( 1 );\r
+\r
+ setFolder( "" );\r
+\r
+ return SUCCESS;\r
+ }\r
+\r
+ public String doEdit()\r
+ throws Exception\r
+ {\r
+ setIdx( getIdx() + 1 );\r
+\r
+ //set folder to "" if we are at the root directory\r
+ if ( getIdx() == 1 )\r
+ {\r
+ setFolder( "" );\r
+ }\r
+\r
+ return SUCCESS;\r
+ }\r
+\r
+ public TreeMap getArtifactMap()\r
+ {\r
+ return artifactMap;\r
+ }\r
+\r
+ public String getGroup()\r
+ {\r
+ return group;\r
+ }\r
+\r
+ public void setGroup( String group )\r
+ {\r
+ this.group = group;\r
+ }\r
+\r
+ public String getFolder()\r
+ {\r
+ return folder;\r
+ }\r
+\r
+ public void setFolder( String folder )\r
+ {\r
+ this.folder = folder;\r
+ }\r
+\r
+ public int getIdx()\r
+ {\r
+ return idx;\r
+ }\r
+\r
+ public void setIdx( int index )\r
+ {\r
+ this.idx = index;\r
+ }\r
+\r
+}\r
--- /dev/null
+<%@ taglib uri="webwork" prefix="ww" %>\r
+<%@page import="java.util.*"%>\r
+<html>\r
+<head>\r
+<title>Repository Browser</title>\r
+</head>\r
+<body>\r
+<h3><a href="<ww:url value="browse!edit.action"><ww:param name="idx" value="0"/></ww:url>">basedir</a> /\r
+<ww:set name="previousFolder" value="''"/>\r
+<ww:set name="counter" value="0"/>\r
+<ww:if test="folder != ''">\r
+ <ww:set name="folderHeader" value="folder.split('/')"/>\r
+ <ww:iterator value="#folderHeader">\r
+ <ww:set name="counter" value="#counter + 1"/>\r
+ <ww:if test="#previousFolder == ''">\r
+ <ww:set name="previousFolder" value="top"/>\r
+ </ww:if>\r
+ <ww:else>\r
+ <ww:set name="previousFolder" value="#previousFolder + '/' + top"/>\r
+ </ww:else>\r
+ <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> /\r
+ </ww:iterator>\r
+</ww:if>\r
+</h3>\r
+<br/>\r
+\r
+<ww:set name="previousFolder" value="'the previous folder'"/>\r
+<ww:set name="in" value="idx" scope="page"/>\r
+<ww:iterator value="artifactMap.keySet().iterator()">\r
+ <ww:set name="groupName" value="top"/>\r
+<ww:if test="idx == 1 || (folder != '' and #groupName.startsWith(folder))">\r
+<%\r
+int ctr = 1;\r
+%>\r
+ <ww:set name="groupFolder" value="#groupName.split('/')"/>\r
+ <ww:iterator value="#groupFolder">\r
+<%\r
+if (ctr == ((Integer)pageContext.getAttribute("in")).intValue()) {%>\r
+ <ww:if test="top != #previousFolder">\r
+ <ww:set name="previousFolder" value="top"/>\r
+ <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>"">\r
+ <ww:property/>/\r
+ </a><br>\r
+ </ww:if>\r
+<%\r
+}\r
+ctr++;\r
+%>\r
+ </ww:iterator>\r
+</ww:if>\r
+</ww:iterator>\r
+\r
+<ww:if test="folder != ''">\r
+ <ww:set name="previousFolder" value="''"/>\r
+ <ww:set name="artifactList" value="artifactMap.get(folder)"/>\r
+ <ww:iterator value="#artifactList">\r
+<table border="1">\r
+ <tr align="left">\r
+ <th>Group ID</th>\r
+ <td><ww:property value="groupId"/></td>\r
+ </tr>\r
+ <tr align="left">\r
+ <th>Artifact ID</th>\r
+ <td><ww:property value="artifactId"/></td>\r
+ </tr>\r
+ <tr align="left">\r
+ <th>Version</th>\r
+ <td><ww:property value="version"/></td>\r
+ </tr>\r
+ <tr align="left">\r
+ <th>Derivatives</th>\r
+ <td><ww:property value="groupId"/></td>\r
+ </tr>\r
+ <tr align="left">\r
+ <th>Parent</th>\r
+ <td><ww:property value="folder"/></td>\r
+ </tr>\r
+</table><br/>\r
+ </ww:iterator>\r
+</ww:if>\r
+</body>\r
+</html>\r