Examples of ZipArchiveOutputStream


Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

        if (AR.equalsIgnoreCase(archiverName)) {
            return new ArArchiveOutputStream(out);
        }
        if (ZIP.equalsIgnoreCase(archiverName)) {
            ZipArchiveOutputStream zip = new ZipArchiveOutputStream(out);
            if (entryEncoding != null) {
                zip.setEncoding(entryEncoding);
            }
            return zip;
        }
        if (TAR.equalsIgnoreCase(archiverName)) {
            if (entryEncoding != null) {
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

      if (windows) {
        // windows: download zip file with pt.py and pt.cmd
        response.setHeader("Content-Disposition", "attachment; filename=\"pt.zip\"");

        OutputStream os = response.getOutputStream();
        ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);

        // add the Python script
        ZipArchiveEntry pyEntry = new ZipArchiveEntry("pt.py");
        pyEntry.setSize(pyBytes.length);
        pyEntry.setUnixMode(FileMode.EXECUTABLE_FILE.getBits());
        pyEntry.setTime(lastModified);
        zos.putArchiveEntry(pyEntry);
        zos.write(pyBytes);
        zos.closeArchiveEntry();

        // add a Python launch cmd file
        byte [] cmdBytes = readAll(getClass().getResourceAsStream("/pt.cmd"));
        ZipArchiveEntry cmdEntry = new ZipArchiveEntry("pt.cmd");
        cmdEntry.setSize(cmdBytes.length);
        cmdEntry.setUnixMode(FileMode.REGULAR_FILE.getBits());
        cmdEntry.setTime(lastModified);
        zos.putArchiveEntry(cmdEntry);
        zos.write(cmdBytes);
        zos.closeArchiveEntry();

        // add a brief readme
        byte [] txtBytes = readAll(getClass().getResourceAsStream("/pt.txt"));
        ZipArchiveEntry txtEntry = new ZipArchiveEntry("readme.txt");
        txtEntry.setSize(txtBytes.length);
        txtEntry.setUnixMode(FileMode.REGULAR_FILE.getBits());
        txtEntry.setTime(lastModified);
        zos.putArchiveEntry(txtEntry);
        zos.write(txtBytes);
        zos.closeArchiveEntry();

        // cleanup
        zos.finish();
        zos.close();
        os.flush();
      } else {
        // unix: download a tar.gz file with pt.py set with execute permissions
        response.setHeader("Content-Disposition", "attachment; filename=\"pt.tar.gz\"");
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

    RevWalk rw = new RevWalk(repository);
    TreeWalk tw = new TreeWalk(repository);
    try {
      tw.reset();
      tw.addTree(commit.getTree());
      ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
      zos.setComment("Generated by Gitblit");
      if (!StringUtils.isEmpty(basePath)) {
        PathFilter f = PathFilter.create(basePath);
        tw.setFilter(f);
      }
      tw.setRecursive(true);
      MutableObjectId id = new MutableObjectId();
      ObjectReader reader = tw.getObjectReader();
      long modified = commit.getAuthorIdent().getWhen().getTime();
      while (tw.next()) {
        FileMode mode = tw.getFileMode(0);
        if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
          continue;
        }
        tw.getObjectId(id, 0);

        ZipArchiveEntry entry = new ZipArchiveEntry(tw.getPathString());
        entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
        entry.setComment(commit.getName());
        entry.setUnixMode(mode.getBits());
        entry.setTime(modified);
        zos.putArchiveEntry(entry);

        ObjectLoader ldr = repository.open(id);
        ldr.copyTo(zos);
        zos.closeArchiveEntry();
      }
      zos.finish();
      success = true;
    } catch (IOException e) {
      error(e, repository, "{0} failed to zip files from commit {1}", commit.getName());
    } finally {
      tw.release();
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

      if (windows) {
        // windows: download zip file with pt.py and pt.cmd
        response.setHeader("Content-Disposition", "attachment; filename=\"pt.zip\"");

        OutputStream os = response.getOutputStream();
        ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);

        // add the Python script
        ZipArchiveEntry pyEntry = new ZipArchiveEntry("pt.py");
        pyEntry.setSize(pyBytes.length);
        pyEntry.setUnixMode(FileMode.EXECUTABLE_FILE.getBits());
        pyEntry.setTime(lastModified);
        zos.putArchiveEntry(pyEntry);
        zos.write(pyBytes);
        zos.closeArchiveEntry();

        // add a Python launch cmd file
        byte [] cmdBytes = readAll(getClass().getResourceAsStream("/pt.cmd"));
        ZipArchiveEntry cmdEntry = new ZipArchiveEntry("pt.cmd");
        cmdEntry.setSize(cmdBytes.length);
        cmdEntry.setUnixMode(FileMode.REGULAR_FILE.getBits());
        cmdEntry.setTime(lastModified);
        zos.putArchiveEntry(cmdEntry);
        zos.write(cmdBytes);
        zos.closeArchiveEntry();

        // add a brief readme
        byte [] txtBytes = readAll(getClass().getResourceAsStream("/pt.txt"));
        ZipArchiveEntry txtEntry = new ZipArchiveEntry("readme.txt");
        txtEntry.setSize(txtBytes.length);
        txtEntry.setUnixMode(FileMode.REGULAR_FILE.getBits());
        txtEntry.setTime(lastModified);
        zos.putArchiveEntry(txtEntry);
        zos.write(txtBytes);
        zos.closeArchiveEntry();

        // cleanup
        zos.finish();
        zos.close();
        os.flush();
      } else {
        // unix: download a tar.gz file with pt.py set with execute permissions
        response.setHeader("Content-Disposition", "attachment; filename=\"pt.tar.gz\"");
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

    RevWalk rw = new RevWalk(repository);
    TreeWalk tw = new TreeWalk(repository);
    try {
      tw.reset();
      tw.addTree(commit.getTree());
      ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
      zos.setComment("Generated by Gitblit");
      if (!StringUtils.isEmpty(basePath)) {
        PathFilter f = PathFilter.create(basePath);
        tw.setFilter(f);
      }
      tw.setRecursive(true);
      MutableObjectId id = new MutableObjectId();
      ObjectReader reader = tw.getObjectReader();
      long modified = commit.getAuthorIdent().getWhen().getTime();
      while (tw.next()) {
        FileMode mode = tw.getFileMode(0);
        if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
          continue;
        }
        tw.getObjectId(id, 0);

        ZipArchiveEntry entry = new ZipArchiveEntry(tw.getPathString());
        entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
        entry.setComment(commit.getName());
        entry.setUnixMode(mode.getBits());
        entry.setTime(modified);
        zos.putArchiveEntry(entry);

        ObjectLoader ldr = repository.open(id);
        ldr.copyTo(zos);
        zos.closeArchiveEntry();
      }
      zos.finish();
      success = true;
    } catch (IOException e) {
      error(e, repository, "{0} failed to zip files from commit {1}", commit.getName());
    } finally {
      tw.release();
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

public final class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
  private static final List<String> SUFFIXES = Collections
      .unmodifiableList(Arrays.asList(".zip")); //$NON-NLS-1$

  public ArchiveOutputStream createArchiveOutputStream(OutputStream s) {
    return new ZipArchiveOutputStream(s);
  }
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

     * @param encoding the encoding of the entry names
     */
    public ArchiveOutputStream getArchiveStream(OutputStream stream,
                                                String encoding)
        throws IOException {
        ZipArchiveOutputStream o = new ZipArchiveOutputStream(stream);
        o.setEncoding(encoding);
        return o;
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

     * formats except zip
     */
    public ArchiveOutputStream getArchiveOutputStream(File file,
                                                      String encoding)
        throws IOException {
        ZipArchiveOutputStream o = new ZipArchiveOutputStream(file);
        o.setEncoding(encoding);
        return o;
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

public class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
  private static final List<String> SUFFIXES =
      Collections.unmodifiableList(Arrays.asList(".zip"));

  public ArchiveOutputStream createArchiveOutputStream(OutputStream s) {
    return new ZipArchiveOutputStream(s);
  }
View Full Code Here

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream

                continue;
            }
            files.add(needCompressFile);
        }
        try {
            ZipArchiveOutputStream zaos = null;
            try {
                zaos = new ZipArchiveOutputStream(compressFile);
                zaos.setUseZip64(Zip64Mode.AsNeeded);
                zaos.setEncoding("GBK");

                for (File file : files) {
                    addFilesToCompression(zaos, file, "");
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.