View Javadoc
1   package org.apache.maven.scm.provider.svn.svnexe;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.maven.scm.CommandParameters;
25  import org.apache.maven.scm.ScmException;
26  import org.apache.maven.scm.ScmFileSet;
27  import org.apache.maven.scm.command.info.InfoScmResult;
28  import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult;
29  import org.apache.maven.scm.provider.ScmProviderRepository;
30  import org.apache.maven.scm.provider.svn.AbstractSvnScmProvider;
31  import org.apache.maven.scm.provider.svn.command.SvnCommand;
32  import org.apache.maven.scm.provider.svn.svnexe.command.add.SvnAddCommand;
33  import org.apache.maven.scm.provider.svn.svnexe.command.blame.SvnBlameCommand;
34  import org.apache.maven.scm.provider.svn.svnexe.command.branch.SvnBranchCommand;
35  import org.apache.maven.scm.provider.svn.svnexe.command.changelog.SvnChangeLogCommand;
36  import org.apache.maven.scm.provider.svn.svnexe.command.checkin.SvnCheckInCommand;
37  import org.apache.maven.scm.provider.svn.svnexe.command.checkout.SvnCheckOutCommand;
38  import org.apache.maven.scm.provider.svn.svnexe.command.diff.SvnDiffCommand;
39  import org.apache.maven.scm.provider.svn.svnexe.command.export.SvnExeExportCommand;
40  import org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommand;
41  import org.apache.maven.scm.provider.svn.svnexe.command.list.SvnListCommand;
42  import org.apache.maven.scm.provider.svn.svnexe.command.mkdir.SvnMkdirCommand;
43  import org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo.SvnRemoteInfoCommand;
44  import org.apache.maven.scm.provider.svn.svnexe.command.remove.SvnRemoveCommand;
45  import org.apache.maven.scm.provider.svn.svnexe.command.status.SvnStatusCommand;
46  import org.apache.maven.scm.provider.svn.svnexe.command.tag.SvnTagCommand;
47  import org.apache.maven.scm.provider.svn.svnexe.command.untag.SvnUntagCommand;
48  import org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateCommand;
49  import org.apache.maven.scm.repository.ScmRepositoryException;
50  
51  /**
52   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
53   *
54   * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="svn"
55   */
56  public class SvnExeScmProvider
57      extends AbstractSvnScmProvider
58  {
59      /**
60       * {@inheritDoc}
61       */
62      protected SvnCommand getAddCommand()
63      {
64          return new SvnAddCommand();
65      }
66  
67      /**
68       * {@inheritDoc}
69       */
70      protected SvnCommand getBranchCommand()
71      {
72          return new SvnBranchCommand();
73      }
74  
75      /**
76       * {@inheritDoc}
77       */
78      protected SvnCommand getChangeLogCommand()
79      {
80          return new SvnChangeLogCommand();
81      }
82  
83      /**
84       * {@inheritDoc}
85       */
86      protected SvnCommand getCheckInCommand()
87      {
88          return new SvnCheckInCommand();
89      }
90  
91      /**
92       * {@inheritDoc}
93       */
94      protected SvnCommand getCheckOutCommand()
95      {
96          return new SvnCheckOutCommand();
97      }
98  
99      /**
100      * {@inheritDoc}
101      */
102     protected SvnCommand getDiffCommand()
103     {
104         return new SvnDiffCommand();
105     }
106 
107     /**
108      * {@inheritDoc}
109      */
110     protected SvnCommand getExportCommand()
111     {
112         return new SvnExeExportCommand();
113     }
114 
115     /**
116      * {@inheritDoc}
117      */
118     protected SvnCommand getRemoveCommand()
119     {
120         return new SvnRemoveCommand();
121     }
122 
123     /**
124      * {@inheritDoc}
125      */
126     protected SvnCommand getStatusCommand()
127     {
128         return new SvnStatusCommand();
129     }
130 
131     /**
132      * {@inheritDoc}
133      */
134     protected SvnCommand getTagCommand()
135     {
136         return new SvnTagCommand();
137     }
138 
139     /**
140      * {@inheritDoc}
141      */
142     protected SvnCommand getUntagCommand()
143     {
144         return new SvnUntagCommand();
145     }
146 
147     /**
148      * {@inheritDoc}
149      */
150     protected SvnCommand getUpdateCommand()
151     {
152         return new SvnUpdateCommand();
153     }
154 
155     /**
156      * {@inheritDoc}
157      */
158     protected SvnCommand getListCommand()
159     {
160         return new SvnListCommand();
161     }
162 
163     public SvnCommand getInfoCommand()
164     {
165         return new SvnInfoCommand();
166     }
167 
168     /**
169      * {@inheritDoc}
170      */
171     protected SvnCommand getBlameCommand()
172     {
173         return new SvnBlameCommand();
174     }
175 
176     /**
177      * {@inheritDoc}
178      */
179     protected SvnCommand getMkdirCommand()
180     {
181         return new SvnMkdirCommand();
182     }
183 
184     /**
185      * {@inheritDoc}
186      */
187     protected String getRepositoryURL( File path )
188         throws ScmException
189     {
190         // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without
191         // a basedir (which isn't used here anyway), so use a dummy file.
192         SvnInfoCommand infoCmd = (SvnInfoCommand) getInfoCommand();
193         infoCmd.setLogger( this.getLogger() );
194         InfoScmResult result =
195             infoCmd.executeInfoCommand( null, new ScmFileSet( new File( "" ), path ), null, false, null );
196 
197         if ( result.getInfoItems().size() != 1 )
198         {
199             throw new ScmRepositoryException(
200                 "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" )
201                     + " items returned by the info command" );
202         }
203 
204         return result.getInfoItems().get( 0 ).getURL();
205     }
206 
207     @Override
208     public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet,
209                                            CommandParameters parameters )
210         throws ScmException
211     {
212         SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand();
213         return svnRemoteInfoCommand.executeRemoteInfoCommand( repository, fileSet, parameters );
214     }
215 
216     @Override
217     public boolean remoteUrlExist( ScmProviderRepository repository, CommandParameters parameters )
218         throws ScmException
219     {
220         SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand();
221         return svnRemoteInfoCommand.remoteUrlExist( repository, parameters );
222     }
223 }