Fix SME components cache after deployment 20/15220/1
authoraravind.est <aravindhan.a@est.tech>
Wed, 12 Nov 2025 11:42:02 +0000 (11:42 +0000)
committeraravind.est <aravindhan.a@est.tech>
Wed, 12 Nov 2025 11:42:02 +0000 (11:42 +0000)
After deployment SME components generated id's updated.

Issue-ID: NONRTRIC-1082
Change-Id: I03473b598b143228d79627860b9d22e13233b640
Signed-off-by: aravind.est <aravindhan.a@est.tech>
rapp-manager-application/src/main/java/org/oransc/rappmanager/service/RappService.java
rapp-manager-sme/src/main/java/org/oransc/rappmanager/sme/service/SmeDeployer.java

index 8ce68b5..2fb30b0 100644 (file)
@@ -117,6 +117,7 @@ public class RappService {
             rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.DEPLOYING);
             if (rappDeployers.parallelStream()
                         .allMatch(rappDeployer -> rappDeployer.deployRappInstance(rapp, rappInstance))) {
+                rappCacheService.putRapp(rapp);
                 return ResponseEntity.accepted().build();
             }
             throw new RappHandlerException(HttpStatus.BAD_GATEWAY, rappInstance.getReason());
@@ -133,6 +134,7 @@ public class RappService {
             rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.UNDEPLOYING);
             if (rappDeployers.parallelStream()
                         .allMatch(rappDeployer -> rappDeployer.undeployRappInstance(rapp, rappInstance))) {
+                rappCacheService.putRapp(rapp);
                 return ResponseEntity.accepted().build();
             }
             throw new RappHandlerException(HttpStatus.BAD_GATEWAY, rappInstance.getReason());
index e7fa608..4c9748e 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START======================================================================
  * Copyright (C) 2023 Nordix Foundation. All rights reserved.
- * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. 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.
@@ -22,6 +22,7 @@ package org.oransc.rappmanager.sme.service;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 import lombok.RequiredArgsConstructor;
 import org.oransc.rappmanager.models.RappDeployer;
@@ -115,6 +116,9 @@ public class SmeDeployer implements RappDeployer {
                                 s -> deletePublishApi(s, rappInstance.getSme().getApfId())));
                 Optional.ofNullable(rappInstance.getSme().getProviderFunctionIds())
                         .ifPresent(providerList -> providerList.forEach(this::deleteProviderFunc));
+                rappInstance.getSme().setInvokerIds(null);
+                rappInstance.getSme().setServiceApiIds(null);
+                rappInstance.getSme().setProviderFunctionIds(null);
                 rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYED);
                 return true;
             } catch (Exception e) {
@@ -222,14 +226,12 @@ public class SmeDeployer implements RappDeployer {
             if (invokerPayload != null) {
                 List<APIInvokerEnrolmentDetails> apiInvokerEnrolmentDetails =
                         objectMapper.readValue(invokerPayload, new TypeReference<>() { });
-                apiInvokerEnrolmentDetails.forEach(apiInvokerEnrolmentDetail -> {
+                List<String> invokerIds = apiInvokerEnrolmentDetails.stream().map(apiInvokerEnrolmentDetail -> {
                     APIInvokerEnrolmentDetails apiInvokerEnrolmentDetailsResponse =
                             invokerDefaultApiClient.postOnboardedInvokers(apiInvokerEnrolmentDetail);
-                    if (apiInvokerEnrolmentDetailsResponse.getApiList() != null) {
-                        rappInstance.getSme()
-                                .setInvokerIds(List.of(apiInvokerEnrolmentDetailsResponse.getApiInvokerId()));
-                    }
-                });
+                    return apiInvokerEnrolmentDetailsResponse.getApiInvokerId();
+                }).filter(Objects::nonNull).toList();
+                rappInstance.getSme().setInvokerIds(invokerIds);
                 return true;
             }
         } catch (Exception e) {