Question

AIG
US
Last activity: 16 Jun 2020 10:58 EDT
how to File Read from Shared folder (not from Service Export dir) in Pega 8
Hi We have written Java code to read from a shared folder as below . It works in pega 7.2 and not working in Pega 8.2
We have PRFile but it is working only with service export directory . Any other file path given for PRfile is throwing null pointer exception.
In pega 8 the code fails at if(thisFile.isFile()) even though files are present and works in pega 7.
workDir.list() is only picking the folders but not files inside of it.
Any help is appreciated either to make PRFile work with external folders .
or
Tweak why the workDir.list() is not working in Pega 8 ..
We also tried RA file but ajav step is not compiling.
try { com.pega.pegarules.storage.fs.resadaptor.RAFile file = new com.pega.pegarules.storage.fs.resadaptor.RAFile("/home/"); System.out.println( "contents length : " + file.listFiles().length);
****************************************
java.io.File workDir = new java.io.File(FolderPath); int FileNo = 0; long lastModified = 0;
try {
Hi We have written Java code to read from a shared folder as below . It works in pega 7.2 and not working in Pega 8.2
We have PRFile but it is working only with service export directory . Any other file path given for PRfile is throwing null pointer exception.
In pega 8 the code fails at if(thisFile.isFile()) even though files are present and works in pega 7.
workDir.list() is only picking the folders but not files inside of it.
Any help is appreciated either to make PRFile work with external folders .
or
Tweak why the workDir.list() is not working in Pega 8 ..
We also tried RA file but ajav step is not compiling.
try { com.pega.pegarules.storage.fs.resadaptor.RAFile file = new com.pega.pegarules.storage.fs.resadaptor.RAFile("/home/"); System.out.println( "contents length : " + file.listFiles().length);
****************************************
java.io.File workDir = new java.io.File(FolderPath); int FileNo = 0; long lastModified = 0;
try {
if(workDir.isDirectory()) { String[] filesInFolder = workDir.list(); for(FileNo = 0; FileNo < filesInFolder.length; FileNo++) { String FilePath = FolderPath +"/"+ filesInFolder[FileNo]; java.io.File thisFile = new java.io.File(FilePath); if(thisFile.isFile()) { String thisFileName = thisFile.getName(); oLog.infoForced("Input file name in EDIClaimFile Activity is LOG 1 ->"+thisFileName); long thisFileModified = thisFile.lastModified(); oLog.infoForced("Input file name in EDIClaimFile Activity is LOG 2 ->"+thisFileModified); if(thisFileName.contains(".xml") || thisFileName.contains(".XML")) { if(thisFileModified > lastModified) { fileName = thisFileName.substring(0,thisFileName.indexOf(".")) + ".xml"; oLog.infoForced("Input file name in EDIClaimFile Activity is LOG 3 ->"+fileName);
lastModified = thisFileModified; } } }
} oLog.infoForced("Input file name in EDIClaimFile Activity is ->"+fileName);
} else { oLog.error("Invalid directory provided in EDIClaimFile Activity"); } } catch (Exception e) { oLog.error("Error getting input file name in EDIClaimFile Activity"); e.printStackTrace(); }
TIA