Package org.sonatype.configuration.validation

Examples of org.sonatype.configuration.validation.ValidationResponse


      if (ctx != null) {
        ctx.incrementGeneration();
      }
    }
    catch (LocalStorageException e) {
      ValidationResponse response = new ApplicationValidationResponse();

      ValidationMessage error =
          new ValidationMessage("overrideLocalStorageUrl", "Repository has an invalid local storage URL '"
              + localUrl, "Invalid file location");

      response.addValidationError(error);

      throw new InvalidConfigurationException(response);
    }

    // clear the NotFoundCache
View Full Code Here


    result.setPatterns(patterns);
    return result;
  }

  protected void validate(CRepositoryTarget target) throws InvalidConfigurationException {
    ValidationResponse response = validator.validateRepositoryTarget(null, target);
    if (!response.isValid()) {
      throw new InvalidConfigurationException(response);
    }
  }
View Full Code Here

  @Override
  public ValidationResponse doValidateChanges(ApplicationConfiguration applicationConfiguration,
                                              CoreConfiguration owner, Xpp3Dom configuration)
  {
    return new ValidationResponse();
  }
View Full Code Here

  @Override
  public ValidationResponse doValidateChanges(ApplicationConfiguration applicationConfiguration,
                                              CoreConfiguration owner, Xpp3Dom config)
  {
    ValidationResponse response = super.doValidateChanges(applicationConfiguration, owner, config);

    // validate master

    List<CRepository> allReposes = applicationConfiguration.getConfigurationModel().getRepositories();

    boolean masterFound = false;

    for (CRepository repository : allReposes) {
      masterFound = masterFound || StringUtils.equals(repository.getId(), getMasterRepositoryId());
    }

    if (!masterFound) {
      String id = ((CRepository) owner.getConfiguration(false)).getId();
      ValidationMessage message =
          new ValidationMessage("shadowOf", "Master repository id=\"" + getMasterRepositoryId()
              + "\" not found for ShadowRepository with id=\"" + id + "\"!",
              "The source nexus repository is not existing.");

      response.addValidationError(message);
    }

    return response;
  }
View Full Code Here

  @Override
  public ValidationResponse doValidateChanges(ApplicationConfiguration applicationConfiguration,
                                              CoreConfiguration owner, Xpp3Dom config)
  {
    ValidationResponse response = super.doValidateChanges(applicationConfiguration, owner, config);

    // validate members existence

    List<CRepository> allReposes = applicationConfiguration.getConfigurationModel().getRepositories();

    List<String> allReposesIds = new ArrayList<String>(allReposes.size());

    for (CRepository repository : allReposes) {
      allReposesIds.add(repository.getId());
    }

    final List<String> memberRepositoryIds = getMemberRepositoryIds();

    if (!allReposesIds.containsAll(memberRepositoryIds)) {
      ValidationMessage message =
          new ValidationMessage(MEMBER_REPOSITORIES, "Group repository points to nonexistent members!",
              "The source nexus repository is not existing.");

      response.addValidationError(message);
    }

    final Set<String> uniqueReposesIds = Sets.newHashSet(memberRepositoryIds);
    if (uniqueReposesIds.size() != memberRepositoryIds.size()) {
      response.addValidationError(new ValidationMessage(
          MEMBER_REPOSITORIES,
          "Group repository has same member multiple times!",
          "Group repository has same member multiple times!"
      ));
    }
View Full Code Here

  {
    getLogger().debug("Configuration error!", e);

    ErrorResponse nexusErrorResponse;

    ValidationResponse vr = e.getValidationResponse();

    if (vr != null && vr.getValidationErrors().size() > 0) {
      org.sonatype.configuration.validation.ValidationMessage vm = vr.getValidationErrors().get(0);
      nexusErrorResponse = getNexusErrorResponse(vm.getKey(), vm.getShortMessage());
    }
    else {
      nexusErrorResponse = getNexusErrorResponse("*", e.getMessage());
    }
View Full Code Here

    getLogger().debug("Configuration error!", e);

    ErrorResponse nexusErrorResponse;

    if (InvalidConfigurationException.class.isAssignableFrom(e.getClass())) {
      ValidationResponse vr = ((InvalidConfigurationException) e).getValidationResponse();

      if (vr != null && vr.getValidationErrors().size() > 0) {
        ValidationMessage vm = vr.getValidationErrors().get(0);
        nexusErrorResponse = getNexusErrorResponse(vm.getKey(), vm.getShortMessage());
      }
      else {
        nexusErrorResponse = getNexusErrorResponse("*", e.getMessage());
      }
View Full Code Here

              try {
                proxyRepo.setRemoteUrl(model.getRemoteStorage().getRemoteStorageUrl());
              }
              catch (RemoteStorageException e) {
                ValidationResponse vr = new ApplicationValidationResponse();
                ValidationMessage error = new ValidationMessage("remoteStorageUrl", e.getMessage(), e.getMessage());
                vr.addValidationError(error);
                throw new InvalidConfigurationException(vr);
              }
              String oldPasswordForRemoteStorage = null;
              if (proxyRepo.getRemoteAuthenticationSettings() != null
                  && UsernamePasswordRemoteAuthenticationSettings.class.isInstance(proxyRepo
View Full Code Here

        log.debug("Failed to invoke action method: {}, java-method: {}", method.getFullName(),
            method.getFullJavaMethodName(), e);

        if (e instanceof InvalidConfigurationException) {
          InvalidConfigurationException cause = (InvalidConfigurationException) e;
          ValidationResponse vr = cause.getValidationResponse();
          if (vr == null || vr.getValidationErrors() == null || vr.getValidationErrors().size() == 0) {
            return asResponse(error(e));
          }
          return asResponse(invalid(cause));
        }
View Full Code Here

    if (cal.before(nowCal)) {
      if (getLogger().isDebugEnabled()) {
        getLogger().debug("Validation error for startDate: " + startDate.toString());
      }

      ValidationResponse vr = new ApplicationValidationResponse();
      ValidationMessage vm = new ValidationMessage("startDate", "Date cannot be in the past.");
      vr.addValidationError(vm);
      throw new InvalidConfigurationException(vr);
    }
  }
View Full Code Here

TOP

Related Classes of org.sonatype.configuration.validation.ValidationResponse

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.