Beispiel #1
0
  /**
   * The purpose of this method is to make final changes for the update processes, like cleaning,
   * rebuilt fields, etc....
   *
   * @return
   * @throws UpdateException
   * @throws IOException
   */
  public Boolean postUpdate() throws UpdateException, IOException {

    logger.info(Messages.getString("UpdateAgent.debug.start.post.process"));

    PostProcess postProcess = new PostProcess(distributionHome, dotcmsHome);

    if (!dryrun) {

      logger.info(Messages.getString("UpdateAgent.debug.start.validation"));

      if (postProcess.postProcess(true)) {

        logger.info(Messages.getString("UpdateAgent.debug.end.validation"));

        // Boolean success = true;

        logger.debug("Finished to clean update process traces.");

        /*if ( !success ) {
            String error = Messages.getString( "UpdateAgent.error.ant.clean" );
            if ( !UpdateAgent.isDebug ) {
                error += Messages.getString( "UpdateAgent.text.use.verbose", UpdateAgent.logFile );
            }
            throw new UpdateException( error, UpdateException.ERROR );
        }*/
      } else {
        String error = Messages.getString("UpdateAgent.error.plugin.incompatible");
        if (!UpdateAgent.isDebug) {
          error += Messages.getString("UpdateAgent.text.use.verbose", UpdateAgent.logFile);
        }

        throw new UpdateException(error, UpdateException.ERROR);
      }
    }

    logger.info(Messages.getString("UpdateAgent.debug.end.post.process"));
    return true;
  }
Beispiel #2
0
  /**
   * This method will be call it before the update process, actually this method will work as
   * preparation for the update, basically what it does to to back-up the current .dotserver/ code
   *
   * @throws IOException
   * @throws UpdateException
   */
  public void preUpdate() throws UpdateException {

    logger.info(Messages.getString("UpdateAgent.debug.start.backUp"));

    // Current format for the back-up folder
    SimpleDateFormat folderDateFormat = new SimpleDateFormat("yyyyMMdd");

    // This is the name of the folder where we are going to store the back-up
    String currentBackUpFolderName = folderDateFormat.format(new Date());
    // Complete back-up path
    String backUpPath =
        distributionHome
            + File.separator
            + UpdateAgent.FOLDER_HOME_BACK_UP
            + File.separator
            + currentBackUpFolderName;
    // .dotserver folder path
    String dotserverPath = distributionHome + File.separator + UpdateAgent.FOLDER_HOME_DOTSERVER;
    // .bin folder path
    String binPath = distributionHome + File.separator + UpdateAgent.FOLDER_HOME_BIN;
    // .plugins folder path
    String pluginsPath = distributionHome + File.separator + UpdateAgent.FOLDER_HOME_PLUGINS;

    try {

      // First we need to create the back up for the current project, for this we need to user hard
      // links, this back up could be huge
      FileUtil.copyDirectory(
          dotserverPath, backUpPath + File.separator + UpdateAgent.FOLDER_HOME_DOTSERVER, true);
      FileUtil.copyDirectory(
          pluginsPath, backUpPath + File.separator + UpdateAgent.FOLDER_HOME_PLUGINS, true);
      FileUtil.copyDirectory(
          binPath, backUpPath + File.separator + UpdateAgent.FOLDER_HOME_BIN, true);

    } catch (Exception e) {
      String error = Messages.getString("UpdateAgent.error.ant.prepare.back-up");
      if (!UpdateAgent.isDebug) {
        error += Messages.getString("UpdateAgent.text.use.verbose", UpdateAgent.logFile);
      }
      logger.error(error, e);
      throw new UpdateException(error, UpdateException.ERROR);
    }
  }