public Collection process()

in git-server/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/VcsPropertiesProcessor.java [34:117]


  public Collection<InvalidProperty> process(Map<String, String> properties) {
    Collection<InvalidProperty> rc = new LinkedList<InvalidProperty>();

    String authMethod = properties.get(Constants.AUTH_METHOD);
    AuthenticationMethod authenticationMethod = authMethod == null ?
                                                AuthenticationMethod.ANONYMOUS : Enum.valueOf(AuthenticationMethod.class, authMethod);

    String url = properties.get(Constants.FETCH_URL);
    if (isEmpty(url)) {
      rc.add(new InvalidProperty(Constants.FETCH_URL, "The URL must be specified"));
    } else {
      if (url.contains("\n") || url.contains("\r")) {
        rc.add(new InvalidProperty(Constants.FETCH_URL, "URL should not contain newline symbols"));
      } else if (!mayContainReference(url)) {
        try {
          new URIish(url);
        } catch (URISyntaxException e) {
          rc.add(new InvalidProperty(Constants.FETCH_URL, "Invalid URL syntax: " + url));
        }

        try {
          validateUrlAuthMethod(url, authenticationMethod, "fetch");
        } catch (VcsException e) {
          rc.add(new InvalidProperty(Constants.FETCH_URL, e.getMessage()));
          rc.add(new InvalidProperty(Constants.AUTH_METHOD, e.getMessage()));
        }

        if (!myConfig.isAllowFileUrl() && GitRemoteUrlInspector.isLocalFileAccess(url)) {
          rc.add(new InvalidProperty(Constants.FETCH_URL, "The URL most not be a local file URL"));
        }
      }
    }
    String pushUrl = properties.get(Constants.PUSH_URL);
    if (!isEmpty(pushUrl)) {
      if (pushUrl.contains("\n") || pushUrl.contains("\r")) {
        rc.add(new InvalidProperty(Constants.PUSH_URL, "URL should not contain newline symbols"));
      } else if (!mayContainReference(pushUrl)) {
        try {
          new URIish(pushUrl);
        } catch (URISyntaxException e) {
          rc.add(new InvalidProperty(Constants.PUSH_URL, "Invalid URL syntax: " + pushUrl));
        }

        try {
          validateUrlAuthMethod(pushUrl, authenticationMethod, "push");
        } catch (VcsException e) {
          rc.add(new InvalidProperty(Constants.PUSH_URL, e.getMessage()));
          rc.add(new InvalidProperty(Constants.AUTH_METHOD, e.getMessage()));
        }

        if (!myConfig.isAllowFileUrl() && GitRemoteUrlInspector.isLocalFileAccess(pushUrl)) {
          rc.add(new InvalidProperty(Constants.PUSH_URL, "The URL most not be a local file URL"));
        }
      }
    }

    rc.addAll(validateBranchName(properties));
    rc.addAll(validateBranchSpec(properties));

    switch (authenticationMethod) {
      case PRIVATE_KEY_FILE:
        String pkFile = properties.get(Constants.PRIVATE_KEY_PATH);
        if (isEmpty(pkFile)) {
          rc.add(new InvalidProperty(Constants.PRIVATE_KEY_PATH, "The private key path must be specified."));
        }
        break;

      case TEAMCITY_SSH_KEY:
        String keyId = properties.get(VcsRootSshKeyManager.VCS_ROOT_TEAMCITY_SSH_KEY_NAME);
        if (isEmpty(keyId)) {
          rc.add(new InvalidProperty(VcsRootSshKeyManager.VCS_ROOT_TEAMCITY_SSH_KEY_NAME, "The Uploaded key must be specified."));
        }
        break;

      case ACCESS_TOKEN:
        final String tokenId = properties.get(Constants.TOKEN_ID);
        if (StringUtil.isEmptyOrSpaces(tokenId)) {
          rc.add(new InvalidProperty(Constants.TOKEN_ID, "The access token must be specified."));
        }
        break;
    }

    return rc;
  }