@Override public boolean hasNext() { if (next != null) { return true; } // this could be optimized to retrieve batches of documents instead of // one at a time; this would need to call SQLSession.getDocumentsById // through a new CoreSession API (or improve getDocuments) for (;;) { if (!it.hasNext()) { return false; } String id = it.next(); IdRef idRef = new IdRef(id); if (!session.exists(idRef)) { continue; } DocumentModel doc; doc = session.getDocument(idRef); if (accept(doc)) { next = doc; return true; } // continue } }
public DocumentModel getDocumentWithPath(String path) { if (StringUtils.isEmpty(path)) { return null; } return documentManager.getDocument(new PathRef(path)); }
@Override public String navigateToRef(DocumentRef docRef) { if (documentManager == null) { throw new IllegalStateException("documentManager not initialized"); } final DocumentModel doc = documentManager.getDocument(docRef); return navigateToDocument(doc, "view"); }
@Override public Set<String> doGetTags(CoreSession session, String docId) { DocumentRef docRef = new IdRef(docId); if (!session.exists(docRef)) { return Collections.emptySet(); } DocumentModel docModel = session.getDocument(docRef); List<Map<String, Serializable>> tags = getTags(docModel); return tags.stream().map(t -> (String) t.get(LABEL_PROPERTY)).collect(Collectors.toSet()); }
@Override public DocumentModel getTargetDocumentModel(Task task, CoreSession coreSession) { try { // TODO handle while target documents from task return coreSession.getDocument(new IdRef(task.getTargetDocumentsIds().get(0))); } catch (DocumentNotFoundException e) { return null; } }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentRef doc) { session.setLock(doc); return session.getDocument(doc); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentRef docRef) { DocumentModel doc = session.getDocument(docRef); unblockPermissionInheritance(doc); return doc; }
public DocumentModel getSelectedCollection() { if (selectedCollection == null && StringUtils.isNotBlank(selectedCollectionUid) && !isCreateNewCollection()) { try { final CoreSession session = (CoreSession) Component.getInstance("documentManager", true); selectedCollection = session.getDocument(new IdRef(selectedCollectionUid)); } catch (DocumentNotFoundException e) { log.error("Cannot fetch collection"); } } return selectedCollection; }
private DocumentModel getDocument() { if (docRef == null) { return navigationContext.getCurrentDocument(); } else { return documentManager.getDocument(new IdRef(docRef)); } }
@Override public DocumentBlob[] getDocumentBlobsExt(@WebParam(name = "sessionId") String sid, @WebParam(name = "uuid") String uuid, @WebParam(name = "useDownloadUrl") boolean useDownloadUrl) { WSRemotingSession rs = initSession(sid); DocumentModel doc = rs.getDocumentManager().getDocument(new IdRef(uuid)); if (doc == null) { return null; } return getDocumentBlobs(doc, rs, useDownloadUrl); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentRef ref) { String n = name; if (name == null || name.length() == 0) { n = session.getDocument(ref).getName(); } return session.copy(ref, target, n); } }
@Path("id/{id}") public Object getDocsById(@PathParam("id") String id) { CoreSession session = getContext().getCoreSession(); DocumentModel doc = session.getDocument(new IdRef(id)); return newObject("Document", doc); }
public DocumentModel getCurrentLibraryNode() { if (getLibraryRoot()) { currentLibraryNode = ToutaticeDocumentHelper.getMediaSpace( navigationContext.getCurrentDocument(), documentManager); } else if (StringUtils.isNotBlank(currentLibraryNodeId)) { IdRef idRef = new IdRef(currentLibraryNodeId); currentLibraryNode = documentManager.getDocument(idRef); } return currentLibraryNode; }
@Override public void run() throws ClientException { String srcDocID = this.proxy.getSourceId(); DocumentModel srcDoc = this.session.getDocument(new IdRef(srcDocID)); this.versionLabel = srcDoc.getVersionLabel(); }
@Override @WebRemote public void putInClipboard(String docId) { DocumentModel doc = documentManager.getDocument(new IdRef(docId)); documentsListsManager.addToWorkingList(DocumentsListsManager.CLIPBOARD, doc); Object[] params = { 1 }; facesMessages.add(StatusMessage.Severity.INFO, "#0 " + messages.get("n_copied_docs"), params); autoSelectCurrentList(DocumentsListsManager.CLIPBOARD); }
@OperationMethod public DocumentModel run() throws OperationException { Object obj = ctx.pop(Constants.O_DOCUMENT); if (obj instanceof DocumentModel) { return (DocumentModel) obj; } else if (obj instanceof DocumentRef) { return ctx.getCoreSession().getDocument((DocumentRef) obj); } throw new OperationException( "Illegal state error for pop document operation. The context stack doesn't contains a document on its top"); }
@GET @Path("approve") public Response approve() { DocumentObject dobj = (DocumentObject) getTarget(); CoreSession session = dobj.getCoreSession(); DocumentModel pageDoc = dobj.getDocument(); FormData form = ctx.getForm(); String commentId = form.getString(FormData.PROPERTY); DocumentModel comment = session.getDocument(new IdRef(commentId)); approveComent(session, pageDoc, comment); return redirect(dobj.getPath()); }
@Override public DocumentObject newDocument(String path) { PathRef pathRef = new PathRef(doc.getPath().append(path).toString()); DocumentModel doc = ctx.getCoreSession().getDocument(pathRef); return (DocumentObject) ctx.newObject("Document", doc); }
protected DocumentModel getParentDocument(CoreSession session, DocumentModel doc) { DocumentModel parent; if (session.exists(doc.getRef())) { parent = session.getParentDocument(doc.getRef()); } else { Path parentPath = doc.getPath().removeLastSegments(1); parent = session.getDocument(new PathRef(parentPath.toString())); } return parent; }
public PublicationNode getToutaticeNodeByPath(String path) throws NuxeoException { DocumentRef docRef = new PathRef(path); if (coreSession.hasPermission(docRef, SecurityConstants.READ)) { return new ToutaticeCoreFolderPublicationNode(coreSession.getDocument(new PathRef(path)), getConfigName(), getSessionId(), factory); } else { return new VirtualCoreFolderPublicationNode(coreSession.getSessionId(), path, getConfigName(), sid, factory); } }