Search in sources :

Example 56 with SuccessResponse

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

Example 57 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class DeletePoolCmd method execute.

@Override
public void execute() {
    boolean result = _storageService.deletePool(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        StoragePool pool = _storageService.getStoragePool(id);
        if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete storage pool");
        }
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 58 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class DeleteTrafficTypeCmd method execute.

@Override
public void execute() {
    boolean result = _networkService.deletePhysicalNetworkTrafficType(getId());
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete traffic type");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 59 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class MoveUserCmd method execute.

@Override
public void execute() {
    Preconditions.checkNotNull(getId(), "I have to have an user to move!");
    Preconditions.checkState(ObjectUtils.anyNotNull(getAccountId(), getAccountName()), "provide either an account name or an account id!");
    CallContext.current().setEventDetails("UserId: " + getId());
    boolean result = _regionService.moveUser(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move the user to a new account");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 60 with SuccessResponse

use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.

the class DeleteImageStoreCmd method execute.

@Override
public void execute() {
    boolean result = _storageService.deleteImageStore(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete image store");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

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