Class BatchPaymentsUtil

java.lang.Object
com.oracle.communications.brm.cc.batchpayments.BatchPaymentsUtil

public class BatchPaymentsUtil extends Object
This utility is used for batch payments related operations.
  • Constructor Details

    • BatchPaymentsUtil

      public BatchPaymentsUtil()
      Creates a BatchPaymentsUtil instance.
  • Method Details

    • uploadFile

      public static boolean uploadFile(InputStream inputStream, String fileName, boolean replaceExistingFile)
      Uploads a file to the given targetPath.
      Parameters:
      inputStream - input stream for upload file
      fileName - file name for upload file
      replaceExistingFile - replace existing file for upload file
      Returns:
      the result of upload file
      Throws:
      ApplicationException - if upload file cannot be completed
    • isValidBatchPaymentFile

      public static boolean isValidBatchPaymentFile(String fileName)
      Validates batch payment file extension, Only .pmt, .txt and .text files are supported for batch payments.
      Parameters:
      fileName - file name for is valid batch payment file
      Returns:
      true; if it is valid file extension, otherwise false.
    • moveFile

      public static void moveFile(String sourceDirPath, String targetDirPath, String fileName, boolean replaceExistingFile) throws ApplicationException
      Checks if target directory exists or not; If not exits; Creates a target directory and moves the given file from source directory to target, If target directory already exists; then directly moves the given file from source directory to target.
      Parameters:
      sourceDirPath - source dir path for move file
      targetDirPath - target dir path for move file
      fileName - file name for move file
      replaceExistingFile - replace existing file for move file
      Throws:
      ApplicationException - if move file cannot be completed
    • isFileExists

      public static boolean isFileExists(String filePath)
      Check if the file is already exists in a given path.
      Parameters:
      filePath - file path for is file exists
      Returns:
      true if file exists
    • getUnProcessedDirectoryPath

      public static String getUnProcessedDirectoryPath()
      Get UnProcessed Batch Payments Directory Path.
      Returns:
      'unprocessed' directory path.
    • getUnProcessedDirectoryPath

      public static String getUnProcessedDirectoryPath(String filesPath)
      Returns the unprocessed directory beneath a captured files root.
      Parameters:
      filesPath - captured batch-payment files root
      Returns:
      unprocessed directory path
    • getProcessingDirectoryPath

      public static String getProcessingDirectoryPath()
      Get Processing Batch Payments Directory Path.
      Returns:
      'processing' directory path.
    • getProcessingDirectoryPath

      public static String getProcessingDirectoryPath(String filesPath)
      Returns the processing directory beneath a captured files root.
      Parameters:
      filesPath - captured batch-payment files root
      Returns:
      processing directory path
    • getProcessedDirectoryPath

      public static String getProcessedDirectoryPath()
      Get Processed Batch Payments Directory Path.
      Returns:
      'processed' directory path.
    • getProcessedDirectoryPath

      public static String getProcessedDirectoryPath(String filesPath)
      Returns the processed directory beneath a captured files root.
      Parameters:
      filesPath - captured batch-payment files root
      Returns:
      processed directory path
    • getErrorDirectoryPath

      public static String getErrorDirectoryPath()
      Get Error Batch Payments Directory Path.
      Returns:
      'error' directory path.
    • getErrorDirectoryPath

      public static String getErrorDirectoryPath(String filesPath)
      Returns the error directory beneath a captured files root.
      Parameters:
      filesPath - captured batch-payment files root
      Returns:
      error directory path
    • readFileAttributes

      public static BasicFileAttributes readFileAttributes(String filePath) throws IOException
      Reads basic file attributes.
      Parameters:
      filePath - file path for read file attributes
      Returns:
      the result of read file attributes
      Throws:
      IOException - if an input or output operation fails
    • getDelimiter

      public static String getDelimiter(Map<String,String> templateDelimiterData)
      Retrieve delimiter of a template file.
      Parameters:
      templateDelimiterData - template delimiter data for get delimiter
      Returns:
      delimiter
    • join

      public static <T> T[] join(T[]... arrays)
      Joins multiple arrays and returns the concatenated array. The arrays being joined should all be of one type only.
      Type Parameters:
      T - Java Type
      Parameters:
      arrays - Arrays that need to be concatenated
      Returns:
      Joined Array
    • savePaymentBatchFileHeaderAsJSONFile

      public static void savePaymentBatchFileHeaderAsJSONFile(String targetDirPath, PaymentBatchFileHeader paymentBatchFileHeader) throws ApplicationException
      Writes batch payment file header to a JSON file and saves the file to the given directory path.
      Parameters:
      targetDirPath - target dir path for save payment batch file header as json file
      paymentBatchFileHeader - payment batch file header for save payment batch file header as json file
      Throws:
      ApplicationException - if save payment batch file header as json file cannot be completed
    • convertJSONToPaymentBatchFileHeader

      public static PaymentBatchFileHeader convertJSONToPaymentBatchFileHeader(File file) throws IOException
      Reads given JSON file and converts to PaymentBatchFileHeader.
      Parameters:
      file - file for convert json to payment batch file header
      Returns:
      paymentBatchFileHeader
      Throws:
      IOException - if an input or output operation fails
    • getFilesList

      public static List<File> getFilesList(String directoryPath, String globbingPattern)
      Get all files of a directory based on the given globbingPattern, For example: globbingPattern "*.pmt" gets only .pmt files, "*.{json}" gets only .json files "*.{pmt,json} gets both .pmt and .json files
      Parameters:
      directoryPath - directory path for get files list
      globbingPattern - globbing pattern for get files list
      Returns:
      list of files
    • deleteFile

      public static boolean deleteFile(String filePath)
      Deletes file from the given filePath.
      Parameters:
      filePath - file path for delete file
      Returns:
      the result of delete file
    • getFilesCountFromDirectory

      public static int getFilesCountFromDirectory(String directoryPath) throws IOException
      Get the count of files for a given directory path.
      Parameters:
      directoryPath - directory path for get files count from directory
      Returns:
      the count of files in a directory
      Throws:
      IOException - if an input or output operation fails
    • getBatchPaymentsFilesPath

      public static String getBatchPaymentsFilesPath()
      Returns the resolved batch-payment files root path.
      Returns:
      the resolved batch-payment files root path
    • getBatchPaymentsTemplatesPath

      public static String getBatchPaymentsTemplatesPath()
      Returns the resolved external batch-payment templates path.
      Returns:
      the resolved external batch-payment templates path