Define the Rest API of VNFM in esr-server. including the CRUD API.
Change-Id: I632e1cf49ae4a0f6b29cf9ee91b3b49f3aaa0efd
Issue-ID: AAI-241
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
--- /dev/null
+/**
+ * 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;
+ }
+
+}
--- /dev/null
+/**
+ * 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
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;
@Timed
public Response queryVnfmList() {
LOGGER.info("start query all vnfm!");
- List<VnfmData> 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<VnfmRestData>());
- } else {
- LOGGER.info("query all vnfm end.size:" + list.size());
- ArrayList<VnfmRestData> restList = new ArrayList<VnfmRestData>();
- 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();
}
/**
@Timed
public Response queryVnfmById(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
LOGGER.info("start query vnfm by id." + vnfmId);
- List<VnfmData> 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);
}
/**
@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);
}
/**
@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);
}
/**
@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);
}
}
--- /dev/null
+/**
+ * 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<VnfmRestData> vnfmList = new ArrayList<VnfmRestData>();
+ //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();
+ }
+}