]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-74
authorEdwin L. Punzalan <epunzalan@apache.org>
Thu, 23 Feb 2006 06:53:23 +0000 (06:53 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Thu, 23 Feb 2006 06:53:23 +0000 (06:53 +0000)
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

maven-repository-webapp/pom.xml
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java [new file with mode: 0644]
maven-repository-webapp/src/main/resources/xwork.xml
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp [new file with mode: 0644]
maven-repository-webapp/src/main/webapp/WEB-INF/web.xml

index d3df67b13a406b85ee7597d939edd937eac60943..92cb24fa0b76d16234fc352072d95afaf2d49464 100644 (file)
       <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>
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java
new file mode 100644 (file)
index 0000000..31ccb4c
--- /dev/null
@@ -0,0 +1,146 @@
+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
index 68c0b362a6b7ba08d0064b011f4a79ad7cd8a5f0..d33cdd365b8d75dcea74120a7316f478d653e4b3 100644 (file)
       <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>
 
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
new file mode 100644 (file)
index 0000000..af45233
--- /dev/null
@@ -0,0 +1,82 @@
+<%@ 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
index 5c664e55c9aeef1446d1f65c54c7acc1526ff6f2..d795317d7979f29ceb5ea4a680633bb746beb5c0 100644 (file)
@@ -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>