From: lizi00164331 Date: Wed, 30 Aug 2017 08:01:25 +0000 (+0800) Subject: Define the REST API of VNFM. X-Git-Tag: v1.0.0~97 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=commitdiff_plain;h=49461a1e9d3b0133671e82cdb67fbc06ae845ca3 Define the REST API of VNFM. Define the Rest API of VNFM in esr-server. including the CRUD API. Change-Id: I632e1cf49ae4a0f6b29cf9ee91b3b49f3aaa0efd Issue-ID: AAI-241 Signed-off-by: lizi00164331 --- diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/RegisterResponse.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/RegisterResponse.java new file mode 100644 index 0000000..617edf9 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/RegisterResponse.java @@ -0,0 +1,30 @@ +/** + * 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.entity.rest; + +public class RegisterResponse { + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiRest.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiRest.java new file mode 100644 index 0000000..e4b7f92 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiRest.java @@ -0,0 +1,37 @@ +/** + * 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.externalservice.aai; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; + +@Path("/aai/v11") +public interface AaiRest { + +@Path("") +@POST +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, + ServiceRegisterEntity entity)throws Exception; +} \ No newline at end of file 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 072da50..53294aa 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 @@ -28,6 +28,7 @@ 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.RestResponseUtil; +import org.onap.aai.esr.wrapper.VnfmManagerWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,26 +69,7 @@ public class VnfmManager { @Timed public Response queryVnfmList() { LOGGER.info("start query all vnfm!"); - List list; - try { - list = handler.getAll(); - } catch (ExtsysException error) { - LOGGER.error("query all vnfm failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - if (list == null || list.size() <= 0) { - LOGGER.info("query all vnfm end.no match condition record"); - return RestResponseUtil.getSuccessResponse(new ArrayList()); - } else { - LOGGER.info("query all vnfm end.size:" + list.size()); - ArrayList restList = new ArrayList(); - for (int i = 0; i < list.size(); i++) { -// restList.add(new VnfmRestData(list.get(i))); - restList.add(new VnfmRestData()); - } - return RestResponseUtil.getSuccessResponse(restList); - } - + return VnfmManagerWrapper.getInstance().queryVnfmList(); } /** @@ -107,21 +89,7 @@ public class VnfmManager { @Timed public Response queryVnfmById(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) { LOGGER.info("start query vnfm by id." + vnfmId); - List list; - try { - list = handler.getVnfmById(vnfmId); - } catch (ExtsysException error) { - LOGGER.error("query vnfm failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - if (list == null || list.size() <= 0) { - LOGGER.info("query vnfm end.no match condition record"); - return RestResponseUtil.getSuccessResponse(null); - } else { - LOGGER.info("query vnfm end.info:" + ExtsysDbUtil.objectToString(list)); -// return RestResponseUtil.getSuccessResponse(new VnfmRestData(list.get(0))); - return RestResponseUtil.getSuccessResponse(new VnfmRestData()); - } + return VnfmManagerWrapper.getInstance().queryVnfmById(vnfmId); } /** @@ -140,14 +108,7 @@ public class VnfmManager { @Timed public Response delVnfm(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) { LOGGER.info("start delete vnfm .id:" + vnfmId); - try { - handler.delete(vnfmId); - } catch (ExtsysException error) { - LOGGER.error("delete vnfm failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - LOGGER.info(" delete vnfm end !"); - return Response.noContent().build(); + return VnfmManagerWrapper.getInstance().delVnfm(vnfmId); } /** @@ -166,19 +127,10 @@ public class VnfmManager { @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)}) @Timed - public Response updateVnfms(@ApiParam(value = "vnfm", required = true) VnfmData vnfm, + 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)); - VnfmData newData; - try { - newData = handler.update(vnfm, vnfmId); - } catch (ExtsysException error) { - LOGGER.error("update vnfm failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - LOGGER.info(" update vnfm end !"); -// return RestResponseUtil.getSuccessResponse(new VnfmRestData(newData)); - return RestResponseUtil.getSuccessResponse(new VnfmRestData()); + return VnfmManagerWrapper.getInstance().updateVnfm(vnfm, vnfmId); } /** @@ -197,17 +149,7 @@ public class VnfmManager { @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)}) @Timed - public Response addVnfms(@ApiParam(value = "vnfm", required = true) VnfmData vnfm) { - LOGGER.info("start add vnfm" + " info:" + ExtsysDbUtil.objectToString(vnfm)); - VnfmData vnfmData; - try { - vnfmData = handler.add(vnfm); - } catch (ExtsysException error) { - LOGGER.error("add vnfm failed.errorMsg:" + error.getErrorMsg()); - return RestResponseUtil.getErrorResponse(error); - } - LOGGER.info(" add vnfm end !"); -// return RestResponseUtil.getCreateSussceeResponse(new VnfmRestData(vnfmData)); - return RestResponseUtil.getCreateSussceeResponse(new VnfmRestData()); + public Response registerVnfm(@ApiParam(value = "vnfm", required = true) VnfmRestData vnfm) { + return VnfmManagerWrapper.getInstance().registerVnfm(vnfm); } } diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java new file mode 100644 index 0000000..80b9dbb --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java @@ -0,0 +1,74 @@ +/** + * 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.VnfmRestData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VnfmManagerWrapper { + private static VnfmManagerWrapper vnfmManagerWrapper; + private static final Logger LOG = LoggerFactory.getLogger(VnfmManagerWrapper.class); + + /** + * get VnfmManagerWrapper instance. + * @return vnfm manager wrapper instance + */ + public static VnfmManagerWrapper getInstance() { + if (vnfmManagerWrapper == null) { + vnfmManagerWrapper = new VnfmManagerWrapper(); + } + return vnfmManagerWrapper; + } + + /** + * query package by id. + * @param csarId package id + * @return Response + */ + public Response registerVnfm(VnfmRestData vnfm) { + //TODO + RegisterResponse result = null; + return Response.ok(result).build(); + } + + public Response updateVnfm(VnfmRestData vnfm, String vnfmId) { + //TODO + return Response.ok().build(); + } + + public Response queryVnfmList() { + ArrayList vnfmList = new ArrayList(); + //TODO + return Response.ok(vnfmList).build(); + } + + public Response queryVnfmById(String vnfmId) { + VnfmRestData vnfm = new VnfmRestData(); + //TODO + return Response.ok(vnfm).build(); + } + + public Response delVnfm(String vnfmId) { + //TODO + return Response.noContent().build(); + } +}