diff options
author | Li Zi <li.zi30@zte.com.cn> | 2018-08-22 06:31:00 +0000 |
---|---|---|
committer | Li Zi <li.zi30@zte.com.cn> | 2018-08-22 06:31:22 +0000 |
commit | 0836ecdc1d78e7fb3c5c8c9be5bd48c4d70e234f (patch) | |
tree | d5cdb2236a47a2c3ac25f2e873e27579e06dc6af /esr-mgr/src | |
parent | d8db76d816a659b91085d4ae0614895ba1e78b65 (diff) |
Fix the nullpointer error when register PNF
Issue-ID: AAI-1496
Change-Id: I2fac156cb35e0a2306abac104a11581f9e363b71
Signed-off-by: Li Zi <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src')
3 files changed, 39 insertions, 1 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/PnfRegisterProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/PnfRegisterProvider.java index 596f062..ec83cc6 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/PnfRegisterProvider.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/PnfRegisterProvider.java @@ -15,6 +15,39 @@ */ package org.onap.aai.esr.externalservice.aai; -public class PnfRegisterProvider { +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.Pnf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.google.gson.Gson; +public class PnfRegisterProvider implements MessageBodyWriter<Pnf> { + private static final Logger logger = LoggerFactory.getLogger(PnfRegisterProvider.class); + + @Override + public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return Pnf.class.isAssignableFrom(type); + } + + @Override + public long getSize(Pnf t, Class<?> type, Type genericType, Annotation[] annotations, + MediaType mediaType) { + return -1; + } + + @Override + public void writeTo(Pnf t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) + throws IOException, WebApplicationException { + String json = new Gson().toJson(t, Pnf.class); + logger.info("the param to register PNF input is:" + json); + entityStream.write(json.getBytes("UTF-8")); + } } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/PnfManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/PnfManagerUtil.java index bb9b47e..20b9bdc 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/util/PnfManagerUtil.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/PnfManagerUtil.java @@ -28,6 +28,7 @@ public class PnfManagerUtil { Pnf pnf = new Pnf(); pnf.setPnfName(pnfRegisterInfo.getPnfId()); pnf.setPnfName2(pnfRegisterInfo.getUserLabel()); + pnf.setInMaint(false); String pnfId = pnfRegisterInfo.getSubnetId() + "-" +pnfRegisterInfo.getNeId(); pnf.setPnfId(pnfId); pnf.setEquipType(pnfRegisterInfo.getManagementType()); diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/PnfManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/PnfManagerWrapper.java index 7b5cf29..30d66cc 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/PnfManagerWrapper.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/PnfManagerWrapper.java @@ -24,6 +24,7 @@ import org.onap.aai.esr.entity.rest.PnfRegisterInfo; import org.onap.aai.esr.exception.ExceptionUtil; import org.onap.aai.esr.exception.ExtsysException; import org.onap.aai.esr.externalservice.aai.NetworkProxy; +import org.onap.aai.esr.util.ExtsysUtil; import org.onap.aai.esr.util.PnfManagerUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +37,7 @@ public class PnfManagerWrapper { private static PnfManagerUtil pnfManagerUtil = new PnfManagerUtil(); private static NetworkProxy networkProxy = new NetworkProxy(); + ExtsysUtil extsysUtil = new ExtsysUtil(); /** * get PnfManagerWrapper instance. * @@ -163,7 +165,9 @@ public class PnfManagerWrapper { * @return */ public Response registerPnf(PnfRegisterInfo pnfRegisterInfo) { + LOG.info("Register PNF with ESR, register info: " + extsysUtil.objectToString(pnfRegisterInfo)); Pnf pnf = pnfManagerUtil.pnfRegisterInfo2pnf(pnfRegisterInfo); + LOG.info("Register PNF with AAI, register info: " + extsysUtil.objectToString(pnf)); String pnfName = pnf.getPnfName(); try { networkProxy.registerPnf(pnfName, pnf); |