Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components
Close Print View
Designing: validate()
 

Classic Java CAPS

Developing Java CAPS Projects

Using SOAP Message Handlers

Creating a Runtime Environment

Designing Business Processes in the Sun Business Process Manager

Working with TCP/IP HL7 Collaborations

Developing Sun Master Indexes (Repository)

Developing Sun Master Patient Indexes

Developing OTDs for Application Adapters

Developing OTDs for Communication Adapters

Developing OTDs for Database Adapters

Developing OTDs for Web Server Adapters

Designing with Application Adapters

Designing with Communication Adapters

Designing with Web Server Adapters

SWIFT Integration Projects

Overview of SWIFT Message Libraries

2008 Library Features

Library Versions and Access

What's New in Java CAPS 6 Update 1

Installing the SWIFT Message Library

SWIFT OTD Library System Requirements

Installing the SWIFT OTD Libraries

Installing the eWay on a Java CAPS Supported System

Increasing the Heap Size

Increasing the heap size from the Enterprise Designer

Using the SWIFT OTD Library

SWIFT Message Type OTDs

SWIFT Message Structure

OTD and Collaboration Locations in Enterprise Designer

SWIFT Message Type Reference

Category 1 Messages

Category 2 Messages

Category 3 Messages

Category 4 Messages

Category 5 Messages

Category 6 Messages

Category 7 Messages

Category 8 Messages

Category 9 Messages

Validation Collaborations

SWIFT Generic Library

SWIFT Message Library JAR Files

Using Message Validation Features

Basic Validation Features

Library Methods

Message Validation Rules

Message Format Validation Rules (MFVR)

MFVR Validation Methods

MFVR Errors

In Collaboration Validation Methods

validate()

SWIFT Projects

Importing a Sample Project

SWIFT Projects and the Enterprise Designer

SWIFT Sample prjSwift_JCD_MFVROnly Project

SWIFT Sample prjSwift_JCD_MFVRAndBICPlusIBAN Project

SWIFT Sample prjSwift_JCD_BICPlusIBANOnly Project

SWIFT MX Validation Sample

SWIFT Correlation Repository Sample

SWIFT Sample eInsight™ Project

Using eGate With eInsight

Using a Business Process

Configuring the Modeling Elements

Creating a Connectivity Map

Binding the eWay Components

Creating an Environment

Configuring the eWays

Configuring the Integration Server

Creating the Deployment Profile

Creating and Starting the Domain

Building and Deploying the Project

Running the Sample

Updating BICDirService

Source of Information

BICDirService Method Operation

Updating BICPlusIBAN

BICPlusIBAN Validation Method Definitions

Error Message Information

Error Messages

Message Examples

Using SWIFT FIN-Based Funds OTDs

SWIFT OTD Library Funds Features

Using SWIFT OTD Library Java Classes

Relation to OTD Message Types

SWIFT OTD Library Javadoc

OTD Library Java Classes

Java EE Based Components

Designing with Sun JCA Adapters

About the TCP/IP JCA Adapter

Defining Constants and Variables

Using Database Operations

Developing Sun Master Indexes

Using the JMS JCA Wizard

Using the JAXB Wizard and Code-Seeder Pallete

validate()

Description

Validates applicable MFVR rules against the OTD instance. Throws a MessageValidationException if the OTD is invalid in regard to applicable MFVR rules. Error message detail can be obtained by calling MessageValidationException.getErrorMessage().

If the OTD does not have applicable MFVR rules, the method call returns without throwing a MessageValidationException.

Syntax
public void validate()
Parameters

None.

Return Values

None.

Throws
com.stc.swift.validation.MessageValidationException: A
 MessageValidationException is thrown when the OTD is invalid in regard
to applicable MFVR rules.
validateMFVR()
Description

Validate applicable MFVR rules against the OTD instance. Throws MFVRException if the OTD is invalid in regard to applicable MFVR rules. Error message detail can be obtained by calling MFVRException.getErrorMessage().

If the OTD does not have applicable MFVR rules the method call always returns without throwing an MFVRException.

Syntax
public void validateMFVR()
Parameters
None.
Return Values

None.

Throws
com.stc.swift.validation.MFVRException
: The MFVRException is thrown when the OTD
is invalid in regard to applicable MFVR rules.
Calling the Validation Methods in your Collaboration

The validation methods are available at the OTD level, and can be called after the OTD is populated with it’s values. This usually occurs after a message is unmarshaled in the OTD.

The following fragment of code demonstrates the use of the validate method within a Collaboration. In this example, validate() is called and either “message OK’ or the exception error String is written to the log.

import com.stc.swift.validation.MFVRException;
import com.stc.swift.validation.SVRException;
import com.stc.swift.validation.ValidatingSWIFTMTOTD;
import com.stc.swift.validation.bic.BICDir;
import com.stc.swift.validation.BICPlusIBAN.*;
import com.stc.swift.validation.MessageValidationException;
import com.stc.swift.otd.v2008.std.mt_541.Mt_541;
import java.util.*;


public class ValidateMt_541_Modified
{

