@Override public void execute() { try { final StoragePool result = _storageService.createPool(this); if (result != null) { final StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add storage pool"); } } catch (final ResourceUnavailableException ex1) { s_logger.warn("Exception: ", ex1); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage()); } catch (final ResourceInUseException ex2) { s_logger.warn("Exception: ", ex2); throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex2.getMessage()); } catch (final UnknownHostException ex3) { s_logger.warn("Exception: ", ex3); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex3.getMessage()); } catch (final Exception ex4) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex4.getMessage()); } }
@Override public void execute() { try { final List<? extends Cluster> result = _resourceService.discoverCluster(this); final ListResponse<ClusterResponse> response = new ListResponse<>(); final List<ClusterResponse> clusterResponses = new ArrayList<>(); if (result != null && result.size() > 0) { for (final Cluster cluster : result) { final ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false); clusterResponses.add(clusterResponse); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add cluster"); } response.setResponses(clusterResponses); response.setResponseName(getCommandName()); setResponseObject(response); } catch (final DiscoveryException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (final ResourceInUseException ex) { s_logger.warn("Exception: ", ex); final ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); for (final String proxyObj : ex.getIdProxyList()) { e.addProxyObject(proxyObj); } throw e; } }