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.ActionSupport;
20 import org.apache.maven.artifact.Artifact;
21 import org.apache.maven.artifact.factory.ArtifactFactory;
22 import org.apache.maven.artifact.repository.ArtifactRepository;
23 import org.apache.maven.model.Model;
24 import org.apache.maven.project.MavenProject;
25 import org.apache.maven.project.MavenProjectBuilder;
26 import org.apache.maven.project.ProjectBuildingException;
27 import org.apache.maven.repository.configuration.Configuration;
28 import org.apache.maven.repository.configuration.ConfigurationStore;
29 import org.apache.maven.repository.configuration.ConfigurationStoreException;
30 import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
31 import org.codehaus.plexus.util.StringUtils;
32 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
34 import java.io.IOException;
35 import java.util.List;
38 * Browse the repository.
40 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="showArtifactAction"
42 public class ShowArtifactAction
48 private ArtifactFactory artifactFactory;
53 private ConfiguredRepositoryFactory repositoryFactory;
58 private MavenProjectBuilder projectBuilder;
63 private ConfigurationStore configurationStore;
65 private String groupId;
67 private String artifactId;
69 private String version;
73 public String execute()
74 throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException
76 if ( StringUtils.isEmpty( groupId ) )
79 addActionError( "You must specify a group ID to browse" );
83 if ( StringUtils.isEmpty( artifactId ) )
86 addActionError( "You must specify a artifact ID to browse" );
90 if ( StringUtils.isEmpty( version ) )
93 addActionError( "You must specify a version to browse" );
97 Configuration configuration = configurationStore.getConfigurationFromStore();
98 List repositories = repositoryFactory.createRepositories( configuration );
100 Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version );
101 // TODO: maybe we can decouple the assembly parts of the project builder from the repository handling to get rid of the temp repo
102 ArtifactRepository localRepository = repositoryFactory.createLocalRepository( configuration );
103 MavenProject project = projectBuilder.buildFromRepository( artifact, repositories, localRepository );
105 model = project.getModel();
110 public Model getModel()
115 public String getGroupId()
120 public void setGroupId( String groupId )
122 this.groupId = groupId;
125 public String getArtifactId()
130 public void setArtifactId( String artifactId )
132 this.artifactId = artifactId;
135 public String getVersion()
140 public void setVersion( String version )
142 this.version = version;