private void uploadJsonFile(String baseFileName, String jsonSource, Folder workflowDefinitionFolder) { LOGGER.info("Upload json source..."); String jsonSrcFileName = baseFileName + ".json"; ContentStream jsonSrcContentStream = new ContentStreamImpl(jsonSrcFileName, null, "application/json", new ByteArrayInputStream(jsonSource.getBytes())); Document jsonDocument = getDocumentFromFolder(workflowDefinitionFolder.getPath(), jsonSrcFileName); if (jsonDocument == null) { HashMap<String, Object> jsonSrcProperties = new HashMap<String, Object>(); jsonSrcProperties.put(PropertyIds.NAME, jsonSrcFileName); jsonSrcProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); workflowDefinitionFolder.createDocument(jsonSrcProperties, jsonSrcContentStream, VersioningState.MAJOR); } else { jsonDocument.setContentStream(jsonSrcContentStream, true); } }
protected void uploadStringToDocument(String string, String folderPath, String documentName, String mimetype) { Session cmisSession = getCmisSession(); Folder folder = (Folder) cmisSession.getObjectByPath(folderPath); ContentStream contentStream = new ContentStreamImpl(documentName, null, mimetype, new ByteArrayInputStream(string.getBytes())); Document document = getDocumentFromFolder(folder.getPath(), documentName); if (document == null) { HashMap<String, Object> properties = new HashMap<String, Object>(); properties.put("cmis:name", documentName); properties.put("cmis:objectTypeId", "cmis:document"); folder.createDocument(properties, contentStream, VersioningState.MAJOR); } else { document.setContentStream(contentStream, true); } }
protected void uploadTaskModel(StringBuilder taskModelsString, String baseFileName) { Session session = getCmisSession(); Folder modelFolder = (Folder) session.getObjectByPath(DATA_DICTIONARY_FOLDER); String taskModelFileName = baseFileName + "-task-model.xml"; // Finally, wrap all taskdefinitions is right XML -> this is the FULL // model file, including generic start-task String taskModelId = UUID.randomUUID().toString(); String taskModelXML = MessageFormat.format(getTaskModelTemplate(), taskModelId, taskModelsString.toString()); LOGGER.info("Deploying task model XML:"); prettyLogXml(taskModelXML); ByteArrayInputStream inputStream = new ByteArrayInputStream(taskModelXML.getBytes()); ContentStream contentStream = new ContentStreamImpl(taskModelFileName, null, "application/xml", inputStream); // Verify whether it is an update or a new workflow Document taskModelDocument = getDocumentFromFolder(DATA_DICTIONARY_FOLDER, taskModelFileName); if (taskModelDocument == null) { HashMap<String, Object> properties = new HashMap<String, Object>(); properties.put("cmis:name", taskModelFileName); properties.put("cmis:objectTypeId", "D:cm:dictionaryModel"); properties.put("cm:modelActive", true); LOGGER.info("Task model file : " + taskModelFileName); modelFolder.createDocument(properties,contentStream, VersioningState.MAJOR); } else { LOGGER.info("Updating content of " + taskModelFileName); taskModelDocument.setContentStream(contentStream, true); } }
doc.setContentStream(contentStream, true); doc.checkIn(true, properties, contentStream, ""); reload();
private void uploadDiagramFile(KickstartWorkflow kickstartWorkflow, String baseFileName, Folder workflowDefinitionFolder) { LOGGER.info("Generating process image..."); ProcessDiagramGenerator diagramGenerator = new ProcessDiagramGenerator(kickstartWorkflow, marshallingService); InputStream diagramInputStream = diagramGenerator.execute(); // Diagram is deployed next to the process xml if (workflowDefinitionFolder == null) { throw new RuntimeException("Cannot find workflow definition folder '" + WORKFLOW_DEFINITION_FOLDER + "'"); } String diagramFileName = baseFileName + ".png"; ContentStream diagramContentStream = new ContentStreamImpl(diagramFileName, null, "image/png", diagramInputStream); Document diagramDocument = getDocumentFromFolder(workflowDefinitionFolder.getPath(), diagramFileName); if (diagramDocument == null) { HashMap<String, Object> diagramProperties = new HashMap<String, Object>(); diagramProperties.put(PropertyIds.NAME, diagramFileName); diagramProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); workflowDefinitionFolder.createDocument(diagramProperties, diagramContentStream, VersioningState.MAJOR); } else { diagramDocument.setContentStream(diagramContentStream, true); } }
processDocument.setContentStream(processContentStream, true);
public void setProcessImage(String processDefinitionId, InputStream processImageStream) { Session cmisSession = getCmisSession(); Folder workflowDefinitionFolder = (Folder) cmisSession.getObjectByPath(WORKFLOW_DEFINITION_FOLDER); String fileName = processDefinitionIdToProcessImage(processDefinitionId); ContentStream contentStream = new ContentStreamImpl(fileName, null, "image/png", processImageStream); Document imageDocument = getDocumentFromFolder(workflowDefinitionFolder.getPath(), fileName); if (imageDocument == null) { HashMap<String, Object> properties = new HashMap<String, Object>(); properties.put("cmis:name", fileName); properties.put("cmis:objectTypeId", "cmis:document"); workflowDefinitionFolder.createDocument(properties, contentStream, VersioningState.MAJOR); } else { imageDocument.setContentStream(contentStream, true); } }
for (CmisObject o : children) { if (o instanceof Document && o.getName().equals(fileName)) { ((Document)o).setContentStream(contentStream, true); log.info("Document at path '{}' found and updated!", path.toString()); return;
BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes)); ObjectId newId = doc.setContentStream(contentStream, true, false); } else { try { doc.setContentStream(contentStream, true, false);
document.setContentStream(contentStream, true);
ContentStream stream = jcrBinaryContent(delta.getDocument()); if (stream != null) { ((org.apache.chemistry.opencmis.client.api.Document)cmisObject).setContentStream(stream, true);
((org.apache.chemistry.opencmis.client.api.Document)cmisObject).setContentStream(stream, true);
contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes)); ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true);