Search in sources :

Example 21 with ResourceInUseException

use of com.cloud.exception.ResourceInUseException in project cloudstack by apache.

the class DeleteConditionCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    boolean result = false;
    try {
        result = _autoScaleService.deleteCondition(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());
        setResponseObject(response);
    } else {
        s_logger.warn("Failed to delete condition " + getId());
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete condition.");
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceInUseException(com.cloud.exception.ResourceInUseException)

Example 22 with ResourceInUseException

use of com.cloud.exception.ResourceInUseException 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)

Aggregations

ResourceInUseException (com.cloud.exception.ResourceInUseException)22 ServerApiException (org.apache.cloudstack.api.ServerApiException)10 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 DiscoveryException (com.cloud.exception.DiscoveryException)8 DB (com.cloud.utils.db.DB)6 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 ArrayList (java.util.ArrayList)4 ConfigurationException (javax.naming.ConfigurationException)4 ServerApiException (com.cloud.api.ServerApiException)3 ClusterVO (com.cloud.dc.ClusterVO)3 DataCenterVO (com.cloud.dc.DataCenterVO)3 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)3 HostVO (com.cloud.host.HostVO)3 VmwareDatacenterVO (com.cloud.hypervisor.vmware.VmwareDatacenterVO)3 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)3 Cluster (com.cloud.org.Cluster)3 TransactionStatus (com.cloud.utils.db.TransactionStatus)3 UnknownHostException (java.net.UnknownHostException)3 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)3 ClusterVSMMapVO (com.cloud.dc.ClusterVSMMapVO)2