Package org.sonatype.nexus.configuration.model

Examples of org.sonatype.nexus.configuration.model.Configuration


  }

  protected void assertTasks()
      throws IOException
  {
    Configuration nexusConfig = getNexusConfigUtil().getNexusConfig();

    List<CScheduledTask> tasks = nexusConfig.getTasks();
    Assert.assertEquals(1, tasks.size());

    CScheduledTask task = tasks.get(0);
    E scheduledTask = getTaskScheduled();
View Full Code Here


  @SuppressWarnings("unchecked")
  public void verifyTargetsConfig(List<RepositoryTargetResource> targetResources)
      throws IOException
  {
    // check the nexus.xml
    Configuration config = new NexusConfigUtil().getNexusConfig();

    List<CRepositoryTarget> repoTargets = config.getRepositoryTargets();

    // TODO: we can't check the size unless we reset the config after each run...
    // check to see if the size matches
    // Assert.assertTrue( "Configuration had a different number: (" + repoTargets.size()
    // + ") of targets then expected: (" + targetResources.size() + ")",
View Full Code Here

  public void verifyCompleteTargetsConfig(List<RepositoryTargetListResource> targets)
      throws IOException
  {
    // check the nexus.xml
    Configuration config = new NexusConfigUtil().getNexusConfig();

    List<CRepositoryTarget> repoTargets = config.getRepositoryTargets();
    // check to see if the size matches
    Assert.assertTrue("Configuration had a different number: (" + repoTargets.size()
        + ") of targets then expected: (" + targets.size() + ")", repoTargets.size() == targets.size());

    // look for the target by id
View Full Code Here

    org.sonatype.nexus.configuration.model.v2_7_0.Configuration oldc =
        (org.sonatype.nexus.configuration.model.v2_7_0.Configuration) message.getConfiguration();

    org.sonatype.nexus.configuration.model.v2_8_0.upgrade.BasicVersionUpgrade versionConverter = new org.sonatype.nexus.configuration.model.v2_8_0.upgrade.BasicVersionUpgrade();

    Configuration newc = versionConverter.upgradeConfiguration(oldc);
    newc.setVersion(Configuration.MODEL_VERSION);

    // no structural change sofar
    // TODO: remove this comment above if we do some

    message.setModelVersion(Configuration.MODEL_VERSION);
View Full Code Here

  public void testBad1()
      throws Exception
  {
    // get start with the default config
    this.copyDefaultConfigToPlace();
    Configuration config = this.loadNexusConfig(new File(this.getNexusConfiguration()));

    // make it bad

    // remove the name from a repository
    CRepository missingNameRepo = (CRepository) config.getRepositories().get(0);
    missingNameRepo.setName(null);

    // TDOD add 2 more warnings

    // wrong shadow type
    CRepository badShadow = new DefaultCRepository();
    badShadow.setId("badShadow");
    badShadow.setName("Does not follow");
    badShadow.setProviderRole(ShadowRepository.class.getName());
    badShadow.setProviderHint("m2-m1-shadow");
    // Manipulate the dom
    Xpp3Dom externalConfig = new Xpp3Dom("externalConfiguration");
    badShadow.setExternalConfiguration(externalConfig);
    ExternalConfigUtil.setNodeValue(externalConfig, "masterRepositoryId", "non-existent");
    config.addRepository(badShadow);

    // now validate it
    ValidationResponse response = underTest.validateModel(new ValidationRequest(config));

    assertThat(response.getValidationWarnings(), hasSize(1));
View Full Code Here

      throws Exception
  {
    // get start with the default config
    this.copyDefaultConfigToPlace();
    this.copyResource("/META-INF/nexus/default-oss-nexus.xml", getNexusConfiguration());
    Configuration config = this.loadNexusConfig(new File(this.getNexusConfiguration()));

    // make it bad

    // invalid policy
    CRepository invalidPolicyRepo = config.getRepositories().get(0);
    Xpp3Dom externalConfig = (Xpp3Dom) invalidPolicyRepo.getExternalConfiguration();
    ExternalConfigUtil.setNodeValue(externalConfig, "repositoryPolicy", "badPolicy");

    // duplicate the repository id
    for (CRepository repo : config.getRepositories()) {
      if (!repo.getId().equals("central")) {
        // duplicate
        repo.setId("central");
        break;
      }
View Full Code Here

    // raw load the config file in place
    FileReader fileReader = new FileReader(configFile);

    NexusConfigurationXpp3Reader reader = new NexusConfigurationXpp3Reader();

    Configuration config = reader.read(fileReader);

    fileReader.close();

    CRepository publicGroup = null;

    // simple put the "public" group (that reference other reposes) as 1st!
    for (CRepository repository : config.getRepositories()) {
      if ("public".equals(repository.getId())) {
        publicGroup = repository;

        break;
      }
    }

    if (publicGroup == null) {
      Assert.fail("Public group not found in default configuration?");
    }

    config.getRepositories().remove(publicGroup);

    config.getRepositories().add(0, publicGroup);

    // raw save the modified config
    FileWriter fileWriter = new FileWriter(configFile);

    NexusConfigurationXpp3Writer writer = new NexusConfigurationXpp3Writer();
View Full Code Here

      log.error(message, e);
      throw new IOException("Could not create configuration file " + file.getAbsolutePath(), e);
    }

    // Clone the conf so we can encrypt the passwords
    final Configuration configuration = configHelper.encryptDecryptPasswords(getConfiguration(), true);
    log.debug("Saving configuration: {}", file);
    final FileReplacer fileReplacer = new FileReplacer(file);
    // we save this file many times, don't litter backups
    fileReplacer.setDeleteBackupFile(true);
    fileReplacer.replace(new ContentWriter()
View Full Code Here

  public ValidationResponse validateModel(ValidationRequest request) {
    ValidationResponse response = new ApplicationValidationResponse();

    response.setContext(new ApplicationValidationContext());

    Configuration model = (Configuration) request.getConfiguration();

    ApplicationValidationContext context = (ApplicationValidationContext) response.getContext();

    response.setContext(context);

    // global conn settings
    if (model.getGlobalConnectionSettings() != null) {
      response.append(validateRemoteConnectionSettings(context, model.getGlobalConnectionSettings()));
    }
    else {
      model.setGlobalConnectionSettings(new CRemoteConnectionSettings());

      response
          .addValidationWarning(
              "Global connection settings block, which is mandatory, was missing. Reset with defaults.");

      response.setModified(true);
    }

    // remote proxy settings (optional)
    final CRemoteProxySettings rps = model.getRemoteProxySettings();
    if (rps != null) {
      if (rps.getHttpProxySettings() != null) {
        response.append(validateRemoteHttpProxySettings(context, rps.getHttpProxySettings()));
      }
      if (rps.getHttpsProxySettings() != null) {
        response.append(validateRemoteHttpProxySettings(context, rps.getHttpsProxySettings()));
      }
    }

    // rest api
    if (model.getRestApi() != null) {
      response.append(validateRestApiSettings(context, model.getRestApi()));
    }

    // nexus built-in http proxy
    if (model.getHttpProxy() != null) {
      response.append(validateHttpProxySettings(context, model.getHttpProxy()));
    }
    else {
      model.setHttpProxy(new CHttpProxySettings());

      response.addValidationWarning("The HTTP Proxy section was missing from configuration, defaulted it.");

      response.setModified(true);
    }

    // routing
    if (model.getRouting() != null) {
      response.append(validateRouting(context, model.getRouting()));
    }
    else {
      model.setRouting(new CRouting());

      response.addValidationWarning("The routing section was missing from configuration, defaulted it.");

      response.setModified(true);
    }

    // check existing reposes and check their realms
    context.addExistingRepositoryIds();

    List<CRepository> reposes = model.getRepositories();

    for (CRepository repo : reposes) {
      response.append(validateRepository(context, repo));
    }

    // check groups (optional section)
    if (model.getRepositoryGrouping() != null) {
      response.append(validateRepositoryGrouping(context, model.getRepositoryGrouping()));
    }

    // check remote nexus instances (optional section)
    if (model.getRemoteNexusInstances() != null) {
      List<CRemoteNexusInstance> instances = model.getRemoteNexusInstances();

      for (CRemoteNexusInstance instance : instances) {
        response.append(validateRemoteNexusInstance(context, instance));
      }
    }

    // check repo targets (optional section)
    if (model.getRepositoryTargets() != null) {
      List<CRepositoryTarget> targets = model.getRepositoryTargets();

      for (CRepositoryTarget target : targets) {
        response.append(validateRepositoryTarget(context, target));
      }
    }

    // check tasks (optional section)
    if (model.getTasks() != null) {
      List<CScheduledTask> tasks = model.getTasks();

      for (CScheduledTask task : tasks) {
        response.append(validateScheduledTask(context, task));
      }
    }

    response.append(validateSmtpConfiguration(context, model.getSmtpConfiguration()));

    return response;
  }
View Full Code Here

  @Test
  public void testSaveRemoteProxyConfiguration()
      throws Exception
  {
    Configuration config = nexusConfiguration.getConfigurationModel();

    assertEquals(null, config.getRemoteProxySettings());

    final DefaultRemoteHttpProxySettings httpProxySettings = new DefaultRemoteHttpProxySettings();
    httpProxySettings.setHostname("http.proxy.com");
    httpProxySettings.setPort(1234);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.configuration.model.Configuration

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.