Author: brett
Date: Mon Jan  9 00:05:46 2006
New Revision: 367243

URL: http://svn.apache.org/viewcvs?rev=367243&view=rev
Log:
[MRM-46] add a basic search action as proof of concept

Added:
    
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
   (with props)
    
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
   (with props)
Modified:
    maven/repository-manager/trunk/maven-repository-webapp/pom.xml
    
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml
    
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp

Modified: maven/repository-manager/trunk/maven-repository-webapp/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/pom.xml?rev=367243&r1=367242&r2=367243&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-webapp/pom.xml (original)
+++ maven/repository-manager/trunk/maven-repository-webapp/pom.xml Mon Jan  9 
00:05:46 2006
@@ -15,5 +15,22 @@
       <artifactId>plexus-xwork-integration</artifactId>
       <version>1.0-alpha-1-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven.repository</groupId>
+      <artifactId>maven-repository-indexer</artifactId>
+    </dependency>
   </dependencies>
+  <build>
+    <finalName>maven-repository-webapp</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>maven-jetty6-plugin</artifactId>
+        <configuration>
+          <scanIntervalSeconds>10</scanIntervalSeconds>
+          <contextPath>/</contextPath>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Added: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java?rev=367243&view=auto
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
 (added)
+++ 
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
 Mon Jan  9 00:05:46 2006
@@ -0,0 +1,95 @@
+package org.apache.maven.repository.manager.web.action;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 com.opensymphony.xwork.Action;
+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.indexing.ArtifactRepositoryIndex;
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndexSearcher;
+import org.apache.maven.repository.indexing.RepositoryIndexException;
+import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
+import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.List;
+
+/**
+ * TODO: Description.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ * @plexus.component role="com.opensymphony.xwork.Action" 
role-hint="org.apache.maven.repository.manager.web.action.PackageSearchAction"
+ */
+public class PackageSearchAction
+    implements Action
+{
+    private String packageName;
+
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryIndexingFactory factory;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactRepositoryFactory repositoryFactory;
+
+    /**
+     * @plexus.requirement role-hint="legacy"
+     */
+    private ArtifactRepositoryLayout layout;
+
+    private List artifacts;
+
+    public String execute()
+        throws MalformedURLException, RepositoryIndexException, 
RepositoryIndexSearchException
+    {
+        if ( packageName == null || packageName.length() == 0 )
+        {
+            return ERROR;
+        }
+
+        // TODO: better config
+        String indexPath = "c:/home/brett/repository/.index";
+
+        // TODO: reduce the amount of lookup?
+        ArtifactRepository repository = 
repositoryFactory.createArtifactRepository( "repository", new File(
+            indexPath ).toURL().toString(), layout, null, null );
+
+        ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( 
indexPath, repository );
+
+        ArtifactRepositoryIndexSearcher searcher = 
factory.createArtifactRepositoryIndexSearcher( index );
+
+        artifacts = searcher.search( new SinglePhraseQuery( "packages", 
packageName ) );
+
+        return SUCCESS;
+    }
+
+    public void setPackageName( String packageName )
+    {
+        this.packageName = packageName;
+    }
+
+    public List getArtifacts()
+    {
+        return artifacts;
+    }
+}

Propchange: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml?rev=367243&r1=367242&r2=367243&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml
 Mon Jan  9 00:05:46 2006
@@ -30,6 +30,11 @@
     <action name="index" class="com.opensymphony.xwork.ActionSupport">
       <result name="success" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
     </action>
+
+    <action name="search" 
class="org.apache.maven.repository.manager.web.action.PackageSearchAction">
+      <result name="success" 
type="dispatcher">/WEB-INF/jsp/results.jsp</result>
+      <result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
+    </action>
   </package>
 </xwork>
 

Modified: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp?rev=367243&r1=367242&r2=367243&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/index.jsp
 Mon Jan  9 00:05:46 2006
@@ -8,5 +8,9 @@
 
 <h1>Maven Repository Manager</h1>
 
+<form action="search.action">
+  <input name="packageName" type="text"/> <input type="submit" value="Search"/>
+</form>
+
 </body>
 </html>

Added: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp?rev=367243&view=auto
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
 (added)
+++ 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
 Mon Jan  9 00:05:46 2006
@@ -0,0 +1,47 @@
+<%--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed 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 uri="webwork" prefix="ww" %>
+<html>
+<head>
+  <title>Maven Repository Manager</title>
+</head>
+
+<body>
+
+<h1>Maven Repository Manager</h1>
+
+<form action="search.action">
+  <input name="packageName" type="text"/> <input type="submit" value="Search"/>
+</form>
+
+<table>
+  <tr>
+    <th>Group ID</th>
+    <th>Artifact ID</th>
+    <th>Version</th>
+  </tr>
+  <ww:iterator value="artifacts">
+    <tr>
+      <td><ww:property value="groupId"/></td>
+      <td><ww:property value="artifactId"/></td>
+      <td><ww:property value="version"/></td>
+    </tr>
+  </ww:iterator>
+</table>
+
+</body>
+</html>
\ No newline at end of file

Propchange: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to