Beispiel #1
0
    protected ConfigSaveState updatePartial(String xmlPartial, final String md5) throws Exception {
      LOGGER.debug("[Config Save] Updating partial");
      org.dom4j.Document document = documentRoot();
      Element root = document.getRootElement();

      Element configElement = ((Element) root.selectSingleNode(getXpath()));
      List nodes = configElement.getParent().content();
      int index = nodes.indexOf(configElement);

      LOGGER.debug("[Config Save] Converting to object");
      Element newConfigElement = reader.read(new StringReader(xmlPartial)).getRootElement();
      nodes.set(index, newConfigElement);

      return saveConfig(document.asXML(), md5);
    }
Beispiel #2
0
    protected ConfigSaveState saveConfig(final String xmlString, final String md5)
        throws Exception {
      LOGGER.debug("[Config Save] Started saving XML");
      final MagicalGoConfigXmlLoader configXmlLoader =
          new MagicalGoConfigXmlLoader(configCache, registry);

      LOGGER.debug("[Config Save] Updating config");
      final CruiseConfig deserializedConfig = configXmlLoader.deserializeConfig(xmlString);

      ConfigSaveState configSaveState =
          systemEnvironment.optimizeFullConfigSave()
              ? saveConfigNewFlow(deserializedConfig, md5)
              : saveConfigOldFlow(deserializedConfig, md5);

      LOGGER.debug("[Config Save] Finished saving XML");
      return configSaveState;
    }
Beispiel #3
0
    private ConfigSaveState saveConfigOldFlow(
        final CruiseConfig deserializedConfig, final String md5) {
      LOGGER.debug("[Config Save] Updating config using the old flow");
      return goConfigDao.updateConfig(
          new NoOverwriteUpdateConfigCommand() {
            public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
              deserializedConfig.setPartials(cruiseConfig.getPartials());
              return deserializedConfig;
            }

            public String unmodifiedMd5() {
              return md5;
            }
          });
    }
Beispiel #4
0
 private ConfigSaveState saveConfigNewFlow(CruiseConfig cruiseConfig, String md5) {
   LOGGER.debug("[Config Save] Updating config using the new flow");
   return goConfigDao.updateFullConfig(new FullConfigUpdateCommand(cruiseConfig, md5));
 }