From 7a491c022d704583166afd8ba613ae94a6a7af04 Mon Sep 17 00:00:00 2001 From: "aravind.est" Date: Fri, 26 Apr 2024 10:45:30 +0100 Subject: [PATCH] Enable sample SME invoker to query dicovered endpoint SME invoker queries the endpoint received from SME service discovery. Issue-ID: NONRTRIC-981 Change-Id: I532aeecf53734d338189fc81740a99355ee2e1a1 Signed-off-by: aravind.est --- .../sample/rest/HelloWorldSmeInvokerComponent.java | 34 ++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/sample-services/hello-world-sme-invoker/src/main/java/org/oransc/nonrtric/sample/rest/HelloWorldSmeInvokerComponent.java b/sample-services/hello-world-sme-invoker/src/main/java/org/oransc/nonrtric/sample/rest/HelloWorldSmeInvokerComponent.java index 7d76b4f9..7902a3b7 100644 --- a/sample-services/hello-world-sme-invoker/src/main/java/org/oransc/nonrtric/sample/rest/HelloWorldSmeInvokerComponent.java +++ b/sample-services/hello-world-sme-invoker/src/main/java/org/oransc/nonrtric/sample/rest/HelloWorldSmeInvokerComponent.java @@ -60,24 +60,22 @@ public class HelloWorldSmeInvokerComponent { throw new CapifAccessException("Unexpected error"); } - //TODO The below should be uncommented once SME Manager provides an accessible URI - -// String helloWorldEndpoint = ""; -// List apiSetEndpoints = getApiSetEndpoints(apiResponse, baseUrl); -// if (apiSetEndpoints != null && !apiSetEndpoints.isEmpty()) { -// helloWorldEndpoint = apiSetEndpoints.get(0); -// } -// -// if (helloWorldEndpoint != null && !helloWorldEndpoint.isEmpty()) { -// try { -// String responseHelloWorld = restTemplate.getForObject(helloWorldEndpoint, String.class); -// logger.info("Response :- ", responseHelloWorld); -// } catch (IllegalArgumentException e) { -// throw new CapifAccessException("Error accessing the URL :- " + helloWorldEndpoint); -// } catch (Exception e) { -// throw new CapifAccessException("Unexpected error"); -// } -// } + String helloWorldEndpoint = ""; + List apiSetEndpoints = getApiSetEndpoints(apiResponse, baseUrl); + if (apiSetEndpoints != null && !apiSetEndpoints.isEmpty()) { + helloWorldEndpoint = apiSetEndpoints.get(0); + } + + if (helloWorldEndpoint != null && !helloWorldEndpoint.isEmpty()) { + try { + String responseHelloWorld = restTemplate.getForObject(helloWorldEndpoint, String.class); + logger.info("rApp SME Provider Response : {}", responseHelloWorld); + } catch (IllegalArgumentException e) { + throw new CapifAccessException("Error accessing the URL :- " + helloWorldEndpoint); + } catch (Exception e) { + throw new CapifAccessException("Unexpected error"); + } + } } } -- 2.16.6