]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-81
authorEdwin L. Punzalan <epunzalan@apache.org>
Wed, 1 Mar 2006 11:39:07 +0000 (11:39 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Wed, 1 Mar 2006 11:39:07 +0000 (11:39 +0000)
Submitted by: John Tolentino

Applied patch for general search webapp and configuration

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@381994 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java [new file with mode: 0644]
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java [new file with mode: 0644]
maven-repository-webapp/src/main/resources/xwork.xml
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp [new file with mode: 0644]
maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml

diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
new file mode 100644 (file)
index 0000000..5b182cc
--- /dev/null
@@ -0,0 +1,83 @@
+package org.apache.maven.repository.manager.web.action;\r
+\r
+import com.opensymphony.xwork.Action;\r
+import org.apache.maven.artifact.repository.ArtifactRepository;\r
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;\r
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;\r
+import org.apache.maven.repository.indexing.RepositoryIndexException;\r
+import org.apache.maven.repository.indexing.RepositoryIndexSearchException;\r
+import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;\r
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;\r
+import org.apache.maven.repository.manager.web.job.Configuration;\r
+\r
+import java.io.File;\r
+import java.net.MalformedURLException;\r
+import java.util.List;\r
+\r
+/**\r
+ * Searches for searchString in all indexed fields.\r
+ *\r
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.GeneralSearchAction"\r
+ */\r
+public class GeneralSearchAction\r
+    implements Action\r
+{\r
+    private String searchString;\r
+\r
+    private List searchResult;\r
+\r
+    /**\r
+     * @plexus.requirement\r
+     */\r
+    private RepositoryIndexingFactory factory;\r
+\r
+    /**\r
+     * @plexus.requirement\r
+     */\r
+    private ArtifactRepositoryFactory repositoryFactory;\r
+\r
+    /**\r
+     * @plexus.requirement\r
+     */\r
+    private Configuration configuration;\r
+\r
+    public String execute()\r
+        throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException\r
+    {\r
+        if ( searchString != null && searchString.length() != 0 )\r
+        {\r
+            String indexPath = configuration.getIndexDirectory();\r
+\r
+            // TODO: reduce the amount of lookup?\r
+\r
+            File repositoryDirectory = new File( configuration.getRepositoryDirectory() );\r
+            String repoDir = repositoryDirectory.toURL().toString();\r
+\r
+            ArtifactRepository repository =\r
+                repositoryFactory.createArtifactRepository( "test", repoDir, configuration.getLayout(), null, null );\r
+\r
+            ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );\r
+\r
+            RepositoryIndexSearchLayer searchLayer = factory.createRepositoryIndexSearchLayer( index );\r
+\r
+            searchResult = searchLayer.searchGeneral( searchString );\r
+\r
+            return SUCCESS;\r
+        }\r
+        else\r
+        {\r
+            return ERROR;\r
+        }\r
+    }\r
+\r
+    public void setSearchString( String searchString )\r
+    {\r
+        this.searchString = searchString;\r
+    }\r
+\r
+    public List getSearchResult()\r
+    {\r
+        return searchResult;\r
+    }\r
+\r
+}\r
index f1e7a5707fd2b98797f1ff391da9242014dced1f..458272b0a09ddbd56a7283f3c22eb089bd58f305 100644 (file)
@@ -21,13 +21,12 @@ 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.DefaultRepositoryIndexSearcher;
 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.DefaultRepositoryIndexSearcher;
 import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
 import org.codehaus.plexus.scheduler.Scheduler;
-import org.codehaus.plexus.scheduler.configuration.SchedulerConfiguration;
 
 import java.io.File;
 import java.net.MalformedURLException;
@@ -89,7 +88,7 @@ public class PackageSearchAction
         }
 
         // TODO: better config
