Package org.sonatype.configuration.validation

Examples of org.sonatype.configuration.validation.InvalidConfigurationException


    try {
      repo.defaultLocalStorageUrl = defaultStorageFile.toURI().toURL().toString();
    }
    catch (MalformedURLException e) {
      // will not happen, not user settable
      throw new InvalidConfigurationException("Malformed URL for LocalRepositoryStorage!", e);
    }

    String localUrl;
    boolean usingDefaultLocalUrl;

    if (repo.getLocalStorage() != null && !Strings.isNullOrEmpty(repo.getLocalStorage().getUrl())) {
      localUrl = repo.getLocalStorage().getUrl();
      usingDefaultLocalUrl = false;
    }
    else {
      localUrl = repo.defaultLocalStorageUrl;
      usingDefaultLocalUrl = true;
    }

    if (repo.getLocalStorage() == null) {
      repo.setLocalStorage(new CLocalStorage());

      repo.getLocalStorage().setProvider("file");
    }

    LocalRepositoryStorage ls = getLocalRepositoryStorage(repo.getId(), repo.getLocalStorage().getProvider());

    try {
      ls.validateStorageUrl(localUrl);

      if (!usingDefaultLocalUrl) {
        repo.getLocalStorage().setUrl(localUrl);
      }

      repository.setLocalStorage(ls);
      // mark local storage context dirty, if applicable
      final LocalStorageContext ctx = repository.getLocalStorageContext();
      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
    if (repository.getNotFoundCache() != null) {
      repository.getNotFoundCache().purge();
View Full Code Here


  {
    final LocalRepositoryStorage result = localRepositoryStorages.get(provider);
    if (result != null) {
      return result;
    }
    throw new InvalidConfigurationException("Repository " + repoId
        + " have local storage with unsupported provider: " + provider);
  }
View Full Code Here

  }

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

              }
              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
                  .getRemoteAuthenticationSettings())) {
View Full Code Here

      private Response handleException(final RegisteredMethod method, final Throwable e) {
        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));
        }

        if (e instanceof ConstraintViolationException) {
          ConstraintViolationException cause = (ConstraintViolationException) e;
          Set<ConstraintViolation<?>> violations = cause.getConstraintViolations();
          if (violations == null || violations.size() == 0) {
            return asResponse(error(e));
          }
          return asResponse(invalid(cause));
        }
View Full Code Here

      }

      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

  {
    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

      // 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

    }

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

      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();
    for (CLdapServerConfiguration ldapServer : ldapServers) {
View Full Code Here

TOP

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

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.