Operations to add new nodes with differing values should just override existing entries, instead of failing with the ALREADY_HAS result (#1198)

This commit is contained in:
Luck 2018-09-20 11:25:31 +01:00
parent 04e511026d
commit d28170cc3f
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 12 additions and 5 deletions

View File

@ -181,9 +181,16 @@ public final class NodeMap {
ImmutableContextSet context = node.getFullContexts().makeImmutable();
LocalizedNode n = localise(node);
this.map.put(context, n);
if (node.isGroupNode() && node.getValue()) {
this.inheritanceMap.put(context, n);
SortedSet<LocalizedNode> nodesInContext = this.map.get(context);
nodesInContext.removeIf(e -> e.equals(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE));
nodesInContext.add(n);
if (node.isGroupNode()) {
SortedSet<LocalizedNode> groupNodesInContext = this.inheritanceMap.get(context);
groupNodesInContext.removeIf(e -> e.equals(node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE));
if (node.getValue()) {
groupNodesInContext.add(n);
}
}
}

View File

@ -539,7 +539,7 @@ public abstract class PermissionHolder {
}
public DataMutateResult setPermission(Node node, boolean callEvent) {
if (hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) != Tristate.UNDEFINED) {
if (hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME) != Tristate.UNDEFINED) {
return DataMutateResult.ALREADY_HAS;
}
@ -565,7 +565,7 @@ public abstract class PermissionHolder {
}
public DataMutateResult setTransientPermission(Node node) {
if (hasPermission(NodeMapType.TRANSIENT, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) != Tristate.UNDEFINED) {
if (hasPermission(NodeMapType.TRANSIENT, node, StandardNodeEquality.IGNORE_EXPIRY_TIME) != Tristate.UNDEFINED) {
return DataMutateResult.ALREADY_HAS;
}