use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class AddAccountToProjectCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
if (accountName == null && email == null) {
throw new InvalidParameterValueException("Either accountName or email is required");
}
CallContext.current().setEventDetails("Project ID: " + projectId + "; accountName " + accountName);
boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName(), getEmail(), getProjectRoleId(), getRoleType());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add account to the project");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteVPCOfferingCmd method execute.
@Override
public void execute() {
boolean result = _vpcProvSvc.deleteVpcOffering(getId());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC offering");
}
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteVPCCmd method execute.
@Override
public void execute() {
try {
boolean result = _vpcService.deleteVpc(getId());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
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());
long ownerId = owner.getId();
boolean result = _ravService.removeVpnUser(ownerId, userName, CallContext.current().getCallingAccount());
if (!result) {
String errorMessage = String.format("Failed to remove VPN user=[%s]. VPN owner id=[%s].", userName, ownerId);
s_logger.error(errorMessage);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errorMessage);
}
boolean appliedVpnUsers = false;
try {
appliedVpnUsers = _ravService.applyVpnUsers(ownerId, userName, true);
} catch (ResourceUnavailableException ex) {
String errorMessage = String.format("Failed to refresh VPN user=[%s] due to resource unavailable. VPN owner id=[%s].", userName, ownerId);
s_logger.error(errorMessage, ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errorMessage, ex);
}
if (!appliedVpnUsers) {
String errorMessage = String.format("Failed to refresh VPN user=[%s]. VPN owner id=[%s].", userName, ownerId);
s_logger.debug(errorMessage);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errorMessage);
}
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.SuccessResponse in project cloudstack by apache.
the class DeleteVpnCustomerGatewayCmd method execute.
@Override
public void execute() {
boolean result = _s2sVpnService.deleteCustomerGateway(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
}
}
Aggregations