public Object execute()

in platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ValidatorListCommand.java [58:98]


    public Object execute(CamelController camelController, PrintStream out, PrintStream err) throws Exception {
        final List<Map<String, String>> camelContextInfos = camelController.getCamelContexts(this.context);
        final Map<String, List<Map<String, String>>> contextsToValidators = new HashMap<>();
        
        for (Map<String, String> camelContextInfo : camelContextInfos) {
            String camelContextName = camelContextInfo.get("name");
            final List<Map<String, String>> validators = camelController.getValidators(camelContextName);
            if (validators.isEmpty()) {
                continue;
            }
            contextsToValidators.put(camelContextName, validators);
        }

        final Map<String, Integer> columnWidths = computeColumnWidths(contextsToValidators);
        final String headerFormat = buildFormatString(columnWidths, true);
        final String rowFormat = buildFormatString(columnWidths, false);

        for (Map.Entry<String, List<Map<String, String>>> stringListEntry : contextsToValidators.entrySet()) {
            final String camelContextName = stringListEntry.getKey();
            final List<Map<String, String>> validators = stringListEntry.getValue();

            if (verbose) {
                out.println(String.format(headerFormat, CONTEXT_NAME_COLUMN_LABEL, TYPE_COLUMN_LABEL, STATE_COLUMN_LABEL, DESCRIPTION_COLUMN_LABEL));
                out.println(String.format(headerFormat, "-------", "----", "-----", "-----------"));
            } else {
                out.println(String.format(headerFormat, CONTEXT_NAME_COLUMN_LABEL, TYPE_COLUMN_LABEL, STATE_COLUMN_LABEL));
                out.println(String.format(headerFormat, "-------", "----", "-----"));
            }
            for (Map<String, String> row : validators) {
                String type = row.get("type");
                String state = row.get("state");
                if (verbose) {
                    String desc = row.get("description");
                    out.println(String.format(rowFormat, camelContextName, type, state, desc));
                } else {
                    out.println(String.format(rowFormat, camelContextName, type, state));
                }
            }
        }
        return null;
    }