use of org.alfresco.repo.domain.permissions.Permission in project alfresco-repository by Alfresco.
the class AbstractPermissionChangePatch method renamePermission.
/**
* Helper method to rename (move) a permission. This involves checking for the existence of the
* new permission and then moving all the entries to point to the new permission.
*
* @param oldTypeQName the old permission type
* @param oldName the old permission name
* @param newTypeQName the new permission type
* @param newName the new permission name
* @return Returns the number of permission entries modified
*/
protected int renamePermission(QName oldTypeQName, String oldName, QName newTypeQName, String newName) {
if (oldTypeQName.equals(newTypeQName) && oldName.equals(newName)) {
throw new IllegalArgumentException("Cannot move permission to itself: " + oldTypeQName + "-" + oldName);
}
SimplePermissionReference oldPermRef = SimplePermissionReference.getPermissionReference(oldTypeQName, oldName);
Permission permission = aclCrudDAO.getPermission(oldPermRef);
if (permission == null) {
// create the permission
SimplePermissionReference newPermRef = SimplePermissionReference.getPermissionReference(newTypeQName, newName);
aclCrudDAO.createPermission(newPermRef);
} else {
// rename the permission
aclCrudDAO.renamePermission(oldTypeQName, oldName, newTypeQName, newName);
}
// done
return 1;
}
Aggregations