@Override public void execute() { Pair<List<? extends Snapshot>, Integer> result = _snapshotService.listSnapshots(this); ListResponse<SnapshotResponse> response = new ListResponse<SnapshotResponse>(); List<SnapshotResponse> snapshotResponses = new ArrayList<SnapshotResponse>(); for (Snapshot snapshot : result.first()) { SnapshotResponse snapshotResponse = _responseGenerator.createSnapshotResponse(snapshot); snapshotResponse.setObjectName("snapshot"); snapshotResponses.add(snapshotResponse); } response.setResponses(snapshotResponses, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); }
@Override public void execute() { UserContext.current().setEventDetails("Volume Id: " + getVolumeId()); Snapshot snapshot = _snapshotService.createSnapshot( getVolumeId(), getPolicyId(), getEntityId(), _accountService.getAccount(getEntityOwnerId())); if (snapshot != null) { SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException( ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId); } }