Clean up ApiServer, ApiServlet and ApiDispatcher in handling various

exceptions, and Introduced ApiErrorCode to handle CloudStack API error
code to standard Http code mapping.
This commit is contained in:
Min Chen 2013-01-16 21:52:48 -08:00
parent e83fe471c7
commit bdcfa1919b
255 changed files with 1016 additions and 962 deletions

View File

@ -145,17 +145,17 @@ public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
} catch (InsufficientCapacityException ex){
s_logger.info(ex);
s_logger.trace(ex);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
if (result != null) {
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a Private network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a Private network");
}
}
@ -167,7 +167,7 @@ public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private network");
}
}

View File

@ -84,7 +84,7 @@ public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy console proxy");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy console proxy");
}
}
}

View File

@ -0,0 +1,59 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api;
/**
* Enum class for various API error code used in CloudStack
* @author minc
*
*/
public enum ApiErrorCode {
MALFORMED_PARAMETER_ERROR(430),
PARAM_ERROR(431),
UNSUPPORTED_ACTION_ERROR(432),
API_LIMIT_EXCEED(429),
INTERNAL_ERROR(530),
ACCOUNT_ERROR(531),
ACCOUNT_RESOURCE_LIMIT_ERROR(532),
INSUFFICIENT_CAPACITY_ERROR(533),
RESOURCE_UNAVAILABLE_ERROR(534),
RESOURCE_ALLOCATION_ERROR(534),
RESOURCE_IN_USE_ERROR(536),
NETWORK_RULE_CONFLICT_ERROR(537);
private int httpCode;
private ApiErrorCode(int httpStatusCode){
httpCode = httpStatusCode;
}
public int getHttpCode() {
return httpCode;
}
public void setHttpCode(int httpCode) {
this.httpCode = httpCode;
}
public String toString(){
return String.valueOf(this.httpCode);
}
}

View File

@ -81,23 +81,6 @@ public abstract class BaseCmd {
BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID
}
// FIXME: Extract these out into a separate file
// Client error codes
public static final int MALFORMED_PARAMETER_ERROR = 430;
public static final int PARAM_ERROR = 431;
public static final int UNSUPPORTED_ACTION_ERROR = 432;
public static final int PAGE_LIMIT_EXCEED = 433;
public static final int API_LIMIT_EXCEED = 429;
// Server error codes
public static final int INTERNAL_ERROR = 530;
public static final int ACCOUNT_ERROR = 531;
public static final int ACCOUNT_RESOURCE_LIMIT_ERROR = 532;
public static final int INSUFFICIENT_CAPACITY_ERROR = 533;
public static final int RESOURCE_UNAVAILABLE_ERROR = 534;
public static final int RESOURCE_ALLOCATION_ERROR = 534;
public static final int RESOURCE_IN_USE_ERROR = 536;
public static final int NETWORK_RULE_CONFLICT_ERROR = 537;
public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -231,7 +214,7 @@ public abstract class BaseCmd {
int arrayStartIndex = key.indexOf('[');
int arrayStartLastIndex = key.lastIndexOf('[');
if (arrayStartIndex != arrayStartLastIndex) {
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
}
@ -240,7 +223,7 @@ public abstract class BaseCmd {
int arrayEndLastIndex = key.lastIndexOf(']');
if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) {
// malformed parameter
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
}
@ -248,7 +231,7 @@ public abstract class BaseCmd {
int fieldIndex = key.indexOf('.');
String fieldName = null;
if (fieldIndex < arrayEndIndex) {
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
} else {
fieldName = key.substring(fieldIndex + 1);
@ -273,7 +256,7 @@ public abstract class BaseCmd {
}
if (!parsedIndex) {
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
}

View File

@ -119,7 +119,7 @@ public abstract class BaseUpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update template/iso permissions");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template/iso permissions");
}
}
}

View File

