From 8d1880e028e5dd21e308873cc7085f7a5c48ceef Mon Sep 17 00:00:00 2001 From: "Edwin L. Punzalan" Date: Wed, 1 Mar 2006 11:39:07 +0000 Subject: [PATCH] PR: MRM-81 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 --- .../web/action/GeneralSearchAction.java | 83 +++++++++++++++++++ .../web/action/PackageSearchAction.java | 5 +- .../manager/web/job/Configuration.java | 83 +++++++++++++++++++ .../src/main/resources/xwork.xml | 5 ++ .../src/main/webapp/WEB-INF/jsp/form.jspf | 7 ++ .../webapp/WEB-INF/jsp/generalresults.jsp | 67 +++++++++++++++ .../src/main/webapp/WEB-INF/plexus.xml | 52 ++++++++++++ 7 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java create mode 100644 maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp 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 index 000000000..5b182cc84 --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java @@ -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; + } + +} diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java index f1e7a5707..458272b0a 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java @@ -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 index 000000000..38940d9f9 --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java @@ -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; + } +} diff --git a/maven-repository-webapp/src/main/resources/xwork.xml b/maven-repository-webapp/src/main/resources/xwork.xml index d33cdd365..5c399c792 100644 --- a/maven-repository-webapp/src/main/resources/xwork.xml +++ b/maven-repository-webapp/src/main/resources/xwork.xml @@ -31,6 +31,11 @@ /WEB-INF/jsp/index.jsp + + /WEB-INF/jsp/generalresults.jsp + /WEB-INF/jsp/index.jsp + + /WEB-INF/jsp/results.jsp /WEB-INF/jsp/index.jsp diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf index dedcec3d6..4c9229e5c 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf @@ -84,6 +84,13 @@

+

Search: +

+ + +
+

+

Search by Java Package:

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 index 000000000..53217d373 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/generalresults.jsp @@ -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" %> + + + Maven Repository Manager + + + + +

Maven Repository Manager

+ +<%@include file="form.jspf"%> + + + + + + + + + + + + + + + + +
Group IDArtifact IDVersionHits
+ + + + + + + + + + + + + +
+ + + +
+
+
+ + + diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml b/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml index 12e677d05..1e13278eb 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml @@ -28,15 +28,67 @@ --> + + + com.opensymphony.xwork.ObjectFactory org.codehaus.plexus.xwork.PlexusObjectFactory + + + org.apache.maven.repository.manager.web.job.Configuration + org.apache.maven.repository.manager.web.job.Configuration + + + + layout + default + + + default.repository.dir + C:/TEST_REPOS/repository + + + legacy.repository.dir + C:/TEST_REPOS/.maven/repository/ + + + index.path + C:/INDEX + + + cron.expression + 0 0 8 * * ? + + + blacklist.patterns + null + + + include.snapshots + true + + + convert.snapshots + true + + + + + + +