List of usage examples for org.springframework.web.multipart MultipartFile getInputStream
@Override
InputStream getInputStream() throws IOException;
From source file:org.flowable.app.rest.service.api.repository.AppDeploymentCollectionResource.java
@ApiOperation(value = "Create a new app deployment", tags = { "App Deployments" }, consumes = "multipart/form-data", produces = "application/json", notes = "The request body should contain data of type multipart/form-data. There should be exactly one file in the request, any additional files will be ignored. The deployment name is the name of the file-field passed in. Make sure the file-name ends with .app, .zip or .bar.") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the app deployment was created."), @ApiResponse(code = 400, message = "Indicates there was no content present in the request body or the content mime-type is not supported for app deployment. The status-description contains additional information.") }) @ApiImplicitParams({ @ApiImplicitParam(name = "file", paramType = "form", dataType = "java.io.File") }) @PostMapping(value = "/app-repository/deployments", produces = "application/json", consumes = "multipart/form-data") public AppDeploymentResponse uploadDeployment( @ApiParam(name = "tenantId") @RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request, HttpServletResponse response) { if (restApiInterceptor != null) { restApiInterceptor.executeNewDeploymentForTenantId(tenantId); }//w w w. j a v a 2 s . com if (!(request instanceof MultipartHttpServletRequest)) { throw new FlowableIllegalArgumentException("Multipart request is required"); } String queryString = request.getQueryString(); Map<String, String> decodedQueryStrings = splitQueryString(queryString); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; if (multipartRequest.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("Multipart request with file content is required"); } MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); try { AppDeploymentBuilder deploymentBuilder = appRepositoryService.createDeployment(); String fileName = file.getOriginalFilename(); if (StringUtils.isEmpty(fileName) || !(fileName.endsWith(".app") || fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip"))) { fileName = file.getName(); } if (fileName.endsWith(".app")) { deploymentBuilder.addInputStream(fileName, file.getInputStream()); } else if (fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip")) { deploymentBuilder.addZipInputStream(new ZipInputStream(file.getInputStream())); } else { throw new FlowableIllegalArgumentException("File must be of type .app"); } if (!decodedQueryStrings.containsKey("deploymentName") || StringUtils.isEmpty(decodedQueryStrings.get("deploymentName"))) { String fileNameWithoutExtension = fileName.split("\\.")[0]; if (StringUtils.isNotEmpty(fileNameWithoutExtension)) { fileName = fileNameWithoutExtension; } deploymentBuilder.name(fileName); } else { deploymentBuilder.name(decodedQueryStrings.get("deploymentName")); } if (decodedQueryStrings.containsKey("deploymentKey") && StringUtils.isNotEmpty(decodedQueryStrings.get("deploymentKey"))) { deploymentBuilder.key(decodedQueryStrings.get("deploymentKey")); } if (tenantId != null) { deploymentBuilder.tenantId(tenantId); } deploymentBuilder.name(fileName); if (tenantId != null) { deploymentBuilder.tenantId(tenantId); } if (restApiInterceptor != null) { restApiInterceptor.enhanceDeployment(deploymentBuilder); } AppDeployment deployment = deploymentBuilder.deploy(); response.setStatus(HttpStatus.CREATED.value()); return appRestResponseFactory.createAppDeploymentResponse(deployment); } catch (Exception e) { if (e instanceof FlowableException) { throw (FlowableException) e; } throw new FlowableException(e.getMessage(), e); } }
From source file:org.flowable.app.service.editor.FlowableModelQueryService.java
public ModelRepresentation importProcessModel(HttpServletRequest request, MultipartFile file) { String fileName = file.getOriginalFilename(); if (fileName != null && (fileName.endsWith(".bpmn") || fileName.endsWith(".bpmn20.xml"))) { try {/*from w w w .java2 s.c o m*/ XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory(); InputStreamReader xmlIn = new InputStreamReader(file.getInputStream(), "UTF-8"); XMLStreamReader xtr = xif.createXMLStreamReader(xmlIn); BpmnModel bpmnModel = bpmnXmlConverter.convertToBpmnModel(xtr); if (CollectionUtils.isEmpty(bpmnModel.getProcesses())) { throw new BadRequestException("No process found in definition " + fileName); } if (bpmnModel.getLocationMap().size() == 0) { BpmnAutoLayout bpmnLayout = new BpmnAutoLayout(bpmnModel); bpmnLayout.execute(); } ObjectNode modelNode = bpmnJsonConverter.convertToJson(bpmnModel); org.flowable.bpmn.model.Process process = bpmnModel.getMainProcess(); String name = process.getId(); if (StringUtils.isNotEmpty(process.getName())) { name = process.getName(); } String description = process.getDocumentation(); ModelRepresentation model = new ModelRepresentation(); model.setKey(process.getId()); model.setName(name); model.setDescription(description); model.setModelType(AbstractModel.MODEL_TYPE_BPMN); Model newModel = modelService.createModel(model, modelNode.toString(), SecurityUtils.getCurrentUserObject()); return new ModelRepresentation(newModel); } catch (BadRequestException e) { throw e; } catch (Exception e) { logger.error("Import failed for " + fileName, e); throw new BadRequestException( "Import failed for " + fileName + ", error message " + e.getMessage()); } } else { throw new BadRequestException( "Invalid file name, only .bpmn and .bpmn20.xml files are supported not " + fileName); } }
From source file:org.flowable.cmmn.rest.service.api.repository.DeploymentCollectionResource.java
@ApiOperation(value = "Create a new deployment", tags = { "Deployment" }, consumes = "multipart/form-data", produces = "application/json", notes = "The request body should contain data of type multipart/form-data. There should be exactly one file in the request, any additional files will be ignored. The deployment name is the name of the file-field passed in. If multiple resources need to be deployed in a single deployment, compress the resources in a zip and make sure the file-name ends with .bar or .zip.\n" + "\n" + "An additional parameter (form-field) can be passed in the request body with name tenantId. The value of this field will be used as the id of the tenant this deployment is done in.") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the deployment was created."), @ApiResponse(code = 400, message = "Indicates there was no content present in the request body or the content mime-type is not supported for deployment. The status-description contains additional information.") }) @ApiImplicitParams({ @ApiImplicitParam(name = "file", dataType = "file", paramType = "form", required = true) }) @PostMapping(value = "/cmmn-repository/deployments", produces = "application/json", consumes = "multipart/form-data") public CmmnDeploymentResponse uploadDeployment( @ApiParam(name = "deploymentKey") @RequestParam(value = "deploymentKey", required = false) String deploymentKey, @ApiParam(name = "deploymentName") @RequestParam(value = "deploymentName", required = false) String deploymentName, @ApiParam(name = "tenantId") @RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request, HttpServletResponse response) { if (!(request instanceof MultipartHttpServletRequest)) { throw new FlowableIllegalArgumentException("Multipart request is required"); }/*from ww w . j a va2 s.c o m*/ if (restApiInterceptor != null) { restApiInterceptor.executeNewDeploymentForTenantId(tenantId); } String queryString = request.getQueryString(); Map<String, String> decodedQueryStrings = splitQueryString(queryString); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; if (multipartRequest.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("Multipart request with file content is required"); } MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); try { CmmnDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(); String fileName = file.getOriginalFilename(); if (StringUtils.isEmpty(fileName) || !(fileName.endsWith(".cmmn.xml") || fileName.endsWith(".cmmn"))) { fileName = file.getName(); } if (fileName.endsWith(".cmmn.xml") || fileName.endsWith(".cmmn")) { deploymentBuilder.addInputStream(fileName, file.getInputStream()); } else { throw new FlowableIllegalArgumentException("File must be of type .cmmn.xml, .cmmn"); } if (!decodedQueryStrings.containsKey("deploymentName") || StringUtils.isEmpty(decodedQueryStrings.get("deploymentName"))) { String fileNameWithoutExtension = fileName.split("\\.")[0]; if (StringUtils.isNotEmpty(fileNameWithoutExtension)) { fileName = fileNameWithoutExtension; } deploymentBuilder.name(fileName); } else { deploymentBuilder.name(decodedQueryStrings.get("deploymentName")); } if (decodedQueryStrings.containsKey("deploymentKey") || StringUtils.isNotEmpty(decodedQueryStrings.get("deploymentKey"))) { deploymentBuilder.key(decodedQueryStrings.get("deploymentKey")); } if (tenantId != null) { deploymentBuilder.tenantId(tenantId); } if (restApiInterceptor != null) { restApiInterceptor.enhanceDeployment(deploymentBuilder); } CmmnDeployment deployment = deploymentBuilder.deploy(); response.setStatus(HttpStatus.CREATED.value()); return restResponseFactory.createDeploymentResponse(deployment); } catch (Exception e) { if (e instanceof FlowableException) { throw (FlowableException) e; } throw new FlowableException(e.getMessage(), e); } }
From source file:org.flowable.cmmn.rest.service.api.runtime.caze.BaseVariableResource.java
protected RestVariable setBinaryVariable(MultipartHttpServletRequest request, CaseInstance caseInstance, int responseVariableType, boolean isNew) { // Validate input and set defaults if (request.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("No file content was found in request body."); }/*w w w . j a v a 2 s.c om*/ // Get first file in the map, ignore possible other files MultipartFile file = request.getFile(request.getFileMap().keySet().iterator().next()); if (file == null) { throw new FlowableIllegalArgumentException("No file content was found in request body."); } String variableScope = null; String variableName = null; String variableType = null; Map<String, String[]> paramMap = request.getParameterMap(); for (String parameterName : paramMap.keySet()) { if (paramMap.get(parameterName).length > 0) { if (parameterName.equalsIgnoreCase("scope")) { variableScope = paramMap.get(parameterName)[0]; } else if (parameterName.equalsIgnoreCase("name")) { variableName = paramMap.get(parameterName)[0]; } else if (parameterName.equalsIgnoreCase("type")) { variableType = paramMap.get(parameterName)[0]; } } } try { // Validate input and set defaults if (variableName == null) { throw new FlowableIllegalArgumentException("No variable name was found in request body."); } if (variableType != null) { if (!CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variableType) && !CmmnRestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variableType)) { throw new FlowableIllegalArgumentException( "Only 'binary' and 'serializable' are supported as variable type."); } } else { variableType = CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE; } RestVariableScope scope = RestVariableScope.LOCAL; if (variableScope != null) { scope = RestVariable.getScopeFromString(variableScope); } if (variableType.equals(CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE)) { // Use raw bytes as variable value byte[] variableBytes = IOUtils.toByteArray(file.getInputStream()); setVariable(caseInstance, variableName, variableBytes, scope, isNew); } else if (isSerializableVariableAllowed) { // Try deserializing the object ObjectInputStream stream = new ObjectInputStream(file.getInputStream()); Object value = stream.readObject(); setVariable(caseInstance, variableName, value, scope, isNew); stream.close(); } else { throw new FlowableContentNotSupportedException("Serialized objects are not allowed"); } return restResponseFactory.createBinaryRestVariable(variableName, scope, variableType, null, caseInstance.getId()); } catch (IOException ioe) { throw new FlowableIllegalArgumentException("Could not process multipart content", ioe); } catch (ClassNotFoundException ioe) { throw new FlowableContentNotSupportedException( "The provided body contains a serialized object for which the class was not found: " + ioe.getMessage()); } }
From source file:org.flowable.cmmn.rest.service.api.runtime.task.TaskVariableBaseResource.java
protected RestVariable setBinaryVariable(MultipartHttpServletRequest request, Task task, boolean isNew) { // Validate input and set defaults if (request.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("No file content was found in request body."); }//from w ww . ja v a2 s . co m // Get first file in the map, ignore possible other files MultipartFile file = request.getFile(request.getFileMap().keySet().iterator().next()); if (file == null) { throw new FlowableIllegalArgumentException("No file content was found in request body."); } String variableScope = null; String variableName = null; String variableType = null; Map<String, String[]> paramMap = request.getParameterMap(); for (String parameterName : paramMap.keySet()) { if (paramMap.get(parameterName).length > 0) { if (parameterName.equalsIgnoreCase("scope")) { variableScope = paramMap.get(parameterName)[0]; } else if (parameterName.equalsIgnoreCase("name")) { variableName = paramMap.get(parameterName)[0]; } else if (parameterName.equalsIgnoreCase("type")) { variableType = paramMap.get(parameterName)[0]; } } } try { if (variableName == null) { throw new FlowableIllegalArgumentException("No variable name was found in request body."); } if (variableType != null) { if (!CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variableType) && !CmmnRestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variableType)) { throw new FlowableIllegalArgumentException( "Only 'binary' and 'serializable' are supported as variable type."); } } else { variableType = CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE; } RestVariableScope scope = RestVariableScope.LOCAL; if (variableScope != null) { scope = RestVariable.getScopeFromString(variableScope); } if (variableType.equals(CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE)) { // Use raw bytes as variable value byte[] variableBytes = IOUtils.toByteArray(file.getInputStream()); setVariable(task, variableName, variableBytes, scope, isNew); } else if (isSerializableVariableAllowed) { // Try deserializing the object ObjectInputStream stream = new ObjectInputStream(file.getInputStream()); Object value = stream.readObject(); setVariable(task, variableName, value, scope, isNew); stream.close(); } else { throw new FlowableContentNotSupportedException("Serialized objects are not allowed"); } return restResponseFactory.createBinaryRestVariable(variableName, scope, variableType, task.getId(), null); } catch (IOException ioe) { throw new FlowableIllegalArgumentException("Error getting binary variable", ioe); } catch (ClassNotFoundException ioe) { throw new FlowableContentNotSupportedException( "The provided body contains a serialized object for which the class was not found: " + ioe.getMessage()); } }
From source file:org.flowable.content.rest.service.api.content.ContentItemDataResource.java
@ApiOperation(value = "Save the content item data", tags = { "Content item" }, notes = "Save the content item data with an attached file. " + "The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the content item.") @ApiImplicitParams({ @ApiImplicitParam(name = "file", dataType = "file", paramType = "form", required = true) }) @ApiResponses(value = {//from w w w . jav a2 s .co m @ApiResponse(code = 201, message = "Indicates the content item data was saved and the result is returned."), @ApiResponse(code = 400, message = "Indicates required content item data is missing from the request.") }) @PostMapping(value = "/content-service/content-items/{contentItemId}/data", produces = "application/json", consumes = "multipart/form-data") public ContentItemResponse saveContentItemData( @ApiParam(name = "contentItemId") @PathVariable("contentItemId") String contentItemId, HttpServletRequest request, HttpServletResponse response) { if (!(request instanceof MultipartHttpServletRequest)) { throw new FlowableException("Multipart request required to save content item data"); } ContentItem contentItem = getContentItemFromRequest(contentItemId); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); if (file == null) { throw new FlowableIllegalArgumentException("Content item file is required."); } try { contentService.saveContentItem(contentItem, file.getInputStream()); response.setStatus(HttpStatus.CREATED.value()); return contentRestResponseFactory.createContentItemResponse(contentItem); } catch (Exception e) { throw new FlowableException("Error creating content item response", e); } }
From source file:org.flowable.dmn.rest.service.api.repository.DmnDeploymentCollectionResource.java
@ApiOperation(value = "Create a new decision table deployment", nickname = "uploadDecisionTableDeployment", tags = { "Deployment" }, consumes = "multipart/form-data", produces = "application/json", notes = "The request body should contain data of type multipart/form-data. There should be exactly one file in the request, any additional files will be ignored. The deployment name is the name of the file-field passed in. If multiple resources need to be deployed in a single deployment, compress the resources in a zip and make sure the file-name ends with .bar or .zip.\n" + "\n" + "An additional parameter (form-field) can be passed in the request body with name tenantId. The value of this field will be used as the id of the tenant this deployment is done in.") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the deployment was created."), @ApiResponse(code = 400, message = "Indicates there was no content present in the request body or the content mime-type is not supported for deployment. The status-description contains additional information.") }) @ApiImplicitParams({ @ApiImplicitParam(name = "file", paramType = "form", dataType = "java.io.File") }) @PostMapping(value = "/dmn-repository/deployments", produces = "application/json", consumes = "multipart/form-data") public DmnDeploymentResponse uploadDeployment( @ApiParam(name = "tenantId") @RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request, HttpServletResponse response) { if (!(request instanceof MultipartHttpServletRequest)) { throw new FlowableIllegalArgumentException("Multipart request is required"); }/* www . j a v a 2s . c o m*/ if (restApiInterceptor != null) { restApiInterceptor.executeNewDeploymentForTenantId(tenantId); } MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; if (multipartRequest.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("Multipart request with file content is required"); } MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); try { DmnDeploymentBuilder deploymentBuilder = dmnRepositoryService.createDeployment(); String fileName = file.getOriginalFilename(); if (StringUtils.isEmpty(fileName) || !DmnResourceUtil.isDmnResource(fileName)) { fileName = file.getName(); } if (DmnResourceUtil.isDmnResource(fileName)) { deploymentBuilder.addInputStream(fileName, file.getInputStream()); } else { throw new FlowableIllegalArgumentException("File must be of type .dmn"); } deploymentBuilder.name(fileName); if (tenantId != null) { deploymentBuilder.tenantId(tenantId); } if (restApiInterceptor != null) { restApiInterceptor.enhanceDeployment(deploymentBuilder); } DmnDeployment deployment = deploymentBuilder.deploy(); response.setStatus(HttpStatus.CREATED.value()); return dmnRestResponseFactory.createDmnDeploymentResponse(deployment); } catch (Exception e) { if (e instanceof FlowableException) { throw (FlowableException) e; } throw new FlowableException(e.getMessage(), e); } }
From source file:org.flowable.form.rest.service.api.repository.FormDeploymentCollectionResource.java
@ApiOperation(value = "Create a new form deployment", tags = { "Form Deployments" }, consumes = "multipart/form-data", produces = "application/json", notes = "The request body should contain data of type multipart/form-data. There should be exactly one file in the request, any additional files will be ignored. The deployment name is the name of the file-field passed in. Make sure the file-name ends with .form or .xml.") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the form deployment was created."), @ApiResponse(code = 400, message = "Indicates there was no content present in the request body or the content mime-type is not supported for form deployment. The status-description contains additional information.") }) @ApiImplicitParams({ @ApiImplicitParam(name = "file", paramType = "form", dataType = "java.io.File") }) @PostMapping(value = "/form-repository/deployments", produces = "application/json", consumes = "multipart/form-data") public FormDeploymentResponse uploadDeployment( @ApiParam(name = "tenantId") @RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request, HttpServletResponse response) { if (!(request instanceof MultipartHttpServletRequest)) { throw new FlowableIllegalArgumentException("Multipart request is required"); }/* ww w . j av a2 s . c om*/ if (restApiInterceptor != null) { restApiInterceptor.executeNewDeploymentForTenantId(tenantId); } MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; if (multipartRequest.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("Multipart request with file content is required"); } MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); try { FormDeploymentBuilder deploymentBuilder = formRepositoryService.createDeployment(); String fileName = file.getOriginalFilename(); if (StringUtils.isEmpty(fileName) || !fileName.endsWith(".form")) { fileName = file.getName(); } if (fileName.endsWith(".form")) { deploymentBuilder.addInputStream(fileName, file.getInputStream()); } else { throw new FlowableIllegalArgumentException("File must be of type .xml or .form"); } deploymentBuilder.name(fileName); if (tenantId != null) { deploymentBuilder.tenantId(tenantId); } if (restApiInterceptor != null) { restApiInterceptor.enhanceDeployment(deploymentBuilder); } FormDeployment deployment = deploymentBuilder.deploy(); response.setStatus(HttpStatus.CREATED.value()); return formRestResponseFactory.createFormDeploymentResponse(deployment); } catch (Exception e) { if (e instanceof FlowableException) { throw (FlowableException) e; } throw new FlowableException(e.getMessage(), e); } }
From source file:org.flowable.rest.content.service.api.content.ContentItemDataResource.java
@ApiOperation(value = "Save the content item data", tags = { "Content item" }, notes = "## Save the content item data with an attached file\n\n" + "The request should be of type multipart/form-data. There should be a single file-part included with the binary value of the content item.") @ApiResponses(value = {/* w w w . j a v a 2 s . c om*/ @ApiResponse(code = 201, message = "Indicates the content item data was saved and the result is returned."), @ApiResponse(code = 400, message = "Indicates required content item data is missing from the request.") }) @RequestMapping(value = "/content-service/content-items/{contentItemId}/data", method = RequestMethod.POST, produces = "application/json") public ContentItemResponse saveContentItemData( @ApiParam(name = "contentItemId") @PathVariable("contentItemId") String contentItemId, HttpServletRequest request, HttpServletResponse response) { if (request instanceof MultipartHttpServletRequest == false) { throw new FlowableException("Multipart request required to save content item data"); } ContentItem contentItem = getContentItemFromRequest(contentItemId); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); if (file == null) { throw new FlowableIllegalArgumentException("Content item file is required."); } try { contentService.saveContentItem(contentItem, file.getInputStream()); response.setStatus(HttpStatus.CREATED.value()); return contentRestResponseFactory.createContentItemResponse(contentItem); } catch (Exception e) { throw new FlowableException("Error creating content item response", e); } }
From source file:org.flowable.rest.dmn.service.api.repository.DmnDeploymentCollectionResource.java
@RequestMapping(value = "/dmn-repository/deployments", method = RequestMethod.POST, produces = "application/json") public DmnDeploymentResponse uploadDeployment( @RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request, HttpServletResponse response) {//from w ww .j a v a2 s . co m if (request instanceof MultipartHttpServletRequest == false) { throw new FlowableIllegalArgumentException("Multipart request is required"); } MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; if (multipartRequest.getFileMap().size() == 0) { throw new FlowableIllegalArgumentException("Multipart request with file content is required"); } MultipartFile file = multipartRequest.getFileMap().values().iterator().next(); try { DmnDeploymentBuilder deploymentBuilder = dmnRepositoryService.createDeployment(); String fileName = file.getOriginalFilename(); if (StringUtils.isEmpty(fileName) || !(fileName.endsWith(".dmn") || fileName.endsWith(".xml"))) { fileName = file.getName(); } if (fileName.endsWith(".dmn") || fileName.endsWith(".xml")) { deploymentBuilder.addInputStream(fileName, file.getInputStream()); } else { throw new FlowableIllegalArgumentException("File must be of type .xml or .dmn"); } deploymentBuilder.name(fileName); if (tenantId != null) { deploymentBuilder.tenantId(tenantId); } DmnDeployment deployment = deploymentBuilder.deploy(); response.setStatus(HttpStatus.CREATED.value()); return dmnRestResponseFactory.createDmnDeploymentResponse(deployment); } catch (Exception e) { if (e instanceof FlowableException) { throw (FlowableException) e; } throw new FlowableException(e.getMessage(), e); } }