Skip to content

Commit

Permalink
bug fixes for immutable and invalid node property handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pdowler committed Jan 15, 2024
1 parent a74308f commit 6b49666
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cadc-vos-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '2.0.6'
version = '2.0.7'

description = 'OpenCADC VOSpace server'
def git_url = 'https://github.com/opencadc/vos'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.opencadc.vospace.ContainerNode;
import org.opencadc.vospace.Node;
import org.opencadc.vospace.NodeProperty;
import org.opencadc.vospace.VOS;

/**
* Utility methods
Expand Down Expand Up @@ -158,17 +159,22 @@ public static String getPath(Node node) {
* @param newProps set of new Node Properties to be used for the update
* @param immutable set of immutable property keys to skip
*/
public static void updateNodeProperties(Set<NodeProperty> oldProps, Set<NodeProperty> newProps, Set<URI> immutable) {
public static void updateNodeProperties(Set<NodeProperty> oldProps, Set<NodeProperty> newProps, Set<URI> immutable)
throws Exception {
for (Iterator<NodeProperty> newIter = newProps.iterator(); newIter.hasNext(); ) {
NodeProperty newProperty = newIter.next();
if (!immutable.contains(newProperty.getKey())) {
if (oldProps.contains(newProperty)) {
oldProps.remove(newProperty);
}
if (!newProperty.isMarkedForDeletion()) {
oldProps.add(newProperty);
if (newProperty.getKey().toASCIIString().startsWith(VOS.VOSPACE_URI_NAMESPACE)) {
if (!VOS.VOSPACE_CORE_PROPERTIES.contains(newProperty.getKey())) {
throw NodeFault.InvalidArgument.getStatus("non-standard property uri in namespace "
+ VOS.VOSPACE_URI_NAMESPACE + ": " + newProperty.getKey());
}
}
if (oldProps.contains(newProperty)) {
oldProps.remove(newProperty);
}
if (!newProperty.isMarkedForDeletion() && !immutable.contains(newProperty.getKey())) {
oldProps.add(newProperty);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ public void doAction() throws Exception {
}

// pick out eligible admin-only props (they are immutable to normal users)
List<NodeProperty> allowedAdminProps = Utils.getAdminProps(clientNode, nodePersistence.getAdminProps(), caller,
final List<NodeProperty> allowedAdminProps = Utils.getAdminProps(clientNode, nodePersistence.getAdminProps(), caller,
nodePersistence);

// sanitize input properties into clean set
Set<NodeProperty> np = new HashSet<>();
Utils.updateNodeProperties(np, clientNode.getProperties(), nodePersistence.getImmutableProps());
clientNode.getProperties().clear();
clientNode.getProperties().addAll(np);
clientNode.getProperties().addAll(allowedAdminProps);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void doAction() throws Exception {
}

public static Node updateProperties(Node serverNode, Node clientNode, NodePersistence nodePersistence, Subject caller)
throws NodeNotSupportedException {
throws Exception {
// merge change request
if (clientNode.clearReadOnlyGroups || !clientNode.getReadOnlyGroup().isEmpty()) {
serverNode.getReadOnlyGroup().clear();
Expand Down

0 comments on commit 6b49666

Please sign in to comment.