try (CloseableCoreSession session = CoreInstance.openCoreSession(downloadBlobInfo.repository)) { DocumentRef docRef = new IdRef(downloadBlobInfo.docId); if (!session.exists(docRef)) {
@Override public Blob resolveBlobFromDownloadUrl(String downloadURL) { Pair<String, Action> pair = getDownloadPathAndAction(downloadURL); if (pair == null) { return null; } String downloadPath = pair.getLeft(); try { DownloadBlobInfo downloadBlobInfo = new DownloadBlobInfo(downloadPath); try (CloseableCoreSession session = CoreInstance.openCoreSession(downloadBlobInfo.repository)) { DocumentRef docRef = new IdRef(downloadBlobInfo.docId); if (!session.exists(docRef)) { return null; } DocumentModel doc = session.getDocument(docRef); Blob blob = resolveBlob(doc, downloadBlobInfo.xpath); if (!checkPermission(doc, downloadBlobInfo.xpath, blob, null, null)) { return null; } return blob; } } catch (IllegalArgumentException e) { return null; } }
@Override public void deleteComment(DocumentModel docModel, DocumentModel comment) { try (CloseableCoreSession session = CoreInstance.openCoreSessionSystem(docModel.getRepositoryName())) { DocumentRef ref = comment.getRef(); if (!session.exists(ref)) { throw new NuxeoException("Comment Document does not exist: " + comment.getId()); } session.removeDocument(ref); notifyEvent(session, CommentEvents.COMMENT_REMOVED, docModel, comment); session.save(); } }