From: <st...@us...> - 2008-02-06 14:11:33
|
Revision: 5871 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5871&view=rev Author: steve_l Date: 2008-02-06 06:11:32 -0800 (Wed, 06 Feb 2008) Log Message: ----------- SFOS-657 add an attribute transferCount to the scp components SFOS-597 Introduce bulk file transfer in SCP Component Modified Paths: -------------- trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java trunk/core/components/ssh/src/org/smartfrog/services/ssh/ScpBulkUploadImpl.java trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/components.sf trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/scpbulkupload/components.sf Modified: trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java =================================================================== --- trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java 2008-02-06 12:36:15 UTC (rev 5870) +++ trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java 2008-02-06 14:11:32 UTC (rev 5871) @@ -30,6 +30,7 @@ import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; import java.rmi.RemoteException; @@ -66,6 +67,8 @@ protected static final String SESSION_IS_DOWN = "session is down"; private static final String AUTH_FAIL = "Auth fail"; private static final String AUTH_CANCEL = "Auth cancel"; + public static final String ERROR_WRONG_PASSWORD_PROVIDER_TYPE = "The attribute "+ATTR_PASSWORD_PROVIDER+" must be a lazy reference to a class that implements the " + +"org.smartfrog.services.passwords.PasswordProvider"+" interface -"; /** * Only subclasses can instantiate this @@ -111,7 +114,13 @@ //create the user info to get filled in. userInfo = new UserInfoImpl(sfLog(), trustAllCerts); - PasswordProvider pwdProvider = (PasswordProvider) sfResolve(pwdProviderRef); + Prim provider = sfResolve(pwdProviderRef,(Prim)null,true); + if(!(provider instanceof PasswordProvider)) { + throw new SmartFrogResolutionException( + ERROR_WRONG_PASSWORD_PROVIDER_TYPE + +"what is present is an instance of "+provider.getClass()+" with value "+provider.toString()); + } + PasswordProvider pwdProvider = (PasswordProvider) provider; passphrase = pwdProvider.getPassword(); if (usePublicKey) { Modified: trunk/core/components/ssh/src/org/smartfrog/services/ssh/ScpBulkUploadImpl.java =================================================================== --- trunk/core/components/ssh/src/org/smartfrog/services/ssh/ScpBulkUploadImpl.java 2008-02-06 12:36:15 UTC (rev 5870) +++ trunk/core/components/ssh/src/org/smartfrog/services/ssh/ScpBulkUploadImpl.java 2008-02-06 14:11:32 UTC (rev 5871) @@ -32,9 +32,8 @@ import java.util.Vector; /** - * Component to do a bulk SCP upload. It works by overriding some - * of the functions to build a list of files. Also, it only supports - * file upload + * Component to do a bulk SCP upload. It works by overriding some of the functions to build a list of files. Also, it + * only supports file upload */ public class ScpBulkUploadImpl extends ScpComponentImpl implements ScpBulkUpload { @@ -45,42 +44,41 @@ } /** - * Read the file lists in, and resolve the local list Subclasses can - * override this, as long as the localFiles and remoteFiles lists are full - * at the end of the operation, and they have the same number of files. + * Read the file lists in, and resolve the local list Subclasses can override this, as long as the localFiles and + * remoteFiles lists are full at the end of the operation, and they have the same number of files. * * @throws SmartFrogResolutionException for resolution problems - * @throws RemoteException network problems - * @throws SmartFrogLifecycleException if there is a mismatch between the - * count of local and remote files + * @throws RemoteException network problems + * @throws SmartFrogLifecycleException if there is a mismatch between the count of local and remote files */ + @Override protected void readFileLists() throws SmartFrogException, RemoteException { - super.readFileLists(); fileset = FilesImpl.resolveFileset(this); - String remoteDir= sfResolve(ATTR_REMOTE_DIR,"",true); + String remoteDir = sfResolve(ATTR_REMOTE_DIR, "", true); //this is the list of files to work with File[] files = fileset.listFiles(); //now we build the local and remote lists from this - Vector<File> local=new Vector<File>(files.length); - Vector<String> remote=new Vector<String>(files.length); - for(File file:files) { + Vector<File> local = new Vector<File>(files.length); + Vector<String> remote = new Vector<String>(files.length); + for (File file : files) { local.add(file); - remote.add(remoteDir+ '/' + file.getName()); + remote.add(remoteDir + '/' + file.getName()); } setLocalFiles(local); setRemoteFileList(remote); + validateFileLists(); } /** * Force the transfer type to be an upload * - * @throws SmartFrogResolutionException if failed to read any attribute or a - * mandatory attribute is not defined. - * @throws SmartFrogLifecycleException if the transfer type is unsupported - * @throws RemoteException in case of network/rmi error + * @throws SmartFrogResolutionException if failed to read any attribute or a mandatory attribute is not defined. + * @throws SmartFrogLifecycleException if the transfer type is unsupported + * @throws RemoteException in case of network/rmi error */ + @Override protected void readTransferType() throws SmartFrogResolutionException, RemoteException, @@ -89,15 +87,12 @@ } /** - * Return a list of files that match the current pattern. This may be a - * compute-intensive operation, so cache the result. Note that filesystem - * race conditions do not guarantee all the files listed still exist...check - * before acting + * Return a list of files that match the current pattern. This may be a compute-intensive operation, so cache the + * result. Note that filesystem race conditions do not guarantee all the files listed still exist...check before + * acting * - * @return a list of files that match the pattern, or an empty list for no - * match - * - * @throws RemoteException when the network plays up + * @return a list of files that match the pattern, or an empty list for no match + * @throws RemoteException when the network plays up * @throws SmartFrogException if something else went wrong */ @@ -109,8 +104,7 @@ * Get the base directory of these files (may be null) * * @return the base directory - * - * @throws RemoteException when the network plays up + * @throws RemoteException when the network plays up * @throws SmartFrogException if something else went wrong */ public File getBaseDir() throws RemoteException, SmartFrogException { Modified: trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/components.sf =================================================================== --- trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/components.sf 2008-02-06 12:36:15 UTC (rev 5870) +++ trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/components.sf 2008-02-06 14:11:32 UTC (rev 5871) @@ -93,6 +93,7 @@ host OPTIONAL("") PROPERTY test.ssh.host; username OPTIONAL("") PROPERTY test.ssh.user; timeout OPTIONAL(5000) IPROPERTY test.ssh.timeout; + remoteDir OPTIONAL("/tmp") PROPERTY test.remote.dir; } Modified: trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/scpbulkupload/components.sf =================================================================== --- trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/scpbulkupload/components.sf 2008-02-06 12:36:15 UTC (rev 5870) +++ trunk/core/components/ssh/test/org/smartfrog/test/system/components/ssh/scpbulkupload/components.sf 2008-02-06 14:11:32 UTC (rev 5871) @@ -28,18 +28,20 @@ temp1 extends TempFileWithCleanup { dir LAZY tempdir; - suffix "txt"; + suffix ".txt"; text "t1"; } temp2 extends temp1; temp3 extends temp1 { - suffix "tmp"; + suffix ".tmp"; } + passwordProvider extends InlinePassword { + password SshTestProperties:password; + } - } /** @@ -59,20 +61,25 @@ upload extends ScpBulkUpload { - remoteDir ""; - baseDir PARENT:PARENT:action:tempdir; + remoteDir SshTestProperties:remoteDir ; + dir LAZY PARENT:PARENT:action:tempdir; + passwordProvider LAZY PARENT:PARENT:action:passwordProvider; pattern "\\w+.txt"; - host SshTestProperties:host; username SshTestProperties:username; timeout SshTestProperties:timeout; sfShouldTerminate true; - passwordProvider extends InlinePassword { - password SshTestProperties:password; - } + } - + assertCount extends Assert { + attribute "transferCount"; + attributeEquals "2"; + //what if the component is unreachable? + reference LAZY upload; + } + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |