Developer

Services Interface – Client Logic Implementation

All services should be exposed through their own <xyz>ClientLogic class, and created as a Spring Bean. An <xyz>ClientLogic class should be a subclass of the BaseClientLogic class, so it inherits the standard client logic methods.

To implement an <xyz>ClientLogic class, import the required service interface and bean (or alias):
import com.sybase365.mobiliser.money.services.api.ITransactionEndpoint;    
    
private ITransactionEndpoint wsTransactionEndpoint;       

public void setWsTransactionEndpoint(ITransactionEndpoint wsTransactionEndpoint) {    
  this.wsTransactionEndpoint =
        wsTransactionEndpoint;   
}
Next, provide an access method that uses the new member field:
public   List <SimpleTransaction> findTransactions (    
  SearchTransactionCriteria criteria, Integer maxNumberToFetch )  
  throws Exception {    
    
  LOG.debug ("#  TransactionClientLogic.findTransactions ()");    
    
  List <SimpleTransaction> transactions = new ArrayList < SimpleTransaction >() ;    
    
  if (PortalUtils.exists(criteria.getCustomerId()))            
     request.setCustomerId(criteria.getCustomerId().longValue());          

  request.setFromDate(criteria.getFromDateXml());      
  request.setToDate(criteria.getToDateXml());      
  request.setMerchantOrderIdFilter(criteria.getOrderID());      
  request.setShowFaulty(criteria.getShowFaulty());      
  request.setStatusFilter(criteria.getTxnStatus());      
  request.setMaxRecords(maxNumberToFetch.intValue());      
  request.setJoinedCustomerId(criteria.getJoinedCustomerId());      
  request.setCustomerIsPayer(criteria.getConsumerIsPayer());      
  request.setShowInitial(criteria.getShowInitial());      
  request.setCaller(criteria.getCallerId());           
  FindTransactionsResponse response = wsTransactionEndpoint. findTransactions(request);              

  if (!evaluateMobiliserResponse(response))
  {            
    LOG.warn("# An error occurred while loading customer transactions");        
  }         
  return response.getTransactions();
         
 }   
} 
Using the getNewMobiliserRequest helper method ensures that all requests are formed with correct values for these properties:
  • Origin – identifies the request as originating from the Web UI.
  • Conversation Id – a random value.
  • Trace No – a random value.
  • Audit Data – contains the browser user agent (or first 80 characters) of the Web request and the remote IP address of the sender.
public <Req extends MobiliserRequestType> 
   Req getNewMobiliserRequest(Class<Req> requestClass) 
   throws Exception {}
Using the evaluateNewMobiliserResponse helper method ensures that all responses are verified:
  • Valid Response – a status response code value of 0 indicates that processing can continue.
  • Session Ended Response – response codes 352 and 353 indicate that the session has been closed or expired; you are automatically redirected to the login page.
  • Another Error Response – other response codes require the method to look up the localized error message associated with the code.
public <Resp extends MobiliserResponseType> 
   boolean evaluateMobiliserResponse(Resp response){ }
Using a Spring Bean for the <xyz>ClientLogic class, defined in the section above, you can inject the client logic handler into a page to use, for example:
...
public class AddFunds extends BaseManageAccountsPage {       
  private static final long serialVersionUID = 1L;       
  @SpringBean(name = "systemAuthTransactionClientLogic")     
  public TransactionClientLogic transactionClientLogic;
...