/** Called from inside _logLock */
  private void flushTempStream() {
    TempStreamApi ts = _tempStream;
    _tempStream = null;
    _tempStreamSize = 0;

    try {
      if (ts != null) {
        if (_os == null) openLog();

        try {
          ReadStream is = ts.openRead();

          try {
            is.writeToStream(_os);
          } finally {
            is.close();
          }
        } catch (IOException e) {
          e.printStackTrace();
        } finally {
          ts.destroy();
        }
      }
    } finally {
      _logLock.notifyAll();
    }
  }
  public static void writeFile(OutputStream os, Path path) throws IOException {
    ReadStream stream = path.openRead();

    try {
      stream.writeToStream(os);
    } finally {
      stream.close();
    }
  }
Esempio n. 3
0
  public void writeToStream(OutputStream os, int length) throws IOException {
    try {
      if (_is != null) {
        _is.writeToStream(os, length);
      }
    } catch (IOException e) {
      _isTimeout = true;
      _isEOF = true;

      log.log(Level.FINER, e.toString(), e);
    }
  }
  public static void writeStream(OutputStream os, Call call, int length) throws Throwable {
    if (length < 1) return;

    char[] buf = new char[256];
    int len;

    Object obj = call.getArgObject(0, length);
    if (obj instanceof ReadStream) {
      ReadStream is = (ReadStream) obj;
      is.writeToStream(os);
    } else if (obj instanceof ReadWritePair) {
      ((ReadWritePair) obj).getReadStream().writeToStream(os);
    } else if (obj instanceof InputStream) {
      if (os instanceof WriteStream) {
        ((WriteStream) os).writeStream((InputStream) obj);
      } else {
        int ch;
        InputStream is = (InputStream) obj;
        while ((ch = is.read()) >= 0) os.write(ch);
      }
    } else throw new IllegalArgumentException("expected stream at " + obj.getClass().getName());
  }
Esempio n. 5
0
  public boolean getFile(String tagName, String fileName, OutputStream os) throws IOException {
    StreamSource fileSource = _deployProxy.getFile(tagName, fileName);

    if (fileSource != null) {
      ReadStream is = null;
      GitObjectStream gitIs = new GitObjectStream(fileSource.getInputStream());

      try {
        is = Vfs.openRead(gitIs);

        is.writeToStream(os);
      } finally {
        gitIs.close();

        IoUtil.close(is);
      }

      return true;
    } else {
      return false;
    }
  }