    public boolean receive( com.stc.connectors.jms.Message input, 
xsd.ValidationReplyMessage.Result output, com.stc.connectors.jms.JMS
 invalidMessages, com.stc.connectors.jms.JMS validMessages,
 com.stc.swift.otd.v2008.std.mt_541.Mt_541 mt_541_1 )
        throws Throwable
    {
        com.stc.connectors.jms.Message result = validMessages.createMessage();
        result.setTextMessage( input.getTextMessage() );
        String errors = null;
        String msg = "";
        try {
            mt_541_1.unmarshal( (com.stc.otd.runtime.OtdInputStream)
 new com.stc.otd.runtime.provider.SimpleOtdInputStreamImpl(
 new java.io.ByteArrayInputStream( input.getTextMessage().getBytes() ) ) );
        } catch ( Exception ex ) {
            errors = ex.getMessage();
            errors += "\r\n";
            errors += "Last successful parse: " + mt_541_1.getLastSuccessInfo();
            result.storeUserProperty( "ValidationErrors", errors );
            invalidMessages.send( result );
            output.setErrorMessages( errors );
            output.setIsError( true );
            output.setSwiftMessage( input.getTextMessage() );
            return false;
        }
        logger.info( "Unmarshalled MT541 message." );
        logger.info( "MFVR validation to follow ....." );
        // Call Default Validation logic for validation against applicable MFVRs
        try {
            mt_541_1.validate();
        } catch ( MessageValidationException mve ) {
            errors = mve.getErrorMessage();
            msg = mve.getMessage();
        }
        logger.info( "Completed MFVR validation" );
        logger.info( "BICPlusIBAN validation to follow ....." );
        if (errors == null) {
            logger.info( "No MFVR Exception" );
        } else {
            logger.info( "Found MFVR Exception" );
            logger.info( "Errors: " + errors );
            logger.info( "msg: " + msg );
        }
        // End of "Default Validation" invoking
        //
        // Call BICPlusIBAN validation
        String BICPlusIBANresult = "";
        String bicCode = mt_541_1.getBasicHeader().getLTAddress().substring( 0, 8 );
        String ibanCode = "DE615088005034573201";
        BICPlusIBANDir.setBIC_Code( bicCode );
        BICPlusIBANDir.setIBAN_Code( ibanCode );
        BICPlusIBANresult = "\n\n\n*** Validating BICPlusIBAN ***\n";
        BICPlusIBANresult = BICPlusIBANresult + 
"    BIC - " + BICPlusIBANDir.getBIC_code() + "\n";
        BICPlusIBANresult = BICPlusIBANresult + 
"    IBAN - " + BICPlusIBANDir.getIBAN_code() + "\n";
        BICPlusIBANresult = BICPlusIBANresult + 
"\n   a) Deriving the BIC from the IBAN...\n";
        ArrayList bicList = BICPlusIBANDir.deriveBICfromIBAN();
        if (bicList == null) {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> Unable to derive BIC data from given IBAN.\n";
            if (errors != null) {
                errors = errors + "\n\nUnable to derive BIC data from given IBAN.\n";
            } else {
                errors = errors + "\n\nUnable to derive BIC data from given IBAN.\n";
            }
        } else {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> BIC CODE and BRANCH CODE = " + (String) bicList.get( 0 ) + ".\n";
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> IBAN BIC CODE and BRANCH CODE = " + (String) bicList.get( 1 ) + ".\n";
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> ROUTING BIC CODE and BRANCH CODE = " + (String) bicList.get( 2 ) + ".\n";
        }
        BICPlusIBANresult = BICPlusIBANresult + "\n   b) Validating the Bank ID...\n";
        if (BICPlusIBANDir.validateBankID()) {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> Valid Bank ID found in BI file.\n";
        } else {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> No valid Bank ID found in BI file.\n";
            if (errors != null) {
                errors = errors + "No valid Bank ID found in BI file.\n";
            } else {
                errors = errors + "No valid Bank ID found in BI file.\n";
            }
        }
        BICPlusIBANresult = BICPlusIBANresult + "\n   c) Validating the BIC...\n";
        if (BICPlusIBANDir.validateBIC()) {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> Valid BIC data found in BI file.\n";
        } else {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> No valid BIC data found in BI file.\n";
            if (errors != null) {
                errors = errors + "No valid BIC data found in BI file.\n";
            } else {
                errors = errors + "No valid BIC data found in BI file.\n";
            }
        }
        BICPlusIBANresult = BICPlusIBANresult + 
"\n   d) Validating the BIC/IBAN Combination...\n";
        if (BICPlusIBANDir.validateBICIBANCombo()) {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> BIC and IBAN codes are belong to the same institution.\n\n\n";
        } else {
            BICPlusIBANresult = BICPlusIBANresult + 
"      ==> BIC and IBAN codes are NOT belong to the same institution.\n\n\n";
            if (errors != null) {
                errors = errors + "BIC and IBAN codes are NOT belong
 to the same institution.\n\n\n";
            } else {
                errors = errors + "BIC and IBAN codes are NOT belong
 to the same institution.\n\n\n";
            }
        }
        logger.info( BICPlusIBANresult );
        //
        if (errors != null) {
            // errors = errors + BICPlusIBANresult;
            result.storeUserProperty( "ValidationErrors", errors );
            invalidMessages.send( result );
            output.setErrorMessages( errors );
            output.setIsError( true );
            output.setSwiftMessage( input.getTextMessage() );
            return false;
        }
        // passed validation
        String currMsg = result.getTextMessage();
        currMsg = currMsg + BICPlusIBANresult;
        result.setTextMessage( currMsg );
        validMessages.send( result );
        output.setErrorMessages( "" );
        output.setIsError( false );
        output.setSwiftMessage( input.getTextMessage() );
        return true;
    }

To select a validation method from the Collaboration Editor’s Business Rules Designer, right-click the SWIFT message OTD and select Select method to call from the shortcut menu.