Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bugfix] Added "user:group" details to function parameter description…

… of sm:chown
  • Loading branch information...
commit 03253aa2e3e80f31b378f9cc1ca29ce27cc928b7 1 parent 1c3fd43
@adamretter adamretter authored
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();
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.