Author: epunzalan
Date: Wed Mar 1 03:39:07 2006
New Revision: 381994
URL: http://svn.apache.org/viewcvs?rev=381994&view=rev
Log:
PR: MRM-81
Submitted by: John Tolentino
Applied patch for general search webapp and configuration
Added:
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp
Modified:
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
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/form.jspf
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
Added:
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java?rev=381994&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
(added)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
Wed Mar 1 03:39:07 2006
@@ -0,0 +1,83 @@
+package org.apache.maven.repository.manager.web.action;
+
+import com.opensymphony.xwork.Action;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
+import org.apache.maven.repository.indexing.RepositoryIndexException;
+import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
+import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
+import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
+import org.apache.maven.repository.manager.web.job.Configuration;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.List;
+
+/**
+ * Searches for searchString in all indexed fields.
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action"
role-hint="org.apache.maven.repository.manager.web.action.GeneralSearchAction"
+ */
+public class GeneralSearchAction
+ implements Action
+{
+ private String searchString;
+
+ private List searchResult;
+
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryIndexingFactory factory;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactRepositoryFactory repositoryFactory;
+
+ /**
+ * @plexus.requirement
+ */
+ private Configuration configuration;
+
+ public String execute()
+ throws MalformedURLException, RepositoryIndexException,
RepositoryIndexSearchException
+ {
+ if ( searchString != null && searchString.length() != 0 )
+ {
+ String indexPath = configuration.getIndexDirectory();
+
+ // TODO: reduce the amount of lookup?
+
+ File repositoryDirectory = new File(
configuration.getRepositoryDirectory() );
+ String repoDir = repositoryDirectory.toURL().toString();
+
+ ArtifactRepository repository =
+ repositoryFactory.createArtifactRepository( "test", repoDir,
configuration.getLayout(), null, null );
+
+ ArtifactRepositoryIndex index =
factory.createArtifactRepositoryIndex( indexPath, repository );
+
+ RepositoryIndexSearchLayer searchLayer =
factory.createRepositoryIndexSearchLayer( index );
+
+ searchResult = searchLayer.searchGeneral( searchString );
+
+ return SUCCESS;
+ }
+ else
+ {
+ return ERROR;
+ }
+ }
+
+ public void setSearchString( String searchString )
+ {
+ this.searchString = searchString;
+ }
+
+ public List getSearchResult()
+ {
+ return searchResult;
+ }
+
+}
Modified:
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=381994&r1=381993&r2=381994&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
(original)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
Wed Mar 1 03:39:07 2006
@@ -21,13 +21,12 @@
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 @@
}
// 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(
Added:
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java?rev=381994&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
(added)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
Wed Mar 1 03:39:07 2006
@@ -0,0 +1,83 @@
+package org.apache.maven.repository.manager.web.job;
+
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+import java.util.Properties;
+/*
+ * 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.
+ */
+
+/**
+ *
+ */
+public class Configuration
+ implements Initializable
+{
+
+ private Properties props;
+
+ public void initialize()
+ throws InitializationException
+ {
+ System.out.println( "Configuration initialized" );
+ }
+
+ public void setProperties( Properties properties )
+ {
+ this.props = properties;
+ }
+
+ public Properties getProperties()
+ {
+ return props;
+ }
+
+ public ArtifactRepositoryLayout getLayout()
+ {
+ ArtifactRepositoryLayout layout;
+ if ( "legacy".equals( props.getProperty( "layout" ) ) )
+ {
+ layout = new LegacyRepositoryLayout();
+ }
+ else
+ {
+ layout = new DefaultRepositoryLayout();
+ }
+ return layout;
+ }
+
+ public String getIndexDirectory()
+ {
+ return props.getProperty( "index.path" );
+ }
+
+ public String getRepositoryDirectory()
+ {
+ String repositoryDir = "";
+ if ( "default".equals( props.getProperty( "layout" ) ) )
+ {
+ repositoryDir = props.getProperty( "default.repository.dir" );
+ }
+ else if ( "legacy".equals( props.getProperty( "layout" ) ) )
+ {
+ repositoryDir = props.getProperty( "legacy.repository.dir" );
+ }
+ return repositoryDir;
+ }
+}
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=381994&r1=381993&r2=381994&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
Wed Mar 1 03:39:07 2006
@@ -31,6 +31,11 @@
<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>
Modified:
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf?rev=381994&r1=381993&r2=381994&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
(original)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
Wed Mar 1 03:39:07 2006
@@ -84,6 +84,13 @@
<!--"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"/>
Added:
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp?rev=381994&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp
(added)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp
Wed Mar 1 03:39:07 2006
@@ -0,0 +1,67 @@
+<%--
+ ~ 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>
+
+<[EMAIL PROTECTED] file="form.jspf"%>
+
+<table border="1px" cellspacing="0">
+ <tr>
+ <th>Group ID</th>
+ <th>Artifact ID</th>
+ <th>Version</th>
+ <th>Hits</th>
+ </tr>
+ <ww:iterator value="searchResult">
+ <tr>
+ <td valign="top">
+ <ww:property value="Artifact.getGroupId()"/>
+ </td>
+ <td valign="top">
+ <ww:property value="Artifact.getArtifactId()"/>
+ </td>
+ <td valign="top">
+ <ww:property value="Artifact.getVersion()"/>
+ </td>
+ <td valign="top">
+ <table border="1px" width="100%" cellspacing="0">
+ <ww:iterator value="FieldMatchesEntrySet">
+ <tr>
+ <td valign="top" width="15%" align="right"><ww:property
value="Key"/></td>
+ <td valign="top">
+ <ww:iterator value="Value" id="test" status="" >
+ <ww:property />
+ </ww:iterator>
+ <br/>
+ </td>
+ </tr>
+ </ww:iterator>
+ </table>
+ </td>
+ </tr>
+ </ww:iterator>
+</table>
+
+</body>
+</html>
Modified:
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
URL:
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml?rev=381994&r1=381993&r2=381994&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
(original)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
Wed Mar 1 03:39:07 2006
@@ -28,15 +28,67 @@
</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