Source:
<code>public void work() { openUserSession(); List<Blob> blobList = new ArrayList<Blob>(); DownloadService downloadService = Framework.getService(DownloadService.class); for (String docId : docIds) { DocumentRef docRef = new IdRef(docId); if (!session.exists(docRef)) { log.info(String.format("Cannot retrieve document '%s', probably deleted in the meanwhile", docId)); continue; } DocumentModel doc = session.getDocument(docRef); Blob blob = downloadService.resolveBlob(doc); if (blob == null) { log.trace("Not able to resolve blob"); continue; } else if (!downloadService.checkPermission(doc, null, blob, "download", Collections.emptyMap())) { <START> log.debug(String.format("Not allowed to bulk download blob for document %s", doc.getId())); <END> continue; } blobList.add(blob); } if (blobList.isEmpty()) { log.info("No blob to be zipped"); updateAndCompleteStoreEntry(Collections.emptyList()); } AutomationService as = Framework.getLocalService(AutomationService.class); try (OperationContext oc = new OperationContext(session)) { Blob blob; if (blobList.size() == 1) { blob = blobList.get(0); blob.setFilename(StringUtils.isNotBlank(this.filename) ? this.filename : this.id); } else { oc.push("filename", StringUtils.isNotBlank(this.filename) ? this.filename : this.id); oc.setInput(new BlobList(blobList)); blob = (Blob) as.run(oc, CreateZip.ID); } updateAndCompleteStoreEntry(Collections.singletonList(blob)); } catch (OperationException e) { TransientStore ts = getTransientStore(); ts.putParameter(key, DownloadService.TRANSIENT_STORE_PARAM_ERROR, e.getMessage()); throw new NuxeoException("Exception while zipping blob list", e); } }</code><technical_language>surround if (log.isDebugEnabled()) avoid unnecessary call String.format add doc.getPathAsString() doc id in message ease debugging</technical_language>

Target:
public void work() { openUserSession(); List<Blob> blobList = new ArrayList<>(); DownloadService downloadService = Framework.getService(DownloadService.class); for (String docId : docIds) { DocumentRef docRef = new IdRef(docId); if (!session.exists(docRef)) { if (log.isDebugEnabled()) { log.debug(String.format("Cannot retrieve document '%s', probably deleted in the meanwhile", docId)); } continue; } DocumentModel doc = session.getDocument(docRef); Blob blob = downloadService.resolveBlob(doc); if (blob == null) { log.trace("Not able to resolve blob"); continue; } else if (!downloadService.checkPermission(doc, null, blob, "download", Collections.emptyMap())) { if (log.isDebugEnabled()) { log.debug( String.format("Not allowed to bulk download blob for document %s", doc.getPathAsString())); } continue; } blobList.add(blob); } if (blobList.isEmpty()) { log.debug("No blob to be zipped"); updateAndCompleteStoreEntry(Collections.emptyList()); return; } Blob blob; String finalFilename = StringUtils.isNotBlank(this.filename) ? this.filename : this.id; if (blobList.size() == 1) { blob = blobList.get(0); blob.setFilename(finalFilename); } else { try { blob = BlobUtils.zip(blobList, finalFilename); } catch (IOException e) { TransientStore ts = getTransientStore(); ts.putParameter(key, DownloadService.TRANSIENT_STORE_PARAM_ERROR, e.getMessage()); throw new NuxeoException("Exception while zipping blob list", e); } } updateAndCompleteStoreEntry(Collections.singletonList(blob)); }