@ -15,28 +15,51 @@
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api;
import java.util.ArrayList;
import com.cloud.exception.CloudException;
import com.cloud.utils.exception.CSExceptionErrorCode;
import com.cloud.utils.exception.CloudRuntimeException;
@SuppressWarnings("serial")
public class ServerApiException extends CloudRuntimeException {
private int _errorCode;
private ApiErrorCode _errorCode;
private String _description;
public ServerApiException() {
_errorCode = 0;
_errorCode = ApiErrorCode.INTERNAL_ERROR;
_description = null;
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ServerApiException.class.getName()));
}
public ServerApiException(int errorCode, String description) {
public ServerApiException(ApiErrorCode errorCode, String description) {
_errorCode = errorCode;
_description = description;
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ServerApiException.class.getName()));
}
public int getErrorCode() {
// wrap a specific CloudRuntimeException to a ServerApiException
public ServerApiException(ApiErrorCode errorCode, String description, Throwable cause){
super(description, cause);
_errorCode = errorCode;
_description = description;
if (cause instanceof CloudRuntimeException || cause instanceof CloudException ) {
CloudRuntimeException rt = (CloudRuntimeException) cause;
ArrayList<String> idList = rt.getIdProxyList();
if (idList != null) {
for (int i = 0; i < idList.size(); i++) {
addProxyObject(idList.get(i));
}
}
setCSErrorCode(rt.getCSErrorCode());
}
}
public ApiErrorCode getErrorCode() {
return _errorCode;
}
public void setErrorCode(int errorCode) {
public void setErrorCode(ApiErrorCode errorCode) {
_errorCode = errorCode;
}

View File

@ -151,7 +151,7 @@ public class CreateAccountCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user account");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user account");
}
}
}

View File

@ -91,7 +91,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete user account and all corresponding users");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user account and all corresponding users");
}
}

View File

@ -115,7 +115,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account" );
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account" );
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.account;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -95,7 +96,7 @@ public class EnableAccountCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable account");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account");
}
}
}

View File

@ -84,7 +84,7 @@ public class LockAccountCmd extends BaseCmd {
// response.setResponseName(getCommandName());
// this.setResponseObject(response);
// } else {
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to lock account");
// throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to lock account");
// }
}
}

View File

@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -125,7 +126,7 @@ public class UpdateAccountCmd extends BaseCmd{
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update account");
}
}
}

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -86,7 +87,7 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
}
}

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -56,7 +57,7 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
result = _autoScaleService.deleteCounter(getId());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
}
if (result) {
@ -64,7 +65,7 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} else {
s_logger.warn("Failed to delete counter with Id: " + getId());
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete counter.");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete counter.");
}
}

View File

@ -156,7 +156,7 @@ public class AddClusterCmd extends BaseCmd {
clusterResponses.add(clusterResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add cluster");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add cluster");
}
response.setResponses(clusterResponses);
@ -165,10 +165,10 @@ public class AddClusterCmd extends BaseCmd {
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
ServerApiException e = new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
for (String proxyObj : ex.getIdProxyList()) {
e.addProxyObject(proxyObj);
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteClusterCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete cluster");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete cluster");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -112,7 +113,7 @@ public class UpdateClusterCmd extends BaseCmd {
clusterResponse.setResponseName(getCommandName());
this.setResponseObject(clusterResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update cluster");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update cluster");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.config;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -76,7 +77,7 @@ public class UpdateCfgCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update config");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update config");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.config;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -86,7 +87,7 @@ public class UpdateHypervisorCapabilitiesCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
}
}
}

View File

@ -84,7 +84,7 @@ public class CreateDomainCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create domain");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain");
}
}
}

View File

@ -93,7 +93,7 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete domain");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete domain");
}
}
}

View File

@ -83,7 +83,7 @@ public class UpdateDomainCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update domain");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update domain");
}
}
}

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -148,7 +149,7 @@ public class AddHostCmd extends BaseCmd {
hostResponses.add(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add host");
}
response.setResponses(hostResponses);
@ -157,7 +158,7 @@ public class AddHostCmd extends BaseCmd {
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -84,11 +84,11 @@ public class AddSecondaryStorageCmd extends BaseCmd {
this.setResponseObject(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -104,7 +105,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel host maintenance");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.HostResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -84,7 +85,7 @@ public class DeleteHostCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete host");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -104,7 +105,7 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName("host");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare host for maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare host for maintenance");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -103,11 +104,11 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reconnect host");
}
} catch (Exception ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -108,7 +109,7 @@ public class UpdateHostCmd extends BaseCmd {
this.setResponseObject(hostResponse);
} catch (Exception e) {
s_logger.debug("Failed to update host:" + getId(), e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -74,9 +75,9 @@ public class AddNetworkDeviceCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -103,7 +104,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider to physical network");
}
}
@ -114,7 +115,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
}
}

View File

