summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src/main
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-02-05 15:03:34 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-02-05 15:05:17 +0800
commit04b59f655d9d9405589babf271f4d9026ce31305 (patch)
treefcc1e113494ceb48f5220a420004827fc5c69343 /sdc-workflow-designer-server/src/main
parent3a8b80d2c524c0df5aa2032896a04a92ae06a0fc (diff)
implement class for the Rest APIs.
Provide implement Service Resource Classes for the Rest APIs. Issue-ID: SDC-997 Change-Id: If94f3835e69e12455380fa10513118a6e11575c5 Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src/main')
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java8
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java101
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java104
3 files changed, 209 insertions, 4 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java
index 002da23b..da40796b 100644
--- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java
+++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java
@@ -13,8 +13,8 @@
package org.onap.sdc.workflowdesigner;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
-// import org.onap.sdc.workflowdesigner.resources.ExtendActivityResource;
-// import org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource;
+import org.onap.sdc.workflowdesigner.resources.ExtendActivityResource;
+import org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,8 +50,8 @@ public class WorkflowDesignerApp extends Application<WorkflowDesignerConfigurati
public void run(WorkflowDesignerConfiguration configuration, Environment environment) {
LOGGER.info("Start to initialize Workflow Designer.");
- // environment.jersey().register(new WorkflowModelerResource());
- // environment.jersey().register(new ExtendActivityResource());
+ environment.jersey().register(new WorkflowModelerResource());
+ environment.jersey().register(new ExtendActivityResource());
// register rest interface
environment.jersey().packages("org.onap.sdc.workflowdesigner.resources");
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java
new file mode 100644
index 00000000..35d77a01
--- /dev/null
+++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+
+package org.onap.sdc.workflowdesigner.resources;
+
+import java.io.IOException;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
+import org.onap.sdc.workflowdesigner.utils.RestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.codahale.metrics.annotation.Timed;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+/**
+ * Extend Activity Resource.
+ *
+ */
+@Path("/ext-activities")
+@Api(tags = {"Workflow Modeler"})
+public class ExtendActivityResource {
+ private static final Logger logger = LoggerFactory.getLogger(ExtendActivityResource.class);
+
+ /**
+ * test function.
+ *
+ * @return Response
+ */
+ @Path("/")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get Model", response = String.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error",
+ response = String.class)})
+ @Timed
+ public Response getExtActivities(@ApiParam(value = "sence") @QueryParam("sence") String sence) {
+ String filePath = "ext-activities.json";
+ try {
+ String json = FileCommonUtils.readString(filePath);
+ return Response.status(Response.Status.OK).entity(json).build();
+ } catch (IOException e) {
+ logger.error("getServiceTemplateById failed.", e);
+ throw RestUtils.newInternalServerErrorException(e);
+ }
+ }
+
+ @Path("/displayInfo")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get Model", response = String.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error",
+ response = String.class)})
+ @Timed
+ public Response getDisplayInfo(@ApiParam(value = "sence") @QueryParam("sence") String sence) {
+ String filePath = "ext-activities-display-info.json";
+ try {
+ String json = FileCommonUtils.readString(filePath);
+ return Response.status(Response.Status.OK).entity(json).build();
+ } catch (IOException e) {
+ logger.error("getServiceTemplateById failed.", e);
+ throw RestUtils.newInternalServerErrorException(e);
+ }
+ }
+
+}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java
new file mode 100644
index 00000000..8b3d7238
--- /dev/null
+++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+
+package org.onap.sdc.workflowdesigner.resources;
+
+import java.io.IOException;
+import java.io.StringBufferInputStream;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
+import org.onap.sdc.workflowdesigner.utils.RestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.codahale.metrics.annotation.Timed;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+/**
+ * Workflow Modeler Resource.
+ *
+ */
+@Path("/models")
+@Api(tags = {"Workflow Modeler"})
+public class WorkflowModelerResource {
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowModelerResource.class);
+
+ /**
+ * test function.
+ *
+ * @return Response
+ */
+ @Path("/{id}")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get Model", response = String.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error",
+ response = String.class)})
+ @Timed
+ public Response getModel(@ApiParam(value = "id") @PathParam("id") String id) {
+ String filePath = "model.json";
+ try {
+ String json = FileCommonUtils.readString(filePath);
+ return Response.status(Response.Status.OK).entity(json).build();
+ } catch (IOException e) {
+ logger.error("getServiceTemplateById failed.", e);
+ throw RestUtils.newInternalServerErrorException(e);
+ }
+ }
+
+ @Path("/{id}")
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Save Model", response = String.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
+ response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+ message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "server internal error",
+ response = String.class)})
+ @Timed
+ public Response saveModel(@ApiParam(value = "id") @PathParam("id") String id,
+ @ApiParam(value = "Model Content", required = true) String json) {
+ String filePath = "model.json";
+ try {
+ FileCommonUtils.saveFile(new StringBufferInputStream(json), "", filePath);
+ return Response.status(Response.Status.OK).entity(id).build();
+ } catch (IOException e) {
+ logger.error("getServiceTemplateById failed.", e);
+ throw RestUtils.newInternalServerErrorException(e);
+ }
+ }
+
+}