in src/main/java/org/apache/sling/distribution/journal/impl/publisher/PackageMessageFactory.java [101:136]
private PackageMessage createAdd(DistributionPackageBuilder packageBuilder, ResourceResolver resourceResolver, String pubAgentName, DistributionRequest request) throws DistributionException {
final DistributionPackage disPkg = requireNonNull(packageBuilder.createPackage(resourceResolver, request));
final byte[] pkgBinary = pkgBinary(disPkg);
long pkgLength = assertPkgLength(pkgBinary.length);
final DistributionPackageInfo pkgInfo = disPkg.getInfo();
final List<String> paths = Arrays.asList(pkgInfo.getPaths());
final List<String> deepPaths = Arrays.asList(pkgInfo.get(PROPERTY_REQUEST_DEEP_PATHS, String[].class));
final String pkgId = disPkg.getId();
PackageMessageBuilder pkgBuilder = PackageMessage.builder()
.pubSlingId(pubSlingId)
.pkgId(pkgId)
.pubAgentName(pubAgentName)
.paths(paths)
.reqType(ReqType.ADD)
.deepPaths(deepPaths)
.pkgLength(pkgLength)
.userId(resourceResolver.getUserID())
.pkgType(packageBuilder.getType());
String storeRef;
try {
storeRef = binaryStore.put(pkgId, disPkg.createInputStream(), pkgLength);
} catch (IOException e) {
throw new DistributionException(e.getMessage(), e);
}
if (StringUtils.isNotEmpty(storeRef)) {
pkgBuilder.pkgBinaryRef(storeRef);
} else {
pkgBuilder.pkgBinary(pkgBinary);
}
PackageMessage pipePackage = pkgBuilder.build();
disPkg.delete();
return pipePackage;
}