we can but we have to create case for every zip file landing on Pega server. That’s the reason I was thinking to write java to iterate over zip files and create case in the loop.
We can’t use file listener because the zip is a complex structure it contains multi folder with multi files with multiple formats. We have to take all files from all folders and attach to a case.
Run the Tracer whilst attaching a file through the end user portal to understand what rules are involved in attaching a file to a case. Alternatively, investigate the Pega API endpoint /attachments/upload (assuming it is available on your Platform version, check the “Pega API” help menu option in Dev Studio). Your implementation might even choose to call this API to fulfil the attachment operation.
If your attachments are being stored in web storage or a Repository (as opposed to in the Pega database) then you will want to reuse the rules that know how to orchestrate the appropriate API calls to where the attachments are stored, based on how the application rule is configured. The typical outcome is that Pega stores an instance of Data-WorkAttach-File and Link-Attachment for each attachment.
If attachment content is stored in Pega, it is stored in Base64-encoded form in the pyAttachStream property of the Data-WorkAttach-File instance.
If attachment content is stored in Web Storage or Repositories, a reference to the location in the remote storage system (a file path or a URL) is stored in the Data-WorkAttach-File instance.
With some Google searching you will be able to find some Java code that can unzip an archive. Ideally, the unzipping would be done into memory since you will either copy each streamed file either into a Data-WorkAttach-File clipboard page; or into the request of the /attachments/upload API call. Keeping it in thread-scoped memory reduces the risk of not cleaning up the file system, running out of disk space - or worse - a race condition where ZIP files containing the files of the same name get incorrectly attached to the wrong cases.
I unzipped the files using below java code and than used pxUploadAndAttachFile activity to attach files to the case. The pre-req to call pxUploadAndAttachFile activity is to move the file to serviceexport directory using java.
Code :
java.io.File path = new java.io.File(unzip);
java.io.File files = path.listFiles();
for (int i = 0; i < files.length; i++){
if (files[i].isFile()){
String fileName = files[i].getName();
String destFile = serviceexport + fileName;
oLog.info(“copying file : " +fileName);
java.io.File source = new java.io.File(unzip+”/"+fileName);
java.io.File dest = new java.io.File(destFile);