Exemplo n.º 1
0
  /**
   * Loans (and legacy insurance) disbursement data submit routine<br>
   * Disburses one account at a time to a specific folder
   *
   * @return returns the loans xml as a string
   */
  public BaseServiceResponse disburse(LoansXML request, BaseServiceResponse response)
      throws ServiceException {
    // use this to get a handle on the IFS share stored inside the connection element
    initialize(BayServConstants.rpgService, response);
    // initialise the XML context
    try {
      if (disbursementCtx == null) disbursementCtx = JAXBContext.newInstance(LoansXML.class);
      if (errorCtx == null) errorCtx = JAXBContext.newInstance(ERRORSXML.class);
    } catch (JAXBException e) {
      throw new ServiceException(ErrorCodes.RPG006, e);
    }

    // put the result into exactus filesystem via AS400
    String loanReference = saveDisbursementFile(request, PATH_LOAN);

    // sleep
    DateUtils.sleep(1);

    // call the RPG to read the result and throw an error if there is one
    try {
      disburseRPG.execute(EProductType.LOAN, loanReference);
    } catch (ServiceException e) {
      // see if there's an error file
      response.setError(true);
      response.getErrors().addAll(findErrorXML(request, PATH_LOAN));
    }

    response.setXmlData(new XMLData());
    response.getXmlData().setXml(renderDisbursementXML(request));

    return response;
  }