use of org.apache.cloudstack.api.ServerApiException 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);
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class UpdateVpnCustomerGatewayCmd method execute.
@Override
public void execute() {
Site2SiteCustomerGateway result = _s2sVpnService.updateCustomerGateway(this);
if (result != null) {
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update customer VPN gateway");
}
}
use of org.apache.cloudstack.api.ServerApiException 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");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class DeleteVpnGatewayCmd method execute.
@Override
public void execute() {
boolean result = false;
result = _s2sVpnService.deleteVpnGateway(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class AddClusterCmdTest method testExecuteForNullResult.
@Test
public void testExecuteForNullResult() {
ResourceService resourceService = Mockito.mock(ResourceService.class);
try {
Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(null);
} catch (ResourceInUseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DiscoveryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
addClusterCmd._resourceService = resourceService;
try {
addClusterCmd.execute();
} catch (ServerApiException exception) {
Assert.assertEquals("Failed to add cluster", exception.getDescription());
}
}
Aggregations