org.apache.maven.wagon.providers.scm
Class ScmWagon

java.lang.Object
  extended by org.apache.maven.wagon.AbstractWagon
      extended by org.apache.maven.wagon.providers.scm.ScmWagon
All Implemented Interfaces:
Wagon

public class ScmWagon
extends AbstractWagon

Wagon provider to get and put files from and to SCM systems, using Maven-SCM as underlying transport.

TODO it probably creates problems if the same wagon is used in two different SCM protocols, as instance variables can keep incorrect state. TODO: For doing releases we either have to be able to add files with checking out the repository structure which may not be possible, or the checkout directory needs to be a constant. Doing releases won't scale if you have to checkout the whole repository structure in order to add 3 files.

Version:
$Id: ScmWagon.java 1174113 2011-09-22 13:16:22Z olamy $
Author:
Brett Porter, Emmanuel Venisse, Carlos Sanchez, Jason van Zyl
Plexus component:
role-hint:
"scm"
instantiation-strategy:
"per-lookup"
role:
"org.apache.maven.wagon.Wagon"

Field Summary
 
Fields inherited from class org.apache.maven.wagon.AbstractWagon
authenticationInfo, DEFAULT_BUFFER_SIZE, interactive, proxyInfo, repository, sessionEventSupport, transferEventSupport
 
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
 
Constructor Summary
ScmWagon()
           
 
Method Summary
 void closeConnection()
           
 void get(String resourceName, File destination)
          Downloads specified resource from the repository to given file.
 File getCheckoutDirectory()
          Get the directory where Wagon will checkout files from SCM.
 List<String> getFileList(String resourcePath)
          

Returns a List of strings naming the files and directories in the directory denoted by this abstract pathname.

 boolean getIfNewer(String resourceName, File destination, long timestamp)
          Not implemented
 org.apache.maven.scm.manager.ScmManager getScmManager()
          Get the ScmManager used in this Wagon
 org.apache.maven.scm.provider.ScmProvider getScmProvider(String scmType)
          Convenience method to get the ScmProvider implementation to handle the provided SCM type
 String getScmVersion()
          Get the scmVersion used in this Wagon
 String getScmVersionType()
          Get the scmVersionType used in this Wagon
 void openConnectionInternal()
          This will cleanup the checkout directory
 void put(File source, String targetName)
          Copy a file from local system to remote
 void putDirectory(File sourceDirectory, String destinationDirectory)
          Copy a directory from local system to remote
 boolean resourceExists(String resourceName)
          Check if a remote resource exists
 void setCheckoutDirectory(File checkoutDirectory)
          Set the directory where Wagon will checkout files from SCM.
 void setScmManager(org.apache.maven.scm.manager.ScmManager scmManager)
          Set the ScmManager used in this Wagon
 void setScmVersion(String scmVersion)
          Set the scmVersion
 void setScmVersionType(String scmVersionType)
          Set the scmVersionType
 boolean supportsDirectoryCopy()
          Flag indicating if this wagon supports directory copy operations.
 
Methods inherited from class org.apache.maven.wagon.AbstractWagon
addSessionListener, addTransferListener, cleanupGetTransfer, cleanupPutTransfer, connect, connect, connect, connect, connect, connect, createParentDirectories, disconnect, finishGetTransfer, finishPutTransfer, fireGetCompleted, fireGetInitiated, fireGetStarted, firePutCompleted, firePutInitiated, firePutStarted, fireSessionConnectionRefused, fireSessionDebug, fireSessionDisconnected, fireSessionDisconnecting, fireSessionError, fireSessionLoggedIn, fireSessionLoggedOff, fireSessionOpened, fireSessionOpening, fireTransferDebug, fireTransferError, fireTransferProgress, getAuthenticationInfo, getPath, getPermissionsOverride, getProxyInfo, getProxyInfo, getReadTimeout, getRepository, getSessionEventSupport, getTimeout, getTransfer, getTransfer, getTransfer, getTransfer, getTransferEventSupport, hasSessionListener, hasTransferListener, isInteractive, openConnection, postProcessListeners, putTransfer, putTransfer, removeSessionListener, removeTransferListener, setInteractive, setPermissionsOverride, setReadTimeout, setSessionEventSupport, setTimeout, setTransferEventSupport, transfer, transfer, transfer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScmWagon

public ScmWagon()
Method Detail

getScmManager

public org.apache.maven.scm.manager.ScmManager getScmManager()
Get the ScmManager used in this Wagon

Returns:
the ScmManager

setScmManager

public void setScmManager(org.apache.maven.scm.manager.ScmManager scmManager)
Set the ScmManager used in this Wagon

Parameters:
scmManager -

getScmVersion

public String getScmVersion()
Get the scmVersion used in this Wagon

