/** * Export all artifacts and configuration-files needed to run the process that is converted in the * given {@link WorkflowDefinitionConversion}. * * @param conversion the conversion object to be exported * @param repositoryFolder the folder where all repository-artifacts and configurations are * exported to * @param shareFolder the folder where all share-artifacts and configurations are exported to */ public void exportArtifacts( WorkflowDefinitionConversion conversion, File repositoryFolder, File shareFolder) { validateArtifactTargets(repositoryFolder, shareFolder); String processId = conversion.getProcess().getId(); try { // Export process BPMN File processFile = new File(repositoryFolder, processId + PROCESS_FILE_SUFFIX); processFile.createNewFile(); FileOutputStream processStream = new FileOutputStream(processFile); writeBpmnModel(processStream, conversion); processStream.close(); // Export content model File contentModelFile = new File(repositoryFolder, processId + MODEL_FILE_SUFFIX); contentModelFile.createNewFile(); FileOutputStream modelStream = new FileOutputStream(contentModelFile); writeContentModel(modelStream, conversion); modelStream.close(); // Export workflow deployer context XML File springContextFile = new File(repositoryFolder, processId + SPRING_CONTEXT_FILE_SUFFIX); springContextFile.createNewFile(); FileOutputStream springContextStream = new FileOutputStream(springContextFile); writeWorkflowDeployerBean( springContextStream, processId, processFile.getName(), contentModelFile.getName()); springContextStream.close(); // Export share config File shareConfigFile = new File(shareFolder, processId + SHARE_CONFIG_FILE_SUFFIX); shareConfigFile.createNewFile(); FileOutputStream shareConfigStream = new FileOutputStream(shareConfigFile); writeShareConfig(shareConfigStream, conversion, false); shareConfigStream.close(); // Export share custom context File shareContextFile = new File(shareFolder, processId + SHARE_CONTEXT_FILE_SUFFIX); shareContextFile.createNewFile(); FileOutputStream shareContextStream = new FileOutputStream(shareContextFile); writeShareCustomConfigBean(shareContextStream, processId, shareConfigFile.getName()); shareContextStream.close(); } catch (IOException ioe) { throw new AlfrescoSimpleWorkflowException("Error while exporting artifacts", ioe); } }
/** Write the BPMN-model in the given conversion to the given stream. */ public void writeBpmnModel(OutputStream out, WorkflowDefinitionConversion conversion) throws IOException { BpmnModel model = conversion.getBpmnModel(); byte[] xmlContent = bpmnConverter.convertToXML(model, "UTF-8"); out.write(xmlContent); }