public void handle()

in src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractPolicyEntryHandler.java [51:91]


    public void handle(@NotNull String path, @NotNull Archive archive, @NotNull Archive.Entry entry, @NotNull ContentPackage2FeatureModelConverter converter, String runMode)
            throws IOException {
        String resourcePath;
        Matcher matcher = getPattern().matcher(path);
        // we are pretty sure it matches, here
        if (matcher.matches()) {
            resourcePath = matcher.group(1);
        } else {
            throw new IllegalStateException("Something went terribly wrong: pattern '"
                                            + getPattern().pattern()
                                            + "' should have matched already with path '"
                                            + path
                                            + "' but it does not, currently");
        }

        try {
            TransformerHandler handler = saxTransformerFactory.newTransformerHandler();
            handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
            handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
            handler.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            StringWriter stringWriter = new StringWriter();
            handler.setResult(new StreamResult(stringWriter));

            AbstractPolicyParser policyParser = createPolicyParser(new RepoPath(PlatformNameFormat.getRepositoryPath(resourcePath)),
                    converter.getAclManager(),
                    handler);
            boolean hasRejectedNodes;
            try (InputStream input = archive.openInputStream(entry)) {
                hasRejectedNodes = policyParser.parse(input);
            }

            if (hasRejectedNodes) {
                try (Reader reader = new StringReader(stringWriter.toString());
                    OutputStreamWriter writer = new OutputStreamWriter(converter.getMainPackageAssembler().createEntry(path))) {
                    IOUtils.copy(reader, writer);
                }
            }
        } catch ( final TransformerConfigurationException e) {
            throw new IOException(e.getMessage(), e);
        }
    }