Package org.sonatype.configuration.upgrade

Examples of org.sonatype.configuration.upgrade.UpgradeMessage


    if (SecurityConfiguration.MODEL_VERSION.equals(modelVersion)) {
      // we have a problem here, model version is OK but we could not load it previously?
      throw new ConfigurationIsCorruptedException(file);
    }

    UpgradeMessage msg = new UpgradeMessage();

    msg.setModelVersion(modelVersion);

    SecurityConfigurationVersionUpgrader upgrader = upgraders.get(msg.getModelVersion());

    if (upgrader != null) {
      logger.info("Upgrading old Security configuration file (version {}) from {}", msg.getModelVersion(),
          file.getAbsolutePath());

      msg.setConfiguration(upgrader.loadConfiguration(file));

      while (!SecurityConfiguration.MODEL_VERSION.equals(msg.getModelVersion())) {
        if (upgrader != null) {
          upgrader.upgrade(msg);
        }
        else {
          // we could parse the XML but have no model version? Is this security config at all?
          throw new UnsupportedConfigurationVersionException(modelVersion, file);
        }

        upgrader = upgraders.get(msg.getModelVersion());
      }

      logger.info("Security configuration file upgraded to current version {} successfully", msg.getModelVersion());

      return (SecurityConfiguration) msg.getConfiguration();
    }
    else {
      // we could parse the XML but have no model version? Is this security config at all?
      throw new UnsupportedConfigurationVersionException(modelVersion, file);
    }
View Full Code Here


    if (Configuration.MODEL_VERSION.equals(modelVersion)) {
      // we have a problem here, model version is OK but we could not load it previously?
      throw new ConfigurationIsCorruptedException(file);
    }

    UpgradeMessage msg = new UpgradeMessage();

    msg.setModelVersion(modelVersion);

    // a correction for SWX
    if ("1.0".equals(modelVersion)) {
      msg.setModelVersion("1.0.0");
    }

    SingleVersionUpgrader upgrader = upgraders.get(msg.getModelVersion());

    if (upgrader != null) {
      log.debug(
          "Upgrading old Nexus configuration file (version {}) at {}", msg.getModelVersion(),
          file.getAbsolutePath());

      msg.setConfiguration(upgrader.loadConfiguration(file));

      while (!Configuration.MODEL_VERSION.equals(msg.getModelVersion())) {
        if (upgrader != null) {
          upgrader.upgrade(msg);
        }
        else {
          // we could parse the XML but have no model version? Is this nexus config at all?
          throw new UnsupportedConfigurationVersionException(modelVersion, file);
        }

        upgrader = upgraders.get(msg.getModelVersion());
      }

      log.info("Nexus configuration file upgraded to current version {} successfully., ", msg.getModelVersion());

      return (Configuration) msg.getConfiguration();
    }
    else {
      // we could parse the XML but have no model version? Is this nexus config at all?
      throw new UnsupportedConfigurationVersionException(modelVersion, file);
    }
View Full Code Here

    if (Configuration.MODEL_VERSION.equals(modelVersion)) {
      // we have a problem here, model version is OK but we could not load it previously?
      throw new ConfigurationIsCorruptedException(file);
    }

    UpgradeMessage msg = new UpgradeMessage();

    msg.setModelVersion(modelVersion);

    SecurityUpgrader upgrader = upgraders.get(msg.getModelVersion());

    if (upgrader != null) {
      log.info("Upgrading old Security configuration file (version " + msg.getModelVersion() + ") from "
          + file.getAbsolutePath());

      msg.setConfiguration(upgrader.loadConfiguration(file));

      while (!Configuration.MODEL_VERSION.equals(msg.getModelVersion())) {

        // an application might need to upgrade content, that is NOT part of the model
        SecurityDataUpgrader dataUpgrader = this.dataUpgraders.get(msg.getModelVersion());

        if (upgrader != null) {
          upgrader.upgrade(msg);

          if (dataUpgrader != null) {
            dataUpgrader.upgrade(msg.getConfiguration());
          }
        }
        else {
          // we could parse the XML but have no model version? Is this security config at all?
          throw new UnsupportedConfigurationVersionException(modelVersion, file);
        }

        upgrader = upgraders.get(msg.getModelVersion());
      }

      log.info("Security configuration file upgraded to current version " + msg.getModelVersion()
          + " succesfully.");

      return (Configuration) msg.getConfiguration();
    }
    else {
      // we could parse the XML but have no model version? Is this security config at all?
      throw new UnsupportedConfigurationVersionException(modelVersion, file);
    }
View Full Code Here

TOP

Related Classes of org.sonatype.configuration.upgrade.UpgradeMessage

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.