This topic provides an overview of the prjBatch_Secure Project, and describes how to run the imported sample.
The prjBatch_Secure Project contains three scenarios that employ three Batch OTDS to enable SSL or SSH secure file transfers.
TheprjBatch_Secure Project uses four External Applications, seven component Adapters, and three Java Collaborations.
The Sun Adapter for Batch performs the following functions
The inbound File Adapters, FileIn_BatchFTPOverSSL, FileIn_BatchSFTP, and FileIn_BatchSCP, act as triggers for the Project. The File Adapters poll an external directory for a specific input file. When the input file is present, the File Adapter triggers the Collaboration.
BatchFTPOverSSL is used by the Collaboration to:
get files from a remote directory and publish them to a local directory
get files from a local directory and publish them to the remote directory
download files from the remote directory to a local directory
upload files from a local directory to a remote directory
create and list remote directories
delete remote directories and list the results
These functions can be seen in the jcdBatchFTPOverSSL Java Collaboration Definition.
BatchSFTP is used by the Collaboration to:
get files from a remote directory and publish them to a local directory
create a new remote directory
change directories to the new directory and publish a file to that directory
rename the published file
delete an unwanted file from the remote directory
These functions can be seen in the jcdBatchSFTP Java Collaboration Definition.
BatchSCP is used by the Collaboration to:
recursively get a file from the remote directory and publish the file to a local directory
recursively put a file from the local directory to a remote directory
These functions can be seen in the jcdBatchSCP Java Collaboration Definition.
The prjBatch_Secure Project includes three Java Collaborations, one for each of the three scenarios provided in the cmBatch_Secure Connectivity Map. The jcdBatchFTPOverSSL, jcdBatchSCP, and jcdBatchSFTP Java Collaboration Definitions are each created using the Collaboration Definition Wizard (Java).
From the Project Explorer, right-click the prjBatch_Secure Project and select New⇒Collaboration Definition (Java) from the context menu.
The Java Collaboration Definition Wizard appears.
Enter a Collaboration Definition name (for this Project, use jcdBatchFTPOverSSL) and click Next.
For Step 2 of the Wizard, from the Web Services Interfaces selection window, double-click CAPS Components Library⇒Adapters⇒File⇒FileClient⇒receive.
The Name field now displays receive.
Click Next.
For Step 3 of the Wizard, from the Select OTDs selection window, double-click CAPS Components Library⇒Adapters⇒BatchAdapter⇒BatchFTPOverSSL.
The jcdBatchFTPOverSSL OTD is added to the Selected OTDs field.
Click the Up One Level button to return to the Repository directory.
Double-click CAPS Components Library ⇒ Adapters ⇒ File ⇒ FileClient.
The FileClient OTD is added to the Selected OTDs field.
Click Finish.
The Java Collaboration Editor opens to the new Collaboration in the right pane of the NetBeans IDE.
To create the jcdBatchSCP Collaboration, follow the procedures in the To Create the jcdBatchFTPOverSSL Java Collaboration, replacing the Collaboration name with jcdBatchSCP, and selecting only the BatchSCP OTD for Step 4 of the Wizard.
To create the jcdBatchSFTP Collaboration, follow the procedures in the To Create the jcdBatchFTPOverSSL Java Collaboration, replacing the Collaboration name with jcdBatchSFTP, and selecting only the BatchSFTP OTD for Step 4 of the Wizard.
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.
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(); } } |
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(); } } |
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" ); } } |
Import the prjBatch_Secure Project described in To Import a Non-JBI Based Sample Project. After the sample Project has been imported and appears in your Project Explorer tree, create the Project’s Environment.
Environments include the External Systems, Logical Hosts, Sun Java System Application Servers and Message Servers used by a Project and contain the configuration information for these components.
From the NetBeans IDE click the Services tab.
Right-click the Repository and select New Environment.
A new Environment is added to the Services tree.
Rename the new Environment to envBatch_Secure.
Right-click envBatch_Secure and select New⇒BatchFTPOverSSL External System.
Name this External System esBatchFTPOverSSL.
The esBatchFTPOverSSL window is added to the Environment Editor.
Right-click envBatch_Secure and select New⇒BatchSCP External System.
Name this External System esBatchSCP.
The esBatchSCP window is added to the Environment Editor.
Right-click envBatch_Secure and select New⇒BatchSFTP External System.
Name this External System esBatchSFTP.
The esBatchSFTP window is added to the Environment Editor.
Right-click envBatch_Secure and select New⇒File External System.
Name the External System esFile and click OK.
The esFile window is added to the Environment Editor.
Right-click envBatch_Secure and select New⇒Logical Host.
The LogicalHost1 box is added to the Environment and LogicalHost1 is added to the Environment Editor tree.
From the Services tree, right-click LogicalHost1 and select New⇒Sun Java System Application Server.
A new Sun Java System Application Server is added to the Services tree under Localhost1.
Save the Project.
The prjBatch_Secure Project uses seven component Adapters, each represented in the Connectivity Map as a node between an External Application and the Service.
From the Connectivity Map, double-click the inbound FileIn_BatchFTPOverSSL Adapter between the FileIn_BatchFTPOverSSL External Application and the jcolBatchFTPOverSSL1 service.
The Properties Editor opens to the inbound File Adapter properties.
Modify the configuration for your system, including the settings in the following table.
Inbound File Adapter Connectivity Map Properties |
|
---|---|
Parameter Settings - Set as directed, otherwise use the default settings |
|
Input File Name |
FileIn_BatchFTPOverSSL.txt |
From the Connectivity Map, modify the inbound FileIn_BatchSFTP Adapter between the FileIn_BatchSFTP External Application and the jcolBatchSFTP1 service.
See the following table.
Inbound File Adapter Connectivity Map Properties |
|
---|---|
Parameter Settings - Set as directed, otherwise use the default settings |
|
Input File Name |
FileIn_BatchSFTP.txt |
From the Connectivity Map, modify the inbound FileIn_BatchSCP Adapter between the FileIn_BatchSCP External Application and the jcolBatchSCP1 service.
See the following table.
Inbound File Adapter Connectivity Map Properties |
|
---|---|
Parameter Settings - Set as directed, otherwise use the default settings |
|
Input File Name |
FileIn_BatchSCP.txt |
From the Connectivity Map, modify the Outbound FileOut_BatchFTPOverSSL Adapter between the FileOut_BatchFTPOverSSL External Application and the jcolBatchFTPOverSSL1 service.
See the following table.
Outbound File Adapter Connectivity Map Properties |
|
---|---|
Parameter Settings - Set as directed, otherwise use the default settings |
|
Output File Name |
FileOut_BatchFTPOverSSL.dat |
From the Services tree, right-click the esFile External System, and select Properties.
The Properties Editor opens to the File Adapter Environment properties.
Modify the File Adapter Environment properties for your system, including the settings in the following table, and click OK.
File Adapter Environment Properties |
|
---|---|
Inbound File Adapter ⇒ Parameter Settings - Set as directed, otherwise use the default settings. |
|
Directory |
An input directory on your system that the inbound File Adapters poll and pick up any specified input files. |
Outbound File Adapter ⇒ Parameter Settings - Set as directed, otherwise use the default settings. |
|
Directory |
An output directory to which the outbound File Adapter publishes (writes) the output messages. |
From the Connectivity Map, double-click the BatchFTPoverSSL1 Adapter, located between the BatchFTPOverSSL1 External Application and the jcolBatchFTPOverSSL1 service.
The Adapter Properties Editor appears.
Modify the BatchFTPoverSSL Adapter Connectivity Map properties for your system, including the settings in the following table, and click OK.
BatchFTPoverSSL Adapter Connectivity Map Properties |
|
---|---|
FTP and SSL Settings - Set as directed, otherwise use the default settings |
|
Local Directory |
The local directory name and path for files that are sent to or received from a remote system. The default is X:/Batch51 |
Target File Name |
The name of the remote file. |
From the Services tree, right-click the BatchFTPoverSSL External System (in this Project, esBatchFTPoverSSL ), and select Properties.
The Properties Editor opens to the BatchFTPoverSSL Adapter Environment properties.
Modify the BatchFTPoverSSL Adapter Environment properties for your system, including the settings in the following table, and click OK.
BatchFTPoverSSL Adapter Environment Properties |
|
---|---|
FTP and SSL Settings - Set as directed, otherwise use the default settings. |
|
Host Name |
Host name or IP of the FTP server |
Server Port |
Port number to use to connect to the FTP server |
User Name |
User ID used to log into the system |
Password |
Password required to log into the system |
Configure the Adapter properties for your system.
The prjBatch_Secure sample Project uses a number of directories.
Create the directories associated with Adapter configuration properties:
Target Directory (Inbound File Adapter Environment Properties):
Select a name for your target directory.
Output Directory (Outbound File Adapter Environment Properties):
Select a name for your output directory.
Create these directories on your system, or change the properties to reference your existing directories.
A Deployment Profile is used to assign Collaborations and message destinations to the Sun Java System Application Server and message server. Deployment profiles are created using the Deployment Editor.
From the Enterprise Explorer’s Project Explorer, right-click the Project (prjBatch_Secure) and select New⇒Deployment Profile.
Enter a name for the Deployment Profile (for this sample dpBatch_Secure).
Make sure that the selected Environment is envBatch_Secure and click OK.
Click Automap.
The Project’s components are automatically mapped to their respective system windows.
If any of your Project components did not successfully map to an external system, open each of your Adapter’s configuration properties (Connectivity Map and Environment) and click OK to close and save the current configuration, then click Automap again.
Save the Project.
A domain is an instance of a Logical Host. After the domain is created, the Project is built and then deployed.
Navigate to your JavaCAPS6\logicalhost directory, where JavaCAPS6 is the location of your Java CAPS installation.
Double-click the domainmgr.bat file.
The Domain Manager appears.
Do one of the following:
If you have already created a domain, select your domain in the Domain Manager and click Start an Existing Domain.
If there are no existing domains, click Yes.
The Create Domain dialog box appears.
Make any necessary changes to the Create Domain dialog box and click Create.
Select the domain and click the Start an Existing Domain button
The new domain is added to the Domain Manager.
Once your domain is started, a green check mark indicates that the domain is running.
The Build process compiles and validates the Project’s Java files and creates the Project EAR file.
From the Deployment Editor toolbar, click the Build icon.
If there are any validation errors, a Validation Errors pane will appear at the bottom of the Deployment Editor and displays information regarding the errors.
Make any necessary corrections and click Build again.
From the Deployment Editor toolbar, click the Deploy icon.
The Deploy prompt appears.
Click Yes.
A message appears when the project is successfully deployed.
To run your deployed sample Project do the following