use of org.apache.cloudstack.acl.ProjectRolePermissionVO in project cloudstack by apache.
the class ProjectRolePermissionsDaoImpl method findAllByRoleIdSorted.
@Override
public List<ProjectRolePermissionVO> findAllByRoleIdSorted(Long roleId, Long projectId) {
final SearchCriteria<ProjectRolePermissionVO> sc = ProjectRolePermissionsSearch.create();
if (roleId != null && roleId > 0L) {
sc.setParameters("projectRoleId", roleId);
}
if (projectId != null && projectId > 0L) {
sc.setParameters("projectId", projectId);
}
final Filter searchBySorted = new Filter(ProjectRolePermissionVO.class, "sortOrder", true, null, null);
final List<ProjectRolePermissionVO> projectRolePermissionList = listBy(sc, searchBySorted);
if (projectRolePermissionList == null) {
return Collections.emptyList();
}
return projectRolePermissionList;
}
use of org.apache.cloudstack.acl.ProjectRolePermissionVO in project cloudstack by apache.
the class ProjectRolePermissionsDaoImpl method update.
@Override
public boolean update(ProjectRole role, ProjectRolePermission rolePermission, Permission permission) {
if (role == null || rolePermission == null || permission == null) {
return false;
}
ProjectRolePermissionVO projectRolePermissionVO = findById(rolePermission.getId());
if (projectRolePermissionVO == null) {
return false;
}
projectRolePermissionVO.setPermission(permission);
return update(rolePermission.getId(), projectRolePermissionVO);
}
use of org.apache.cloudstack.acl.ProjectRolePermissionVO in project cloudstack by apache.
the class ProjectRolePermissionsDaoImpl method persist.
@Override
public ProjectRolePermissionVO persist(final ProjectRolePermissionVO item) {
item.setSortOrder(0);
final List<ProjectRolePermissionVO> permissionsList = findAllByRoleIdSorted(item.getProjectRoleId(), item.getProjectId());
if (permissionsList != null && permissionsList.size() > 0) {
ProjectRolePermission lastRule = permissionsList.get(permissionsList.size() - 1);
item.setSortOrder(lastRule.getSortOrder() + 1);
}
return super.persist(item);
}
Aggregations