isRevokePermission;
boolean isAll = isRead && isWrite && isReadAcl &&
isWriteAcl;
SourcePermission sourcepermission = null;
if (principal.equals("~")) {
sourcepermission = new PrincipalSourcePermission(PrincipalSourcePermission.PRINCIPAL_SELF,
null, inheritedPermissions, negative);
} else if (principal.equals("nobody")) {
sourcepermission = new PrincipalSourcePermission(PrincipalSourcePermission.PRINCIPAL_GUEST,
null, inheritedPermissions, negative);
} else if (principal.equals(userspath)) {
sourcepermission = new PrincipalSourcePermission(PrincipalSourcePermission.PRINCIPAL_ALL,
null, inheritedPermissions, negative);
} else if (principal.startsWith(userspath+"/")) {
sourcepermission = new PrincipalSourcePermission(principal.substring(userspath.length()+
1), null, inheritedPermissions, negative);
} else if (principal.startsWith("+"+userspath+"/")) {
sourcepermission = new GroupSourcePermission(principal.substring(userspath.length()+
2), null, inheritedPermissions, negative);
} else {
sourcepermission = new PrincipalSourcePermission(principal,
null, inheritedPermissions, negative);
}
if (isAll) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_ALL);
} else {
if (isRead) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ);
} else {
if (isReadObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_SOURCE);
}
if (isReadLocks) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_LOCKS);
}
if (isReadRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_PROPERTY);
}
if (isReadRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_CONTENT);
}
}
if (isWrite) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_WRITE);
} else {
if (isCreateObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_SOURCE);
}
if (isRemoveObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_SOURCE);
}
if (isLockObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_LOCK_SOURCE);
}
if (isCreateRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_PROPERTY);
}
if (isModifyRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_MODIFY_PROPERTY);
}
if (isRemoveRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_PROPERTY);
}
if (isCreateRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_CONTENT);
}
if (isModifyRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_MODIFY_CONTENT);
}
if (isRemoveRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_CONTENT);
}
}
if (isReadAcl) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_ACL);
}
if (isWriteAcl) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_WRITE_ACL);
} else {
if (isGrantPermission) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_GRANT_PERMISSION);
}
if (isRevokePermission) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REVOKE_PERMISSION);
}
}
}
sourcepermissions.add(sourcepermission);