Moving a File from a Local Directory on the File System to Another Local Directory

4-206 Oracle Fusion Middleware Users Guide for Technology Adapters 12. Drag the small triangle in the BPEL process in the Components area to the drop zone that appears as a green triangle in FileMove in the External References area. The BPEL component is connected to the Oracle File Adapter outbound service. 13. Create an invoke activity for the FileMove service that you just created by selecting the default settings. The next step is to modify the generated WSDL file for MoveFileService service and configure it with the new interaction specification for the move operation. 14. Open the FileMove_file.jca file and modify the endpoint interaction, as shown in the following example. You must configure the JCA file with the source and target directory and file details. You can either hardcode the source and target directory and file details in the JCA file or use header variables to populate them. In this example, header variables are used. adapter-config name=FileMove adapter=File Adapter xmlns=http:platform.integration.oracleblocksadapterfwmetadata connection-factory location=eisFileAdapter adapterRef= endpoint-interaction portType=FileMove_ptt operation=FileMove interaction-spec className=oracle.tip.adapter.file.outbound.FileIoInteractionSpec property name=SourcePhysicalDirectory value=foo1 property name=SourceFileName value=bar1 property name=TargetPhysicalDirectory value=foo2 property name=TargetFileName value=bar2 property name=Type value=MOVE interaction-spec endpoint-interaction adapter-config 15. Map the actual directory and file names to the source and target file parameters by performing the following procedure: a. Create 4 string variables with appropriate names. You must populate these variables with the source and target directory details. The BPEL source view shows you this: variables variable name=InvokeMoveOperation_FileMove_InputVariable messageType=ns1:Empty_msg variable name=InvokeMoveOperation_FileMove_OutputVariable messageType=ns1:FileMove_msg variable name=sourceDirectory type=xsd:string variable name=sourceFileName type=xsd:string variable name=targetDirectory type=xsd:string Note: You have modified the className attribute, and added SourcePhysicalDirectory, SourceFileName,TargetPhysicalDirectory, TargetFileName and Type. Currently, the values for the source and target details are dummy. You must populate them at run-time. You can also hardcode them to specific directories or file names. The Type attributes decides the type of operation. Apart from MOVE, the other acceptable values for the Type attribute are COPY and DELETE. Oracle JCA Adapter for FilesFTP 4-207 variable name=targetFileName type=xsd:string variables b. Create an assign activity to assign values to sourceDirectory, sourceFileName, targetDirectory, and targetFileName variables. The assign operation appears in the BPEL source view as in the following example: assign name=AssignFileDetails copy from expression=homealex to variable=sourceDirectory copy copy from expression=input.txt to variable=sourceFileName copy copy from expression=homealex to variable=targetDirectory copy copy from expression=output.txt to variable=targetFileName copy assign In the preceding example, input.txt is moved from homealex to output.txt in homealex. c. Pass these parameters as headers to the invoke operation. The values in these variables override the parameters in the JCA file. invoke name=InvokeMoveOperation inputVariable=InvokeMoveOperation_FileMove_InputVariable outputVariable=InvokeMoveOperation_FileMove_OutputVariable partnerLink=FileMove portType=ns1:FileMove_ptt operation=FileMove bpelx:inputProperty name=jca.file.SourceDirectory variable=sourceDirectory bpelx:inputProperty name=jca.file.SourceFileName variable=sourceFileName bpelx:inputProperty name=jca.file.TargetDirectory variable=targetDirectory bpelx:inputProperty name=jca.file.TargetFileName variable=targetFileName invoke 16. Finally, add an initial receive or pick activity. You have completed moving a file from a local directory on the file system to another local directory. Note: The source and target details are hardcoded in the preceding example. You can also provide these details as run-time parameters. 4-208 Oracle Fusion Middleware Users Guide for Technology Adapters

4.5.11.2 Copying a File from a Local Directory on the File System to Another Local Directory

