コード例 #1
0
 public ValidationResultMessage validatePackageConfiguration(
     PackageMaterialProperties configurationProvidedByUser) {
   ValidationResultMessage validationResultMessage = new ValidationResultMessage();
   validateKeys(packageConfiguration(), configurationProvidedByUser, validationResultMessage);
   PackageMaterialProperty artifactIdConfiguration =
       configurationProvidedByUser.getProperty(Constants.PACKAGE_SPEC);
   if (artifactIdConfiguration == null) {
     validationResultMessage.addError(
         ValidationError.create(Constants.PACKAGE_SPEC, "Package spec not specified"));
     return validationResultMessage;
   }
   String packageSpec = artifactIdConfiguration.value();
   if (packageSpec == null) {
     validationResultMessage.addError(
         ValidationError.create(Constants.PACKAGE_SPEC, "Package spec is null"));
     return validationResultMessage;
   }
   if (isBlank(packageSpec.trim())) {
     validationResultMessage.addError(
         ValidationError.create(Constants.PACKAGE_SPEC, "Package spec is empty"));
     return validationResultMessage;
   }
   return validationResultMessage;
 }
コード例 #2
0
  public ValidationResultMessage validateRepositoryConfiguration(
      PackageMaterialProperties configurationProvidedByUser) {
    ValidationResultMessage validationResultMessage = new ValidationResultMessage();
    validateKeys(repositoryConfiguration(), configurationProvidedByUser, validationResultMessage);
    PackageMaterialProperty repositoryUrl =
        configurationProvidedByUser.getProperty(Constants.REPO_URL);
    PackageMaterialProperty username = configurationProvidedByUser.getProperty(Constants.USERNAME);
    PackageMaterialProperty password = configurationProvidedByUser.getProperty(Constants.PASSWORD);

    if (repositoryUrl == null) {
      validationResultMessage.addError(
          ValidationError.create(Constants.REPO_URL, "Repository url not specified"));
      return validationResultMessage;
    }
    String usernameValue = username == null ? null : username.value();
    String passwordValue = password == null ? null : password.value();

    new RepoUrl(repositoryUrl.value(), usernameValue, passwordValue)
        .validate(validationResultMessage);

    return validationResultMessage;
  }