From: Edwin L. Punzalan
Date: Wed, 1 Mar 2006 11:39:07 +0000 (+0000)
Subject: PR: MRM-81
X-Git-Tag: archiva-0.9-alpha-1~902
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8d1880e028e5dd21e308873cc7085f7a5c48ceef;p=archiva.git
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
---
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: