public DistributionResponse execute()

in src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java [148:199]


    public DistributionResponse execute(@NotNull ResourceResolver resourceResolver, @NotNull DistributionRequest distributionRequest)
            throws DistributionException {

        ResourceResolver agentResourceResolver = null;

        final String requestId = "DSTRQ" + nextRequestId.incrementAndGet();
        String callingUser = resourceResolver.getUserID();

        try {
            // check if the request type can be executed by this agent
            if (!isAcceptedRequestType(distributionRequest)) {
                log.debug("request type not accepted {}", distributionRequest.getRequestType());
                return new SimpleDistributionResponse(DistributionRequestState.DROPPED, "Request type not accepted");
            }

            // check if the request paths can be distributed via this agent
            if (!isAcceptedRequestRoot(distributionRequest)) {
                log.debug("request paths not accepted {}", Arrays.toString(distributionRequest.getPaths()));
                return new SimpleDistributionResponse(DistributionRequestState.DROPPED, "Request paths not accepted");
            }

            boolean silent = DistributionRequestType.PULL.equals(distributionRequest.getRequestType());

            log.info(silent, "REQUEST-START {}: {} paths={}, user={}", requestId,
                    distributionRequest.getRequestType(), distributionRequest.getPaths(), callingUser);

            // check permissions
            distributionRequestAuthorizationStrategy.checkPermission(resourceResolver, distributionRequest);

            agentResourceResolver = DistributionUtils.getResourceResolver(callingUser, agentAuthenticationInfo.getAgentService(),
                    agentAuthenticationInfo.getSlingRepository(), agentAuthenticationInfo.getSubServiceName(),
                    agentAuthenticationInfo.getResourceResolverFactory());

            // export packages
            CompositeDistributionResponse distributionResponse = exportPackages(agentResourceResolver, distributionRequest, callingUser, requestId);

            log.debug("REQUEST-STARTED {}: {} paths={}, success={}, state={}, exportTime={}ms, noPackages={}, size={}B, noQueues={}", requestId,
                    distributionRequest.getRequestType(), distributionRequest.getPaths(),
                    distributionResponse.isSuccessful(), distributionResponse.getState(),
                    distributionResponse.getExportTime(),
                    distributionResponse.getPackagesCount(), distributionResponse.getPackagseSize(),
                    distributionResponse.getQueuesCount());

            return distributionResponse;
        } catch (DistributionException e) {
            log.error("REQUEST-FAIL {}: {} paths={}, user={}, message={}", requestId,
                    distributionRequest.getRequestType(), distributionRequest.getPaths(), callingUser, e.getMessage());
            throw e;
        } finally {
            DistributionUtils.ungetResourceResolver(agentResourceResolver);
        }
    }