Package com.caucho.server.cache

Examples of com.caucho.server.cache.TempFileInode$TempFileOutputStream


    return _inode.openInputStream();
  }

  public void close()
  {
    TempFileInode inode = _inode;
    _inode = null;

    if (inode != null)
      inode.free();
  }
View Full Code Here


            String rev,
            String ext)
  {
    String urlString = resolveArtifactString(org, module, artifact, rev, ext);

    TempFileInode inode = _tempFileManager.createInode();

    try {
      String sha1 = loadChecksum(urlString, "sha1");
      String md5 = null;

      if (sha1 == null)
  md5 = loadChecksum(urlString, "md5");

      URL url = null;

      try {
  url = new URL(urlString);
      } catch (MalformedURLException e) {
  throw new ConfigException(L.l("'{0}' is an invalid URL", urlString));
      }

      URLConnection conn = url.openConnection();

      if (conn == null)
  return null;

      InputStream is = null;
      try {
  conn.connect();
  int length = conn.getContentLength();
 
  is = conn.getInputStream();

  OutputStream out = inode.openOutputStream();

  TempBuffer tempBuffer = TempBuffer.allocate();
  byte []buffer = tempBuffer.getBuffer();
 
  int readLength = 0;
  int len;

  log.info("ModuleRepository[] loading " + urlString);

  while ((len = is.read(buffer, 0, buffer.length)) > 0) {
    out.write(buffer, 0, len);
    readLength += len;
  }

  out.close();

  TempBuffer.free(tempBuffer);

  InodeDataSource dataSource
    = new InodeDataSource(urlString, inode);

  if (md5 != null)
    validateSignature(dataSource, md5, "MD5");

  if (sha1 != null)
    validateSignature(dataSource, sha1, "SHA1");
 
  inode = null;

  return dataSource;
      } finally {
  if (is != null)
    is.close();
      }
    } catch (SecurityException e) {
      throw new ModuleNotFoundException(L.l("{0} failed signature validation",
              urlString, e));
    } catch (MalformedURLException e) {
      throw new ModuleNotFoundException(e);
    } catch (IOException e) {
      throw new ModuleNotFoundException(L.l("{0} is an unknown module",
              urlString),
          e);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      if (inode != null)
  inode.free();
    }
  }
View Full Code Here

    if (_path != null)
      path = _path.lookup(urlString);
    else
      path = Vfs.lookup(urlString);

    TempFileInode inode = _tempFileManager.createInode();

    try {
      String sha1 = loadChecksum(urlString, "sha1");
      String md5 = null;

      if (sha1 == null)
  md5 = loadChecksum(urlString, "md5");

      InputStream is = null;
      try {
  long length = path.getLength();
 
  is = path.openRead();

  OutputStream out = inode.openOutputStream();

  TempBuffer tempBuffer = TempBuffer.allocate();
  byte []buffer = tempBuffer.getBuffer();
 
  int readLength = 0;
  int len;

  log.info("ModuleRepository[] loading " + urlString);

  while ((len = is.read(buffer, 0, buffer.length)) > 0) {
    out.write(buffer, 0, len);
    readLength += len;
  }

  out.close();

  TempBuffer.free(tempBuffer);

  InodeDataSource dataSource
    = new InodeDataSource(path.getURL(), inode);
 
  if (md5 != null)
    validateSignature(dataSource, md5, "MD5");

  if (sha1 != null)
    validateSignature(dataSource, sha1, "SHA1");
 
  inode = null;

  return dataSource;
      } finally {
  if (is != null)
    is.close();
      }
    } catch (SecurityException e) {
      throw new ModuleNotFoundException(L.l("{0} failed signature validation",
              path.getURL(), e));
    } catch (MalformedURLException e) {
      throw new ModuleNotFoundException(e);
    } catch (IOException e) {
      throw new ModuleNotFoundException(L.l("{0} is an unknown module",
              path.getURL()),
          e);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      if (inode != null)
  inode.free();
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.server.cache.TempFileInode$TempFileOutputStream

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.