@ -225,7 +225,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network offering");
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -151,7 +152,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create physical network");
}
}
@ -162,7 +163,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network entity");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create physical network entity");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -110,7 +111,7 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Create storage network IP range failed", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -65,12 +66,12 @@ public class DeleteNetworkDeviceCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network device:" + getId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network device:" + getId());
}
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteNetworkOfferingCmd extends BaseCmd{
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete service offering");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -76,14 +77,14 @@ public class DeleteNetworkServiceProviderCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network service provider");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -70,7 +70,7 @@ public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete physical network");
}
}

View File

@ -70,7 +70,7 @@ public class DeleteStorageNetworkIpRangeCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to delete storage network ip range " + getId(), e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.APICommand;
@ -85,9 +86,9 @@ public class ListNetworkDeviceCmd extends BaseListCmd {
listResponse.setResponseName(getCommandName());
this.setResponseObject(listResponse);
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}

View File

@ -23,6 +23,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.APICommand;
@ -100,7 +101,7 @@ public class ListPhysicalNetworksCmd extends BaseListCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to search for physical networks");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to search for physical networks");
}
}
}

View File

@ -88,7 +88,7 @@ public class ListStorageNetworkIpRangeCmd extends BaseListCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to list storage network ip range for rangeId=" + getRangeId() + " podId=" + getPodId() + " zoneId=" + getZoneId());
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -102,7 +102,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update network offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network offering");
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -88,7 +89,7 @@ public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service provider");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update service provider");
}
}

View File

@ -96,7 +96,7 @@ public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Update storage network IP range failed", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -115,7 +116,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create disk offering");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -162,7 +163,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create service offering");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete disk offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete disk offering");
}
}
}

View File

@ -68,7 +68,7 @@ public class DeleteServiceOfferingCmd extends BaseCmd{
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete service offering");
}
}
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.offering;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -91,7 +92,7 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update disk offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update disk offering");
}
}
}

View File

@ -89,7 +89,7 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update service offering");
}
}
}

View File

@ -111,7 +111,7 @@ public class CreatePodCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create pod");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create pod");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.pod;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeletePodCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete pod");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete pod");
}
}
}

View File

@ -110,7 +110,7 @@ public class UpdatePodCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update pod");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update pod");
}
}
}

View File

@ -99,7 +99,7 @@ public class UploadCustomCertificateCmd extends BaseAsyncCmd {
response.setObjectName("customcertificate");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upload custom certificate");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload custom certificate");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -120,7 +121,7 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure the virtual router provider");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the virtual router provider");
}
}
}

View File

@ -82,7 +82,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
}
}
@ -93,7 +93,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -104,7 +105,7 @@ public class DestroyRouterCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy router");
}
}
}

View File

@ -98,7 +98,7 @@ public class RebootRouterCmd extends BaseAsyncCmd {
response.setResponseName("router");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reboot router");
}
}
}

View File

@ -102,7 +102,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -109,7 +110,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router");
}
}
}

View File

@ -81,7 +81,7 @@ public class UpgradeRouterCmd extends BaseCmd {
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upgrade router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade router");
}
}
}

View File

@ -31,6 +31,7 @@ import static org.apache.cloudstack.api.BaseCmd.CommandType.STRING;
import static org.apache.cloudstack.api.BaseCmd.CommandType.BOOLEAN;
import static com.cloud.user.Account.ACCOUNT_ID_SYSTEM;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -93,12 +94,12 @@ public final class AddS3Cmd extends BaseCmd {
result = _resourceService.discoverS3(this);
if (result == null) {
throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3.");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3.");
}
} catch (DiscoveryException e) {
throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage());
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -107,7 +108,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
}
}
}

View File

@ -122,17 +122,17 @@ public class CreateStoragePoolCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add storage pool");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add storage pool");
}
} catch (ResourceUnavailableException ex1) {
s_logger.warn("Exception: ", ex1);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
}catch (ResourceInUseException ex2) {
s_logger.warn("Exception: ", ex2);
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex2.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex2.getMessage());
} catch (UnknownHostException ex3) {
s_logger.warn("Exception: ", ex3);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex3.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex3.getMessage());
}
}
}

View File

@ -78,9 +78,9 @@ public class DeletePoolCmd extends BaseCmd {
} else {
StoragePool pool = _storageService.getStoragePool(id);
if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
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(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete storage pool");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -105,7 +106,7 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName("storagepool");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
}
}
}

View File

@ -78,7 +78,7 @@ public class UpdateStoragePoolCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update storage pool");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update storage pool");
}
}
}

View File

