Package org.eclipse.jgit.util

Examples of org.eclipse.jgit.util.TemporaryBuffer


          throw new TransportException(uri,
              JGitText.get().startingReadStageWithoutWrittenRequestDataPendingIsNotSupported);
        }

        // Try to compress the content, but only if that is smaller.
        TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
        try {
          GZIPOutputStream gzip = new GZIPOutputStream(buf);
          out.writeTo(gzip, null);
          gzip.close();
          if (out.length() < buf.length())
            buf = out;
        } catch (IOException err) {
          // Most likely caused by overflowing the buffer, meaning
          // its larger if it were compressed. Don't compress.
          buf = out;
        }

        openStream();
        if (buf != out)
          conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
        conn.setFixedLengthStreamingMode((int) buf.length());
        final OutputStream httpOut = conn.getOutputStream();
        try {
          buf.writeTo(httpOut, null);
        } finally {
          httpOut.close();
        }
      }
View Full Code Here


        e.write(dos);
      }
    }

    if (tree != null) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }
    writeIndexChecksum = foot.digest();
    os.write(writeIndexChecksum);
    os.close();
  }
View Full Code Here

          throw new TransportException(uri,
              JGitText.get().startingReadStageWithoutWrittenRequestDataPendingIsNotSupported);
        }

        // Try to compress the content, but only if that is smaller.
        TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
        try {
          GZIPOutputStream gzip = new GZIPOutputStream(buf);
          out.writeTo(gzip, null);
          gzip.close();
          if (out.length() < buf.length())
            buf = out;
        } catch (IOException err) {
          // Most likely caused by overflowing the buffer, meaning
          // its larger if it were compressed. Don't compress.
          buf = out;
        }

        openStream();
        if (buf != out)
          conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
        conn.setFixedLengthStreamingMode((int) buf.length());
        final OutputStream httpOut = conn.getOutputStream();
        try {
          buf.writeTo(httpOut, null);
        } finally {
          httpOut.close();
        }
      }
View Full Code Here

        e.write(dos);
      }
    }

    if (tree != null) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }

    os.write(foot.digest());
    os.close();
  }
View Full Code Here

          throw new TransportException(uri,
              JGitText.get().startingReadStageWithoutWrittenRequestDataPendingIsNotSupported);
        }

        // Try to compress the content, but only if that is smaller.
        TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
        try {
          GZIPOutputStream gzip = new GZIPOutputStream(buf);
          out.writeTo(gzip, null);
          gzip.close();
          if (out.length() < buf.length())
            buf = out;
        } catch (IOException err) {
          // Most likely caused by overflowing the buffer, meaning
          // its larger if it were compressed. Don't compress.
          buf = out;
        }

        openStream();
        if (buf != out)
          conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
        conn.setFixedLengthStreamingMode((int) buf.length());
        final OutputStream httpOut = conn.getOutputStream();
        try {
          buf.writeTo(httpOut, null);
        } finally {
          httpOut.close();
        }
      }
View Full Code Here

        MergeFormatter fmt = new MergeFormatter();
        Map<String, MergeResult<? extends Sequence>> r = m.getMergeResults();
        Map<String, ObjectId> resolved = new HashMap<String, ObjectId>();
        for (String path : r.keySet()) {
          MergeResult<? extends Sequence> p = r.get(path);
          TemporaryBuffer buf = new TemporaryBuffer.LocalFile(10 * 1024 * 1024);
          try {
            fmt.formatMerge(buf, p, "BASE", oursName, theirsName, "UTF-8");
            buf.close();

            InputStream in = buf.openInputStream();
            try {
              resolved.put(path, ins.insert(Constants.OBJ_BLOB, buf.length(), in));
            } finally {
              in.close();
            }
          } finally {
            buf.destroy();
          }
        }

        DirCacheBuilder builder = dc.builder();
        int cnt = dc.getEntryCount();
View Full Code Here

    if (!startedOutput) {
      // If output hasn't started yet, the entire thing fit into our
      // buffer. Try to use a proper Content-Length header, and also
      // deflate the response with gzip if it will be smaller.
      TemporaryBuffer out = this;

      if (256 < out.length() && acceptsGzipEncoding(req)) {
        TemporaryBuffer gzbuf = new TemporaryBuffer.Heap(LIMIT);
        try {
          GZIPOutputStream gzip = new GZIPOutputStream(gzbuf);
          try {
            out.writeTo(gzip, null);
          } finally {
            gzip.close();
          }
          if (gzbuf.length() < out.length()) {
            out = gzbuf;
            rsp.setHeader(HDR_CONTENT_ENCODING, ENCODING_GZIP);
          }
        } catch (IOException err) {
          // Most likely caused by overflowing the buffer, meaning
View Full Code Here

        e.write(dos);
      }
    }

    if (tree != null) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }

    os.write(foot.digest());
    os.close();
  }
View Full Code Here

    final byte[] buf = readFully(is);
    parse(buf, 0, buf.length);
  }

  private static byte[] readFully(final InputStream is) throws IOException {
    final TemporaryBuffer b = new TemporaryBuffer.LocalFile();
    try {
      b.copy(is);
      b.close();
      return b.toByteArray();
    } finally {
      b.destroy();
    }
  }
View Full Code Here

   */
  public OutputStream beginPut(final String bucket, final String key,
      final ProgressMonitor monitor, final String monitorTask)
      throws IOException {
    final MessageDigest md5 = newMD5();
    final TemporaryBuffer buffer = new TemporaryBuffer.LocalFile() {
      @Override
      public void close() throws IOException {
        super.close();
        try {
          putImpl(bucket, key, md5.digest(), this, monitor,
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.util.TemporaryBuffer

Copyright © 2018 www.massapicom. 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.