/*
   * (non-Javadoc)
   * @see com.aptana.core.io.vfs.BaseConnectionFileManager#canUseTemporaryFile(org.eclipse.core.runtime.IPath,
   * com.aptana.core.io.vfs.ExtendedFileInfo, org.eclipse.core.runtime.IProgressMonitor)
   */
  @Override
  protected boolean canUseTemporaryFile(
      IPath path, ExtendedFileInfo fileInfo, IProgressMonitor monitor) {
    ConnectionContext context = CoreIOPlugin.getConnectionContext(this);
    if (context != null && context.containsKey(ConnectionContext.USE_TEMPORARY_ON_UPLOAD)) {
      return context.getBoolean(ConnectionContext.USE_TEMPORARY_ON_UPLOAD);
    }
    if (fileInfo.exists()) {
      // test if using temporary file for existing file may cause any differences on remote side
      if (defaultOwner == null || defaultGroup == null) {
        IPath tempFile =
            basePath
                .append(path)
                .removeLastSegments(1)
                .append(System.currentTimeMillis() + TMP_UPLOAD_SUFFIX);
        ExtendedFileInfo tempFileInfo = null;
        monitor.beginTask(Messages.BaseFTPConnectionFileManager_GetheringServerDetails, 3);
        try {
          try {
            createFile(tempFile, Policy.subMonitorFor(monitor, 1));
            tempFileInfo = fetchFileInternal(tempFile, EFS.NONE, Policy.subMonitorFor(monitor, 1));
          } finally {
            deleteFile(tempFile, Policy.subMonitorFor(monitor, 1));
          }
        } catch (Exception e) {
          FTPPlugin.log(
              new Status(
                  IStatus.WARNING,
                  FTPPlugin.PLUGIN_ID,
                  Messages.BaseFTPConnectionFileManager_ErrorDetectOwnerGroup,
                  e));
        }

        if (tempFileInfo != null) {
          defaultOwner = tempFileInfo.getOwner();
          defaultGroup = tempFileInfo.getGroup();
        }
      }
      if (defaultOwner == null) {
        defaultOwner = Long.toHexString(System.currentTimeMillis());
      }
      if (defaultGroup == null) {
        defaultGroup = Long.toHexString(System.currentTimeMillis());
      }
      if (!defaultOwner.equals(fileInfo.getOwner()) || !defaultGroup.equals(fileInfo.getGroup())) {
        return false;
      }
    }
    return true;
  }
 /*
  * (non-Javadoc)
  * @see com.aptana.core.io.vfs.BaseConnectionFileManager#testConnection(boolean)
  */
 @Override
 protected void testConnection(boolean force) {
   if (!isConnected()) {
     return;
   }
   if (force || (System.currentTimeMillis() - lastOperationTime > CHECK_CONNECTION_TIMEOUT)) {
     try {
       checkConnected();
       if (isConnected()) {
         setLastOperationTime();
       }
     } catch (Exception e) {
       FTPPlugin.log(
           new Status(
               IStatus.WARNING,
               FTPPlugin.PLUGIN_ID,
               Messages.BaseFTPConnectionFileManager_connection_check_failed,
               e));
     }
   }
 }