Sun Adapter for Batch Tutorial

Collaboration Business Rules

The Java Collaboration Business Rules for the Project are separated into three Java Collaborations as seen from the Java Collaboration Editor: jcdBatchFTPOverSSL, jcdBatchSCP, and jcdBatchSFTP. The following images display the business rules for each of the Java Collaboration Definitions along with the Java source code.

jcdBatchFTPOverSSL Business Rules

Image shows the business rules for the jcdBatchFTPOverSSL
Java Collaboration Definition

jcdBatchFTPOverSSL Java Source File


package prBatch_Secure;


public class jcdBatchFTPOverSSL
{

    public com.stc.codegen.logger.Logger logger;

    public com.stc.codegen.alerter.Alerter alerter;

    public com.stc.codegen.util.CollaborationContext collabContext;

    public com.stc.codegen.util.TypeConverter typeConverter;

    public void receive( com.stc.connector.appconn.file.FileTextMessage 
input, com.stc.connector.batchadapter.appconn.ftps.FTPOverSSL 
BatchFTPOverSSL_1,com.stc.connector.appconn.file.FileApplication FileClient_1 )
        throws Throwable
    {
        // get and put
        BatchFTPOverSSL_1.getConfiguration().setLocalFile( 
"FTPOverSSL_from_remote.txt" );
        BatchFTPOverSSL_1.getClient().get();
        BatchFTPOverSSL_1.getConfiguration().setRemoteFile( 
"FTPOverSSL_to_remote.txt" );
        BatchFTPOverSSL_1.getClient().put();
        // download and upload
        BatchFTPOverSSL_1.getConfiguration().setLocalDirectory( 
"c:/BatchSecurity/FTPOverSSL" );
        BatchFTPOverSSL_1.getConfiguration().setLocalFile( 
"FTPOverSSL_from_remote.txt" );
        BatchFTPOverSSL_1.getClient().download();
        BatchFTPOverSSL_1.getConfiguration().setRemoteDirectory( 
"BatchSecurity/FTPOverSSL" );
        BatchFTPOverSSL_1.getConfiguration().setRemoteFile( 
"FTPOverSSL_to_remote.txt" );
        BatchFTPOverSSL_1.getClient().upload();
        // Create and list directories
        String entryInfo;
        int entryCnt;
        for (int i = 1; i < 6; i++) {
            BatchFTPOverSSL_1.getClient().mkdir( "mydir_" + i );
        }
        BatchFTPOverSSL_1.getClient().listDirLong();
        entryCnt = BatchFTPOverSSL_1.getClient().getEntryCount();
        entryInfo = "Directory Listing:\n";
        for (int i = 0; i < entryCnt; i++) {
            entryInfo = "[" + BatchFTPOverSSL_1.getClient().getEntry( 
i ).getDirectory() + "]" + "[" + BatchFTPOverSSL_1.getClient().getEntry( 
i ).getFile() + "]" + "[" + BatchFTPOverSSL_1.getClient().getEntry( i ).
getFileSize() + "]" + "[" + BatchFTPOverSSL_1.getClient().getEntry( 
i ).isDir() + "]" + "\n";
        }
        FileClient_1.setText( entryInfo );
        FileClient_1.write();
        // Delete and list directories
        for (int i = 1; i < 5; i++) {
            BatchFTPOverSSL_1.getClient().deleteDir( "mydir_" + i );
        }
        BatchFTPOverSSL_1.getClient().listDir();
        entryCnt = BatchFTPOverSSL_1.getClient().getEntryCount();
        entryInfo = "Directory Listing:\n";
        for (int i = 0; i < entryCnt; i++) {
            entryInfo = "[" + BatchFTPOverSSL_1.getClient().getEntry( 
i ).getDirectory() + "]" + "\n";
        }
        FileClient_1.setText( entryInfo );
        FileClient_1.write();
    }

}

jcdBatchSCP Business Rules

Image shows the business rules for the jcdBatchSCP Java
Collaboration Definition

jcdBatchSCP Java Source File


package prBatch_Secure;


public class jcdBatchSCP
{

    public com.stc.codegen.logger.Logger logger;

    public com.stc.codegen.alerter.Alerter alerter;

    public com.stc.codegen.util.CollaborationContext collabContext;

    public com.stc.codegen.util.TypeConverter typeConverter;

    public void receive( com.stc.connector.appconn.file.FileTextMessage input, 
com.stc.connector.batchadapter.appconn.scp.SCP BatchSCP_1 )
        throws Throwable
    {
        // recursive get and put
        BatchSCP_1.getConfiguration().setLocalDirectory( "C:/BatchSecurity/SCP" );
        BatchSCP_1.getConfiguration().setLocalFile( "recursive" );
        BatchSCP_1.getClient().getRecursive();
        BatchSCP_1.getConfiguration().setRemoteDirectory( "BatchSecurity/SCP" );
        BatchSCP_1.getConfiguration().setRemoteFile( "recursive" );
        BatchSCP_1.getClient().putRecursive();
    }

}

jcdBatchSFTP Business Rules

Image shows the business rules for the jcdBatchSFTP Java
Collaboration Definition

jcdBatchSFTP Java Source File


package prBatch_Secure;


public class jcdBatchSFTP
{

    public com.stc.codegen.logger.Logger logger;

    public com.stc.codegen.alerter.Alerter alerter;

    public com.stc.codegen.util.CollaborationContext collabContext;

    public com.stc.codegen.util.TypeConverter typeConverter;

    public void receive( com.stc.connector.appconn.file.FileTextMessage input, 
com.stc.connector.batchadapter.appconn.sftp.SFTP BatchSFTP_1 )
        throws Throwable
    {
        // get, make directory, change directory, put, rename, delete
        BatchSFTP_1.getConfiguration().setLocalDirectory( "C:/BatchSecurity/SFTP" );
        BatchSFTP_1.getConfiguration().setLocalFile( "SFTP_from_remote.txt" );
        BatchSFTP_1.getClient().get();
        BatchSFTP_1.getClient().mkdir( "BatchSecurity/new_SFTP" );
        BatchSFTP_1.getClient().cd( "BatchSecurity/new_SFTP" );
        BatchSFTP_1.getConfiguration().setRemoteDirectory( "" );
        BatchSFTP_1.getConfiguration().setRemoteFile( "SFTP_to_remote.txt" );
        BatchSFTP_1.getClient().put();
        BatchSFTP_1.getClient().rename( "BatchSecurity/new_SFTP/SFTP_to_remote.txt", 
"BatchSecurity/new_SFTP/renamed_SFTP_to_remote.txt" );
        BatchSFTP_1.getClient().delete( "BatchSecurity/useless_SFTP.txt" );
    }

}