// This is because during a save we receive a list of nodes from RedirectMappingsData, and we need to keep track
// if an existing stored redirect node has been deleted or not.
Set<String> notFoundNodeMappings = new HashSet<String>(mappings.getNodeMap().keySet());
for (String key : mappingsData.getMappings().keySet()) {
NodeMap nodeMap = mappings.getNodeMap().get(Text.escapeIllegalJcrChars(key));
if (nodeMap == null) {
nodeMap = mappings.createNode();
mappings.getNodeMap().put(Text.escapeIllegalJcrChars(key), nodeMap);
} else {
notFoundNodeMappings.remove(Text.escapeIllegalJcrChars(key));
}
nodeMap.setOriginNode(key);
nodeMap.setRedirectNode(mappingsData.getMappings().get(key));
}
// remove all the device conditions which were not in the RedirectConditionData list
for (String nodeName : notFoundNodeMappings) {
mappings.getNodeMap().remove(nodeName);