Ejemplo n.º 1
0
  public synchronized void loadConfiguration(boolean force)
      throws ConfigurationException, IOException {
    if (force || configurationSource.getConfiguration() == null) {
      getLogger().info("Loading Nexus Configuration...");

      configurationSource.loadConfiguration();

      boolean modified = false;
      for (ConfigurationModifier modifier : configurationModifiers) {
        modified |= modifier.apply(configurationSource.getConfiguration());
      }

      if (modified) {
        configurationSource.backupConfiguration();
        configurationSource.storeConfiguration();
      }

      globalLocalStorageContext = new DefaultLocalStorageContext(null);

      // create global remote ctx
      // this one has no parent
      globalRemoteStorageContext = new DefaultRemoteStorageContext(null);

      globalRemoteConnectionSettings.configure(this);

      globalRemoteStorageContext.setRemoteConnectionSettings(globalRemoteConnectionSettings);

      remoteProxySettingsConfiguration.configure(this);

      globalRemoteStorageContext.setRemoteProxySettings(remoteProxySettingsConfiguration);

      ConfigurationPrepareForLoadEvent loadEvent = new ConfigurationPrepareForLoadEvent(this);

      eventBus.post(loadEvent);

      if (loadEvent.isVetoed()) {
        getLogger()
            .info(
                vetoFormatter.format(
                    new VetoFormatterRequest(loadEvent, getLogger().isDebugEnabled())));

        throw new ConfigurationException("The Nexus configuration is invalid!");
      }

      applyConfiguration();

      // we successfully loaded config
      eventBus.post(new ConfigurationLoadEvent(this));
    }
  }
Ejemplo n.º 2
0
  public synchronized void saveConfiguration() throws IOException {
    if (applyConfiguration()) {
      // TODO: when NEXUS-2215 is fixed, this should be remove/moved/cleaned
      // START <<<
      // validate before we do anything
      ValidationRequest request = new ValidationRequest(configurationSource.getConfiguration());
      ValidationResponse response = configurationValidator.validateModel(request);
      if (!response.isValid()) {
        this.getLogger()
            .error("Saving nexus configuration caused unexpected error:\n" + response.toString());
        throw new IOException(
            "Saving nexus configuration caused unexpected error:\n" + response.toString());
      }
      // END <<<

      configurationSource.storeConfiguration();

      // we successfully saved config
      eventBus.post(new ConfigurationSaveEvent(this));
    }
  }
Ejemplo n.º 3
0
 public boolean isConfigurationDefaulted() {
   return configurationSource.isConfigurationDefaulted();
 }
Ejemplo n.º 4
0
 public boolean isConfigurationUpgraded() {
   return configurationSource.isConfigurationUpgraded();
 }
Ejemplo n.º 5
0
 public boolean isInstanceUpgraded() {
   return configurationSource.isInstanceUpgraded();
 }
Ejemplo n.º 6
0
 @Deprecated
 public Configuration getConfigurationModel() {
   return configurationSource.getConfiguration();
 }