Search in sources :

Example 1 with ProjectRolePermissionVO

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;
}
Also used : ProjectRolePermissionVO(org.apache.cloudstack.acl.ProjectRolePermissionVO) Filter(com.cloud.utils.db.Filter)

Example 2 with ProjectRolePermissionVO

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);
}
Also used : ProjectRolePermissionVO(org.apache.cloudstack.acl.ProjectRolePermissionVO)

Example 3 with 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);
}
Also used : ProjectRolePermission(org.apache.cloudstack.acl.ProjectRolePermission) ProjectRolePermissionVO(org.apache.cloudstack.acl.ProjectRolePermissionVO)

Aggregations

ProjectRolePermissionVO (org.apache.cloudstack.acl.ProjectRolePermissionVO)3 Filter (com.cloud.utils.db.Filter)1 ProjectRolePermission (org.apache.cloudstack.acl.ProjectRolePermission)1