-        String indexPath = "c:/home/brett/repository/.index";
+        String indexPath = "C:/0John/java/projects/repository-manager/maven-repository-indexer/target/index";
 
         // TODO: reduce the amount of lookup?
         ArtifactRepository repository = repositoryFactory.createArtifactRepository( "repository", new File(
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
new file mode 100644 (file)
index 0000000..38940d9
--- /dev/null
@@ -0,0 +1,83 @@
+package org.apache.maven.repository.manager.web.job;\r
+\r
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;\r
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;\r
+import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;\r
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;\r
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;\r
+\r
+import java.util.Properties;\r
+/*\r
+ * Copyright 2005-2006 The Apache Software Foundation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ *\r
+ */\r
+public class Configuration\r
+    implements Initializable\r
+{\r
+\r
+    private Properties props;\r
+\r
+    public void initialize()\r
+        throws InitializationException\r
+    {\r
+        System.out.println( "Configuration initialized" );\r
+    }\r
+\r
+    public void setProperties( Properties properties )\r
+    {\r
+        this.props = properties;\r
+    }\r
+\r
+    public Properties getProperties()\r
+    {\r
+        return props;\r
+    }\r
+\r
+    public ArtifactRepositoryLayout getLayout()\r
+    {\r
+        ArtifactRepositoryLayout layout;\r
+        if ( "legacy".equals( props.getProperty( "layout" ) ) )\r
+        {\r
+            layout = new LegacyRepositoryLayout();\r
+        }\r
+        else\r
+        {\r
+            layout = new DefaultRepositoryLayout();\r
+        }\r
+        return layout;\r
+    }\r
+\r
+    public String getIndexDirectory()\r
+    {\r
+        return props.getProperty( "index.path" );\r
+    }\r
+\r
+    public String getRepositoryDirectory()\r
+    {\r
+        String repositoryDir = "";\r
+        if ( "default".equals( props.getProperty( "layout" ) ) )\r
+        {\r
+            repositoryDir = props.getProperty( "default.repository.dir" );\r
+        }\r
+        else if ( "legacy".equals( props.getProperty( "layout" ) ) )\r
+        {\r
+            repositoryDir = props.getProperty( "legacy.repository.dir" );\r
+        }\r
+        return repositoryDir;\r
+    }\r
+}\r
index d33cdd365b8d75dcea74120a7316f478d653e4b3..5c399c792fa6918de525949c1efc0109c5fe13b5 100644 (file)
       <result name="success" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
     </action>
 
+    <action name="searchg" class="org.apache.maven.repository.manager.web.action.GeneralSearchAction">
+      <result name="success" type="dispatcher">/WEB-INF/jsp/generalresults.jsp</result>
+      <result name="error" 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>
index dedcec3d6a4ed573130e3df029469bc7ea89a869..4c9229e5c8b1201da6338a29afb30434b7c97443 100644 (file)
 <!--"END_CONVERTED_APPLET"-->
 </p>
 
+<p>Search:
+  <form action="searchg.action">
+    <input name="searchString" type="text"/>
+    <input type="submit" value="Search"/>
+  </form>
+</p>
+
 <p>Search by Java Package:
   <form action="search.action">
     <input name="packageName" type="text"/>
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp
new file mode 100644 (file)
index 0000000..53217d3
--- /dev/null
@@ -0,0 +1,67 @@
+<%--\r
+  ~ Copyright 2005-2006 The Apache Software Foundation.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~      http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  --%>\r
+\r
+<%@ taglib uri="webwork" prefix="ww" %>\r
+<html>\r
+<head>\r
+  <title>Maven Repository Manager</title>\r
+</head>\r
+\r
+<body>\r
+\r
+<h1>Maven Repository Manager</h1>\r
+\r
+<%@include file="form.jspf"%>\r
+\r
+<table border="1px" cellspacing="0">\r
+  <tr>\r
+    <th>Group ID</th>\r
+    <th>Artifact ID</th>\r
+    <th>Version</th>\r
+    <th>Hits</th>\r
+  </tr>\r
+  <ww:iterator value="searchResult">\r
+    <tr>\r
+      <td valign="top">\r
+        <ww:property value="Artifact.getGroupId()"/>\r
+      </td>\r
+      <td valign="top">\r
+        <ww:property value="Artifact.getArtifactId()"/>\r
+      </td>\r
+      <td valign="top">\r
+        <ww:property value="Artifact.getVersion()"/>\r
+      </td>\r
+      <td valign="top">\r
+        <table border="1px" width="100%" cellspacing="0">\r
+          <ww:iterator value="FieldMatchesEntrySet">\r
+            <tr>\r
+              <td valign="top" width="15%" align="right"><ww:property value="Key"/></td>\r
+              <td valign="top">\r
+                <ww:iterator value="Value" id="test" status="" >\r
+                  <ww:property />\r
+                </ww:iterator>\r
+                <br/>\r
+              </td>\r
+            </tr>\r
+          </ww:iterator>\r
+        </table>\r
+      </td>\r
+    </tr>\r
+  </ww:iterator>\r
+</table>\r
+\r
+</body>\r
+</html>\r
index 12e677d05b05f266955f4b94bfa37a6f373956b6..1e13278ebc68a7545200ef5879351c1d2a8081bf 100644 (file)
     </load-on-start>
   -->
 
+
   <components>
 
+
     <!--
      | Object factory for WebWork
      -->
+
     <component>
       <role>com.opensymphony.xwork.ObjectFactory</role>
       <implementation>org.codehaus.plexus.xwork.PlexusObjectFactory</implementation>
     </component>
+                             
+    <component>
+      <role>org.apache.maven.repository.manager.web.job.Configuration</role>
+      <implementation>org.apache.maven.repository.manager.web.job.Configuration</implementation>
+      <configuration>
+        <properties>
+          <property>
+            <name>layout</name>
+            <value>default</value>
+          </property>
+          <property>
+            <name>default.repository.dir</name>
+            <value>C:/TEST_REPOS/repository</value>
+          </property>
+          <property>
+            <name>legacy.repository.dir</name>
+            <value>C:/TEST_REPOS/.maven/repository/</value>
+          </property>
+          <property>
+            <name>index.path</name>
+            <value>C:/INDEX</value>
+          </property>
+          <property>
+            <name>cron.expression</name>
+            <value>0 0 8 * * ?</value>
+          </property>
+          <property>
+            <name>blacklist.patterns</name>
+            <value>null</value>
+          </property>
+          <property>
+            <name>include.snapshots</name>
+            <value>true</value>
+          </property>
+          <property>
+            <name>convert.snapshots</name>
+            <value>true</value>
+          </property>
+        </properties>
+      </configuration>
+    </component>
+
+
+    <!--
+    <component>
+      <role>org.apache.maven.repository.manager.web.job.DiscovererJob</role>
+    </component>
+
+     -->
 
     <!--
      | Logger manager