Perform the following procedure to copy a file from a local directory on the file system to another local directory: 1. Follow steps 1 through 12 of Section 4.5.11.1, Moving a File from a Local Directory on the File System to Another Local Directory . 2. Change the value of the TYPE attribute to COPY instead of MOVE in the endpoint interaction, in Step 14 of Section 4.5.11.1, Moving a File from a Local Directory on the File System to Another Local Directory as shown in the following example: adapter-config ... connection-factory ... endpoint-interaction ... interaction-spec className=oracle.tip.adapter.file.outbound.FileIoInteractionSpec property ... property name=Type value=COPY interaction-spec endpoint-interaction adapter-config

4.5.11.3 Deleting a File from a Local File System Directory

To delete a file, you require TargetPhysicalDirectory and TargetFileName parameters. To delete a file, delete_me.txt, from homealex directory, you must perform the following:

1. Follow steps 1 through 12 in

Section 4.5.11.1, Moving a File from a Local Directory on the File System to Another Local Directory

2. Change the value of the TYPE attribute to DELETE in the endpoint interaction in

Step 14 of Section 4.5.11.1, Moving a File from a Local Directory on the File System to Another Local Directory , as shown in the following example: adapter-config name=FileDelete adapter=File Adapter xmlns=http:platform.integration.oracleblocksadapterfwmetadata connection-factory location=eisFileAdapter adapterRef= endpoint-interaction portType=FileDelete_ptt operation=FileDelete interaction-spec className=oracle.tip.adapter.file.outbound.FileIoInteractionSpec property name=TargetPhysicalDirectory value=homealex property name=TargetFileName value=delete_me.txt property name=Type value=DELETE interaction-spec endpoint-interaction adapter-config Note: You do not require SourcePhysicalDirectory and SourceFileName to delete a file from a local file system directory. Oracle JCA Adapter for FilesFTP 4-209

4.5.11.4 Using a Large CSV Source File

Consider the following scenario, where you have a large CSV file of size 1 gigabyte coming on the source directory, and you must perform the following:

1. Translate the CSV into XML.

2. Transform the resulting XML using XSL.

3. Translate the result from the transform operation into a fixed length file.

This use case is similar to the FlatStructure sample in the BPEL samples directory. The difference is that the three steps occur in a single File IO interaction. To use a large CSV file and perform the operations listed in the preceding scenario, you must perform the following steps:

1. Copy the address-csv.xsd and address-fixedLength.xsd files from the

FlatStructure sample into the xsd directory of your project. 2. Copy addr1Toaddr2.xsl from the FlatStructure sample into the xsl directory of your project.

3. Configure the File IO interaction, as shown in the following example. At a high

level, you must specify the source schema, the target schema, and the XSL in the interaction specification along with the source and target directory or file details, as shown in the following example: adapter-config name=FileMove adapter=File Adapter xmlns=http:platform.integration.oracleblocksadapterfwmetadata connection-factory location=eisFileAdapter adapterRef= endpoint-interaction portType=FileMove_ptt operation=FileMove interaction-spec className=oracle.tip.adapter.file.outbound.FileIoInteractionSpec property name=SourcePhysicalDirectory value=foo1 property name=SourceFileName value=bar1 property name=SourceSchema value=xsdaddress-csv.xsd property name=SourceSchemaRoot value=Root-Element property name=SourceType value=native property name=TargetPhysicalDirectory value=foo2 property name=TargetFileName value=bar2 property name=TargetSchema value=xsdaddress-fixedLength.xsd property name=TargetSchemaRoot value=Root-Element property name=TargetType value=native property name=Xsl value=xsladdr1Toaddr2.xsl property name=Type value=MOVE interaction-spec endpoint-interaction adapter-config Note that you have provided the following additional parameters: ■ SourceSchema: Relative path to the source schema. ■ SourceSchemaRoot: The root element in the source schema. ■ SourceType: The type of data. The other possible type is XML. ■ TargetSchema: Relative path to the target schema. Note: All the three steps occur in a single File IO interaction. This works only if all the records in the data file are of the same type.