@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 DocumentLocationImpl(DocumentModel doc) { serverName = doc.getRepositoryName(); docRef = doc.getRef(); String id = doc.getId(); if (id != null) { docIdRef = new IdRef(id); } else { docIdRef = null; } String path = doc.getPathAsString(); if (path != null) { docPathRef = new PathRef(path); } else { docPathRef = null; } }
protected void reinitLifecycle(List<String> docIds, CoreSession session) { for (String docId : docIds) { session.reinitLifeCycleState(new IdRef(docId)); } }
@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; } }
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)); } }
public void addBlobs(String[] inDocIDs, String inXPath, CoreSession inSession) { for (String id : inDocIDs) { DocumentModel doc = inSession.getDocument(new IdRef(id)); addBlob(doc, inXPath); } }
@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); }
@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); }
@PUT @Path("{taskId}/{action}") public Response completeTask(@PathParam("taskId") String taskId, @PathParam("action") String action, TaskCompletionRequest taskCompletionRequest) { Map<String, Object> data = taskCompletionRequest.getDataMap(); CoreSession session = getContext().getCoreSession(); Framework.getService(DocumentRoutingService.class).endTask(session, session.getDocument(new IdRef(taskId)).getAdapter(Task.class), data, action); Task completedTask = session.getDocument(new IdRef(taskId)).getAdapter(Task.class); return Response.ok(completedTask).status(Status.OK).build(); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel input) { IdRef idRef = new IdRef(input.getId()); return session.getLastDocumentVersion(idRef); }
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 public DocumentDescriptor getCurrentVersion(@WebParam(name = "sessionId") String sid, @WebParam(name = "uuid") String uuid) { WSRemotingSession rs = initSession(sid); DocumentModel doc = rs.getDocumentManager().getLastDocumentVersion(new IdRef(uuid)); if (doc != null) { return new DocumentDescriptor(doc, doc.getVersionLabel()); } return null; }
@Override public DocumentModelList getAttachedDocuments(CoreSession coreSession) { try { DocumentRef stepIdRef = new IdRef(getTargetDocumentId()); DocumentModel targetDocument = coreSession.getDocument(stepIdRef); DocumentModelList docList = new DocumentModelListImpl(); docList.add(targetDocument); return docList; } catch (ClientException e) { throw new RuntimeException(e); } }
@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); }
@Override public void run() { String targetUUID = (String) proxy.getPropertyValue(RENDITION_SOURCE_VERSIONABLE_ID_PROPERTY); liveDocument = session.getDocument(new IdRef(targetUUID)); liveDocument.detach(true); liveDocument.attach(sid); }
@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()); }
@OperationMethod public void setStepDocument() throws ClientException { String stepDocumentId = getRoutingStepDocumentId(context); DocumentModel docStep = session.getDocument(new IdRef(stepDocumentId)); if (mappingComments) { mappCommentsFromTaskToStep(session, docStep); } context.put(DocumentRoutingConstants.OPERATION_STEP_DOCUMENT_KEY, docStep.getAdapter(DocumentRouteStep.class)); }