@ -92,12 +92,12 @@ public class AddSwiftCmd extends BaseCmd {
swiftResponse.setObjectName("swift");
this.setResponseObject(swiftResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Swift");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Swift");
}
} catch (DiscoveryException ex) {
String errMsg = "Failed to add Swift due to " + ex.toString();
s_logger.warn(errMsg, ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, errMsg);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errMsg);
}
}
}

View File

@ -95,7 +95,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to destroy system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to destroy system vm");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -116,20 +117,20 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate the system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate the system vm");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (ManagementServerException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (VirtualMachineMigrationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -105,7 +106,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to reboot system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -109,7 +110,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to start system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to start system vm");
}
}
}

View File

@ -112,7 +112,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to stop system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to stop system vm");
}
}
}

View File

@ -94,7 +94,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to reboot system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -123,7 +124,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add traffic type to physical network");
}
}
@ -134,7 +135,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add traffic type to physical network");
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.TrafficTypeResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -73,7 +74,7 @@ public class DeleteTrafficTypeCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete traffic type");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete traffic type");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.usage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -95,7 +96,7 @@ public class UpdateTrafficTypeCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update traffic type");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update traffic type");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.user;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -137,7 +138,7 @@ public class CreateUserCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.user;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -76,7 +77,7 @@ public class DeleteUserCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete user");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.user;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -92,7 +93,7 @@ public class DisableUserCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disable user");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable user");
}
}

View File

@ -76,7 +76,7 @@ public class EnableUserCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable user");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable user");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.user;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -77,7 +78,7 @@ public class LockUserCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to lock user");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to lock user");
}
}
}

View File

@ -132,7 +132,7 @@ public class UpdateUserCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update user");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update user");
}
}
}

View File

@ -169,14 +169,14 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create vlan ip range");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vlan ip range");
}
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (InsufficientCapacityException ex) {
s_logger.info(ex);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.VlanIpRangeResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteVlanIpRangeCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete vlan ip range");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete vlan ip range");
}
}
}

View File

@ -101,14 +101,14 @@ public class AssignVMCmd extends BaseCmd {
try {
UserVm userVm = _userVmService.moveVMToUser(this);
if (userVm == null){
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to move vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm");
}
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0);
response.setResponseName(DeployVMCmd.getResultObjectName());
this.setResponseObject(response);
}catch (Exception e){
e.printStackTrace();
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to move vm " + e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm " + e.getMessage());
}
}

View File

@ -150,20 +150,20 @@ public class MigrateVMCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate vm");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (ManagementServerException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (VirtualMachineMigrationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.vm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -77,7 +78,7 @@ public class RecoverVMCmd extends BaseCmd {
recoverVmResponse.setResponseName(getCommandName());
this.setResponseObject(recoverVmResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to recover vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to recover vm");
}
}

View File

@ -21,6 +21,7 @@ import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
@ -115,17 +116,17 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
} catch (InsufficientCapacityException ex){
s_logger.info(ex);
s_logger.trace(ex);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
if (result != null) {
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private gateway");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway");
}
}
@ -138,7 +139,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private gateway");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway");
}
}

View File

@ -72,7 +72,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
this.setEntityId(vpcOff.getId());
this.setEntityUuid(vpcOff.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a VPC offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a VPC offering");
}
}
@ -84,7 +84,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd{
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create VPC offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC offering");
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.PrivateGatewayResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -87,7 +88,7 @@ public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete private gateway");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete private gateway");
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -71,7 +72,7 @@ public class DeleteVPCOfferingCmd extends BaseAsyncCmd{
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete VPC offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC offering");
}
}

View File

@ -90,7 +90,7 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd{
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update VPC offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC offering");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.zone;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -156,7 +157,7 @@ public class CreateZoneCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a zone");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a zone");
}
}
}

View File

@ -71,7 +71,7 @@ public class DeleteZoneCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete zone");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete zone");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.zone;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -109,7 +110,7 @@ public class MarkDefaultZoneForAccountCmd extends BaseAsyncCmd {
this.setResponseObject(response);
}
else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to mark the account with the default zone");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to mark the account with the default zone");
}
}
}

View File

@ -164,7 +164,7 @@ public class UpdateZoneCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update zone; internal error.");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update zone; internal error.");
}
}
}

View File

@ -87,7 +87,7 @@ public class AddAccountToProjectCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add account to the project");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add account to the project");
}
}

View File

@ -76,7 +76,7 @@ public class DeleteAccountFromProjectCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete account from the project");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete account from the project");
}
}

Some files were not shown because too many files have changed in this diff Show More