diff options
author | seanbeirne <sean.beirne@est.tech> | 2023-10-17 11:03:16 +0100 |
---|---|---|
committer | Seán Beirne <sean.beirne@est.tech> | 2023-11-02 13:07:16 +0000 |
commit | f41dd3b24da2cc956c3d6e27fc14e409f11c65c0 (patch) | |
tree | 83d17101101a07061b6d2172e9895f05bfc51dc7 /cps-ncmp-service/src/main/java/org/onap | |
parent | e5c66c7fec638412e10d5abef14d2a7afc86cb23 (diff) |
Initial Registration with trustLevel on NCMP
- Updated NcmpServiceCmHandle class to include registration trustLevel
Issue-ID: CPS-1902
Signed-off-by: seanbeirne <sean.beirne@est.tech>
Change-Id: I7c97928f5cdd82f3036a57ea5f0c149e2872f4f1
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap')
2 files changed, 18 insertions, 8 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index febd1cf9c5..4ec00daea5 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -99,7 +99,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private final LcmEventsCmHandleStateHandler lcmEventsCmHandleStateHandler; private final CpsDataService cpsDataService; private final IMap<String, Object> moduleSyncStartedOnCmHandles; - private final Map<String, TrustLevel> trustLevelPerDmiPlugin; + private final Map<String, TrustLevel> trustLevelPerCmHandle; @Override public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule( @@ -113,6 +113,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } if (!dmiPluginRegistration.getCreatedCmHandles().isEmpty()) { + populateTrustLevelPerCmHandleCache(dmiPluginRegistration); dmiPluginRegistrationResponse.setCreatedCmHandles( parseAndProcessCreatedCmHandlesInRegistration(dmiPluginRegistration)); } @@ -127,8 +128,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService parseAndProcessUpgradedCmHandlesInRegistration(dmiPluginRegistration)); } - setTrustLevelPerDmiPlugin(dmiPluginRegistration); - return dmiPluginRegistrationResponse; } @@ -487,11 +486,17 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService return cmHandleStatePerCmHandle.keySet().stream().map(YangModelCmHandle::getId).toList(); } - private void setTrustLevelPerDmiPlugin(final DmiPluginRegistration dmiPluginRegistration) { - if (DmiPluginRegistration.isNullEmptyOrBlank(dmiPluginRegistration.getDmiDataPlugin())) { - trustLevelPerDmiPlugin.put(dmiPluginRegistration.getDmiPlugin(), TrustLevel.COMPLETE); - } else { - trustLevelPerDmiPlugin.put(dmiPluginRegistration.getDmiDataPlugin(), TrustLevel.COMPLETE); + private void populateTrustLevelPerCmHandleCache(final DmiPluginRegistration dmiPluginRegistration) { + for (final NcmpServiceCmHandle cmHandle: dmiPluginRegistration.getCreatedCmHandles()) { + if (cmHandle.getRegistrationTrustLevel() == null) { + if (trustLevelPerCmHandle.containsKey(cmHandle.getCmHandleId())) { + log.warn("CmHandle : {}, Already exists, Initial trustLevel ignored.", cmHandle.getCmHandleId()); + } else { + trustLevelPerCmHandle.put(cmHandle.getCmHandleId(), TrustLevel.COMPLETE); + } + } else { + trustLevelPerCmHandle.put(cmHandle.getCmHandleId(), cmHandle.getRegistrationTrustLevel()); + } } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java index 0b50346f81..f323079e0b 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java @@ -29,6 +29,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.onap.cps.ncmp.api.impl.inventory.CompositeState; +import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel; import org.springframework.validation.annotation.Validated; /** @@ -55,6 +56,9 @@ public class NcmpServiceCmHandle { @JsonSetter(nulls = Nulls.AS_EMPTY) private String moduleSetTag; + @JsonSetter(nulls = Nulls.AS_EMPTY) + private TrustLevel registrationTrustLevel; + /** * NcmpServiceCmHandle copy constructor. * @@ -67,5 +71,6 @@ public class NcmpServiceCmHandle { this.compositeState = ncmpServiceCmHandle.getCompositeState() != null ? new CompositeState( ncmpServiceCmHandle.getCompositeState()) : null; this.moduleSetTag = ncmpServiceCmHandle.getModuleSetTag(); + this.registrationTrustLevel = ncmpServiceCmHandle.getRegistrationTrustLevel(); } } |