* @throws SourceException If an exception occurs during this operation
**/
public void removeSourcePermission(SourcePermission sourcepermission)
throws SourceException {
NamespaceConfig config = this.nat.getNamespaceConfig();
String subject = null;
if (sourcepermission instanceof PrincipalSourcePermission) {
subject = config.getUsersPath()+"/"+
((PrincipalSourcePermission) sourcepermission).getPrincipal();
// Test if principal exists
try {
ObjectNode objectnode = structure.retrieve(this.slideToken,
subject);
if ( !(objectnode instanceof SubjectNode)) {
throw new SourceException("Principal '"+
((PrincipalSourcePermission) sourcepermission).getPrincipal()+
"' doesn't exists");
}
} catch (SlideException se) {
throw new SourceException("Could not retrieve object for principal '"+
((PrincipalSourcePermission) sourcepermission).getPrincipal()+
"'", se);
}
} else if (sourcepermission instanceof GroupSourcePermission) {
subject = config.getUsersPath()+"/"+
((GroupSourcePermission) sourcepermission).getGroup();
// Test if group exists
try {
ObjectNode objectnode = structure.retrieve(this.slideToken,
subject);
if ( !(objectnode instanceof GroupNode)) {
throw new SourceException("Group '"+
((GroupSourcePermission) sourcepermission).getGroup()+
"' doesn't exists");
}
} catch (SlideException se) {
throw new SourceException("Could not retrieve object for group '"+
((GroupSourcePermission) sourcepermission).getGroup()+
"'", se);
}
subject = "+"+subject; // Additional '+' to expand the group
} else {
throw new SourceException("Does't support category of permission");
}
boolean negative = sourcepermission.isNegative();
boolean inheritable = sourcepermission.isInheritable();
if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_ALL)) {
removePermission(subject, "/", negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ)) {
removePermission(subject, config.getReadObjectAction().getUri(),
negative, inheritable);
removePermission(subject, config.getReadLocksAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getReadRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getReadRevisionContentAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_SOURCE)) {
removePermission(subject, config.getReadObjectAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_LOCKS)) {
removePermission(subject, config.getReadLocksAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_PROPERTY)) {
removePermission(subject,
config.getReadRevisionMetadataAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_CONTENT)) {
removePermission(subject,
config.getReadRevisionContentAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE)) {
removePermission(subject,
config.getCreateObjectAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRemoveObjectAction().getUri(),
negative, inheritable);
removePermission(subject, config.getLockObjectAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_SOURCE)) {
removePermission(subject,
config.getCreateObjectAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_SOURCE)) {
removePermission(subject,
config.getRemoveObjectAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_LOCK_SOURCE)) {
removePermission(subject, config.getLockObjectAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_PROPERTY)) {
removePermission(subject,
config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_PROPERTY)) {
removePermission(subject,
config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_PROPERTY)) {
removePermission(subject,
config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_CONTENT)) {
removePermission(subject,
config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_CONTENT)) {
removePermission(subject,
config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_CONTENT)) {
removePermission(subject,
config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_ACL)) {
removePermission(subject,
config.getReadPermissionsAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE_ACL)) {
removePermission(subject,
config.getGrantPermissionAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRevokePermissionAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_GRANT_PERMISSION)) {
removePermission(subject,
config.getGrantPermissionAction().getUri(),
negative, inheritable);
} else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REVOKE_PERMISSION)) {
removePermission(subject,
config.getRevokePermissionAction().getUri(),
negative, inheritable);
}
}