diff options
author | a.sreekumar <ajith.sreekumar@bell.ca> | 2021-01-20 14:35:18 +0000 |
---|---|---|
committer | Ram Krishna Verma <ram_krishna.verma@bell.ca> | 2021-01-26 15:54:28 +0000 |
commit | 715ff2b45f99fe53b96acf7f7f23247df6cce38f (patch) | |
tree | f080542209af63217aadf2d18e41dbe1dbdad372 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src | |
parent | 05d98e3da6fc5188810fa110552391c37c69ddf9 (diff) |
Add logs for REST request/response in APEX
Change-Id: Ibf2cf19a1ec91473d8c655b87a712aa8738848c8
Issue-ID: POLICY-3003
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
(cherry picked from commit de9bb70b25d498e844c2c6205061aa9e5e9d8d7a)
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src')
-rw-r--r-- | plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java index aa951b823..54dba7a7c 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -47,8 +48,12 @@ import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventReceiver; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; +import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters.HttpMethod; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -308,23 +313,26 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer { restRequestThread = Thread.currentThread(); try { + if (restConsumerProperties.getHttpMethod().equals(HttpMethod.PUT) + || restConsumerProperties.getHttpMethod().equals(HttpMethod.POST)) { + NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, untaggedUrl, + request.getEvent().toString()); + } // Execute the REST request final Response response = sendEventAsRestRequest(untaggedUrl); - + // Get the event we received + final String eventJsonString = response.readEntity(String.class); + NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, untaggedUrl, eventJsonString); // Match the return code Matcher isPass = httpCodeFilterPattern.matcher(String.valueOf(response.getStatus())); // Check that the request worked if (!isPass.matches()) { final String errorMessage = "reception of event from URL \"" + restConsumerProperties.getUrl() - + "\" failed with status code " + response.getStatus() + " and message \"" - + response.readEntity(String.class) + "\""; + + "\" failed with status code " + response.getStatus(); throw new ApexEventRuntimeException(errorMessage); } - // Get the event we received - final String eventJsonString = response.readEntity(String.class); - // Check there is content if (StringUtils.isBlank(eventJsonString)) { final String errorMessage = |