From 1ba64a4a45f26e8bdb58e866e540aa58f32e2e52 Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Wed, 20 Sep 2017 14:08:19 +0300 Subject: Change management and PNF support Issue-ID: VID-44, VID-48, VID-49, VID-50, VID-51, VID-52 Change-Id: I83e940aad2e4e294a0927b546c4c08ca8e539a65 Signed-off-by: Ofir Sonsino --- .../org/openecomp/aai/util/AAIRestInterface.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'vid-app-common/src/main/java/org/openecomp/aai') diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java index 243410050..d9bb5c1f4 100755 --- a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java +++ b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java @@ -253,6 +253,54 @@ public class AAIRestInterface { return false; } + + /** + * Rest put. + * + * @param fromAppId the from app id + * @param transId the trans id + * @param path the path + * @param payload the payload + * @param xml the xml + * @return the string + */ + public Response RestPut(String fromAppId, String transId, String path, String payload, boolean xml) { + String methodName = "RestPost"; + String url=""; + transId = UUID.randomUUID().toString(); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + + try { + + String responseType = "application/json"; + if (xml) + responseType = "application/xml"; + + initRestClient(); + + url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL) + path; + + final Response cres = client.target(url) + .request() + .accept(responseType) + .header("X-TransactionId", transId) + .header("X-FromAppId", fromAppId) + .put(Entity.entity(payload, MediaType.APPLICATION_JSON)); + + if (cres.getStatus() == 200 && cres.getStatus() <= 299) { + logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!"); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!"); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +" with status="+cres.getStatus()+", url="+url); + } + return cres; + } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString()); + } + return null; + } + + /** * Rest post. -- cgit 1.2.3-korg