private void zipDirectory(ZipOutputStream zip, String path) {
    try {
      zip.putNextEntry(new ZipEntry(path.substring(1) + "/"));
    } catch (IOException ex) {
      LOG.error("Error zipping directory {} (directory ignored).", path, ex);
    } finally {
      try {
        zip.closeEntry();
      } catch (IOException ex) {
        LOG.error("Error zipping directory {} (directory ignored).", path, ex);
      }
    }
  }
Download entire file
@param path path to file
@param download download as octet strem or as file mime type
@param checkperm used to check if the file can be downloaded. Takes precedence when both download and checkperm
                 is set.
@param headers http headers
@param ui uri info
@return response with file
contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java