001package org.apache.maven.scm.provider.svn.svnexe;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.File;
023
024import org.apache.maven.scm.CommandParameters;
025import org.apache.maven.scm.ScmException;
026import org.apache.maven.scm.ScmFileSet;
027import org.apache.maven.scm.command.info.InfoScmResult;
028import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult;
029import org.apache.maven.scm.provider.ScmProviderRepository;
030import org.apache.maven.scm.provider.svn.AbstractSvnScmProvider;
031import org.apache.maven.scm.provider.svn.command.SvnCommand;
032import org.apache.maven.scm.provider.svn.svnexe.command.add.SvnAddCommand;
033import org.apache.maven.scm.provider.svn.svnexe.command.blame.SvnBlameCommand;
034import org.apache.maven.scm.provider.svn.svnexe.command.branch.SvnBranchCommand;
035import org.apache.maven.scm.provider.svn.svnexe.command.changelog.SvnChangeLogCommand;
036import org.apache.maven.scm.provider.svn.svnexe.command.checkin.SvnCheckInCommand;
037import org.apache.maven.scm.provider.svn.svnexe.command.checkout.SvnCheckOutCommand;
038import org.apache.maven.scm.provider.svn.svnexe.command.diff.SvnDiffCommand;
039import org.apache.maven.scm.provider.svn.svnexe.command.export.SvnExeExportCommand;
040import org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommand;
041import org.apache.maven.scm.provider.svn.svnexe.command.list.SvnListCommand;
042import org.apache.maven.scm.provider.svn.svnexe.command.mkdir.SvnMkdirCommand;
043import org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo.SvnRemoteInfoCommand;
044import org.apache.maven.scm.provider.svn.svnexe.command.remove.SvnRemoveCommand;
045import org.apache.maven.scm.provider.svn.svnexe.command.status.SvnStatusCommand;
046import org.apache.maven.scm.provider.svn.svnexe.command.tag.SvnTagCommand;
047import org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateCommand;
048import org.apache.maven.scm.repository.ScmRepositoryException;
049
050/**
051 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
052 *
053 * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="svn"
054 */
055public class SvnExeScmProvider
056    extends AbstractSvnScmProvider
057{
058    /**
059     * {@inheritDoc}
060     */
061    protected SvnCommand getAddCommand()
062    {
063        return new SvnAddCommand();
064    }
065
066    /**
067     * {@inheritDoc}
068     */
069    protected SvnCommand getBranchCommand()
070    {
071        return new SvnBranchCommand();
072    }
073
074    /**
075     * {@inheritDoc}
076     */
077    protected SvnCommand getChangeLogCommand()
078    {
079        return new SvnChangeLogCommand();
080    }
081
082    /**
083     * {@inheritDoc}
084     */
085    protected SvnCommand getCheckInCommand()
086    {
087        return new SvnCheckInCommand();
088    }
089
090    /**
091     * {@inheritDoc}
092     */
093    protected SvnCommand getCheckOutCommand()
094    {
095        return new SvnCheckOutCommand();
096    }
097
098    /**
099     * {@inheritDoc}
100     */
101    protected SvnCommand getDiffCommand()
102    {
103        return new SvnDiffCommand();
104    }
105
106    /**
107     * {@inheritDoc}
108     */
109    protected SvnCommand getExportCommand()
110    {
111        return new SvnExeExportCommand();
112    }
113
114    /**
115     * {@inheritDoc}
116     */
117    protected SvnCommand getRemoveCommand()
118    {
119        return new SvnRemoveCommand();
120    }
121
122    /**
123     * {@inheritDoc}
124     */
125    protected SvnCommand getStatusCommand()
126    {
127        return new SvnStatusCommand();
128    }
129
130    /**
131     * {@inheritDoc}
132     */
133    protected SvnCommand getTagCommand()
134    {
135        return new SvnTagCommand();
136    }
137
138    /**
139     * {@inheritDoc}
140     */
141    protected SvnCommand getUpdateCommand()
142    {
143        return new SvnUpdateCommand();
144    }
145
146    /**
147     * {@inheritDoc}
148     */
149    protected SvnCommand getListCommand()
150    {
151        return new SvnListCommand();
152    }
153
154    public SvnCommand getInfoCommand()
155    {
156        return new SvnInfoCommand();
157    }
158
159    /**
160     * {@inheritDoc}
161     */
162    protected SvnCommand getBlameCommand()
163    {
164        return new SvnBlameCommand();
165    }
166
167    /**
168     * {@inheritDoc}
169     */
170    protected SvnCommand getMkdirCommand()
171    {
172        return new SvnMkdirCommand();
173    }
174
175    /**
176     * {@inheritDoc}
177     */
178    protected String getRepositoryURL( File path )
179        throws ScmException
180    {
181        // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without
182        // a basedir (which isn't used here anyway), so use a dummy file.
183        SvnInfoCommand infoCmd = (SvnInfoCommand) getInfoCommand();
184        infoCmd.setLogger( this.getLogger() );
185        InfoScmResult result =
186            infoCmd.executeInfoCommand( null, new ScmFileSet( new File( "" ), path ), null, false, null );
187
188        if ( result.getInfoItems().size() != 1 )
189        {
190            throw new ScmRepositoryException(
191                "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" )
192                    + " items returned by the info command" );
193        }
194
195        return result.getInfoItems().get( 0 ).getURL();
196    }
197
198    @Override
199    public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet,
200                                           CommandParameters parameters )
201        throws ScmException
202    {
203        SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand();
204        return svnRemoteInfoCommand.executeRemoteInfoCommand( repository, fileSet, parameters );
205    }
206
207    @Override
208    public boolean remoteUrlExist( ScmProviderRepository repository, CommandParameters parameters )
209        throws ScmException
210    {
211        SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand();
212        return svnRemoteInfoCommand.remoteUrlExist( repository, parameters );
213    }
214}