Skip to content

Commit

Permalink
Renamed 'authority' to 'owner' on request of Dmitriy
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Jan 22, 2014
1 parent 2944100 commit 1aeb428
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public class PermissionsFunctions extends BasicFunction {
"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("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 FunctionParameterSequenceType("owner", 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)
);
Expand Down Expand Up @@ -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 authority = args[1].itemAt(0).getStringValue();
result = functionChOwn(pathUri, authority);
final String owner = args[1].itemAt(0).getStringValue();
result = functionChOwn(pathUri, owner);
} else if(isCalledAs(qnChGrp.getLocalName())) {
final String groupname = args[1].itemAt(0).getStringValue();
result = functionChGrp(pathUri, groupname);
Expand Down Expand Up @@ -394,16 +394,16 @@ public void modify(final Permission permission) throws PermissionDeniedException
return Sequence.EMPTY_SEQUENCE;
}

private Sequence functionChOwn(final XmldbURI pathUri, final String authority) throws PermissionDeniedException {
private Sequence functionChOwn(final XmldbURI pathUri, final String owner) throws PermissionDeniedException {
PermissionFactory.updatePermissions(context.getBroker(), pathUri, new PermissionModifier(){
@Override
public void modify(final Permission permission) throws PermissionDeniedException {

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));
if(owner.indexOf(OWNER_GROUP_SEPARATOR) > -1) {
permission.setOwner(owner.substring(0, owner.indexOf((OWNER_GROUP_SEPARATOR))));
permission.setGroup(owner.substring(owner.indexOf(OWNER_GROUP_SEPARATOR) + 1));
} else {
permission.setOwner(authority);
permission.setOwner(owner);
}
}
});
Expand Down

0 comments on commit 1aeb428

Please sign in to comment.