summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-08-31 12:35:16 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-08-31 12:35:16 +0800
commit50439f3a9d1c1d99fc644ae71c68971e8e46b0e7 (patch)
tree5122f3fdc50a0696d8b253b498ebbb24480e22ca
parent49461a1e9d3b0133671e82cdb67fbc06ae845ca3 (diff)
Add the EMS REST API definition.
add EMS REST API definition. change API base url. Change-Id: I7b3884799a6a2fad13f0c2940c004427043ab113 Issue-ID: AAI-243 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
-rw-r--r--esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml16
-rw-r--r--esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java73
-rw-r--r--esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java70
-rw-r--r--esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java5
4 files changed, 79 insertions, 85 deletions
diff --git a/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml b/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml
index 46529d8..b7a6c69 100644
--- a/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml
+++ b/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml
@@ -20,20 +20,6 @@ defaultName: ${DW_DEFAULT_NAME:-Stranger}
# the micro service ip
serviceIp:
msbServerAddr: http://127.0.0.1:80
-#database
-database:
-
- # the name of your JDBC driver
- driverClass: com.mysql.jdbc.Driver
-
- # the username
- user: extsys
-
- # the password
- password: extsys
-
- # the JDBC URL
- url: jdbc:mysql://127.0.0.1:3306/extsys
# use the simple server factory if you only want to run on a single port
#server:
@@ -43,7 +29,7 @@ database:
# port: 8080
server:
type: simple
- rootPath: '/onapapi/aai/esr/v1/*'
+ rootPath: '/api/aai-esr-server/v1/*'
applicationContextPath: /
adminContextPath: /admin
connector:
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 1542f83..bc338e1 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
@@ -29,6 +29,7 @@ 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.RestResponseUtil;
+import org.onap.aai.esr.wrapper.EmsManagerWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,26 +70,7 @@ public class EmsManager {
@Timed
public Response queryEmsList() {
LOGGER.info("start query all ems!");
- List<EmsData> list;
- try {
- list = handler.getAll();
- } catch (ExtsysException error) {
- LOGGER.error("query all ems failed.errorMsg:" + error.getErrorMsg());
- return RestResponseUtil.getErrorResponse(error);
- }
- if (list == null || list.size() <= 0) {
- LOGGER.info("query all ems end.no match condition record");
- return RestResponseUtil.getSuccessResponse(new ArrayList<EmsRestData>());
- } else {
- LOGGER.info("query all ems end.size:" + list.size());
- ArrayList<EmsRestData> restList = new ArrayList<EmsRestData>();
- for (int i = 0; i < list.size(); i++) {
-// restList.add(new EmsRestData(list.get(i)));
- //TODO
- }
- return RestResponseUtil.getSuccessResponse(restList);
- }
-
+ return EmsManagerWrapper.getInstance().queryEmsList();
}
/**
@@ -108,21 +90,7 @@ public class EmsManager {
@Timed
public Response queryemsById(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) {
LOGGER.info("start query ems by id." + emsId);
- List<EmsData> list;
- try {
- list = handler.getEmsById(emsId);
- } catch (ExtsysException error) {
- LOGGER.error("query ems failed.errorMsg:" + error.getErrorMsg());
- return RestResponseUtil.getErrorResponse(error);
- }
- if (list == null || list.size() <= 0) {
- LOGGER.info("query ems end.no match condition record");
- return RestResponseUtil.getSuccessResponse(null);
- } else {
- LOGGER.info("query ems end.info:" + ExtsysDbUtil.objectToString(list));
-// return RestResponseUtil.getSuccessResponse(new EmsRestData(list.get(0)));
- return RestResponseUtil.getSuccessResponse(new EmsRestData());
- }
+ return EmsManagerWrapper.getInstance().queryEmsById(emsId);
}
/**
@@ -141,14 +109,7 @@ public class EmsManager {
@Timed
public Response delems(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) {
LOGGER.info("start delete ems .id:" + emsId);
- try {
- handler.delete(emsId);
- } catch (ExtsysException error) {
- LOGGER.error("delete ems failed.errorMsg:" + error.getErrorMsg());
- return RestResponseUtil.getErrorResponse(error);
- }
- LOGGER.info(" delete ems end !");
- return Response.noContent().build();
+ return EmsManagerWrapper.getInstance().delEms(emsId);
}
/**
@@ -167,23 +128,14 @@ public class EmsManager {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
response = String.class)})
@Timed
- public Response updateemss(@ApiParam(value = "ems", required = true) EmsData ems,
+ 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));
- EmsData newData;
- try {
- newData = handler.update(ems, emsId);
- } catch (ExtsysException error) {
- LOGGER.error("update ems failed.errorMsg:" + error.getErrorMsg());
- return RestResponseUtil.getErrorResponse(error);
- }
- LOGGER.info(" update ems end !");
-// return RestResponseUtil.getSuccessResponse(new EmsRestData(newData));
return RestResponseUtil.getSuccessResponse(new EmsRestData());
}
/**
- * add ems.
+ * register ems.
*/
@POST
@Path("")
@@ -198,17 +150,8 @@ public class EmsManager {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
response = String.class)})
@Timed
- public Response addemss(@ApiParam(value = "ems", required = true) EmsData ems) {
+ public Response registerEms(@ApiParam(value = "ems", required = true) EmsRestData ems) {
LOGGER.info("start add ems" + " info:" + ExtsysDbUtil.objectToString(ems));
- EmsData emsData;
- try {
- emsData = handler.add(ems);
- } catch (ExtsysException error) {
- LOGGER.error("add ems failed.errorMsg:" + error.getErrorMsg());
- return RestResponseUtil.getErrorResponse(error);
- }
- LOGGER.info(" add ems end !");
-// return RestResponseUtil.getCreateSussceeResponse(new EmsRestData(emsData));
- return RestResponseUtil.getCreateSussceeResponse(new EmsRestData());
+ return EmsManagerWrapper.getInstance().registerEms(ems);
}
}
diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
new file mode 100644
index 0000000..7b4ee8e
--- /dev/null
+++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.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.EmsRestData;
+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 EmsManagerWrapper {
+ private static EmsManagerWrapper emsManagerWrapper;
+ private static final Logger LOG = LoggerFactory.getLogger(EmsManagerWrapper.class);
+
+ /**
+ * get VnfmManagerWrapper instance.
+ * @return vnfm manager wrapper instance
+ */
+ public static EmsManagerWrapper getInstance() {
+ if (emsManagerWrapper == null) {
+ emsManagerWrapper = new EmsManagerWrapper();
+ }
+ return emsManagerWrapper;
+ }
+
+ public Response registerEms(EmsRestData ems) {
+ //TODO
+ RegisterResponse result = null;
+ return Response.ok(result).build();
+ }
+
+ public Response updateEms(EmsRestData ems) {
+ //TODO
+ return Response.ok().build();
+ }
+
+ public Response queryEmsList() {
+ //TODO
+ ArrayList<EmsRestData> emsList = new ArrayList<EmsRestData>();
+ return Response.ok(emsList).build();
+ }
+
+ public Response queryEmsById(String emsId) {
+ EmsRestData ems = new EmsRestData();
+ //TODO
+ return Response.ok(ems).build();
+ }
+
+ public Response delEms(String emsId) {
+ //TODO
+ return Response.noContent().build();
+ }
+}
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
index 80b9dbb..a1ac53c 100644
--- 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
@@ -39,11 +39,6 @@ public class VnfmManagerWrapper {
return vnfmManagerWrapper;
}
- /**
- * query package by id.
- * @param csarId package id
- * @return Response
- */
public Response registerVnfm(VnfmRestData vnfm) {
//TODO
RegisterResponse result = null;