Search in sources :

Example 11 with SuccessResponse

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

the class DeleteAlertsCmd method execute.

@Override
public void execute() {
    if (ids == null && type == null && endDate == null) {
        throw new InvalidParameterValueException("either ids, type or enddate must be specified");
    } else if (startDate != null && endDate == null) {
        throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
    }
    boolean result = _mgr.deleteAlerts(this);
    if (result) {
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Alerts, one or more parameters has invalid values");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 12 with SuccessResponse

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

the class DeleteDiskOfferingCmd method execute.

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

Example 13 with SuccessResponse

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

the class DeleteServiceOfferingCmd method execute.

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

Example 14 with SuccessResponse

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

the class DeletePortableIpRangeCmd method execute.

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

Example 15 with SuccessResponse

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

the class RemoveVpnUserCmd method execute.

@Override
public void execute() {
    Account owner = _accountService.getAccount(getEntityOwnerId());
    boolean result = _ravService.removeVpnUser(owner.getId(), userName, CallContext.current().getCallingAccount());
    if (!result) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user");
    }
    try {
        if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply vpn user removal");
        }
    } catch (Exception ex) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user due to resource unavailable");
    }
    SuccessResponse response = new SuccessResponse(getCommandName());
    setResponseObject(response);
}
Also used : Account(com.cloud.user.Account) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Aggregations

SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)137 ServerApiException (org.apache.cloudstack.api.ServerApiException)125 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)26 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)8 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)6 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)5 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)5 ResourceInUseException (com.cloud.exception.ResourceInUseException)4 ArrayList (java.util.ArrayList)3 Role (org.apache.cloudstack.acl.Role)3 Account (com.cloud.user.Account)2 List (java.util.List)2 RolePermission (org.apache.cloudstack.acl.RolePermission)2 Domain (com.cloud.domain.Domain)1 Host (com.cloud.host.Host)1 ResourceTag (com.cloud.server.ResourceTag)1 StoragePool (com.cloud.storage.StoragePool)1 UserAccount (com.cloud.user.UserAccount)1