String asRepoInit()

in src/main/java/org/apache/sling/repoinit/parser/operations/AclGroupBase.java [67:88]


    String asRepoInit(@NotNull String topLine, boolean hasPathLines) {
        try (Formatter formatter = new Formatter()) {
            formatter.format("%s",topLine);
            for (AclLine line : lines) {
                String action = actionToString(line.getAction());
                String privileges = privilegesToString(line.getAction(), line.getProperty(AclLine.PROP_PRIVILEGES));
                String onOrFor;
                if (hasPathLines) {
                    String pathStr = pathsToString(line.getProperty(AclLine.PROP_PATHS));
                    onOrFor = (pathStr.isEmpty()) ? "" : " on " + pathStr;
                } else {
                    onOrFor = " for " + listToString(
                            QuotableStringUtil.forRepoInitString(line.getProperty(AclLine.PROP_PRINCIPALS)));
                }
                formatter.format("    %s %s%s%s%s%n", action, privileges, onOrFor,
                        nodetypesToString(line.getProperty(AclLine.PROP_NODETYPES)),
                        restrictionsToString(line.getRestrictions()));
            }
            formatter.format("end%n");
            return formatter.toString();
        }
    }