2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.workflow.resources;
19 import io.swagger.annotations.Api;
20 import io.swagger.annotations.ApiOperation;
21 import io.swagger.annotations.ApiParam;
22 import io.swagger.annotations.ApiResponse;
23 import io.swagger.annotations.ApiResponses;
25 import java.io.InputStream;
27 import javax.ws.rs.Consumes;
28 import javax.ws.rs.DELETE;
29 import javax.ws.rs.POST;
30 import javax.ws.rs.Path;
31 import javax.ws.rs.PathParam;
32 import javax.ws.rs.Produces;
33 import javax.ws.rs.core.MediaType;
34 import javax.ws.rs.core.Response;
36 import org.eclipse.jetty.http.HttpStatus;
37 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
38 import org.glassfish.jersey.media.multipart.FormDataParam;
39 import org.jvnet.hk2.annotations.Service;
40 import org.onap.workflow.common.RestResponse;
41 import org.onap.workflow.entity.DeployBpmnFileResponse;
42 import org.onap.workflow.entity.StartProcessRequest;
43 import org.onap.workflow.wrapper.WorkflowInstanceWrapper;
46 @Api(tags = {"Workflow Resource"})
47 @Produces(MediaType.APPLICATION_JSON)
49 public class WorkflowResource {
52 @Consumes({"multipart/form-data"})
53 @Produces({"application/json"})
54 @ApiOperation(value = "deploy bpmn file")
55 @ApiResponses(value = {
56 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
57 response = DeployBpmnFileResponse.class),
58 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
59 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
60 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "error")})
61 public Response deployBpmnFile(
62 @ApiParam(value = "file inputstream",
63 required = true) @FormDataParam("file") InputStream fileInputStream,
64 @ApiParam(value = "file detail",
65 required = false) @FormDataParam("file") FormDataContentDisposition fileDetail) {
66 return WorkflowInstanceWrapper.getInstance().deployBpmnFile(fileDetail.getFileName(),
67 fileInputStream, null);
70 @Path("/package/{deployId}")
72 @Consumes(MediaType.APPLICATION_JSON)
73 @Produces(MediaType.APPLICATION_JSON)
74 @ApiOperation(value = "undeploy bpmn file")
75 @ApiResponses(value = {
76 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
77 response = DeployBpmnFileResponse.class),
78 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
79 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
80 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "error")})
81 public RestResponse undeployBpmnFile(
82 @ApiParam("deployId") @PathParam("deployId") String deployId) {
83 return WorkflowInstanceWrapper.getInstance().undeployBpmnFile(deployId);
86 @Path("process/instance")
88 @Consumes(MediaType.APPLICATION_JSON)
89 @Produces(MediaType.APPLICATION_JSON)
90 @ApiOperation(value = "package process")
91 @ApiResponses(value = {
92 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
93 response = DeployBpmnFileResponse.class),
94 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
95 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
96 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "error")})
97 public Response startProcess(
98 @ApiParam(value = "request", required = false) StartProcessRequest request) {
99 return WorkflowInstanceWrapper.getInstance().startProcess(request);