From: lizi00164331 Date: Fri, 1 Sep 2017 03:03:40 +0000 (+0800) Subject: Define the REST API of thirdParty SDNC. X-Git-Tag: v1.0.0~95 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=commitdiff_plain;h=ac489e7598190f1165ff6f7a5dee32e506386770 Define the REST API of thirdParty SDNC. Define the Rest API of thirdParty SDNC. Also including some file rename work. Change-Id: Ied018e3ca96813bbd6756644a73a5c7c87e997bd Issue-ID: AAI-250 Signed-off-by: lizi00164331 --- diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java index 290d2d4..c8c979c 100644 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java @@ -21,7 +21,7 @@ import com.eclipsesource.jaxrs.consumer.ConsumerFactory; import org.glassfish.jersey.client.ClientConfig; import org.onap.aai.esr.common.Config; import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; -import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.ExtsysUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +36,7 @@ public class MicroserviceBusConsumer { */ public static boolean registerService(ServiceRegisterEntity entity) { ClientConfig config = new ClientConfig(); - LOG.info("microservice register body:" + ExtsysDbUtil.objectToString(entity)); + LOG.info("microservice register body:" + ExtsysUtil.objectToString(entity)); try { MicroserviceBusRest resourceserviceproxy = ConsumerFactory.createConsumer( Config.getConfigration().getMsbServerAddr(), config, MicroserviceBusRest.class); diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java index 60fef2d..997fb88 100644 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java @@ -21,7 +21,7 @@ import org.onap.aai.esr.dao.BaseDao; import org.onap.aai.esr.dao.DaoManager; import org.onap.aai.esr.entity.aai.BaseData; import org.onap.aai.esr.exception.ExtsysException; -import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.ExtsysUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +51,7 @@ public abstract class BaseHandler { public T create(T data, String resouceType) throws ExtsysException { T rtnData = null; boolean check = true; - logger.info("BaseHandler:start create data.info:" + ExtsysDbUtil.objectToString(data)); + logger.info("BaseHandler:start create data.info:" + ExtsysUtil.objectToString(data)); try { check = validity(data); if (check) { @@ -65,8 +65,8 @@ public abstract class BaseHandler { throw error; } try { - data.setId(ExtsysDbUtil.generateId()); - data.setCreateTime(ExtsysDbUtil.getNowTime()); + data.setId(ExtsysUtil.generateId()); + data.setCreateTime(ExtsysUtil.getNowTime()); data.setCategory(resouceType); BaseDao dao = DaoManager.getInstance().getDao(resouceType); rtnData = (T) dao.create(data); @@ -74,7 +74,7 @@ public abstract class BaseHandler { logger.error("BaseHandler:error while creating " + resouceType, error); throw error; } - logger.info("BaseHandler:create data end.info:" + ExtsysDbUtil.objectToString(data)); + logger.info("BaseHandler:create data end.info:" + ExtsysUtil.objectToString(data)); return rtnData; } @@ -86,7 +86,7 @@ public abstract class BaseHandler { */ @SuppressWarnings({"rawtypes", "unchecked"}) public void delete(T data, String resouceType) throws ExtsysException { - logger.info("BaseHandler:start delete data.info:" + ExtsysDbUtil.objectToString(data)); + logger.info("BaseHandler:start delete data.info:" + ExtsysUtil.objectToString(data)); try { BaseDao dao = DaoManager.getInstance().getDao(resouceType); dao.delete(data); @@ -106,7 +106,7 @@ public abstract class BaseHandler { @SuppressWarnings({"rawtypes", "unchecked"}) public void delete(Map queryParam, String resouceType) throws ExtsysException { logger.info("BaseHandler:start delete data by condition.info:" - + ExtsysDbUtil.objectToString(queryParam)); + + ExtsysUtil.objectToString(queryParam)); List datas; try { BaseDao dao = DaoManager.getInstance().getDao(resouceType); @@ -130,7 +130,7 @@ public abstract class BaseHandler { */ @SuppressWarnings({"rawtypes", "unchecked"}) public void update(T data, String filter, String resouceType) throws ExtsysException { - logger.info("BaseHandler:start update data .info:" + ExtsysDbUtil.objectToString(data) + logger.info("BaseHandler:start update data .info:" + ExtsysUtil.objectToString(data) + " filter:" + filter); try { BaseDao dao = DaoManager.getInstance().getDao(resouceType); @@ -153,7 +153,7 @@ public abstract class BaseHandler { */ @SuppressWarnings({"rawtypes", "unchecked"}) public List query(Map queryParam, String resouceType) throws ExtsysException { - logger.info("BaseHandler:start query data .info:" + ExtsysDbUtil.objectToString(queryParam)); + logger.info("BaseHandler:start query data .info:" + ExtsysUtil.objectToString(queryParam)); List datas = null; try { BaseDao dao = DaoManager.getInstance().getDao(resouceType); @@ -163,7 +163,7 @@ public abstract class BaseHandler { logger.error("BaseHandler:error while querying " + resouceType, error); throw error; } - logger.info("BaseHandler: query data end .info:" + ExtsysDbUtil.objectToString(datas)); + logger.info("BaseHandler: query data end .info:" + ExtsysUtil.objectToString(datas)); return datas; } @@ -186,7 +186,7 @@ public abstract class BaseHandler { logger.error("BaseHandler:error while union querying " + resouceType, error); throw error; } - logger.info("BaseHandler:union query data end .info:" + ExtsysDbUtil.objectToString(datas)); + logger.info("BaseHandler:union query data end .info:" + ExtsysUtil.objectToString(datas)); return datas; } diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java index bc338e1..0ab970a 100644 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java @@ -27,7 +27,7 @@ import org.onap.aai.esr.entity.aai.EmsData; import org.onap.aai.esr.entity.rest.EmsRestData; import org.onap.aai.esr.exception.ExtsysException; import org.onap.aai.esr.handle.EmsHandler; -import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.ExtsysUtil; import org.onap.aai.esr.util.RestResponseUtil; import org.onap.aai.esr.wrapper.EmsManagerWrapper; import org.slf4j.Logger; @@ -130,7 +130,7 @@ public class EmsManager { @Timed public Response updateEms(@ApiParam(value = "ems", required = true) EmsRestData ems, @ApiParam(value = "ems id", required = true) @PathParam("emsId") String emsId) { - LOGGER.info("start update ems .id:" + emsId + " info:" + ExtsysDbUtil.objectToString(ems)); + LOGGER.info("start update ems .id:" + emsId + " info:" + ExtsysUtil.objectToString(ems)); return RestResponseUtil.getSuccessResponse(new EmsRestData()); } @@ -151,7 +151,7 @@ public class EmsManager { response = String.class)}) @Timed public Response registerEms(@ApiParam(value = "ems", required = true) EmsRestData ems) { - LOGGER.info("start add ems" + " info:" + ExtsysDbUtil.objectToString(ems)); + LOGGER.info("start add ems" + " info:" + ExtsysUtil.objectToString(ems)); return EmsManagerWrapper.getInstance().registerEms(ems); } } diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/SdncManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/SdncManager.java deleted file mode 100644 index 6e17d0e..0000000 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/SdncManager.java +++ /dev/null @@ -1,214 +0,0 @@ -/** - * Copyright 2016-2017 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.aai.esr.resource; - -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; - -import org.eclipse.jetty.http.HttpStatus; -import org.onap.aai.esr.entity.aai.SdncData; -import org.onap.aai.esr.entity.rest.ThirdPartySdncRestData; -import org.onap.aai.esr.exception.ExtsysException; -import org.onap.aai.esr.handle.SdncHandler; -import org.onap.aai.esr.util.ExtsysDbUtil; -import org.onap.aai.esr.util.RestResponseUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -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; - -@Path("/sdncontrollers") -@Api(tags = {" sdnc Management "}) -public class SdncManager { - - SdncHandler handler = new SdncHandler(); - private static final Logger LOGGER = LoggerFactory.getLogger(SdncManager.class); - - /** - *query all sdnc. - */ - @Path("") - @GET - @ApiOperation(value = "get all sdnc ") - @Produces(MediaType.APPLICATION_JSON) - @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 = "internal server error", - response = String.class)}) - @Timed - public Response querysdncList() { - LOGGER.info("start query all sdnc!"); - List list; - try { - list = handler.getAll(); - } catch (ExtsysException error) { - LOGGER.error("query all sdnc failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - if (list == null || list.size() <= 0) { - LOGGER.info("query all sdnc end.no match condition record"); - return RestResponseUtil.getSuccessResponse(new ArrayList()); - } else { - LOGGER.info("query all sdnc end.size:" + list.size()); - ArrayList restList = new ArrayList(); - for (int i = 0; i < list.size(); i++) { -// restList.add(new ThirdPartySdncRestData(list.get(i))); - restList.add(new ThirdPartySdncRestData()); - } - return RestResponseUtil.getSuccessResponse(restList); - } - - } - - /** - *query sdnc by id. - */ - @Path("/{sdncId}") - @GET - @ApiOperation(value = "get sdnc by id") - @Produces(MediaType.APPLICATION_JSON) - @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 = "internal server error", - response = String.class)}) - @Timed - public Response querysdncById(@ApiParam(value = "sdnc id") @PathParam("sdncId") String sdncId) { - LOGGER.info("start query sdnc by id." + sdncId); - List list; - try { - list = handler.getSdncById(sdncId); - } catch (ExtsysException error) { - LOGGER.error("query sdnc failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - if (list == null || list.size() <= 0) { - LOGGER.info("query sdnc end.no match condition record"); - return RestResponseUtil.getSuccessResponse(null); - } else { - LOGGER.info("query sdnc end.info:" + ExtsysDbUtil.objectToString(list)); -// return RestResponseUtil.getSuccessResponse(new ThirdPartySdncRestData(list.get(0))); - return RestResponseUtil.getSuccessResponse(new ThirdPartySdncRestData()); - } - } - - /** - *delete sdnc by id. - */ - @Path("/{sdncId}") - @DELETE - @ApiOperation(value = "delete a sdnc") - @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 = "internal server error", - response = String.class)}) - @Timed - public Response delsdnc(@ApiParam(value = "sdnc id") @PathParam("sdncId") String sdncId) { - LOGGER.info("start delete sdnc .id:" + sdncId); - try { - handler.delete(sdncId); - } catch (ExtsysException error) { - LOGGER.error("delete sdnc failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - LOGGER.info(" delete sdnc end !"); - return Response.noContent().build(); - } - - /** - *update sdnc by id. - */ - @PUT - @Path("/{sdncId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "update a sdnc") - @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 = "internal server error", - response = String.class)}) - @Timed - public Response updatesdncs(@ApiParam(value = "sdnc", required = true) SdncData sdnc, - @ApiParam(value = "sdnc id", required = true) @PathParam("sdncId") String sdncId) { - LOGGER.info("start update sdnc .id:" + sdncId + " info:" + ExtsysDbUtil.objectToString(sdnc)); - SdncData newData; - try { - newData = handler.update(sdnc, sdncId); - } catch (ExtsysException error) { - LOGGER.error("update sdnc failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - LOGGER.info(" update sdnc end !"); -// return RestResponseUtil.getSuccessResponse(new ThirdPartySdncRestData(newData)); - return RestResponseUtil.getSuccessResponse(new ThirdPartySdncRestData()); - } - - /** - *add sdnc. - */ - @POST - @Path("") - @Consumes(MediaType.APPLICATION_JSON) - @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "create a sdnc") - @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 = "internal server error", - response = String.class)}) - @Timed - public Response addsdncs(@ApiParam(value = "sdnc", required = true) SdncData sdnc) { - LOGGER.info("start add sdnc" + " info:" + ExtsysDbUtil.objectToString(sdnc)); - SdncData sdncData; - try { - sdncData = handler.add(sdnc); - } catch (ExtsysException error) { - LOGGER.error("add sdnc failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - LOGGER.info(" add sdnc end !"); -// return RestResponseUtil.getCreateSussceeResponse(new ThirdPartySdncRestData(sdncData)); - return RestResponseUtil.getCreateSussceeResponse(new ThirdPartySdncRestData()); - } -} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java new file mode 100644 index 0000000..b5a1e30 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java @@ -0,0 +1,152 @@ +/** + * Copyright 2016-2017 ZTE Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.aai.esr.resource; + +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; + +import org.eclipse.jetty.http.HttpStatus; +import org.onap.aai.esr.entity.rest.ThirdPartySdncRestData; +import org.onap.aai.esr.handle.SdncHandler; +import org.onap.aai.esr.util.ExtsysUtil; +import org.onap.aai.esr.wrapper.ThirdpatySdncWrapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +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; + +@Path("/sdncontrollers") +@Api(tags = {"ThirdParty sdnc Management "}) +public class ThirdpatySdncManager { + + SdncHandler handler = new SdncHandler(); + private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpatySdncManager.class); + + /** + *query all thirdParty sdnc. + */ + @Path("") + @GET + @ApiOperation(value = "get all thirdParty sdnc ") + @Produces(MediaType.APPLICATION_JSON) + @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 = "internal server error", + response = String.class)}) + @Timed + public Response queryThirdpartySdncList() { + LOGGER.info("start query all thirdParty sdnc!"); + return ThirdpatySdncWrapper.getInstance().queryThirdpartySdncList(); + } + + /** + *query thirdParty sdnc by id. + */ + @Path("/{thirdPartySdncId}") + @GET + @ApiOperation(value = "get thirdParty sdnc by id") + @Produces(MediaType.APPLICATION_JSON) + @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 = "internal server error", + response = String.class)}) + @Timed + public Response queryThirdpartySdncById(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) { + LOGGER.info("start query thirdparty sdnc by id." + thirdPartySdncId); + return ThirdpatySdncWrapper.getInstance().queryThirdpartySdncById(thirdPartySdncId); + } + + /** + *delete thirdparty sdnc by id. + */ + @Path("/{thirdPartySdncId}") + @DELETE + @ApiOperation(value = "delete a thirdparty sdnc") + @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 = "internal server error", + response = String.class)}) + @Timed + public Response delThirdpartySdnc(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) { + LOGGER.info("start delete thirdparty sdnc .id:" + thirdPartySdncId); + return ThirdpatySdncWrapper.getInstance().delThirdpartySdnc(thirdPartySdncId); + } + + /** + *update thirdParty sdnc by id. + */ + @PUT + @Path("/{thirdPartySdncId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "update a thirdParty Sdnc") + @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 = "internal server error", + response = String.class)}) + @Timed + public Response updateThirdpartySdnc(@ApiParam(value = "thirdpartySdnc", required = true) ThirdPartySdncRestData thirdPartySdnc, + @ApiParam(value = "sdnc id", required = true) @PathParam("thirdPartySdncId") String thirdPartySdncId) { + LOGGER.info("start update sdnc .id:" + thirdPartySdncId + " info:" + ExtsysUtil.objectToString(thirdPartySdnc)); + return ThirdpatySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc); + } + + /** + *thirdParty sdnc register. + */ + @POST + @Path("") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "register a thirdparty sdnc") + @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 = "internal server error", + response = String.class)}) + @Timed + public Response registerThirdpatySdnc(@ApiParam(value = "thirdPartySdnc", required = true) ThirdPartySdncRestData thirdPartySdnc) { + LOGGER.info("start register sdnc" + " info:" + ExtsysUtil.objectToString(thirdPartySdnc)); + return ThirdpatySdncWrapper.getInstance().registerThirdpartySdnc(thirdPartySdnc); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java index 8bf5b3f..15e5198 100644 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java @@ -26,7 +26,7 @@ import org.onap.aai.esr.entity.aai.VimData; import org.onap.aai.esr.entity.rest.VimRestData; import org.onap.aai.esr.exception.ExtsysException; import org.onap.aai.esr.handle.VimHandler; -import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.ExtsysUtil; import org.onap.aai.esr.util.RestResponseUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -118,7 +118,7 @@ public class VimManager { LOGGER.info("query vim end.no match condition record"); return RestResponseUtil.getSuccessResponse(null); } else { - LOGGER.info("query vim end.info:" + ExtsysDbUtil.objectToString(list)); + LOGGER.info("query vim end.info:" + ExtsysUtil.objectToString(list)); // return RestResponseUtil.getSuccessResponse(new VimRestData(list.get(0))); return RestResponseUtil.getSuccessResponse(new VimRestData()); } @@ -168,7 +168,7 @@ public class VimManager { @Timed public Response updatevims(@ApiParam(value = "vim", required = true) VimData vim, @ApiParam(value = "vim id", required = true) @PathParam("vimId") String vimId) { - LOGGER.info("start update vim .id:" + vimId + " info:" + ExtsysDbUtil.objectToString(vim)); + LOGGER.info("start update vim .id:" + vimId + " info:" + ExtsysUtil.objectToString(vim)); VimData newData; try { newData = handler.update(vim, vimId); @@ -198,7 +198,7 @@ public class VimManager { response = String.class)}) @Timed public Response addvims(@ApiParam(value = "vim", required = true) VimData vim) { - LOGGER.info("start add vim" + " info:" + ExtsysDbUtil.objectToString(vim)); + LOGGER.info("start add vim" + " info:" + ExtsysUtil.objectToString(vim)); VimData vimData; try { vimData = handler.add(vim); diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java index 53294aa..d01114e 100644 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java @@ -26,7 +26,7 @@ import org.onap.aai.esr.entity.aai.VnfmData; import org.onap.aai.esr.entity.rest.VnfmRestData; import org.onap.aai.esr.exception.ExtsysException; import org.onap.aai.esr.handle.VnfmHandler; -import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.ExtsysUtil; import org.onap.aai.esr.util.RestResponseUtil; import org.onap.aai.esr.wrapper.VnfmManagerWrapper; import org.slf4j.Logger; @@ -129,7 +129,7 @@ public class VnfmManager { @Timed public Response updateVnfm(@ApiParam(value = "vnfm", required = true) VnfmRestData vnfm, @ApiParam(value = "vnfm id", required = true) @PathParam("vnfmId") String vnfmId) { - LOGGER.info("start update vnfm .id:" + vnfmId + " info:" + ExtsysDbUtil.objectToString(vnfm)); + LOGGER.info("start update vnfm .id:" + vnfmId + " info:" + ExtsysUtil.objectToString(vnfm)); return VnfmManagerWrapper.getInstance().updateVnfm(vnfm, vnfmId); } diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysDbUtil.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java similarity index 96% rename from esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysDbUtil.java rename to esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java index 093f3fc..72f8bd7 100644 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysDbUtil.java +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java @@ -24,8 +24,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.UUID; -public class ExtsysDbUtil { - private final static Logger logger = LoggerFactory.getLogger(ExtsysDbUtil.class); +public class ExtsysUtil { + private final static Logger logger = LoggerFactory.getLogger(ExtsysUtil.class); public static String generateId() { return UUID.randomUUID().toString(); diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java new file mode 100644 index 0000000..d88c9ae --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java @@ -0,0 +1,70 @@ +/** + * Copyright 2017 ZTE Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.aai.esr.wrapper; + +import java.util.ArrayList; + +import javax.ws.rs.core.Response; + +import org.onap.aai.esr.entity.rest.RegisterResponse; +import org.onap.aai.esr.entity.rest.ThirdPartySdncRestData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ThirdpatySdncWrapper { + + private static ThirdpatySdncWrapper thirdpatySdncWrapper; + private static final Logger LOG = LoggerFactory.getLogger(ThirdpatySdncWrapper.class); + + /** + * get ThirdpatySdncWrapper instance. + * @return ThirdpatySdnc manager wrapper instance + */ + public static ThirdpatySdncWrapper getInstance() { + if (thirdpatySdncWrapper == null) { + thirdpatySdncWrapper = new ThirdpatySdncWrapper(); + } + return thirdpatySdncWrapper; + } + + public Response registerThirdpartySdnc(ThirdPartySdncRestData thirdpartySdnc) { + //TODO + RegisterResponse result = null; + return Response.ok(result).build(); + } + + public Response updateThirdpartySdnc(ThirdPartySdncRestData thirdpartySdnc) { + //TODO + return Response.ok().build(); + } + + public Response queryThirdpartySdncList() { + //TODO + ArrayList thirdpartySdncList = new ArrayList(); + return Response.ok(thirdpartySdncList).build(); + } + + public Response queryThirdpartySdncById(String thirdpartySdncId) { + ThirdPartySdncRestData thirdpartySdnc = new ThirdPartySdncRestData(); + //TODO + return Response.ok(thirdpartySdnc).build(); + } + + public Response delThirdpartySdnc(String thirdpartySdncId) { + //TODO + return Response.noContent().build(); + } +} diff --git a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java index 6458737..6fb8f3a 100644 --- a/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java +++ b/esr-core/esr-mgr/src/test/java/org/onap/aai/esr/db/util/CatalogDbUtilTest.java @@ -19,41 +19,41 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Test; -import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.ExtsysUtil; public class CatalogDbUtilTest { @Test public void when_generate_id_is_not_null() { - String actualUuid = ExtsysDbUtil.generateId(); + String actualUuid = ExtsysUtil.generateId(); assertNotNull(actualUuid); } @Test public void when_input_empty_string_output_false() { boolean expect = false; - boolean actual = ExtsysDbUtil.isNotEmpty(""); + boolean actual = ExtsysUtil.isNotEmpty(""); assertEquals(expect, actual); } @Test public void when_input_blan_string_output_true() { boolean expect = true; - boolean actual = ExtsysDbUtil.isNotEmpty(" "); + boolean actual = ExtsysUtil.isNotEmpty(" "); assertEquals(expect, actual); } @Test public void when_input_null_string_output_false() { boolean expect = false; - boolean actual = ExtsysDbUtil.isNotEmpty(null); + boolean actual = ExtsysUtil.isNotEmpty(null); assertEquals(expect, actual); } @Test public void when_input_str_string_output_true() { boolean expect = true; - boolean actual = ExtsysDbUtil.isNotEmpty("str"); + boolean actual = ExtsysUtil.isNotEmpty("str"); assertEquals(expect, actual); }