Invalid deploy result code: HTTP/1.1 404 http://localhost:8068/flowable-task/process-api/app-repository/deployments?deploymentKey=testApplicationDemo1&deploymentName=%E6%B5%8B%E8%AF%95%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F1
如图,发布操作时,报错,对应的rest api未找到。
.yml
pom
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process-rest</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-rest</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-task-rest</artifactId>
<version>6.4.1</version>
</dependency>
是少引用了,还是引用粗了,还是api地址错了?
哎,找了一下午了。头大。
有熟悉的老哥吗?感激不尽。
已解决,自己写个对应路由的action。内容从源码中拷贝加修改。
@RestController
@RequestMapping(value = "/flowable-task/process-api")
public class DeploymentController {
// @Autowired
// protected RestResponseFactory restResponseFactory;
@Autowired
protected RepositoryService repositoryService;
@Autowired(required=false)
protected BpmnRestApiInterceptor restApiInterceptor;
/**
* 部署(发布) rest api publish中会调用此接口而非直接ui调用
* @param deploymentKey
* @param deploymentName
* @param tenantId
* @param request
* @param response
* @return
*/
@ApiImplicitParams({
@ApiImplicitParam(name = "file", dataType = "file", paramType = "form", required = true)
})
@PostMapping(value = "/app-repository/deployments", produces = "application/json", consumes = "multipart/form-data")
public DeploymentResponse 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");
}
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 {
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
String fileName = file.getOriginalFilename();
if (StringUtils.isEmpty(fileName) || !(fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn") || fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip"))) {
fileName = file.getName();
}
if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
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 .bpmn20.xml, .bpmn, .bar or .zip");
}
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);
}
Deployment deployment = deploymentBuilder.deploy();
response.setStatus(HttpStatus.CREATED.value());
return createDeploymentResponse(deployment);// restResponseFactory.createDeploymentResponse(deployment);
} catch (Exception e) {
if (e instanceof FlowableException) {
throw (FlowableException) e;
}
throw new FlowableException(e.getMessage(), e);
}
}
public Map<String, String> splitQueryString(String queryString) {
if (StringUtils.isEmpty(queryString)) {
return Collections.emptyMap();
}
Map<String, String> queryMap = new HashMap<>();
for (String param : queryString.split("&")) {
queryMap.put(StringUtils.substringBefore(param, "="), decode(StringUtils.substringAfter(param, "=")));
}
return queryMap;
}
protected String decode(String string) {
if (string != null) {
try {
return URLDecoder.decode(string, "UTF-8");
} catch (UnsupportedEncodingException uee) {
throw new IllegalStateException("JVM does not support UTF-8 encoding.", uee);
}
}
return null;
}
public DeploymentResponse createDeploymentResponse(Deployment deployment) {
return createDeploymentResponse(deployment, createUrlBuilder());
}
public DeploymentResponse createDeploymentResponse(Deployment deployment, RestUrlBuilder urlBuilder) {
return new DeploymentResponse(deployment, urlBuilder.buildUrl(RestUrls.URL_DEPLOYMENT, deployment.getId()));
}
protected RestUrlBuilder createUrlBuilder() {
return RestUrlBuilder.fromCurrentRequest();
}
}