| Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components | |
| Close Print View | |
| Designing: validate() |
|
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
Overview of SWIFT Message Libraries
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 from the Enterprise Designer
OTD and Collaboration Locations in Enterprise Designer
SWIFT Message Library JAR Files
Using Message Validation Features
Message Format Validation Rules (MFVR)
In Collaboration Validation Methods
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 Correlation Repository Sample
SWIFT Sample eInsight™ Project
Configuring the Modeling Elements
Configuring the Integration Server
Creating the Deployment Profile
Creating and Starting the Domain
Building and Deploying the Project
BICDirService Method Operation
BICPlusIBAN Validation Method Definitions
Using SWIFT FIN-Based Funds OTDs
SWIFT OTD Library Funds Features
Using SWIFT OTD Library Java Classes
Designing with Sun JCA Adapters
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.
public void validate()
None.
None.
com.stc.swift.validation.MessageValidationException: A MessageValidationException is thrown when the OTD is invalid in regard to applicable MFVR rules.
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.
public void validateMFVR()
None.
None.
com.stc.swift.validation.MFVRException : The MFVRException is thrown when the OTD is invalid in regard to applicable MFVR rules.
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.