2 * Copyright (c) 2017 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the Apache License, Version 2.0
5 * and the Eclipse Public License v1.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial API and implementation and/or initial documentation
13 package org.onap.sdc.workflowdesigner.resources;
15 import java.io.IOException;
17 import javax.ws.rs.Consumes;
18 import javax.ws.rs.GET;
19 import javax.ws.rs.Path;
20 import javax.ws.rs.Produces;
21 import javax.ws.rs.QueryParam;
22 import javax.ws.rs.core.MediaType;
23 import javax.ws.rs.core.Response;
25 import org.eclipse.jetty.http.HttpStatus;
26 import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
27 import org.onap.sdc.workflowdesigner.utils.RestUtils;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 import com.codahale.metrics.annotation.Timed;
33 import io.swagger.annotations.Api;
34 import io.swagger.annotations.ApiOperation;
35 import io.swagger.annotations.ApiParam;
36 import io.swagger.annotations.ApiResponse;
37 import io.swagger.annotations.ApiResponses;
40 * Extend Activity Resource.
43 @Path("/ext-activities")
44 @Api(tags = {"Workflow Modeler"})
45 public class ExtendActivityResource {
46 private static final Logger logger = LoggerFactory.getLogger(ExtendActivityResource.class);
55 @Consumes(MediaType.APPLICATION_JSON)
56 @Produces(MediaType.APPLICATION_JSON)
57 @ApiOperation(value = "Get Model", response = String.class)
58 @ApiResponses(value = {
59 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
60 response = String.class),
61 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
62 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
63 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error",
64 response = String.class)})
66 public Response getExtActivities(@ApiParam(value = "sence") @QueryParam("sence") String sence) {
67 String filePath = "ext-activities.json";
69 String json = FileCommonUtils.readString(filePath);
70 return Response.status(Response.Status.OK).entity(json).build();
71 } catch (IOException e) {
72 logger.error("getServiceTemplateById failed.", e);
73 throw RestUtils.newInternalServerErrorException(e);
79 @Consumes(MediaType.APPLICATION_JSON)
80 @Produces(MediaType.APPLICATION_JSON)
81 @ApiOperation(value = "Get Model", response = String.class)
82 @ApiResponses(value = {
83 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
84 response = String.class),
85 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
86 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
87 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error",
88 response = String.class)})
90 public Response getDisplayInfo(@ApiParam(value = "sence") @QueryParam("sence") String sence) {
91 String filePath = "ext-activities-display-info.json";
93 String json = FileCommonUtils.readString(filePath);
94 return Response.status(Response.Status.OK).entity(json).build();
95 } catch (IOException e) {
96 logger.error("getServiceTemplateById failed.", e);
97 throw RestUtils.newInternalServerErrorException(e);