Wednesday, January 21, 2015

#375 SOA / BPM 12c Bundle Patch released

















Upgrading to Bundle Patch 1

Here I am patching my SOA12c Quickstart environment.

Unzip to a directory of your choice.
Read the README.














The Readme mentions -

 Oracle recommends that all customers be on the latest version of OPatch for
their release. Download the latest version of OPatch 13.2.x via My Oracle
Support Patch 6880880. (Choose 13.2.0.0.0 or "OUI NextGen 13.2")

p6880880_132000_Generic.zip






So I install the newest OPatch first -

Install the newest version of OPatch


Here is its Readme -
















So here is my SOA Quickstart directory structure -

























Here are the contents of the patch -




















So we are essentially overwriting the OPatch directory.

Once that is done, we can install BP1.

Install BP1

Ensure that the integrated server is stopped.

Open a cmd window in the OPatch directory -

opatch lsinventory












Open another window in the patch directory -
Set oracle_home






Apply the patch -

opatch apply





























































Now I delete the following system--cache directory from the integrated server -

























I also have a BPM Quickstart on this machine and
I need to apply the patch to it, as well.




















Again, last step is to delete the system-cache directory.




Thursday, January 15, 2015

#374 MFT --> Creating Custom Callouts - A simple example

Introduction 

Let's go straight to the MFT docs -


Oracle Managed File Transfer provides built-in compression, decompression, encryption, and decryption actions for transfer preprocessing and postprocessing. See Setting Up Transfer Preprocessing and Postprocessing Actions and Setting Up Source Processing Actions for details.

You can create new preprocessing and postprocessing actions, which are called custom callout
Custom callouts can be associated with either the source or the target. The sequence of processing action execution during a transfer is as follows:

Source preprocessing actions
Target preprocessing actions

Payload delivery

Target postprocessing actions
Source postprocessing actions








Here is the jar containing the interfaces -
YourFMW4MFTDir\mft\modules\oracle.mft_12.1.3.0\core-12.1.1.0.jar



Now before I get to my simple example, I just want to highlight the
excellent MFT resources available on the Oracle SOA PM blog.
Check it out right here

The Simple Example 


So now to my simple example -
I need to parse the files and convert the contents as follows -

Change any occurrences of Ireland to Eire
or
Change any occurrences Eire to Ireland and visa-versa.

The test file I use is as follows -









So I will expect the output to have Eire instead of Ireland.
Eire, for those interested is the Gaelic name for Emerald Isle.

Implement the Callout


I followed this section from the MFT docs to create the Java class that will
do the conversion.

The code is very simple - the main jar required is here -



I add this to the JDev project -










Here is the implementation -

package mftcallout;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import java.util.Map;

import oracle.tip.mft.engine.processsor.plugin.PluginContext;
import oracle.tip.mft.engine.processsor.plugin.PluginOutput;
import oracle.tip.mft.engine.processsor.plugin.PreCalloutPlugin;

public class NcIECallout implements PreCalloutPlugin {
    public NcIECallout() {
        super();
    }
    // Callout changes the payload
    @Override
        public boolean isPayloadChangeRequired(PluginContext context,
                Map calloutParams) {
            return true;
        }
    
    @Override
       public PluginOutput process(PluginContext context, InputStream input,
               Map calloutParams) {
           return null;
       }
    
    @Override
       public PluginOutput process(PluginContext context, InputStream input,
               OutputStream out, Map calloutParams) {
           String type = calloutParams.get("Type");
           if ("Eire2Ireland".equals(type)) {
               doConversionEire2Ireland(input,out);
               
           }
           else{
               doConversionIreland2Eire(input,out);
           }
           return new PluginOutput();
       }
    
    private void doConversionIreland2Eire(InputStream in, OutputStream out) {
            BufferedReader bufferIn = null;
            BufferedWriter bufferOut = null;
            try {
                DataInputStream dataIn = new DataInputStream(in);
                bufferIn = new BufferedReader(new InputStreamReader(dataIn));
                DataOutputStream dataOut = new DataOutputStream(out);
                bufferOut = new BufferedWriter(new OutputStreamWriter(dataOut));
                // For each line in the un-normalized file
                String line;
                while ((line = bufferIn.readLine()) != null) {
                    if(line.equalsIgnoreCase("Ireland")){
                        line = "Eire";
                    }
                    bufferOut.write(line);
                    bufferOut.write("\r\n");
                          }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    bufferIn.close();
                    bufferOut.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    private void doConversionEire2Ireland(InputStream in, OutputStream out) {
            BufferedReader bufferIn = null;
            BufferedWriter bufferOut = null;
            try {
                DataInputStream dataIn = new DataInputStream(in);
                bufferIn = new BufferedReader(new InputStreamReader(dataIn));
                DataOutputStream dataOut = new DataOutputStream(out);
                bufferOut = new BufferedWriter(new OutputStreamWriter(dataOut));
                // For each line in the un-normalized file
                String line;
                while ((line = bufferIn.readLine()) != null) {
                    if(line.equalsIgnoreCase("Eire")){
                        line = "Ireland";
                    }
                    bufferOut.write(line);
                    bufferOut.write("\r\n");
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    bufferIn.close();
                    bufferOut.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
}

Now to the creation of the callout definition file -
The details here surface in the MFT console - i.e. the MFT user will be
able to add a pre-processing action - "Eire to Ireland text conversion"









I jar up the Java class and copy it, along with the xml file above to the following directory -
YourFMW4MFTDir\user_projects\domains\mft_domain\mft\callouts e.g.










Create this directory, is it doesn't already exist.








Now the next step is to register the new callout with MFT. We do this via WLST -



wls:/mft_domain/serverConfig> crtCalls('D:\Work\envs\FMW12c\MFT\user_projects\do
mains\mft_domain\mft\callouts\EireCalloutDef.xml')

Create a simple MFT Transfer to leverage the callout


Now I create a new source (File) in MFT and add a pre-processing step -










Now you can see how all of these values come from the callout definition file.
I then create a target and a transfer and test with the following file -







the output file is as follows -







btw. the Gaelic for England is Sasana, for France, is an Fhrainc.
  
Java Project here

#373 MFT --> Leveraging Remote sFTP as target / WLST support

Simple scenario: MFT transfer from local file to remote sFTP server.

I am using Cerberus FTP server here.
It is configured for sFTP as follows -


















I used PuttyGen to generate keys - they are here -












My Cerberus user - niall - is configured as follows -














Folder is D:\Work\envs\CerberusFTP\NcFolder

niall will use the public key, generated earlier.























I now import the private key into MFT using wlst -




















type help("mft") to see all mft related commands.





















now import the key -

importCSFKey('SSH', 'PRIVATE', 'ncMFTssh', 'D:\Work\keys\myPriv.ppk')




Now to the MFT Console - Administration tab

I set the SSH Keystore - PrivateKey password

















I now define my remote sFTP target -

















I create a file source -

























and then a transfer -


















I deploy and test -

source folder -











target directory -