Examples of ValidationResponse


Examples of org.sonatype.configuration.validation.ValidationResponse

  public void validateTime(String key, Date date)
      throws InvalidConfigurationException
  {
    if (date.before(new Date())) {
      ValidationResponse vr = new ApplicationValidationResponse();
      ValidationMessage vm = new ValidationMessage(key, "Time cannot be in the past.");
      vr.addValidationError(vm);
      throw new InvalidConfigurationException(vr);
    }
  }
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

    LdapConfigurationSource source = this.lookup(LdapConfigurationSource.class);
    try {
      // Note: This test original also used configuration source, but it does not validate anymore
      // it is done by manager. Hence, validatio code added here below
      final CLdapConfiguration conf = source.load();
      final ValidationResponse vr = lookup(LdapConfigurationValidator.class).validateModel(new ValidationRequest<CLdapConfiguration>(conf));
      if (!vr.isValid()) {
        throw new InvalidConfigurationException(vr);
      }
    }
    catch (InvalidConfigurationException e) {
      return new ExpectedResult(e.getValidationResponse());
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

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

    ErrorResponse errorResponse;

    ValidationResponse vr = e.getValidationResponse();

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

Examples of org.sonatype.configuration.validation.ValidationResponse

        found = true;
      }
    }

    if (!found) {
      ValidationResponse response = new ValidationResponse();
      response.addValidationError(new ValidationMessage("status", "Users status is not valid."));
      throw new InvalidConfigurationException(response);
    }
  }
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

  @Override
  public synchronized void setServerOrder(final List<String> orderdServerIds)
      throws InvalidConfigurationException
  {
    final List<CLdapServerConfiguration> ldapServers = getConfiguration().getServers();
    final ValidationResponse vr = configurationValidator.validateLdapServerOrder(ldapServers, orderdServerIds);
    if (vr.getValidationErrors().size() > 0) {
      throw new InvalidConfigurationException(vr);
    }

    // build a map so its easier
    final Map<String, CLdapServerConfiguration> idToServerMap = Maps.newHashMap();
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

    if (request.getResourceRef() != null) {
      ldapServerId = request.getResourceRef().getQueryAsForm().getFirstValue("ldapServerId");
    }
    replaceFakePassword(connectionInfo, ldapServerId, ldapConfigurationManager);

    ValidationResponse validationResponse = this.configurationValidator.validateConnectionInfo(
        null,
        connectionInfo);
    // if the info is not valid throw
    if (!validationResponse.isValid()) {
      throw new InvalidConfigurationException(validationResponse);
    }

    try {
      LdapContextFactory ldapContextFactory = this.buildDefaultLdapContextFactory(ldapServerId, connectionInfo);
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

  @Override
  public synchronized void addLdapServerConfiguration(final CLdapServerConfiguration ldapServerConfiguration)
      throws InvalidConfigurationException
  {
    final ValidationResponse vr = configurationValidator
        .validateLdapServerConfiguration(ldapServerConfiguration, false);
    if (vr.getValidationErrors().size() > 0) {
      throw new InvalidConfigurationException(vr);
    }
    final boolean wasUnconfigured = getConfiguration().getServers().isEmpty();
    getConfiguration().addServer(ldapServerConfiguration);
    save();
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

  @Override
  public synchronized void updateLdapServerConfiguration(final CLdapServerConfiguration ldapServerConfiguration)
      throws InvalidConfigurationException,
             LdapServerNotFoundException
  {
    final ValidationResponse vr = configurationValidator
        .validateLdapServerConfiguration(ldapServerConfiguration, true);
    if (vr.getValidationErrors().size() > 0) {
      throw new InvalidConfigurationException(vr);
    }

    // this list is ordered so we need to replace the old one
    final CLdapConfiguration ldapConfiguration = getConfiguration();
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

  private CLdapConfiguration getConfiguration() {
    if (ldapConfiguration == null) {
      try {
        final CLdapConfiguration config = configurationSource.load();
        final ValidationResponse vr = configurationValidator
            .validateModel(new ValidationRequest<CLdapConfiguration>(config));
        if (vr.getValidationErrors().size() > 0) {
          throw new InvalidConfigurationException(vr);
        }
        ldapConfiguration = config;
      }
      catch (ConfigurationException e) {
View Full Code Here

Examples of org.sonatype.configuration.validation.ValidationResponse

  }

  public ValidationResponse validateLdapServerConfiguration(CLdapServerConfiguration ldapServerConfiguration,
                                                            boolean update)
  {
    ValidationResponse response = new ValidationResponse();

    if (ldapServerConfiguration == null) {
      ValidationMessage msg = new ValidationMessage("*", "Configuration is missing.");
      response.addValidationError(msg);
    }
    else {

      if (StringUtils.isEmpty(ldapServerConfiguration.getId()) && !update) {
        ValidationMessage msg = new ValidationMessage("id", "Id was generated.");
        response.addValidationWarning(msg);

        ldapServerConfiguration.setId(idGenerator.generateId());
      }
      else if (StringUtils.isEmpty(ldapServerConfiguration.getId()) && update) {
        ValidationMessage msg = new ValidationMessage("id", "Id cannot be empty.");
        response.addValidationWarning(msg);
      }

      if (StringUtils.isEmpty(ldapServerConfiguration.getName())) {
        ValidationMessage msg = new ValidationMessage("name", "Name cannot be empty.");
        response.addValidationError(msg);
      }

      if (ldapServerConfiguration.getConnectionInfo() != null) {
        ValidationResponse vr = this.validateConnectionInfo(null, ldapServerConfiguration.getConnectionInfo());
        response.append(vr);
      }
      else {
        ValidationMessage msg = new ValidationMessage("*", "Connection Configuration is missing.");
        response.addValidationError(msg);
      }

      if (ldapServerConfiguration.getUserAndGroupConfig() != null) {
        ValidationResponse vr = this.validateUserAndGroupAuthConfiguration(null, ldapServerConfiguration
            .getUserAndGroupConfig());
        response.append(vr);
      }
      else {
        ValidationMessage msg = new ValidationMessage("*", "User And Group Configuration is missing.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.