- private DataNode fetchDataNodeFromDmiRegistryForCmHandle(final String cmHandle) {
- final String xpathForDmiRegistryToFetchCmHandle = "/dmi-registry/cm-handles[@id='" + cmHandle + "']";
- return cpsDataService.getDataNode(NCMP_DATASPACE_NAME,
- NCMP_DMI_REGISTRY_ANCHOR,
- xpathForDmiRegistryToFetchCmHandle,
- FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS);
- }
-
- private String prepareOperationBody(final GenericRequestBody requestBodyObject) {
- try {
- return objectMapper.writeValueAsString(requestBodyObject);
- } catch (final JsonProcessingException e) {
- log.error("Parsing error occurred while converting Object to JSON.");
- throw new NcmpException("Parsing error occurred while converting given object to JSON.",
- e.getMessage());
- }
- }
-
- private static Map<String, String> getCmHandlePropertiesAsMap(
- final Collection<DataNode> cmHandlePropertiesAsDataNode) {
- if (cmHandlePropertiesAsDataNode.isEmpty()) {
- return Collections.emptyMap();
- }
- final Map<String, String> cmHandlePropertiesAsMap = new LinkedHashMap<>();
- for (final DataNode dataNode: cmHandlePropertiesAsDataNode) {
- cmHandlePropertiesAsMap.put(String.valueOf(dataNode.getLeaves().get("name")),
- String.valueOf(dataNode.getLeaves().get("value")));
- }
- return cmHandlePropertiesAsMap;
- }
-
- private static Map<String, String> getCmHandlePropertiesAsMap(
- final List<AdditionalProperty> cmHandlePropertiesAsList) {
- if (cmHandlePropertiesAsList == null || cmHandlePropertiesAsList.isEmpty()) {
- return Collections.emptyMap();
- }
- final Map<String, String> cmHandlePropertiesAsMap = new LinkedHashMap<>();
- for (final AdditionalProperty additionalProperty: cmHandlePropertiesAsList) {
- cmHandlePropertiesAsMap.put(additionalProperty.getName(),
- additionalProperty.getValue());
- }
- return cmHandlePropertiesAsMap;
+ /**
+ * THis method registers a cm handle and intiates modules sync.
+ *
+ * @param dmiPluginRegistration dmi plugin registration information.
+ * @throws JsonProcessingException thrown if json is malformed or missing.
+ */
+ public void parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(
+ final DmiPluginRegistration dmiPluginRegistration) throws JsonProcessingException {
+ final PersistenceCmHandlesList createdPersistenceCmHandlesList =
+ getUpdatedPersistenceCmHandlesList(dmiPluginRegistration, dmiPluginRegistration.getCreatedCmHandles());
+ registerAndSyncNewCmHandles(createdPersistenceCmHandlesList);