/**
- * 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,
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;
@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.
@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),
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")
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);
}
}