Пример #1
0
  @Override
  public void validatePlatform() throws InstallException {

    super.validatePlatform();
    try {

      boolean valid = true;

      FileObject catalinaJar = targetLibDir.resolveFile("catalina.jar");

      if (catalinaJar == null
          || !catalinaJar.exists()
          || !catalinaJar.getType().getName().equals(FileType.FILE.getName())) {
        valid = false;
        getPrinter().printErrStatus("CatalinaHome", "Cannot find catalina");
      }

      FileObject serverXml = targetConfDir.resolveFile("server.xml");
      if (serverXml == null
          || !serverXml.exists()
          || !serverXml.getType().getName().equals(FileType.FILE.getName())) {
        valid = false;
        getPrinter().printErrStatus("CatalinaHome", "Cannot find server.xml");
      }

      // TODO : Validate Version ?

      if (!valid)
        throw new InstallException(
            "Target does not seem a " + getTargetPlatform().getDescription() + " install.");

    } catch (IOException e) {
      getPrinter().printErrStatus("CatalinaHome", e.getMessage());
      throw new InstallException(e.getMessage(), e);
    }

    getPrinter().printOkStatus("CatalinaHome");
  }
Пример #2
0
  @Override
  public boolean backupAgentConfigurations(boolean remove) {
    try {
      super.backupAgentConfigurations(remove);
      // backup jaas.conf
      FileObject jaasConfigFile = targetConfDir.resolveFile("jaas.conf");
      if (jaasConfigFile.exists()) {
        // backup file in the same folder it is installed
        backupFile(jaasConfigFile, jaasConfigFile.getParent());
        if (remove) {
          jaasConfigFile.delete();
        }
      }
      // backup setenv.sh and setenv.bat
      FileObject[] libs = targetBinDir.getChildren();
      for (int i = 0; i < libs.length; i++) {
        FileObject cfgFile = libs[i];

        if (!cfgFile.getType().getName().equals(FileType.FILE.getName())) {
          // ignore folders
          continue;
        }
        if (cfgFile.getName().getBaseName().startsWith("setenv")
            && (cfgFile.getName().getBaseName().endsWith(".sh")
                || cfgFile.getName().getBaseName().endsWith(".bat"))) {
          // backup files in the same folder they're installed in
          backupFile(cfgFile, cfgFile.getParent());
          if (remove) {
            cfgFile.delete();
          }
        }
      }
    } catch (Exception e) {
      getPrinter().printErrStatus("BackupAgentConfigurations", e.getMessage());
      return false;
    }
    return true;
  }