protected void doPost()

in src/main/java/org/apache/sling/clam/http/internal/ClamJcrScanServlet.java [124:171]


    protected void doPost(@NotNull final SlingHttpServletRequest request, @NotNull final SlingHttpServletResponse response) throws ServletException, IOException {
        final List<String> groups = Arrays.asList(configuration.scan_authorized_groups());
        boolean isAuthorized = false;
        try {
            isAuthorized = isAuthorized(request, groups);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        if (!isAuthorized) {
            handleError(response, HttpServletResponse.SC_FORBIDDEN, null);
            return;
        }

        final String path;
        final Pattern pattern;
        final Set<Integer> propertyTypes;
        final long maxLength;
        final int maxDepth;
        try {
            path = path(request);
            pattern = pattern(request, this.pattern);
            propertyTypes = propertyTypes(request, this.propertyTypes);
            maxLength = maxLength(request, configuration.digger_default_property_length_max());
            maxDepth = maxDepth(request, configuration.digger_default_node_depth_max());
        } catch (Exception e) {
            handleError(response, HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
            return;
        }

        final Resource resource = request.getResourceResolver().getResource(path);
        if (resource == null) {
            handleError(response, HttpServletResponse.SC_BAD_REQUEST, "No resource at given path found: " + path);
            return;
        }

        final Node node = resource.adaptTo(Node.class);
        if (node == null) {
            handleError(response, HttpServletResponse.SC_BAD_REQUEST, "Resource at given path is not a Node: " + path);
            return;
        }

        try {
            logger.debug("digging in {} (not deeper than {} levels) for properties of types {} matching {} limited by {} bytes", node.getPath(), maxDepth, propertyTypes, pattern, maxLength);
            digger.dig(node, pattern, propertyTypes, maxLength, maxDepth);
        } catch (Exception e) {
            handleError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
        }
    }