Package net.sourceforge.squirrel_sql.fw.util

Examples of net.sourceforge.squirrel_sql.fw.util.FileWrapper


     }
    
   }
  
   private FileWrapper getDirectoryMock(String name) {
     FileWrapper result = mockHelper.createMock(name, FileWrapper.class);
     expect(result.isDirectory()).andStubReturn(true);
     return result;
   }
View Full Code Here


     expect(result.isDirectory()).andStubReturn(true);
     return result;
   }
  
   private FileWrapper getFileMock(String name, String path) {
     FileWrapper result = mockHelper.createMock(name, FileWrapper.class);
     expect(result.isDirectory()).andStubReturn(false);
     expect(result.getAbsolutePath()).andStubReturn(path);
     return result;    
   }
View Full Code Here

    final String destDir, final long fileSize, final long checksum, final IProxySettings proxySettings)
    throws Exception
  {
    URL url = _iou.constructHttpUrl(host, port, fileToGet);
    String result = null;
    FileWrapper resultFile = _fileWrapperFactory.create(destDir, _pathUtils.getFileFromPath(fileToGet));
    result = resultFile.getAbsolutePath();

    if (s_log.isDebugEnabled())
    {
      s_log.debug("downloadHttpFile: writing http response body to file: " + resultFile);
    }
View Full Code Here

   * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#
   *      getDownloadFileLocation(net.sourceforge.squirrel_sql.client.update.gui.ArtifactStatus)
   */
  public FileWrapper getDownloadFileLocation(ArtifactStatus status)
  {
    FileWrapper result = null;
    if (CORE_ARTIFACT_ID.equals(status.getType()))
    {
      result = getFile(getCoreDownloadsDir(), status.getName());
    }
    if (PLUGIN_ARTIFACT_ID.equals(status.getType()))
View Full Code Here

   */
  public boolean isPresentInDownloadsDirectory(ArtifactStatus status)
  {
    boolean result = false;

    FileWrapper downloadFile = getDownloadFileLocation(status);

    if (downloadFile.exists())
    {
      long checkSum = getCheckSum(downloadFile);
      if (status.getChecksum() == checkSum)
      {
        if (downloadFile.length() == status.getSize())
        {
          result = true;
        }
      }
    }
View Full Code Here

   * @param create
   * @return
   */
  private FileWrapper getDir(FileWrapper parent, String dirName, boolean create)
  {
    FileWrapper result = null;
    if (dirName != null)
    {
      result = _fileWrapperFactory.create(parent, dirName);
    }
    else
    {
      result = parent;
    }
    if (!result.isDirectory())
    {
      if (result.exists())
      {
        // If the update dir, is actually a file, log an error.
        s_log.error(dirName + " directory (" + result.getAbsolutePath()
          + ") doesn't appear to be a directory");
      }
      else
      {
        // If the downloads dir doesn't already exist, just create it.
        if (create)
        {
          result.mkdir();
        }
      }
    }
    return result;
  }
View Full Code Here

      // We set expected and checksum to -1 here, since we don't have that information for release.xml file
      // TODO: Can HttpClient be used to get the byte-size of release.xml so we can perform this check?
      String filename =
        downloadHttpUpdateFile(host, port, fileToGet, getDownloadsDir().getAbsolutePath(), -1, -1,
          proxySettings);
      FileWrapper releaseXmlFile = _fileWrapperFactory.create(filename);
      if (releaseXmlFile.exists())
      {
        result = _serializer.readChannelBean(releaseXmlFile);
      }
      else
      {
View Full Code Here

  public ChannelXmlBean loadUpdateFromFileSystem(final String path)
  {
    ChannelXmlBean result = null;
    try
    {
      FileWrapper f = _fileWrapperFactory.create(path);
      if (!f.isDirectory())
      {
        s_log.error("FileSystem path (" + path + ") is not a directory.");
      }
      else
      {
View Full Code Here

   */
  public boolean downloadLocalUpdateFile(String fileToGet, String destDir) throws FileNotFoundException,
    IOException
  {
    boolean result = false;
    FileWrapper fromFile = _fileWrapperFactory.create(fileToGet);
    if (fromFile.isFile() && fromFile.canRead())
    {
      String filename = fromFile.getName();
      FileWrapper toFile = _fileWrapperFactory.create(destDir, filename);
      copyFile(fromFile, toFile);
      result = true;
    }
    else
    {
View Full Code Here

    if (!from.exists())
    {
      s_log.error("Cannot copy from file (" + from.getAbsolutePath() + ") which doesn't appear to exist.");
      return;
    }
    FileWrapper toFile = to;
    // Check to see if to is a directory and convert toFile to be the name of the file in that directory.
    if (to.isDirectory())
    {
      toFile = getFile(to, from.getName());
    }
    if (s_log.isDebugEnabled())
    {
      s_log.debug("Copying from file (" + from.getAbsolutePath() + ") to file ("
        + toFile.getAbsolutePath() + ")");
    }
    if (toFile.exists())
    {
      long fromCheckSum = getCheckSum(from);
      long toCheckSum = getCheckSum(toFile);
      if (fromCheckSum == toCheckSum)
      {
        if (s_log.isInfoEnabled())
        {
          s_log.info("File to be copied(" + from.getAbsolutePath() + ") has the same checksum("
            + fromCheckSum + ") as the file to copy to (" + toFile.getAbsolutePath()
            + "). Skipping copy.");
        }
        return;
      }
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.fw.util.FileWrapper

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.