/** * Instantiates a new typed exported document impl. * * @param doc the doc * @param inlineBlobs the inline blobs * @throws IOException Signals that an I/O exception has occurred. */ public TypedExportedDocumentImpl(DocumentModel doc, boolean inlineBlobs) throws IOException { super(doc, doc.getPath(), inlineBlobs); }
public ExportedDocumentImpl(DocumentModel doc, boolean inlineBlobs) throws IOException { this(doc, doc.getPath(), inlineBlobs); }
public DocumentTreeReader(CoreSession session, DocumentModel root, boolean excludeRoot) { super(session); iterator = new DocumentTreeIterator(session, root, excludeRoot); pathSegmentsToRemove = root.getPath().segmentCount() - (excludeRoot ? 0 : 1); }
public ExtensibleDocumentTreeReader(CoreSession session, DocumentModel root, boolean excludeRoot) { super(session); iterator = new DocumentTreeIterator(session, root, excludeRoot); pathSegmentsToRemove = root.getPath().segmentCount() - (excludeRoot ? 0 : 1); }
private boolean isNewlyCreatedChangeableDocument(DocumentModel changeableDocument) throws NuxeoException { return changeableDocument != null && changeableDocument.getId() == null && changeableDocument.getPath() == null && changeableDocument.getTitle() == null; }
public String resolvePath(String relative) { return doc.getPath().append(relative).toString(); }
public String resolvePath(String relative) { return doc.getPath().append(relative).toString(); }
public DocumentRef resolvePathAsRef(String relative) { return new PathRef(doc.getPath().append(relative).toString()); }
public DocumentRef resolvePathAsRef(String relative) { return new PathRef(doc.getPath().append(relative).toString()); }
@Override public DocumentModel getAboveDocument(DocumentModel doc, Set<Path> rootPaths) { CoreSession session = doc.getCoreSession(); while (underOneOf(doc.getPath(), rootPaths)) { doc = session.getParentDocument(doc.getRef()); if (doc == null) { // handle placeless document break; } } return doc; }
@Override public Serializable getReference(Object entity) throws IllegalStateException { checkConfig(); if (entity instanceof DocumentModel) { DocumentModel doc = (DocumentModel) entity; switch (mode) { case ID_ONLY_REF: return doc.getId(); case PATH_ONLY_REF: return doc.getPath().toString(); case REPO_AND_ID_REF: return doc.getRepositoryName() + ":" + doc.getId(); case REPO_AND_PATH_REF: return doc.getRepositoryName() + ":" + doc.getPath().toString(); } } return null; }
@Override public ExportedDocument read() throws IOException { if (iterator.hasNext()) { DocumentModel docModel = iterator.next(); if (pathSegmentsToRemove > 0) { // remove unwanted leading segments return new ExportedDocumentImpl(docModel, docModel.getPath().removeFirstSegments(pathSegmentsToRemove), inlineBlobs); } else { return new ExportedDocumentImpl(docModel, inlineBlobs); } } return null; }
@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 String getCommentContainerPath(CoreSession session, String commentedDocumentId) { return CoreInstance.doPrivileged(session, s -> { // Create or retrieve the folder to store the comment. // If the document is under a domain, the folder is a child of this domain. // Otherwise, it is a child of the root document. DocumentModel annotatedDoc = s.getDocument(new IdRef(commentedDocumentId)); String parentPath = "/"; if (annotatedDoc.getPath().segmentCount() > 1) { parentPath += annotatedDoc.getPath().segment(0); } PathRef ref = new PathRef(parentPath, COMMENTS_DIRECTORY); DocumentModel commentFolderDoc = s.createDocumentModel(parentPath, COMMENTS_DIRECTORY, HIDDEN_FOLDER_TYPE); s.getOrCreateDocument(commentFolderDoc); s.save(); return ref.toString(); }); }
/** * Adds the concerned users to the list of targeted users for these notifications. */ private void gatherConcernedUsersForDocument(CoreSession coreSession, DocumentModel doc, List<Notification> notifs, Map<Notification, List<String>> targetUsers) { if (doc.getPath().segmentCount() > 1) { log.debug("Searching document: " + doc.getName()); getInterstedUsers(doc, notifs, targetUsers); if (doc.getParentRef() != null && coreSession.exists(doc.getParentRef())) { DocumentModel parent = getDocumentParent(coreSession, doc); gatherConcernedUsersForDocument(coreSession, parent, notifs, targetUsers); } } }
@Path("last") public DocumentObject getLastVersion() { DocumentObject dobj = (DocumentObject) getTarget(); DocumentModel doc = dobj.getDocument(); DocumentModel v = dobj.getCoreSession().getLastDocumentVersion(doc.getRef()); if (v != null) { return dobj.newDocument(v); } throw new WebResourceNotFoundException( "No version found for " + ((DocumentObject) getTarget()).getDocument().getPath()); }
public DocumentObject newDocument(String path) { PathRef pathRef = new PathRef(doc.getPath().append(path).toString()); DocumentModel doc = ctx.getCoreSession().getDocument(pathRef); return (DocumentObject) ctx.newObject(doc.getType(), 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; }
@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; } }
public ShallowDocumentModel(DocumentModel doc) { id = doc.getId(); repoName = doc.getRepositoryName(); name = doc.getName(); path = doc.getPath(); type = doc.getType(); isFolder = doc.isFolder(); isVersion = doc.isVersion(); isProxy = doc.isProxy(); isImmutable = doc.isImmutable(); contextData = new HashMap<>(doc.getContextData()); facets = doc.getFacets(); if (doc.isLifeCycleLoaded()) { lifecycleState = doc.getCurrentLifeCycleState(); } else { lifecycleState = null; } }