use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteCounterCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
boolean result = false;
try {
result = _autoScaleService.deleteCounter(getId());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
}
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
s_logger.warn("Failed to delete counter with Id: " + getId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete counter.");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class UpdateProjectRolePermissionCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// API Implementation //////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
ProjectRole projectRole = projRoleService.findProjectRole(getProjectRoleId(), getProjectId());
boolean result = false;
if (projectRole == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided");
}
if (getProjectRulePermissionOrder() != null) {
if (getProjectRuleId() != null || getProjectRolePermission() != null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Parameters permission and ruleid must be mutually exclusive with ruleorder");
}
CallContext.current().setEventDetails("Reordering permissions for role id: " + projectRole.getId());
result = updateProjectRolePermissionOrder(projectRole);
} else if (getProjectRuleId() != null || getProjectRolePermission() != null) {
if (getProjectRulePermissionOrder() != null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Parameters permission and ruleid must be mutually exclusive with ruleorder");
}
ProjectRolePermission rolePermission = getValidProjectRolePermission();
CallContext.current().setEventDetails("Updating project role permission for rule id: " + getProjectRuleId() + " to: " + getProjectRolePermission().toString());
result = projRoleService.updateProjectRolePermission(projectId, projectRole, rolePermission, getProjectRolePermission());
}
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 ReleasePodIpCmdByAdmin method execute.
@Override
public void execute() {
boolean result = _networkService.releasePodIp(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setDisplayText("IP is released sucessfully");
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release Pod ip ");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteAccountCmd method execute.
@Override
public void execute() {
Account account = _accountService.getAccount(getId());
// Account not found is already handled by service
CallContext.current().setEventDetails("Account ID: " + (account != null ? account.getUuid() : getId()));
boolean result = _regionService.deleteUserAccount(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user account and all corresponding users");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteRolePermissionCmd method execute.
@Override
public void execute() {
RolePermission rolePermission = roleService.findRolePermission(getRolePermissionId());
if (rolePermission == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role permission id provided");
}
CallContext.current().setEventDetails("Role permission id: " + rolePermission.getId());
boolean result = roleService.deleteRolePermission(rolePermission);
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
setResponseObject(response);
}
Aggregations