Account


Earned badges

Achievement: Latest Unlocked

Topic Started

This user has not created any forum posts.

Replies Created

Reply to: Error during downloading the attachment

0 votes
Hello Duo, All the directories until /appli/MINF/var/www-espacepartenaires-cmcic-leasing-fr.cm-cic.fr/usr/elisa42/application/tmp exist. They are not created by the application. The application is trying to create only the last directory: hpHHaUoNRWlgACRIpRmKcKWIQ_E= Regards, Michail

Reply to: Error during downloading the attachment

0 votes

Hello Duo,

The JSON Payload I receive from OneSpan, when it fails, looks like this:

JSON Payload:
{"name":"PACKAGE_ATTACHMENT","sessionUser":"customer","packageId":"hpHHaUoNRWlgACRIpRmKcKWIQ_E=","message":"PIECE D'IDENTITE","documentId":""} 

Could it be that it fails because the documentId is coming as empty?

 

Best Regards,

MIchail


Reply to:

0 votes

Hello Duo,

Here is the code:

String attachmentType = trimToEmpty(notification.getMessage());
        String attachmentId = null;
        ESLAttachment attachmentDoc = null;
        
        Signer signer = eslClient.getPackageService().getSigner(new PackageId(prospectESignTransaction.getPackageId()), "customer");
        AttachmentRequirement attachment = signer.getAttachmentRequirement(attachmentType);
        attachmentId = null != attachment ? attachment.getId() : null;
        
        RestClient client = new RestClient(prospectESignTransaction.getApiKey());
        String path = MinConstant.ESL_API_URL + "/packages/" + prospectESignTransaction.getPackageId() 
                + "/attachment/" + attachmentId;
        Map<String, Object> responseMap = client.get(path, "application/octet-stream");
        
        if (null != responseMap && null != responseMap.get("responseBody")) {
            String attachmentName = "attachment.pdf";
            CloseableHttpResponse response = (CloseableHttpResponse) responseMap.get("response");
            byte[] byteArray = (byte[]) responseMap.get("responseBody");
            HeaderElement[] headerElements = response.getFirstHeader("Content-Disposition").getElements();
            
            if (null != headerElements && headerElements.length > 0) {
                for (int i=0; i<headerElements.length; i++) {
                    if (null != headerElements[i].getParameterByName("filename")) {
                        attachmentName = headerElements[i].getParameterByName("filename").getValue();
                        break;
                    }
                }
            }
            File dir = new File(tempFolder);
            if (!dir.exists()) {
                dir.mkdir();
            }
            
            List<ESLAttachment> eslAttachments = eslDAO.getAttachmentsForPlatform(prospectESignTransaction.getPlatformId());
            if (CollectionUtils.isNotEmpty(eslAttachments)) {
                for (ESLAttachment eslAttachment : eslAttachments) {
                    if (equalsIgnoreCase(attachmentType, eslAttachment.getName())) {
                        attachmentDoc = eslAttachment;
                        break;
                    }
                }
            }
            
            attachmentName = Normalizer.normalize(attachmentName, Normalizer.Form.NFC).replaceAll("[^\\p{ASCII}]", "");
            
            Files.saveTo(byteArray, tempFolder + File.separator + attachmentName);
            FileUtils.deleteQuietly(dir);            

                }
            }
        }

 

Best Regards,

Michail


Subscriptions

This user is not subscribed to any release notes.

Code Share

This user has not submitted any code shares.

Subscriptions Release Notes

This user is not subscribed to any release notes.