Skip to content
Browse files

Merge branch 'feature/improve-chown' into develop

  • Loading branch information...
2 parents 142bed9 + 03253aa commit 294410033aff99da036c112001d3f0d0b74fc57d @adamretter adamretter committed Jan 22, 2014
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/org/exist/xquery/functions/securitymanager/PermissionsFunctions.java
View
18 src/org/exist/xquery/functions/securitymanager/PermissionsFunctions.java
@@ -179,7 +179,7 @@
"Changes the owner of a resource or collection.",
new SequenceType[] {
new FunctionParameterSequenceType("path", Type.ANY_URI, Cardinality.EXACTLY_ONE, "The path to the resource or collection whoose owner you wish to set"),
- new FunctionParameterSequenceType("user-name", Type.STRING, Cardinality.EXACTLY_ONE, "The name of the user owner to set on the resource or collection e.g. 'guest'"),
+ new FunctionParameterSequenceType("authority", Type.STRING, Cardinality.EXACTLY_ONE, "The name of the user owner to set on the resource or collection e.g. 'guest'. You may also provide a group owner, by using the syntax 'user:group' if you wish."),
},
new SequenceType(Type.EMPTY, Cardinality.ZERO)
);
@@ -275,8 +275,8 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
final String mode = args[1].itemAt(0).getStringValue();
result = functionChMod(pathUri, mode);
} else if(isCalledAs(qnChOwn.getLocalName())) {
- final String username = args[1].itemAt(0).getStringValue();
- result = functionChOwn(pathUri, username);
+ final String authority = args[1].itemAt(0).getStringValue();
+ result = functionChOwn(pathUri, authority);
} else if(isCalledAs(qnChGrp.getLocalName())) {
final String groupname = args[1].itemAt(0).getStringValue();
result = functionChGrp(pathUri, groupname);
@@ -394,16 +394,16 @@ public void modify(final Permission permission) throws PermissionDeniedException
return Sequence.EMPTY_SEQUENCE;
}
- private Sequence functionChOwn(final XmldbURI pathUri, final String username) throws PermissionDeniedException {
+ private Sequence functionChOwn(final XmldbURI pathUri, final String authority) throws PermissionDeniedException {
PermissionFactory.updatePermissions(context.getBroker(), pathUri, new PermissionModifier(){
@Override
public void modify(final Permission permission) throws PermissionDeniedException {
- if(username.indexOf(OWNER_GROUP_SEPARATOR) > -1) {
- permission.setOwner(username.substring(0, username.indexOf((OWNER_GROUP_SEPARATOR))));
- permission.setGroup(username.substring(username.indexOf(OWNER_GROUP_SEPARATOR) + 1));
+ if(authority.indexOf(OWNER_GROUP_SEPARATOR) > -1) {
+ permission.setOwner(authority.substring(0, authority.indexOf((OWNER_GROUP_SEPARATOR))));
+ permission.setGroup(authority.substring(authority.indexOf(OWNER_GROUP_SEPARATOR) + 1));
} else {
- permission.setOwner(username);
+ permission.setOwner(authority);
}
}
});
@@ -513,4 +513,4 @@ private Permission getPermissions(final XmldbURI pathUri) throws XPathException,
return builder.getDocument();
}
-}
+}

0 comments on commit 2944100

Please sign in to comment.
Something went wrong with that request. Please try again.