Handling Local Transfer Requests
In this document, we will explain the process of handling a local transfer request. The process involves receiving the transfer request, processing the transaction data, writing the transfer to the database, and managing the database connection.
The flow starts with receiving a transfer request. The request is then processed internally, where the transaction data is checked and prepared for database insertion. The transfer details are written to the database, ensuring the data is correctly formatted. Finally, the database connection is managed, ensuring it is open and ready for use, and handling any exceptions that may occur during the connection process.
Flow drill down
Handling the Transfer Request
First, the writeTransferLocalExternal
writeTransferLocalInternal
@POST
@Produces("application/json")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/transferLocal")
public Response writeTransferLocalExternal(
ProcessedTransactionTransferLocalJSON proctranLocal)
{
Response myResponse = writeTransferLocalInternal(proctranLocal);
HBankDataAccess myHBankDataAccess = new HBankDataAccess();
myHBankDataAccess.terminate();
return myResponse;
}
Processing the Transfer Internally
Next, the writeTransferLocalInternal
ProcessedTransaction
public Response writeTransferLocalInternal(
ProcessedTransactionTransferLocalJSON proctranLocal)
{
com.ibm.cics.cip.bankliberty.web.db2.ProcessedTransaction myProcessedTransactionDB2 = new com.ibm.cics.cip.bankliberty.web.db2.ProcessedTransaction();
if (myProcessedTransactionDB2.writeTransferLocal(
proctranLocal.getSortCode(), proctranLocal.getAccountNumber(),
proctranLocal.getAmount(),
proctranLocal.getTargetAccountNumber()))
{
return Response.ok().build();
}
else
{
return Response.serverError().build();
}
}
Writing the Transfer to the Database
Then, the writeTransferLocal
public boolean writeTransferLocal(String sortCode2, String accountNumber2,
BigDecimal amount2, String targetAccountNumber2)
{
logger.entering(this.getClass().getName(), WRITE_TRANSFER_LOCAL);
sortOutDateTimeTaskString();
String transferDescription = "";
transferDescription = transferDescription
+ PROCTRAN.PROC_TRAN_DESC_XFR_FLAG;
transferDescription = transferDescription.concat(" ");
transferDescription = transferDescription
.concat(padSortCode(Integer.parseInt(sortCode2)));
transferDescription = transferDescription.concat(
padAccountNumber(Integer.parseInt(targetAccountNumber2)));
openConnection();
logger.log(Level.FINE, () -> ABOUT_TO_INSERT + SQL_INSERT + ">");
Opening the Database Connection
Moving to the openConnection
protected void openConnection()
{
// Open a connection to the DB2 database
logger.entering(this.getClass().getName(), "openConnection()");
Integer taskNumberInteger = Task.getTask().getTaskNumber();
String db2ConnString = DB2CONN.concat(taskNumberInteger.toString());
logger.log(Level.FINE,
() -> "Attempting to get DB2CONN for task number "
+ taskNumberInteger.toString());
this.conn = (Connection) cornedBeef.get(db2ConnString);
if (this.conn == null)
{
HBankDataAccess.incrementConnCount();
logger.log(Level.FINE,
() -> "Attempting to create DB2CONN for task number "
+ taskNumberInteger.toString());
// Attempt to open a connection
openConnectionInternal();
logger.log(Level.FINE,
() -> "Creation succcessful for DB2CONN for task number "
Establishing the Internal Database Connection
Finally, the openConnectionInternal
@SuppressWarnings("unchecked")
void openConnectionInternal()
{
logger.entering(this.getClass().getName(), "openConnectionInternal");
String jndiString = "jdbc/defaultCICSDataSource";
Context ctx;
try
{
ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(jndiString);
logger.log(Level.FINE, () -> "jndi string is " + jndiString);
// If there is no current connection
if (this.conn == null)
{
logger.log(Level.FINE,
() -> "About to attempt to get DB2 connection");
// Try and get a connection
this.conn = ds.getConnection();
this.conn.setTransactionIsolation(
Connection.TRANSACTION_READ_UNCOMMITTED);
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human