summaryrefslogtreecommitdiffstats
path: root/esr-mgr
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-18 14:11:29 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-18 14:11:29 +0800
commita4771e502b3385e1cfc314e79deba7aca0c828c0 (patch)
treef36db55b7c870d63fece8a8297537e2e2e9cf30f /esr-mgr
parent54c4773879f0a39d463267070679ba3d4022419f (diff)
Realize thirdparty sdnc register API.
Change-Id: I65ddaa9cc96eacd21234425d33efe4ebe19211ea Issue-ID: AAI-315 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java11
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ThirdpartySdncRegisterProvider.java58
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/VimRegisterProvider.java (renamed from esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java)4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/VnfmRegisterProvider.java (renamed from esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java)4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java9
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java26
7 files changed, 98 insertions, 16 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
index 53e5fef..f21510e 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
@@ -35,7 +35,7 @@ public class CloudRegionProxy {
public static void registerVim(String cloudOwner, String cloudRegionId, CloudRegionDetail cloudRegion)
throws Exception {
- ClientConfig config = new ClientConfig(new RegisterVimProvider());
+ ClientConfig config = new ClientConfig(new VimRegisterProvider());
ICloudRegion registerVimServiceproxy = ConsumerFactory
.createConsumer(AaiAdapterConfig.getCloudInfrastructureAddr(), config, ICloudRegion.class);
registerVimServiceproxy.registerVIMService(transactionId, fromAppId, authorization, cloudOwner,
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
index 7328f97..cebab2c 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
@@ -16,6 +16,7 @@
package org.onap.aai.esr.externalservice.aai;
import org.glassfish.jersey.client.ClientConfig;
+import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
@@ -34,7 +35,7 @@ public class ExternalSystemProxy {
}
public static void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws Exception {
- ClientConfig config = new ClientConfig(new RegisterVnfmProvider());
+ ClientConfig config = new ClientConfig(new VnfmRegisterProvider());
IExternalSystem registerVnfmServiceproxy = ConsumerFactory
.createConsumer(AaiAdapterConfig.getExternalSystemAddr(), config, IExternalSystem.class);
registerVnfmServiceproxy.registerVNFM(transactionId, fromAppId, authorization, vnfmId,
@@ -52,4 +53,12 @@ public class ExternalSystemProxy {
public static void deleteVnfm(String vnfmId, String resourceVersion) throws Exception {
externalSystemproxy.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion);
}
+
+ public static void registerSdnc(String thirdpartySdncId, EsrThirdpartySdncDetail esrSdncDetail) throws Exception {
+ ClientConfig config = new ClientConfig(new ThirdpartySdncRegisterProvider());
+ IExternalSystem registerVnfmServiceproxy = ConsumerFactory
+ .createConsumer(AaiAdapterConfig.getExternalSystemAddr(), config, IExternalSystem.class);
+ registerVnfmServiceproxy.registerThirdpartySdnc(transactionId, fromAppId, authorization, thirdpartySdncId,
+ esrSdncDetail);
+ }
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ThirdpartySdncRegisterProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ThirdpartySdncRegisterProvider.java
new file mode 100644
index 0000000..61964fc
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ThirdpartySdncRegisterProvider.java
@@ -0,0 +1,58 @@
+/**
+ * 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 java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+public class ThirdpartySdncRegisterProvider implements MessageBodyWriter<EsrThirdpartySdncDetail>{
+
+ private static final Logger logger = LoggerFactory.getLogger(VimRegisterProvider.class);
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return EsrThirdpartySdncDetail.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(EsrThirdpartySdncDetail t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(EsrThirdpartySdncDetail t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ String json = new Gson().toJson(t, EsrThirdpartySdncDetail.class);
+ logger.info("the param to register VIM input is:" + json);
+ entityStream.write(json.getBytes("UTF-8"));
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/VimRegisterProvider.java
index 8f6394d..58a0c72 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/VimRegisterProvider.java
@@ -31,8 +31,8 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-public class RegisterVimProvider implements MessageBodyWriter<CloudRegionDetail>{
- private static final Logger logger = LoggerFactory.getLogger(RegisterVimProvider.class);
+public class VimRegisterProvider implements MessageBodyWriter<CloudRegionDetail>{
+ private static final Logger logger = LoggerFactory.getLogger(VimRegisterProvider.class);
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/VnfmRegisterProvider.java
index 42ad5f5..00ed0c5 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVnfmProvider.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/VnfmRegisterProvider.java
@@ -31,9 +31,9 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-public class RegisterVnfmProvider implements MessageBodyWriter<EsrVnfmDetail>{
+public class VnfmRegisterProvider implements MessageBodyWriter<EsrVnfmDetail>{
- private static final Logger logger = LoggerFactory.getLogger(RegisterVnfmProvider.class);
+ private static final Logger logger = LoggerFactory.getLogger(VnfmRegisterProvider.class);
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java
index b361527..2cf4a0a 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java
@@ -25,7 +25,7 @@ import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
public class ThirdpartySdncManagerUtil {
- public EsrThirdpartySdncDetail sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
+ public static EsrThirdpartySdncDetail sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
EsrThirdpartySdncDetail esrThirdpartySdnc = new EsrThirdpartySdncDetail();
sdncRegisterInfo.setThirdpartySdncId(ExtsysUtil.generateId());
esrThirdpartySdnc.setThirdpartySdncId(sdncRegisterInfo.getThirdpartySdncId());
@@ -35,11 +35,12 @@ public class ThirdpartySdncManagerUtil {
return esrThirdpartySdnc;
}
- private EsrSystemInfoList getEsrSystemInfoList(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
+ private static EsrSystemInfoList getEsrSystemInfoList(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
EsrSystemInfo authInfo = new EsrSystemInfo();
- authInfo.setResouceVersion(sdncRegisterInfo.getVersion());
+ authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
+ authInfo.setVersion(sdncRegisterInfo.getVersion());
authInfo.setSystemName(sdncRegisterInfo.getName());
authInfo.setServiceUrl(sdncRegisterInfo.getUrl());
authInfo.setVendor(sdncRegisterInfo.getVendor());
@@ -53,7 +54,7 @@ public class ThirdpartySdncManagerUtil {
return esrSystemInfoList;
}
- public ThirdpartySdncRegisterInfo esrSdnc2SdncRegisterInfo(EsrThirdpartySdncDetail esrSdnc) {
+ public static ThirdpartySdncRegisterInfo esrSdnc2SdncRegisterInfo(EsrThirdpartySdncDetail esrSdnc) {
ThirdpartySdncRegisterInfo registerSdncInfo = new ThirdpartySdncRegisterInfo();
EsrSystemInfo esrSystemInfo = esrSdnc.getEsrSystemInfoList().getEsrSystemInfo().get(0);
registerSdncInfo.setThirdpartySdncId(esrSdnc.getThirdpartySdncId());
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
index b06b1f7..9bc61ad 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
@@ -19,15 +19,18 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
+import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
+import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
+import org.onap.aai.esr.util.ThirdpartySdncManagerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ThirdpatySdncWrapper {
private static ThirdpatySdncWrapper thirdpatySdncWrapper;
-// private static final Logger LOG = LoggerFactory.getLogger(ThirdpatySdncWrapper.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ThirdpatySdncWrapper.class);
/**
* get ThirdpatySdncWrapper instance.
@@ -41,9 +44,20 @@ public class ThirdpatySdncWrapper {
}
public Response registerThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) {
- //TODO
- CommonRegisterResponse result = null;
- return Response.ok(result).build();
+ CommonRegisterResponse result = new CommonRegisterResponse();
+ EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail();
+ esrSdncDetail = ThirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc);
+ String sdncId = esrSdncDetail.getThirdpartySdncId();
+ try {
+ ExternalSystemProxy.registerSdnc(sdncId, esrSdncDetail);
+ result.setId(sdncId);
+ return Response.ok(result).build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOG.error("Register thirdParty SDNC failed !" + e.getMessage());
+ return Response.serverError().build();
+ }
+
}
public Response updateThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) {