Returns:
the scmVersion

setScmVersion

public void setScmVersion(String scmVersion)
Set the scmVersion

Parameters:
scmVersion - the scmVersion to set

getScmVersionType

public String getScmVersionType()
Get the scmVersionType used in this Wagon

Returns:
the scmVersionType

setScmVersionType

public void setScmVersionType(String scmVersionType)
Set the scmVersionType

Parameters:
scmVersionType - the scmVersionType to set

getCheckoutDirectory

public File getCheckoutDirectory()
Get the directory where Wagon will checkout files from SCM. This directory will be deleted!

Returns:
directory

setCheckoutDirectory

public void setCheckoutDirectory(File checkoutDirectory)
Set the directory where Wagon will checkout files from SCM. This directory will be deleted!

Parameters:
checkoutDirectory -

getScmProvider

public org.apache.maven.scm.provider.ScmProvider getScmProvider(String scmType)
                                                         throws org.apache.maven.scm.manager.NoSuchScmProviderException
Convenience method to get the ScmProvider implementation to handle the provided SCM type

Parameters:
scmType - type of SCM, eg. svn, cvs
Returns:
the ScmProvider that will handle provided SCM type
Throws:
org.apache.maven.scm.manager.NoSuchScmProviderException - if there is no ScmProvider able to handle that SCM type

openConnectionInternal

public void openConnectionInternal()
                            throws ConnectionException
This will cleanup the checkout directory

Specified by:
openConnectionInternal in class AbstractWagon
Throws:
ConnectionException

put

public void put(File source,
                String targetName)
         throws TransferFailedException,
                ResourceDoesNotExistException,
                AuthorizationException
Description copied from interface: Wagon
Copy a file from local system to remote

Parameters:
source - the local file
targetName - the remote destination
Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException

supportsDirectoryCopy

public boolean supportsDirectoryCopy()
Description copied from interface: Wagon
Flag indicating if this wagon supports directory copy operations.

Specified by:
supportsDirectoryCopy in interface Wagon
Overrides:
supportsDirectoryCopy in class AbstractWagon
Returns:
true

putDirectory

public void putDirectory(File sourceDirectory,
                         String destinationDirectory)
                  throws TransferFailedException,
                         ResourceDoesNotExistException,
                         AuthorizationException
Description copied from interface: Wagon
Copy a directory from local system to remote

Specified by:
putDirectory in interface Wagon
Overrides:
putDirectory in class AbstractWagon
Parameters:
sourceDirectory - the local directory
destinationDirectory - the remote destination
Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException

closeConnection

public void closeConnection()
                     throws ConnectionException
Specified by:
closeConnection in class AbstractWagon
Throws:
ConnectionException

getIfNewer

public boolean getIfNewer(String resourceName,
                          File destination,
                          long timestamp)
                   throws TransferFailedException,
                          ResourceDoesNotExistException,
                          AuthorizationException
Not implemented

Returns:
true if newer resource has been downloaded, false if resource in the repository is older or has the same age.
Throws:
UnsupportedOperationException - always
TransferFailedException
ResourceDoesNotExistException
AuthorizationException

get

public void get(String resourceName,
                File destination)
         throws TransferFailedException,
                ResourceDoesNotExistException,
                AuthorizationException
Description copied from interface: Wagon
Downloads specified resource from the repository to given file.

Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException

getFileList

public List<String> getFileList(String resourcePath)
                         throws TransferFailedException,
                                ResourceDoesNotExistException,
                                AuthorizationException
Description copied from interface: Wagon

Returns a List of strings naming the files and directories in the directory denoted by this abstract pathname.

If this abstract pathname does not denote a directory, or does not exist, then this method throws ResourceDoesNotExistException. Otherwise a List of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

There is no guarantee that the name strings in the resulting list will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Specified by:
getFileList in interface Wagon
Overrides:
getFileList in class AbstractWagon
Parameters:
resourcePath - directory to list contents of
Returns:
a List<String> with filenames/directories at the resourcepath.
Throws:
TransferFailedException - if there's an error trying to access the remote side
ResourceDoesNotExistException - if destinationDirectory does not exist or is not a directory
AuthorizationException - if not authorized to list the contents of the directory
See Also:
AbstractWagon.getFileList(java.lang.String)

resourceExists

public boolean resourceExists(String resourceName)
                       throws TransferFailedException,
                              AuthorizationException
Description copied from interface: Wagon
Check if a remote resource exists

Specified by:
resourceExists in interface Wagon
Overrides:
resourceExists in class AbstractWagon
Returns:
whether the resource exists or not
Throws:
TransferFailedException - if there's an error trying to access the remote side
AuthorizationException - if not authorized to verify the existence of the resource


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.