public static Response remove(BackendResource resource, Guid guid, String consoleId) { List<GraphicsDevice> devices = DisplayHelper.getGraphicsDevicesForEntity(resource, guid, false); if (devices == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = asGraphicsType(consoleId); return devices.stream() .filter(device -> device.getGraphicsType().equals(graphicsType)) .findFirst() .map(device -> resource.performAction(ActionType.RemoveGraphicsAndVideoDevices, new GraphicsParameters(device))) .orElseThrow(() -> new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build())); }