protected void validateRepository(CRepository settings, boolean create) throws ConfigurationException { ApplicationValidationContext ctx = getRepositoryValidationContext(); if (!create && !StringUtils.isEmpty(settings.getId())) { // remove "itself" from the list to avoid hitting "duplicate repo" problem ctx.getExistingRepositoryIds().remove(settings.getId()); } ValidationResponse vr = configurationValidator.validateRepository(ctx, settings); if (!vr.isValid()) { throw new InvalidConfigurationException(vr); } }
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)); } }