]> source.dussan.org Git - archiva.git/commitdiff
improve quick search validation, take some notes
authorBrett Porter <brett@apache.org>
Wed, 12 Jul 2006 06:18:24 +0000 (06:18 +0000)
committerBrett Porter <brett@apache.org>
Wed, 12 Jul 2006 06:18:24 +0000 (06:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@421160 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java
maven-repository-webapp/src/main/resources/xwork.xml

index 68fe27b8eca2723e7a7ee82cc12bb40ffc14b382..35f5de74fa251527eacc0ff26ddd0e07b9ae6044 100644 (file)
@@ -16,11 +16,13 @@ package org.apache.maven.repository.manager.web.action;
  * limitations under the License.
  */
 
-import com.opensymphony.xwork.Action;
+import com.opensymphony.xwork.ActionSupport;
 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.configuration.Configuration;
+import org.apache.maven.repository.configuration.ConfigurationStore;
+import org.apache.maven.repository.configuration.ConfigurationStoreException;
 import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
 import org.apache.maven.repository.indexing.RepositoryIndexException;
 import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
@@ -38,7 +40,7 @@ import java.util.Map;
  * @plexus.component role="com.opensymphony.xwork.Action" role-hint="quickSearchAction"
  */
 public class QuickSearchAction
-    implements Action
+    extends ActionSupport
 {
     /**
      * Query string.
@@ -70,38 +72,48 @@ public class QuickSearchAction
      */
     private Map repositoryLayouts;
 
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationStore configurationStore;
+
     public String execute()
-        throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
+        throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException,
+        ConfigurationStoreException
     {
-        if ( q != null && q.length() != 0 )
-        {
-            Configuration configuration = new Configuration(); // TODO!
-            File indexPath = new File( configuration.getIndexPath() );
-
-            // TODO: [!] repository should only have been instantiated once
-            File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
-            String repoDir = repositoryDirectory.toURL().toString();
-
-            ArtifactRepositoryLayout layout =
-                (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
-            ArtifactRepository repository =
-                repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
-
-            ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
-
-            searchResult = searchLayer.searchGeneral( q, index );
-
-            return SUCCESS;
-        }
-        else
-        {
-            return INPUT;
-        }
+        // TODO: give action message if indexing is in progress
+
+        // TODO: return zero results if index doesn't yet exist
+
+        assert q != null && q.length() != 0;
+
+        Configuration configuration = configurationStore.getConfigurationFromStore();
+        File indexPath = new File( configuration.getIndexPath() );
+
+        ArtifactRepository repository = getDefaultRepository( configuration );
+
+        ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
+
+        searchResult = searchLayer.searchGeneral( q, index );
+
+        return SUCCESS;
+    }
+
+    private ArtifactRepository getDefaultRepository( Configuration configuration )
+        throws MalformedURLException
+    {
+        // TODO: [!] repository should only have been instantiated once
+        File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
+        String repoDir = repositoryDirectory.toURI().toURL().toString();
+
+        ArtifactRepositoryLayout layout =
+            (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
+        return repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
     }
 
     public String doInput()
     {
-        return SUCCESS;
+        return INPUT;
     }
 
     public String getQ()
index 433d0ee817ce79bba6ea8a3bfa4cdd34ee2d94f3..6ccb922a3ff631084549c121f278ee5a70d2a685 100644 (file)
@@ -59,7 +59,7 @@ public class ConfigureAction
         if ( !file.exists() )
         {
             file.mkdirs();
-            // TODO: error handling when this fails
+            // TODO: error handling when this fails, or is not a directory
         }
 
         // TODO: these defaults belong in the model. They shouldn't be stored here, as you want them to re-default
index 85390a2df27114ce55912b3cbf9604fd2b10bd83..c7952d0edd0859df86536e026a58fbccc3eb2daa 100644 (file)
@@ -18,6 +18,8 @@
     "http://www.opensymphony.com/xwork/xwork-1.1.dtd">
 
 <xwork>
+  <!-- TODO: better error handling for exceptions needed -->
+
   <!-- Include webwork defaults (from WebWork JAR). -->
   <include file="webwork-default.xml"/>