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.indexing.ArtifactRepositoryIndex;
24 import org.apache.maven.repository.indexing.DefaultRepositoryIndexSearcher;
25 import org.apache.maven.repository.indexing.RepositoryIndexException;
26 import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
27 import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
28 import org.codehaus.plexus.scheduler.Scheduler;
31 import java.net.MalformedURLException;
32 import java.util.List;
37 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
38 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.PackageSearchAction"
40 public class PackageSearchAction
43 private String packageName;
50 private Scheduler scheduler;
55 private RepositoryIndexingFactory factory;
60 private ArtifactRepositoryFactory repositoryFactory;
63 * @plexus.requirement role-hint="legacy"
65 private ArtifactRepositoryLayout layout;
67 private List artifacts;
69 public String execute()
70 throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
74 if ( packageName != null && packageName.length() != 0 )
76 searchTerm = packageName;
79 else if ( md5 != null && md5.length() != 0 )
89 // TODO: better config
90 String indexPath = "c:/home/brett/repository/.index";
92 // TODO: reduce the amount of lookup?
93 ArtifactRepository repository = repositoryFactory.createArtifactRepository( "repository", new File(
94 indexPath ).toURL().toString(), layout, null, null );
96 ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
98 DefaultRepositoryIndexSearcher searcher = factory.createDefaultRepositoryIndexSearcher( index );
103 public void setPackageName( String packageName )
105 this.packageName = packageName;
108 public void setMd5( String md5 )
113 public List getArtifacts()