Exemplo n.º 1
0
  /** Finds the error XML file in the specified folder */
  private List<BaseError> findErrorXML(LoansXML request, String path) throws ServiceException {
    List<BaseError> results = new ArrayList<>();
    ConfigCredential configCredential =
        boot.findMount(BayServConstants.rpgService, boot.findMasterEnvironment());
    if (configCredential == null) {
      throw new ServiceException(ErrorCodes.EXA001);
    }

    AS400 as400 =
        AS400IFSUtil.connectToAS400(
            configCredential.getId(),
            configCredential.getIdentity(),
            configCredential.getCredential());
    String exportPath =
        config.findServiceFeature(environmentConfig.getFeatures(), "ExportPath") + "/" + path + "/";

    try {
      String result = StringUtils.leftPad(String.valueOf(request.getLoanID()), 10, '0');
      String fileName = result + "err.xml";
      fileName = exportPath + "/" + fileName;
      IFSFile ifsFile = new IFSFile(as400, fileName);

      if (ifsFile.exists()) {
        String xml = AS400IFSUtil.readFileToStringFromIFS(as400, fileName);
        ERRORSXML obj = fromXML(errorCtx, xml);
        for (ERROR err : obj.getERROR()) {
          BaseError res = new BaseError();
          res.setCode(err.getERRORCODE());
          res.setDescription(err.getERRORDESC());
          res.setMessage(err.getFIELD());
          results.add(res);
        }
      }
      AS400IFSUtil.disconnectAS400(as400);
    } catch (IOException e) {
      throw new ServiceException(ErrorCodes.COR027, e);
    }
    return results;
  }
Exemplo n.º 2
0
  /**
   * Saves the disbursement XML file in the specified folder
   *
   * @return a formatted loan reference number
   */
  private String saveDisbursementFile(LoansXML request, String path) throws ServiceException {
    ConfigCredential configCredential =
        boot.findMount(BayServConstants.rpgService, boot.findMasterEnvironment());
    if (configCredential == null) {
      throw new ServiceException(ErrorCodes.EXA001);
    }

    AS400 as400 =
        AS400IFSUtil.connectToAS400(
            configCredential.getId(),
            configCredential.getIdentity(),
            configCredential.getCredential());
    String exportPath =
        config.findServiceFeature(environmentConfig.getFeatures(), "ExportPath") + "/" + path + "/";

    String xml = renderDisbursementXML(request);
    String result = StringUtils.leftPad(String.valueOf(request.getLoanID()), 10, '0');
    String fileName = result + ".xml";
    fileName = exportPath + "/" + fileName;
    AS400IFSUtil.writeToIFS(as400, fileName, xml);
    AS400IFSUtil.disconnectAS400(as400);
    return result;
  }