+ cmHandleUpgradeResponses.add(
+ CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLE_INVALID_ID));
+ }
+ }
+ cmHandleUpgradeResponses.addAll(upgradeCmHandles(acceptedCmHandleStatePerCmHandle));
+ dmiPluginRegistrationResponse.setUpgradedCmHandles(cmHandleUpgradeResponses);
+ }
+
+ private Collection<String> checkAlternateIds(
+ final List<NcmpServiceCmHandle> cmHandlesToBeCreated,
+ final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses) {
+ final Collection<String> rejectedCmHandleIds = alternateIdChecker
+ .getIdsOfCmHandlesWithRejectedAlternateId(cmHandlesToBeCreated, AlternateIdChecker.Operation.CREATE);
+ cmHandleRegistrationResponses.addAll(CmHandleRegistrationResponse.createFailureResponses(
+ rejectedCmHandleIds, ALTERNATE_ID_ALREADY_ASSOCIATED));
+ return rejectedCmHandleIds;
+ }
+
+ private List<String> persistCmHandlesWithState(final DmiPluginRegistration dmiPluginRegistration,
+ final DmiPluginRegistrationResponse dmiPluginRegistrationResponse,
+ final List<NcmpServiceCmHandle> cmHandlesToBeCreated,
+ final Collection<String> rejectedCmHandleIds) {
+ final List<String> succeededCmHandleIds = new ArrayList<>(cmHandlesToBeCreated.size());
+ final List<YangModelCmHandle> yangModelCmHandlesToRegister = new ArrayList<>(cmHandlesToBeCreated.size());
+ final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
+ new ArrayList<>(cmHandlesToBeCreated.size());
+ for (final NcmpServiceCmHandle ncmpServiceCmHandle: cmHandlesToBeCreated) {
+ if (!rejectedCmHandleIds.contains(ncmpServiceCmHandle.getCmHandleId())) {
+ yangModelCmHandlesToRegister.add(getYangModelCmHandle(dmiPluginRegistration, ncmpServiceCmHandle));
+ cmHandleRegistrationResponses.add(
+ CmHandleRegistrationResponse.createSuccessResponse(ncmpServiceCmHandle.getCmHandleId()));
+ succeededCmHandleIds.add(ncmpServiceCmHandle.getCmHandleId());
+ }
+ }
+ lcmEventsCmHandleStateHandler.initiateStateAdvised(yangModelCmHandlesToRegister);
+ dmiPluginRegistrationResponse.setCreatedCmHandles(cmHandleRegistrationResponses);
+ return succeededCmHandleIds;
+ }
+
+ private YangModelCmHandle getYangModelCmHandle(final DmiPluginRegistration dmiPluginRegistration,
+ final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ return YangModelCmHandle.toYangModelCmHandle(
+ dmiPluginRegistration.getDmiPlugin(),
+ dmiPluginRegistration.getDmiDataPlugin(),
+ dmiPluginRegistration.getDmiModelPlugin(),
+ ncmpServiceCmHandle,
+ ncmpServiceCmHandle.getModuleSetTag(),
+ ncmpServiceCmHandle.getAlternateId());
+ }
+
+ private void processTrustLevels(final Collection<NcmpServiceCmHandle> cmHandlesToBeCreated,
+ final Collection<String> succeededCmHandleIds) {
+ final Map<String, TrustLevel> initialTrustLevelPerCmHandleId = new HashMap<>(cmHandlesToBeCreated.size());
+ for (final NcmpServiceCmHandle ncmpServiceCmHandle: cmHandlesToBeCreated) {
+ if (succeededCmHandleIds.contains(ncmpServiceCmHandle.getCmHandleId())) {
+ initialTrustLevelPerCmHandleId.put(ncmpServiceCmHandle.getCmHandleId(),
+ ncmpServiceCmHandle.getRegistrationTrustLevel());