private Object readResolve() throws ObjectStreamException { // we need a transaction for this boolean started = false; if (!TransactionHelper.isTransactionActiveOrMarkedRollback()) { started = TransactionHelper.startTransaction(); } try { try (CloseableCoreSession session = CoreInstance.openCoreSession(repositoryName, principal)) { referent = session.getDocument(ref); referent.detach(true); return referent; } } catch (RuntimeException cause) { InvalidObjectException error = new InvalidObjectException( "Cannot refetch " + ref + " from " + repositoryName); error.initCause(cause); throw error; } finally { if (started) { TransactionHelper.commitOrRollbackTransaction(); } } }
uuid = docRef.toString(); } else { DocumentModel doc = session.getDocument(docRef); uuid = doc.getId();
Set<Resource> allResources = new HashSet<Resource>(); for (DocumentRef docRef : sources) { DocumentModel doc = session.getDocument(docRef); Map<String, Object> context = Collections.<String, Object> singletonMap( ResourceAdapter.CORE_SESSION_CONTEXT_KEY, session);
return; DocumentModel doc = session.getDocument(docRef); if (info) { Blob blob = resolveBlob(doc, xpath);
@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 DocumentModel createComment(DocumentModel docModel, DocumentModel parent, DocumentModel child) { try (CloseableCoreSession session = CoreInstance.openCoreSessionSystem(docModel.getRepositoryName())) { DocumentModel parentDocModel = session.getDocument(parent.getRef()); String containerPath = parent.getPath().removeLastSegments(1).toString(); DocumentModel newComment = internalCreateComment(session, parentDocModel, child, containerPath); session.save(); return newComment; } }
for (String routeId : routeIds) { try { DocumentModel docRoute = session.getDocument(new IdRef(routeId)); DocumentRoute route = docRoute.getAdapter(DocumentRoute.class); List<String> relatedDocIds = route.getAttachedDocuments();
newDoc = session.getDocument(newRef); } catch (DocumentNotFoundException e) {
for (DocumentRef source : sources) { DocumentTranslationMap map = new DocumentTranslationMapImpl(repo, repo); DocumentModel sourceDoc = session.getDocument(source); DocumentModel destDoc = session.copy(source, targetLocation.getDocRef(), null); roots.add(destDoc.getRef());
@Override public DocumentTranslationMap importDocuments(InputStream in, String repo, DocumentRef root) { DocumentReader reader = null; DocumentModelWriter writer = null; try (CloseableCoreSession coreSession = CoreInstance.openCoreSessionSystem(repo)) { final DocumentModel dst = coreSession.getDocument(root); reader = new NuxeoArchiveReader(in); writer = new DocumentModelWriter(coreSession, dst.getPathAsString()); DocumentPipe pipe = new DocumentPipeImpl(10); pipe.setReader(reader); pipe.setWriter(writer); DocumentTranslationMap map = pipe.run(); coreSession.save(); return map; } catch (IOException e) { throw new NuxeoException(e); } finally { if (reader != null) { reader.close(); } if (writer != null) { writer.close(); } } }