Class BatchPaymentsUtil
java.lang.Object
com.oracle.communications.brm.cc.batchpayments.BatchPaymentsUtil
This utility is used for batch payments related operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PaymentBatchFileHeaderReads given JSON file and converts to PaymentBatchFileHeader.static booleandeleteFile(String filePath) Deletes file from the given filePath.static StringReturns the resolved batch-payment files root path.static StringReturns the resolved external batch-payment templates path.static StringgetDelimiter(Map<String, String> templateDelimiterData) Retrieve delimiter of a template file.static StringGet Error Batch Payments Directory Path.static StringgetErrorDirectoryPath(String filesPath) Returns the error directory beneath a captured files root.static intgetFilesCountFromDirectory(String directoryPath) Get the count of files for a given directory path.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 filesstatic StringGet Processed Batch Payments Directory Path.static StringgetProcessedDirectoryPath(String filesPath) Returns the processed directory beneath a captured files root.static StringGet Processing Batch Payments Directory Path.static StringgetProcessingDirectoryPath(String filesPath) Returns the processing directory beneath a captured files root.static StringGet UnProcessed Batch Payments Directory Path.static StringgetUnProcessedDirectoryPath(String filesPath) Returns the unprocessed directory beneath a captured files root.static booleanisFileExists(String filePath) Check if the file is already exists in a given path.static booleanisValidBatchPaymentFile(String fileName) Validates batch payment file extension, Only .pmt, .txt and .text files are supported for batch payments.static <T> T[]join(T[]... arrays) Joins multiple arrays and returns the concatenated array.static voidChecks 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.static BasicFileAttributesreadFileAttributes(String filePath) Reads basic file attributes.static voidsavePaymentBatchFileHeaderAsJSONFile(String targetDirPath, PaymentBatchFileHeader paymentBatchFileHeader) Writes batch payment file header to a JSON file and saves the file to the given directory path.static booleanuploadFile(InputStream inputStream, String fileName, boolean replaceExistingFile) Uploads a file to the given targetPath.
-
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 filefileName- file name for upload filereplaceExistingFile- replace existing file for upload file- Returns:
- the result of upload file
- Throws:
ApplicationException- if upload file cannot be completed
-
isValidBatchPaymentFile
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 filetargetDirPath- target dir path for move filefileName- file name for move filereplaceExistingFile- replace existing file for move file- Throws:
ApplicationException- if move file cannot be completed
-
isFileExists
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
Get UnProcessed Batch Payments Directory Path.- Returns:
- 'unprocessed' directory path.
-
getUnProcessedDirectoryPath
Returns the unprocessed directory beneath a captured files root.- Parameters:
filesPath- captured batch-payment files root- Returns:
- unprocessed directory path
-
getProcessingDirectoryPath
Get Processing Batch Payments Directory Path.- Returns:
- 'processing' directory path.
-
getProcessingDirectoryPath
Returns the processing directory beneath a captured files root.- Parameters:
filesPath- captured batch-payment files root- Returns:
- processing directory path
-
getProcessedDirectoryPath
Get Processed Batch Payments Directory Path.- Returns:
- 'processed' directory path.
-
getProcessedDirectoryPath
Returns the processed directory beneath a captured files root.- Parameters:
filesPath- captured batch-payment files root- Returns:
- processed directory path
-
getErrorDirectoryPath
Get Error Batch Payments Directory Path.- Returns:
- 'error' directory path.
-
getErrorDirectoryPath
Returns the error directory beneath a captured files root.- Parameters:
filesPath- captured batch-payment files root- Returns:
- error directory path
-
readFileAttributes
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
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 filepaymentBatchFileHeader- 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
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 listglobbingPattern- globbing pattern for get files list- Returns:
- list of files
-
deleteFile
Deletes file from the given filePath.- Parameters:
filePath- file path for delete file- Returns:
- the result of delete file
-
getFilesCountFromDirectory
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
Returns the resolved batch-payment files root path.- Returns:
- the resolved batch-payment files root path
-
getBatchPaymentsTemplatesPath
Returns the resolved external batch-payment templates path.- Returns:
- the resolved external batch-payment templates path
-