aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-03-20 10:40:59 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-03-20 10:40:59 +0800
commitc02b6b423f6fba9504c8a8d526b0bc4cdba6785d (patch)
tree72463429d5cd2fac7189714d2451150bf093e846
parentce8cfcde32b56477f80be5980e5954f5bebdbb69 (diff)
Extract Constant & Method.
Extract Constant & Method. Issue-ID: SDC-1079 Change-Id: I3d2d310eae2f3eb82bf6540b4beee5d7924da48e Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java22
1 files changed, 17 insertions, 5 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 47e56d1a..86aae064 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
@@ -45,6 +45,9 @@ import io.swagger.annotations.ApiResponses;
@Path("/ext-activities")
@Api(tags = {"Workflow Modeler"})
public class ExtendActivityResource {
+ /** */
+ private static final String EXT_ACTIVITIES_DISPLAY_INFO_FILE_NAME = "ext-activities-display-info.json";
+
private static final Logger LOGGER = LoggerFactory.getLogger(ExtendActivityResource.class);
private static final String EXT_ACTIVITIES_FILE_NAME = "..\\distribution\\src\\main\\assembly\\ext-activities.json";
@@ -70,10 +73,8 @@ public class ExtendActivityResource {
public Response getExtActivities(@ApiParam(value = "sence") @QueryParam("sence") String sence) {
try {
- String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME);
+ ExtendActivity[] extActivities = retriveExtActivites(sence);
- 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);
@@ -82,6 +83,18 @@ public class ExtendActivityResource {
}
+ /**
+ * @param sence
+ * @return
+ * @throws IOException
+ */
+ private ExtendActivity[] retriveExtActivites(String sence) throws IOException {
+ String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME);
+ Gson gson = new Gson();
+ return gson.fromJson(json, ExtendActivity[].class);
+ }
+
+
@Path("/displayInfo")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@@ -96,9 +109,8 @@ public class ExtendActivityResource {
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);
+ String json = FileCommonUtils.readString(EXT_ACTIVITIES_DISPLAY_INFO_FILE_NAME);
return Response.status(Response.Status.OK).entity(json).build();
} catch (IOException e) {
LOGGER.error("getServiceTemplateById failed.", e);