Package org.nasutekds.quicksetup.util

Examples of org.nasutekds.quicksetup.util.FileManager$DeleteOperation


   *
   * @param root of the stage directory
   */
  public Stage(File root) {
    this.root = root;
    this.fm = new FileManager();
  }
View Full Code Here


   * @throws ApplicationException if there is an error copying the new
   * ADS backend file.
   */
  public void migrateADS(File newADSFile) throws ApplicationException
  {
    FileManager fileManager = new FileManager();
    fileManager.copy(newADSFile, installation.getConfigurationDirectory(),
        true);
  }
View Full Code Here

   * properties file.
   */
  public void migrateToolPropertiesFile(File newPropertiesFile)
  throws ApplicationException
  {
    FileManager fileManager = new FileManager();
    fileManager.copy(newPropertiesFile,
        installation.getConfigurationDirectory(), true);
  }
View Full Code Here

      File root = getInstallation().getRootDirectory();
      File backupDirectory;
      try {
        backupDirectory = getFilesInstallBackupDirectory();
        FileManager fm = new FileManager();
        boolean restoreError = false;
        for (String fileName : backupDirectory.list()) {
          File f = new File(backupDirectory, fileName);

          // Do our best to restore the filesystem like
          // we found it.  Just report potential problems
          // to the user.
          try {
            fm.move(f, root, null);
          } catch (Throwable t) {
            restoreError = true;
            notifyListeners(INFO_ERROR_RESTORING_FILE.get(Utils.getPath(f),
                    Utils.getPath(root)));
          }
        }
        if (!restoreError) {
          fm.deleteRecursively(backupDirectory);
        }

        if (! instanceAndInstallInSameDir())
        {
          root = getInstallation().getInstanceDirectory();
          backupDirectory = getFilesInstanceBackupDirectory();
          fm = new FileManager();
          for (String fileName : backupDirectory.list()) {
            File f = new File(backupDirectory, fileName);

            // Do our best to restore the filesystem like
            // we found it.  Just report potential problems
            // to the user.
            try {
              fm.move(f, root, null);
            } catch (Throwable t) {
              restoreError = true;
              notifyListeners(INFO_ERROR_RESTORING_FILE.get(Utils.getPath(f),
                      Utils.getPath(root)));
            }
          }
          if (!restoreError) {
            fm.deleteRecursively(backupDirectory);
          }
        }

        // Restart the server after putting the files
        // back like we found them.
View Full Code Here

                     Installation.CONFIG_PATH_RELATIVE);
    File newInstallConfigDir =
            getInstallation().getInstallConfigurationDirectory();
    File newInstanceConfigDir =
      getInstallation().getConfigurationDirectory();
    FileManager fm = new FileManager();

    // Define a filter for files that we don't want to copy over
    // from the old config directory.
    {
      final File oldConfigUpgradeDir = new File(oldInstallConfigDir, "upgrade");
      final File oldConfigSchemaDir = new File(oldInstallConfigDir, "schema");
      FileFilter filter = new FileFilter()
      {
        public boolean accept(File f)
        {
          return !Utils.isDescendant(f, oldConfigUpgradeDir)
              && !Utils.isDescendant(f, oldConfigSchemaDir);
        }
      };

      fm.synchronize(oldInstallConfigDir, newInstallConfigDir, filter);
    }

    {
      final File oldConfigUpgradeDir =
        new File(oldInstanceConfigDir, "upgrade");
      FileFilter filter = new FileFilter()
      {
        public boolean accept(File f)
        {
          return !Utils.isDescendant(f, oldConfigUpgradeDir);
        }
      };

      fm.synchronize(oldInstanceConfigDir, newInstanceConfigDir, filter);
    }
  }
View Full Code Here

    File savedDir =
            new File(getFilesInstanceBackupDirectory(),
                     Installation.LIBRARIES_PATH_RELATIVE);
    File destDir = getInstallation().getInstanceDirectory();

    FileManager fm = new FileManager();
    fm.copyRecursively(savedDir, destDir);

    // Get classes back
    savedDir =
            new File(getFilesInstanceBackupDirectory(),
                     Installation.CLASSES_PATH_RELATIVE);
    destDir = getInstallation().getInstanceDirectory();

    fm.copyRecursively(savedDir, destDir);

  }
