private DistributionResponse execute()

in src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java [256:296]


    private DistributionResponse execute(ResourceResolver resourceResolver,
                                         DistributionRequest request,
                                         ToLongFunction<PackageMessage> sender)
            throws DistributionException {
        final PackageMessage pkg;
        try {
            if (request.getRequestType() != TEST && request.getPaths().length == 0) {
                throw new DistributionException("Empty paths are not allowed");
            }
            pkg = timed(distributionMetricsService.getBuildPackageDuration(), () -> factory.create(packageBuilder, resourceResolver, pubAgentName, request));
        } catch (Exception e) {
            distributionMetricsService.getDroppedRequests().mark();
            String msg = format("Failed to create content package for requestType=%s, paths=%s. Error=%s",
                    request.getRequestType(), Arrays.toString(request.getPaths()), e.getMessage());
            log.error(msg, e);
            throw new DistributionException(msg, e);
        }

        try {
            long offset = timed(distributionMetricsService.getEnqueuePackageDuration(), () -> sender.applyAsLong(pkg));
            distributionMetricsService.getExportedPackageSize().update(pkg.getPkgLength());
            distributionMetricsService.getAcceptedRequests().mark();
            String msg = format("Request accepted with distribution package %s at offset=%s", pkg, offset);
            log.info(msg);
            return new SimpleDistributionResponse(ACCEPTED, msg, new DistributionResponseInfo() {
                @Nonnull @Override 
                public String getId() {
                    return pkg.getPkgId();
                }
            });
        } catch (Throwable e) {
            distributionMetricsService.getDroppedRequests().mark();
            String msg = format("Failed to append distribution package %s to the journal", pkg);
            log.error(msg, e);
            if (e instanceof Error) {
                throw (Error) e;
            } else {
                throw new DistributionException(msg, e);
            }
        }
    }