Hello Everybody,
I have put a few documents in a list and these documents I want to upload to Alfresco.
This is the code I made:
import org.bonitasoft.connectors.alfresco34.AlfrescoResponse; import org.bonitasoft.connectors.alfresco34.AlfrescoRestClient; import org.bonitasoft.engine.api.DocumentAPI; import org.bonitasoft.engine.bpm.document.Document; import org.bonitasoft.engine.bpm.document.DocumentDefinition; import org.bonitasoft.engine.bpm.document.impl.DocumentDefinitionImpl; import org.apache.abdera.*;import java.util.logging.Logger;
import com.google.gson.Gson;
Logger logger= Logger.getLogger(“org.bonitasoft”);
Gson gson = new Gson();
logger.severe("*UPLOAD listWithImages: " + listWithImages);
try {
def host = alfrescoHost;
def port = alfrescoPort;
def user = alfrescoUser;
def pass = alfrescoPass;
AlfrescoRestClient alfresco = new AlfrescoRestClient(host, port, user, pass);
logger.severe("*UPLOAD objAlfresco: " + gson.toJson(alfresco));
String fileName = "";
String description = "";
String mimeType = "";
String destinationFolder = "";
for (file in listWithImages) {
Document doc = apiAccessor.processAPI.getDocumentAtProcessInstantiation(processInstanceId, file["newAPImage"]);
byte[] fileBytes = apiAccessor.processAPI.getDocumentContent(doc.contentStorageId)
//apiAccessor.processAPI.getDo
logger.severe("*UPLOAD hasContent: " + doc.hasContent().toString());
logger.severe("*UPLOAD contentFileName: " + doc.contentFileName);
logger.severe("*UPLOAD contentStorageId: " + doc.contentStorageId);
//def fileLength = fileBytes;
fileName = URLEncoder.encode(file["strAcceptancePointName"]);
description = "null";
mimeType = "image/jpeg";
destinationFolder = URLEncoder.encode("/Startpagina's van gebruikers/Bonita");
AlfrescoResponse resp = alfresco.uploadFileFromDocument(doc, fileBytes, doc.contentFileName, description, mimeType, destinationFolder);
def statusInfo = [resp.getStackTrace(),
resp.getResponseType(),
resp.getStatusCode(),
resp.getStatusText()];
logger.servere(statusInfo);
}
} catch (Exception e) {
logger.severe("*UPLOAD ErrorMessage: " + e.getMessage());
}
In the log I get the following line:
INFO: uploadFileFromDocument documentName=newAPImage_0-cb5d87c4-1b97-4338-937b-bb1937fdd486 fileName=CabinetOverview.jpg description=null mimeType=image/jpeg destinationFolder=%2FStartpagina%27s+van+gebruikers%2FBonita
and nothing else…
What am I missing here? Via de Alfresco connector I can upload a document but with the above code the execution seems to get stuck.
Kind regards, Steven