Bonita Connector "Get document" Exception
Hi,
I am using Bonita Studio - Community Edition version 5.8 and have been trying to use the Bonita Connector - "Get document".
These are the steps that I have made:
1. I set the DocumentUUID that is required (stored in a database)
2. I set the Destination Variable to a global variable named "myDocument" which is an attachment data type
I have been getting the error:
"Caused by: org.ow2.bonita.facade.exception.HookInvocationException: Bonita Error: bsi_HEI_3
Exception caught while executing Hook: org.bonitasoft.connectors.bonita.GetDocument because Unexpected Exception arrived in Bonita: Only an array of bytes or an AttachmentInstance can be used to set an Attachment using setVariable method"
Please help
Hi,
Here is a snippet from one of my process.
Variable fichierDestinationExport is a file created with Jasperreport.
documentExport is the document created from this file and associated with a field of type attachment in the form.
In this form, user click on a PDF button.
Then, a PDF file is created and converted in a document (the snippet).
The form is refreshed with a link associated with this document as the user can download it.
Hope this helps.
Fred
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.io.File;
import java.io.InputStream;
File file = new File(fichierDestinationExport);
FileInputStream fileStream = new FileInputStream(file);
byte[] fileContent = new byte[(int)file.length()];
fileStream.read(fileContent);
fileStream.close();
try {
apiAccessor.getRuntimeAPI().deleteDocuments(true,documentExport.getUUID());
}
catch (Exception e) {
}
apiAccessor.getRuntimeAPI().createDocument("documentExport",processInstance.getProcessInstanceUUID(),file.getName(),"application/pdf",fileContent);
file.delete();