1 package org.apache.maven.repository.manager.web.action;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import com.opensymphony.xwork.Action;
20 import org.apache.maven.artifact.repository.ArtifactRepository;
21 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
22 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
23 import org.apache.maven.repository.configuration.Configuration;
24 import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
25 import org.apache.maven.repository.indexing.RepositoryIndexException;
26 import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
27 import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
28 import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
31 import java.net.MalformedURLException;
32 import java.util.List;
36 * Searches for searchString in all indexed fields.
38 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="quickSearchAction"
40 public class QuickSearchAction
51 private List searchResult;
56 private RepositoryIndexingFactory factory;
61 private RepositoryIndexSearchLayer searchLayer;
66 private ArtifactRepositoryFactory repositoryFactory;
69 * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
71 private Map repositoryLayouts;
73 public String execute()
74 throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
76 if ( q != null && q.length() != 0 )
78 Configuration configuration = new Configuration(); // TODO!
79 File indexPath = new File( configuration.getIndexPath() );
81 // TODO: [!] repository should only have been instantiated once
82 File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
83 String repoDir = repositoryDirectory.toURL().toString();
85 ArtifactRepositoryLayout layout =
86 (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
87 ArtifactRepository repository =
88 repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
90 ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
92 searchResult = searchLayer.searchGeneral( q, index );
107 public void setQ( String q )
112 public List getSearchResult()