diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2017-09-18 12:58:10 +0530 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2017-09-18 12:58:10 +0530 |
commit | 043f000141590ef5c5944b6d717c7a592df69c47 (patch) | |
tree | 32a29bf25d81be8e5c08ce793d395ff2a9f43a3e /adapters/mso-sdnc-adapter/src/main/java | |
parent | 5e2aa1fec3c51e8eb0e6b43285c8414105a51b2f (diff) |
Fixed issues in adapter package
Issue-Id: SO-141
Change-Id: I1a6905aa7e1328e47b3d0f7580a1dca33c6a069c
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'adapters/mso-sdnc-adapter/src/main/java')
7 files changed, 67 insertions, 31 deletions
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java index 28f5403afd..757ea8207d 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -271,7 +272,7 @@ public class SDNCRestClient implements Runnable { msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e); alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); - return(sdncResp); + return sdncResp; } finally { @@ -308,18 +309,23 @@ public class SDNCRestClient implements Runnable { SDNCCallbackAdapterPortType cbPort = cbSvc.getSDNCCallbackAdapterSoapHttpPort(); BindingProvider bp = (BindingProvider)cbPort; - + + if(null != wsdlUrl) { bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl.toExternalForm()); + } + else { + msoLogger.debug("wsdlUrl is NULL:"); + } //authentication try { - Map<String, Object> req_ctx = bp.getRequestContext(); - Map<String, List<String>> headers = new HashMap<String, List<String>>(); + Map<String, Object> reqCtx = bp.getRequestContext(); + Map<String, List<String>> headers = new HashMap<>(); String userCredentials = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getEncryptedProperty(Constants.BPEL_AUTH_PROP, Constants.DEFAULT_BPEL_AUTH, Constants.ENCRYPTION_KEY); String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers); + reqCtx.put(MessageContext.HTTP_REQUEST_HEADERS, headers); headers.put ("Authorization", Collections.singletonList(basicAuth)); } catch (Exception e2) { diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java index 656334f2e7..d41291420e 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResource.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,7 +172,7 @@ public class SDNCNotifyResource { msoLogger.error (MessageEnum.RA_MISSING_PARAM, Constants.SDNC_SVCCFGRESP_ROOT + Constants.SDNC_RESP_MSG, "SDNC", "SDNCNotify", MsoLogger.ErrorCode.DataError, "Exception - Missing param", e); } - String bpelUrl = null; + String bpelUrl; /* * TODO Hibernate * try { @@ -182,8 +183,10 @@ public class SDNCNotifyResource { * logger.error("Unable to get SDNC_CALLBACK_URL from ActiveRequests, using default for reqid:" + reqId, e); * } */ + + bpelUrl = SDNCAdapterPortTypeImpl.getProperty (Constants.BPEL_URL_PROP, Constants.DEFAULT_BPEL_URL,msoPropertiesFactory); if (bpelUrl == null) { - bpelUrl = SDNCAdapterPortTypeImpl.getProperty (Constants.BPEL_URL_PROP, Constants.DEFAULT_BPEL_URL,msoPropertiesFactory); + msoLogger.debug("bpelUrl is NULL:"); } SDNCResponse sdncResp = new SDNCResponse (reqId); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java index 5b18002f22..0622c48c41 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,7 +156,7 @@ public class BPRestCallback { try { EntityUtils.consume(httpResponse.getEntity()); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } @@ -163,7 +164,7 @@ public class BPRestCallback { try { method.reset(); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java index 1e28920ab2..893ff82f11 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCAdapterUtils.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,16 +28,24 @@ import org.w3c.dom.NodeList; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; +import org.openecomp.mso.logger.MsoLogger; /** * Utility methods used by SDNCAdapterRest. */ public final class SDNCAdapterUtils { - /** + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + /** + * Instantiation is not allowed. + */ + private SDNCAdapterUtils() { + } + + /** * Returns a node's child elements in a list. */ public static List<Element> childElements(Node node) { - List<Element> elements = new ArrayList<Element>(); + List<Element> elements = new ArrayList<>(); NodeList nodeList = node.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { @@ -58,13 +67,8 @@ public final class SDNCAdapterUtils { try { return UriUtils.encodePathSegment(pathSegment, "UTF-8"); } catch (UnsupportedEncodingException e) { + LOGGER.debug("Exception:", e); throw new RuntimeException("UTF-8 encoding is not supported"); } } - - /** - * Instantiation is not allowed. - */ - private SDNCAdapterUtils() { - } }
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java index 19a93da5b5..262d23bd09 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,9 +104,15 @@ public abstract class SDNCConnector { String userCredentials = SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - method.setHeader("Authorization", authorization); + if(null != method) { + method.setHeader("Authorization", authorization); + method.setHeader("Accept", "application/yang.data+xml"); + } + else { + LOGGER.debug("method is NULL:"); + } - method.setHeader("Accept", "application/yang.data+xml"); + httpResponse = client.execute(method); @@ -134,8 +141,14 @@ public abstract class SDNCConnector { } httpResponse = null; + + if(null != method) { + method.reset(); + } + else { + LOGGER.debug("method is NULL:"); + } - method.reset(); method = null; LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", ""); @@ -161,7 +174,7 @@ public abstract class SDNCConnector { try { EntityUtils.consume(httpResponse.getEntity()); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } @@ -169,7 +182,7 @@ public abstract class SDNCConnector { try { method.reset(); } catch (Exception e) { - // Ignore + LOGGER.debug("Exception:", e); } } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java index 6ea43d828c..2263ab74df 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCEventParser.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ package org.openecomp.mso.adapters.sdnc.sdncrest; import org.openecomp.mso.adapters.sdncrest.SDNCEvent; +import org.openecomp.mso.logger.MsoLogger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -33,7 +35,13 @@ import java.text.ParseException; * SDNCConnector for "agnostic" API services. */ public class SDNCEventParser { - /** + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); + + // Instantiation is not allowed. + private SDNCEventParser() { + } + + /** * Parses SDNC event XML. If the content can be parsed and contains all required * elements, then an object is returned. Otherwise, a ParseException is thrown. * This method performs no logging or alarming. @@ -79,7 +87,7 @@ public class SDNCEventParser { } else if ("event-correlator".equals(child.getNodeName())) { eventCorrelator = child.getTextContent(); } else if ("event-parameters".equals(child.getNodeName())) { - eventParameters = (Element) child; + eventParameters = child; } } @@ -146,11 +154,8 @@ public class SDNCEventParser { } catch (ParseException e) { throw e; } catch (Exception e) { - throw new ParseException("Failed to parse SDNC event", 0); + LOGGER.debug("Exception:", e); + throw new ParseException("Failed to parse SDNC event:", 0 ); } } - - // Instantiation is not allowed. - private SDNCEventParser() { - } }
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java index e12384071c..f0fcf18afd 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,12 +35,14 @@ import java.net.HttpURLConnection; import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import org.openecomp.mso.logger.MsoLogger; /** * SDNCConnector for "agnostic" API services. */ public class SDNCServiceRequestConnector extends SDNCConnector { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); @Override protected SDNCResponseCommon createResponseFromContent(int statusCode, String statusMessage, String responseContent, TypedRequestTunables rt) { @@ -99,7 +102,7 @@ public class SDNCServiceRequestConnector extends SDNCConnector { String responseMessage = null; String svcRequestId = null; String ackFinalIndicator = null; - List<Element> responseParameters = new ArrayList<Element>(); + List<Element> responseParameters = new ArrayList<>(); for (Element child : SDNCAdapterUtils.childElements(configurationResponseCommon)) { if ("response-code".equals(child.getNodeName())) { @@ -133,7 +136,7 @@ public class SDNCServiceRequestConnector extends SDNCConnector { ackFinalIndicator = "Y"; } - if (!ackFinalIndicator.equals("Y") && !ackFinalIndicator.equals("N")) { + if (!ackFinalIndicator.equals("Y") && !"N".equals(ackFinalIndicator)) { throw new ParseException("Invalid ack-final-indicator in SDNC response: '" + ackFinalIndicator + "'", 0); } @@ -189,6 +192,7 @@ public class SDNCServiceRequestConnector extends SDNCConnector { } catch (ParseException e) { throw e; } catch (Exception e) { + LOGGER.debug("Exception:", e); throw new ParseException("Failed to parse SDNC response", 0); } } |