1 package org.apache.maven.repository.manager.web.action;
\r
4 * Copyright 2005-2006 The Apache Software Foundation.
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
19 import com.opensymphony.xwork.Action;
\r
20 import org.apache.maven.artifact.repository.ArtifactRepository;
\r
21 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
\r
22 import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
\r
23 import org.apache.maven.repository.indexing.RepositoryIndexException;
\r
24 import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
\r
25 import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
\r
26 import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
\r
27 import org.apache.maven.repository.manager.web.job.Configuration;
\r
29 import java.io.File;
\r
30 import java.net.MalformedURLException;
\r
31 import java.util.List;
\r
34 * Searches for searchString in all indexed fields.
\r
36 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.GeneralSearchAction"
\r
38 public class GeneralSearchAction
\r
41 private String searchString;
\r
43 private List searchResult;
\r
46 * @plexus.requirement
\r
48 private RepositoryIndexingFactory factory;
\r
51 * @plexus.requirement
\r
53 private RepositoryIndexSearchLayer searchLayer;
\r
56 * @plexus.requirement
\r
58 private ArtifactRepositoryFactory repositoryFactory;
\r
61 * @plexus.requirement
\r
63 private Configuration configuration;
\r
65 public String execute()
\r
66 throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
\r
68 if ( searchString != null && searchString.length() != 0 )
\r
70 String indexPath = configuration.getIndexDirectory();
\r
72 // TODO: reduce the amount of lookup?
\r
74 File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
\r
75 String repoDir = repositoryDirectory.toURL().toString();
\r
77 ArtifactRepository repository =
\r
78 repositoryFactory.createArtifactRepository( "test", repoDir, configuration.getLayout(), null, null );
\r
80 ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
\r
82 searchResult = searchLayer.searchGeneral( searchString, index );
\r
92 public void setSearchString( String searchString )
\r
94 this.searchString = searchString;
\r
97 public List getSearchResult()
\r
99 return searchResult;
\r