@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { try { List<NiciraNvpDeviceVO> niciraDevices = niciraNvpElementService.listNiciraNvpDevices(this); ListResponse<NiciraNvpDeviceResponse> response = new ListResponse<NiciraNvpDeviceResponse>(); List<NiciraNvpDeviceResponse> niciraDevicesResponse = new ArrayList<NiciraNvpDeviceResponse>(); if (niciraDevices != null && !niciraDevices.isEmpty()) { for (NiciraNvpDeviceVO niciraDeviceVO : niciraDevices) { NiciraNvpDeviceResponse niciraDeviceResponse = niciraNvpElementService.createNiciraNvpDeviceResponse(niciraDeviceVO); niciraDevicesResponse.add(niciraDeviceResponse); } } response.setResponses(niciraDevicesResponse); response.setResponseName(getCommandName()); setResponseObject(response); } catch (InvalidParameterValueException invalidParamExcp) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); } catch (CloudRuntimeException runtimeExcp) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); } }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { List<? extends Network> networks = _niciraNvpElementService.listNiciraNvpDeviceNetworks(this); ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>(); List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>(); if (networks != null && !networks.isEmpty()) { for (Network network : networks) { NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(network); networkResponses.add(networkResponse); } } response.setResponses(networkResponses); response.setResponseName(getCommandName()); this.setResponseObject(response); } catch (InvalidParameterValueException invalidParamExcp) { throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage()); } catch (CloudRuntimeException runtimeExcp) { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage()); } }