Search in sources :

Example 86 with SuccessResponse

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.");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceInUseException(com.cloud.exception.ResourceInUseException)

Example 87 with SuccessResponse

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);
}
Also used : ProjectRolePermission(org.apache.cloudstack.acl.ProjectRolePermission) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ProjectRole(org.apache.cloudstack.acl.ProjectRole)

Example 88 with SuccessResponse

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 ");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 89 with SuccessResponse

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");
    }
}
Also used : Account(com.cloud.user.Account) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 90 with SuccessResponse

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);
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) RolePermission(org.apache.cloudstack.acl.RolePermission)

Aggregations

SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)171 ServerApiException (org.apache.cloudstack.api.ServerApiException)154 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)29 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)28 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)20 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)19 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)14 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)13 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)13 ResourceInUseException (com.cloud.exception.ResourceInUseException)4 Host (com.cloud.host.Host)3 Account (com.cloud.user.Account)3 ArrayList (java.util.ArrayList)3 List (java.util.List)2 EntityExistsException (javax.persistence.EntityExistsException)2 ProjectRole (org.apache.cloudstack.acl.ProjectRole)2 ProjectRolePermission (org.apache.cloudstack.acl.ProjectRolePermission)2 Role (org.apache.cloudstack.acl.Role)2 RolePermission (org.apache.cloudstack.acl.RolePermission)2 Domain (com.cloud.domain.Domain)1