--- /dev/null
+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
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;
}
// 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(
--- /dev/null
+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
<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>
<!--"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"/>
--- /dev/null
+<%--\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
</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