+ if (updateProperties.isEmpty()) {
+ nodeConfigList.remove(nodeId);
+ } else {
+ if (!nodeConfigList.replace(nodeId, sc, switchConfig)) {
+ return new Status(StatusCode.CONFLICT, "Cluster conflict: Unable to update node configuration");
+ }
+ }
+ }
+ Node node = Node.fromString(nodeId);
+ Map<String, Property> propMapCurr = nodeProps.get(node);
+ if (propMapCurr == null) {
+ return new Status(StatusCode.SUCCESS);
+ }
+ Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
+ if (!prevNodeProperties.isEmpty()) {
+ for (String prop : prevNodeProperties.keySet()) {
+ if (!updateProperties.containsKey(prop)) {
+ if (prop.equals(Description.propertyName)) {
+ Map<Node, Map<String, Property>> nodeProp = this.inventoryService.getNodeProps();
+ if (nodeProp.get(node) != null) {
+ propMap.put(Description.propertyName, nodeProp.get(node).get(Description.propertyName));
+ continue;
+ }
+ }
+ propMap.remove(prop);
+ }
+ }
+ }
+ propMap.putAll(updateProperties);
+ if (!nodeProps.replace(node, propMapCurr, propMap)) {
+ // TODO rollback using Transactionality
+ return new Status(StatusCode.CONFLICT, "Cluster conflict: Unable to update node configuration.");
+ }
+ if (modeChange) {
+ notifyModeChange(node, (mode == null) ? false : mode.isProactive());
+ }
+ return new Status(StatusCode.SUCCESS);
+ }