use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class UpdateRolePermissionCmd method execute.
@Override
public void execute() {
final Role role = roleService.findRole(getRoleId());
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided");
}
CallContext.current().setEventDetails("Reordering permissions for role id: " + role.getId());
final List<RolePermission> rolePermissionsOrder = new ArrayList<>();
for (Long rolePermissionId : getRulePermissionOrder()) {
final RolePermission rolePermission = roleService.findRolePermission(rolePermissionId);
if (rolePermission == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Provided role permission(s) do not exist");
}
rolePermissionsOrder.add(rolePermission);
}
boolean result = roleService.updateRolePermission(role, rolePermissionsOrder);
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteClusterCmd method execute.
@Override
public void execute() {
boolean result = _resourceService.deleteCluster(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete cluster");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteDomainCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Domain Id: " + getId());
boolean result = _regionService.deleteDomain(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete domain");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class GenerateUsageRecordsCmd method execute.
@Override
public void execute() {
boolean result = _usageService.generateUsageRecords(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to generate usage records");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class ReleasePublicIpRangeCmd method execute.
@Override
public void execute() {
boolean result = _configService.releasePublicIpRange(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release public ip range");
}
}
Aggregations