View Full Code Here

  protected void backupFilesystem() throws ApplicationException {
    try {
      // Backup first install (potentially everything if install and instance
      //  are in the same dir
      File filesBackupDirectory = getFilesInstallBackupDirectory();
      FileManager fm = new FileManager();
      File root = getInstallation().getRootDirectory();
      FileFilter filter = new UpgradeFileFilter(root);
      for (String fileName : root.list()) {
        File f = new File(root, fileName);

        // Replacing a Windows bat file while it is running with a different
        // version leads to unpredictable behavior so we make a special case
        // here and during the upgrade components step.  This file will only
        // be backed up at the end of the process if everything went fine.
        if (Utils.isWindows() &&
                fileName.equals(Installation.WINDOWS_UPGRADE_FILE_NAME)) {
          continue;
        }

        fm.move(f, filesBackupDirectory, filter);
      }
      if (!instanceAndInstallInSameDir())
      {
        filesBackupDirectory = getFilesInstanceBackupDirectory();
        root = getInstallation().getInstanceDirectory();
        filter = new UpgradeFileFilter(root);
        for (String fileName : root.list())
        {
          File f = new File(root, fileName);

          // Replacing a Windows bat file while it is running with a different
          // version leads to unpredictable behavior so we make a special case
          // here and during the upgrade components step. This file will only
          // be backed up at the end of the process if everything went fine.
          if (Utils.isWindows()
              && fileName.equals(Installation.WINDOWS_UPGRADE_FILE_NAME))
          {
            continue;
          }
          fm.move(f, filesBackupDirectory, filter);
        }
      }
    } catch (ApplicationException ae) {
      throw ae;
    } catch (Exception e) {
View Full Code Here

    try
    {
      if (Utils.isWindows())
      {
        File filesBackupDirectory = getFilesInstallBackupDirectory();
        FileManager fm = new FileManager();
        File root = getInstallation().getRootDirectory();
        File f = new File(root, Installation.WINDOWS_UPGRADE_FILE_NAME);
        fm.copy(f, filesBackupDirectory);
      }
    } catch (ApplicationException ae) {
      throw ae;
    } catch (Exception e) {
      throw new ApplicationException(
View Full Code Here

  private void deleteStagingDirectory() throws ApplicationException {
    File stagingDir = null;
    try {
      stagingDir = getStageDirectory();
      FileManager fm = new FileManager();

      // On Linux at least the deleteOnExit seems not to work very well
      // for directories that contain files, even if they have been marked
      // for deletion upon exit as well.  Note that on Windows there are
      // file locking issues so we mark files for deletion after this JVM exits.
      if (stagingDir.exists()) {
        fm.deleteRecursively(stagingDir, null,
                FileManager.DeletionPolicy.DELETE_ON_EXIT_IF_UNSUCCESSFUL);
      }

    } catch (IOException e) {
      throw ApplicationException.createFileSystemException(
View Full Code Here

  private void backupCurrentInstallation() throws ApplicationException {
    LOG.log(Level.INFO, "Backing up filesystem");
    try {
      File filesBackupDirectory = getTempBackupDirectory();
      FileManager fm = new FileManager();
      File root = getInstallation().getRootDirectory();
      FileFilter filter = new RevertFileFilter(root);
      for (String fileName : root.list()) {
        File f = new File(root, fileName);

        // Replacing a Windows bat file while it is running with a different
        // version leads to unpredictable behavior so we make a special case
        // here and during the upgrade components step.
        if (Utils.isWindows() &&
                fileName.equals(WINDOWS_UPGRADE_FILE_NAME)) {
          continue;
        }

        fm.move(f, filesBackupDirectory, filter);
      }
      LOG.log(Level.INFO, "Finished backing up filesystem");
    } catch (ApplicationException ae) {
      LOG.log(Level.INFO, "Error backing up filesystem", ae);
      throw ae;
View Full Code Here

TOP

Related Classes of org.nasutekds.quicksetup.util.FileManager$DeleteOperation

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.