public void validate()

in impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsValidator.java [45:210]


    public void validate(Settings settings, boolean isProjectSettings, ProblemCollector<BuilderProblem> problems) {
        if (isProjectSettings) {
            String msgS = "is not supported on project settings.";
            String msgP = "are not supported on project settings.";
            if (settings.getLocalRepository() != null
                    && !settings.getLocalRepository().isEmpty()) {
                addViolation(problems, BuilderProblem.Severity.WARNING, "localRepository", null, msgS);
            }
            if (!settings.isInteractiveMode()) {
                addViolation(problems, BuilderProblem.Severity.WARNING, "interactiveMode", null, msgS);
            }
            if (settings.isOffline()) {
                addViolation(problems, BuilderProblem.Severity.WARNING, "offline", null, msgS);
            }
            if (!settings.getProxies().isEmpty()) {
                addViolation(problems, BuilderProblem.Severity.WARNING, "proxies", null, msgP);
            }
            if (settings.isUsePluginRegistry()) {
                addViolation(problems, BuilderProblem.Severity.WARNING, "usePluginRegistry", null, msgS);
            }
            List<Server> servers = settings.getServers();
            for (int i = 0; i < servers.size(); i++) {
                Server server = servers.get(i);
                String serverField = "servers.server[" + i + "]";
                validateStringEmpty(problems, serverField + ".username", server.getUsername(), msgS);
                validateStringEmpty(problems, serverField + ".password", server.getPassword(), msgS);
                validateStringEmpty(problems, serverField + ".privateKey", server.getPrivateKey(), msgS);
                validateStringEmpty(problems, serverField + ".passphrase", server.getPassphrase(), msgS);
                validateStringEmpty(problems, serverField + ".filePermissions", server.getFilePermissions(), msgS);
                validateStringEmpty(
                        problems, serverField + ".directoryPermissions", server.getDirectoryPermissions(), msgS);
            }
        }

        if (settings.isUsePluginRegistry()) {
            addViolation(
                    problems,
                    BuilderProblem.Severity.WARNING,
                    "usePluginRegistry",
                    null,
                    "is deprecated and has no effect.");
        }

        List<String> pluginGroups = settings.getPluginGroups();

        if (pluginGroups != null) {
            for (int i = 0; i < pluginGroups.size(); i++) {
                String pluginGroup = pluginGroups.get(i);

                validateStringNotEmpty(problems, "pluginGroups.pluginGroup[" + i + "]", pluginGroup, null);

                if (!ID_REGEX.matcher(pluginGroup).matches()) {
                    addViolation(
                            problems,
                            BuilderProblem.Severity.ERROR,
                            "pluginGroups.pluginGroup[" + i + "]",
                            null,
                            "must denote a valid group id and match the pattern " + ID);
                }
            }
        }

        List<Server> servers = settings.getServers();

        if (servers != null) {
            Set<String> serverIds = new HashSet<>();

            for (int i = 0; i < servers.size(); i++) {
                Server server = servers.get(i);

                validateStringNotEmpty(problems, "servers.server[" + i + "].id", server.getId(), null);

                if (!serverIds.add(server.getId())) {
                    addViolation(
                            problems,
                            BuilderProblem.Severity.WARNING,
                            "servers.server.id",
                            null,
                            "must be unique but found duplicate server with id " + server.getId());
                }
            }
        }

        List<Mirror> mirrors = settings.getMirrors();

        if (mirrors != null) {
            for (Mirror mirror : mirrors) {
                validateStringNotEmpty(problems, "mirrors.mirror.id", mirror.getId(), mirror.getUrl());

                validateBannedCharacters(
                        problems,
                        "mirrors.mirror.id",
                        BuilderProblem.Severity.WARNING,
                        mirror.getId(),
                        null,
                        ILLEGAL_REPO_ID_CHARS);

                if ("local".equals(mirror.getId())) {
                    addViolation(
                            problems,
                            BuilderProblem.Severity.WARNING,
                            "mirrors.mirror.id",
                            null,
                            "must not be 'local'"
                                    + ", this identifier is reserved for the local repository"
                                    + ", using it for other repositories will corrupt your repository metadata.");
                }

                validateStringNotEmpty(problems, "mirrors.mirror.url", mirror.getUrl(), mirror.getId());

                validateStringNotEmpty(problems, "mirrors.mirror.mirrorOf", mirror.getMirrorOf(), mirror.getId());
            }
        }

        List<Profile> profiles = settings.getProfiles();

        if (profiles != null) {
            Set<String> profileIds = new HashSet<>();

            for (Profile profile : profiles) {
                if (!profileIds.add(profile.getId())) {
                    addViolation(
                            problems,
                            BuilderProblem.Severity.WARNING,
                            "profiles.profile.id",
                            null,
                            "must be unique but found duplicate profile with id " + profile.getId());
                }

                String prefix = "profiles.profile[" + profile.getId() + "].";

                validateRepositories(problems, profile.getRepositories(), prefix + "repositories.repository");
                validateRepositories(
                        problems, profile.getPluginRepositories(), prefix + "pluginRepositories.pluginRepository");
            }
        }

        List<Proxy> proxies = settings.getProxies();

        if (proxies != null) {
            Set<String> proxyIds = new HashSet<>();

            for (Proxy proxy : proxies) {
                if (!proxyIds.add(proxy.getId())) {
                    addViolation(
                            problems,
                            BuilderProblem.Severity.WARNING,
                            "proxies.proxy.id",
                            null,
                            "must be unique but found duplicate proxy with id " + proxy.getId());
                }
                validateStringNotEmpty(problems, "proxies.proxy.host", proxy.getHost(), proxy.getId());

                try {
                    Integer.parseInt(proxy.getPortString());
                } catch (NumberFormatException e) {
                    addViolation(
                            problems,
                            BuilderProblem.Severity.ERROR,
                            "proxies.proxy[" + proxy.getId() + "].port",
                            null,
                            "must be a valid integer but found '" + proxy.getPortString() + "'");
                }
            }
        }
    }