diff options
author | YuanHu <yuan.hu1@zte.com.cn> | 2018-03-20 08:57:44 +0800 |
---|---|---|
committer | YuanHu <yuan.hu1@zte.com.cn> | 2018-03-20 09:27:11 +0800 |
commit | 47f5e6707e9684076c855523c4c9f74dff58133b (patch) | |
tree | 3a692f6c853ef9f0d6976ff49ed608dd6373ebeb /sdc-workflow-designer-server | |
parent | 8ffa3474ef62373b4ac2657bf2be9b5a31629009 (diff) |
Parsing extend activities from file.
Parsing extend activities from json file.
Issue-ID: SDC-1129
Change-Id: Ideb7c473d17c2d533676fcc44bdefba183d34a9f
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server')
-rw-r--r-- | sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java | 24 |
1 files changed, 16 insertions, 8 deletions
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 index 35d77a01..47e56d1a 100644 --- 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 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, @@ -23,12 +23,14 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.eclipse.jetty.http.HttpStatus; +import org.onap.sdc.workflowdesigner.resources.entity.ExtendActivity; 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 com.google.gson.Gson; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -43,7 +45,9 @@ import io.swagger.annotations.ApiResponses; @Path("/ext-activities") @Api(tags = {"Workflow Modeler"}) public class ExtendActivityResource { - private static final Logger logger = LoggerFactory.getLogger(ExtendActivityResource.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ExtendActivityResource.class); + + private static final String EXT_ACTIVITIES_FILE_NAME = "..\\distribution\\src\\main\\assembly\\ext-activities.json"; /** * test function. @@ -54,7 +58,7 @@ public class ExtendActivityResource { @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Get Model", response = String.class) + @ApiOperation(value = "Get Model", response = ExtendActivity.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class), @@ -64,14 +68,18 @@ public class ExtendActivityResource { 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(); + String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME); + + Gson gson = new Gson(); + ExtendActivity[] extActivities = gson.fromJson(json, ExtendActivity[].class); + return Response.status(Response.Status.OK).entity(extActivities).build(); } catch (IOException e) { - logger.error("getServiceTemplateById failed.", e); + LOGGER.error("getServiceTemplateById failed.", e); throw RestUtils.newInternalServerErrorException(e); } + } @Path("/displayInfo") @@ -93,7 +101,7 @@ public class ExtendActivityResource { String json = FileCommonUtils.readString(filePath); return Response.status(Response.Status.OK).entity(json).build(); } catch (IOException e) { - logger.error("getServiceTemplateById failed.", e); + LOGGER.error("getServiceTemplateById failed.", e); throw RestUtils.newInternalServerErrorException(e); } } |