use of org.apache.cloudstack.acl.Role in project cloudstack by apache.
the class ListRolePermissionsCmd method setupResponse.
private void setupResponse(final List<RolePermission> rolePermissions, final Long roleId) {
final Role roleProvided = roleService.findRole(roleId);
final ListResponse<RolePermissionResponse> response = new ListResponse<>();
final List<RolePermissionResponse> rolePermissionResponses = new ArrayList<>();
for (final RolePermission rolePermission : rolePermissions) {
final RolePermissionResponse rolePermissionResponse = new RolePermissionResponse();
Role role = roleProvided;
if (role == null) {
role = roleService.findRole(rolePermission.getRoleId());
}
rolePermissionResponse.setRoleId(role.getUuid());
rolePermissionResponse.setRoleName(role.getName());
rolePermissionResponse.setId(rolePermission.getUuid());
rolePermissionResponse.setRule(rolePermission.getRule());
rolePermissionResponse.setRulePermission(rolePermission.getPermission());
rolePermissionResponse.setDescription(rolePermission.getDescription());
rolePermissionResponse.setObjectName("rolepermission");
rolePermissionResponses.add(rolePermissionResponse);
}
response.setResponses(rolePermissionResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.acl.Role in project cloudstack by apache.
the class UpdateRoleCmd method execute.
@Override
public void execute() {
Role role = roleService.findRole(getRoleId());
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided");
}
CallContext.current().setEventDetails("Role: " + getRoleName() + ", type:" + getRoleType() + ", description: " + getRoleDescription());
boolean result = roleService.updateRole(role, getRoleName(), getRoleType(), getRoleDescription());
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
setResponseObject(response);
}
use of org.apache.cloudstack.acl.Role in project cloudstack by apache.
the class ApiDBUtils method newUserResponse.
public static UserResponse newUserResponse(UserAccountJoinVO usr, Long domainId) {
UserResponse response = s_userAccountJoinDao.newUserResponse(usr);
// Populate user account role information
if (usr.getAccountRoleId() != null) {
Role role = s_roleService.findRole(usr.getAccountRoleId());
if (role != null) {
response.setRoleId(role.getUuid());
response.setRoleType(role.getRoleType());
response.setRoleName(role.getName());
}
}
if (domainId != null && usr.getDomainId() != domainId)
response.setIsCallerChildDomain(true);
else
response.setIsCallerChildDomain(false);
return response;
}
use of org.apache.cloudstack.acl.Role in project cloudstack by apache.
the class ApiDBUtils method newAccountResponse.
public static AccountResponse newAccountResponse(ResponseView view, AccountJoinVO ve) {
AccountResponse response = s_accountJoinDao.newAccountResponse(view, ve);
// Populate account role information
if (ve.getRoleId() != null) {
Role role = s_roleService.findRole(ve.getRoleId());
if (role != null) {
response.setRoleId(role.getUuid());
response.setRoleType(role.getRoleType());
response.setRoleName(role.getName());
}
}
return response;
}
Aggregations