public class BatchPaymentsUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BATCH_PAYMENT_FILES_PATH |
static String |
BATCH_PAYMENT_TEMPLATES_PATH |
Constructor and Description |
---|
BatchPaymentsUtil() |
Modifier and Type | Method and Description |
---|---|
static PaymentBatchFileHeader |
convertJSONToPaymentBatchFileHeader(File file)
Reads given JSON file and converts to PaymentBatchFileHeader.
|
static boolean |
deleteFile(String filePath)
Deletes file from the given filePath.
|
static String |
getBatchPaymentsDirectoryName()
Retrieves batch payment directory name from configurations xml if its not
populated with Installer path, Else it returns the batch payment files
path populated with Installer.
|
static String |
getBatchPaymentsFilesPath(HttpServletRequest servletRequest)
Retrieves batch payment files path from context-param
BATCH_PAYMENT_FILES_PATH in web.xml
|
static String |
getBatchPaymentsTemplatesPath(HttpServletRequest servletRequest)
Retrieves batch payment template files path from context-param
BATCH_PAYMENT_TEMPLATES_PATH in web.xml.
|
static String |
getDelimiter(Map<String,String> templateDelimiterData)
Retrieve delimiter of a template file.
|
static String |
getErrorDirectoryPath()
Get Error Batch Payments Directory Path.
|
static int |
getFilesCountFromDirectory(String directoryPath)
Get the count of files for a given directory path.
|
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
|
static String |
getProcessedDirectoryPath()
Get Processed Batch Payments Directory Path.
|
static String |
getProcessingDirectoryPath()
Get Processing Batch Payments Directory Path.
|
static String |
getUnProcessedDirectoryPath()
Get UnProcessed Batch Payments Directory Path.
|
static boolean |
isFileExists(String filePath)
Check if the file is already exists in a given path.
|
static boolean |
isValidBatchPaymentFile(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 void |
moveFile(String sourceDirPath,
String targetDirPath,
String fileName,
boolean replaceExistingFile)
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.
|
static void |
populateInstallerFilePaths(HttpServletRequest servletRequest)
Populates batch payments related files paths that are given through
BillingCare Installation wizard; The file paths will get retrieved from
context parameters BATCH_PAYMENT_FILES_PATH and
BATCH_PAYMENT_TEMPLATES_PATH; The context-param values will get populated
via Plan.xml that gets updated on deployment path of BillingCare.war
through BillingCare OUI installer.
|
static BasicFileAttributes |
readFileAttributes(String filePath)
Reads basic file attributes.
|
static void |
savePaymentBatchFileHeaderAsJSONFile(String targetDirPath,
PaymentBatchFileHeader paymentBatchFileHeader)
Writes batch payment file header to a JSON file and saves the file to the
given directory path.
|
static boolean |
uploadFile(InputStream inputStream,
String fileName,
boolean replaceExistingFile)
Uploads a file to the given targetPath.
|
public static String BATCH_PAYMENT_FILES_PATH
public static String BATCH_PAYMENT_TEMPLATES_PATH
public static boolean uploadFile(InputStream inputStream, String fileName, boolean replaceExistingFile)
inputStream
- fileName
- replaceExistingFile
- ApplicationException
public static boolean isValidBatchPaymentFile(String fileName)
fileName
- public static void moveFile(String sourceDirPath, String targetDirPath, String fileName, boolean replaceExistingFile) throws ApplicationException
sourceDirPath
- targetDirPath
- fileName
- replaceExistingFile
- ApplicationException
public static boolean isFileExists(String filePath)
filePath
- public static String getBatchPaymentsDirectoryName()
public static String getUnProcessedDirectoryPath()
public static String getProcessingDirectoryPath()
public static String getProcessedDirectoryPath()
public static String getErrorDirectoryPath()
public static BasicFileAttributes readFileAttributes(String filePath) throws IOException
filePath
- IOException
public static String getDelimiter(Map<String,String> templateDelimiterData)
templateDelimiterData
- public static <T> T[] join(T[]... arrays)
T
- Java Typearrays
- Arrays that need to be concatenatedpublic static void savePaymentBatchFileHeaderAsJSONFile(String targetDirPath, PaymentBatchFileHeader paymentBatchFileHeader) throws ApplicationException
targetDirPath
- paymentBatchFileHeader
- ApplicationException
public static PaymentBatchFileHeader convertJSONToPaymentBatchFileHeader(File file) throws IOException
file
- IOException
public static List<File> getFilesList(String directoryPath, String globbingPattern)
directoryPath
- globbingPattern
- public static boolean deleteFile(String filePath)
filePath
- public static int getFilesCountFromDirectory(String directoryPath) throws IOException
directoryPath
- IOException
public static void populateInstallerFilePaths(HttpServletRequest servletRequest)
servletRequest
- public static String getBatchPaymentsFilesPath(HttpServletRequest servletRequest)
servletRequest
- is a servletRequestpublic static String getBatchPaymentsTemplatesPath(HttpServletRequest servletRequest)
servletRequest
- is a servletRequest