String caller,
String objectUri,
String subjectUri) throws Exception {
SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
Content content = nat.getContentHelper();
try {
NodeRevisionDescriptors revisions = content.retrieve(slideToken,objectUri);
NodeRevisionDescriptor revision = content.retrieve(slideToken,revisions);
NodeProperty property = revision.getProperty("group-member-set","DAV:");
if (property == null) {
// group has no members
return;
}
String value = (String) property.getValue();
int index = value.indexOf(subjectUri);
if (index == -1) {
// subject is not a member of this group
return;
}
// looking for the end of </D:href> after subjectUri
int end = index + subjectUri.length();
do {
end++;
}
while (value.charAt(end) != '>');
// looking for the start of <D:href> before subjectUri
int from = index;
do {
from--;
}
while(value.charAt(from) != '<');
// snip out the user
String before = value.substring(0,from);
String after = value.substring(end+1);
value = before + after;
revision.setProperty("group-member-set","DAV:",value);
nat.begin();
content.store(slideToken,objectUri,revision,null);
nat.commit();
}
catch (ObjectNotFoundException e) {
// no such user or group
}