public boolean isEmptyFork(DocumentModel forkDoc) throws ClientException { return forkDoc.hasFacet("Folderish") && !documentManager.hasChildren(forkDoc.getRef()); }
@Override public boolean canValidateRoute(DocumentModel documentRoute, CoreSession coreSession) { if (!coreSession.hasChildren(documentRoute.getRef())) { // Cannot validate an empty route return false; } return coreSession.hasPermission(documentRoute.getRef(), SecurityConstants.EVERYTHING); }
@Deprecated /** * @deprecated use * {@link #canValidateRoute(DocumentModel)} * instead. */ public boolean canValidateRoute() { try { DocumentModel currentDoc = navigationContext.getCurrentDocument(); if (!documentManager.hasChildren(currentDoc.getRef())) { // Cannot validate an empty route return false; } } catch (ClientException e) { new RuntimeException(e); } return getDocumentRoutingService().canUserValidateRoute(currentUser); }
protected Set<DocumentRef> doUntrashDocument(DocumentModel doc, boolean processChildren) { CoreSession session = doc.getCoreSession(); DocumentRef docRef = doc.getRef(); DocumentModel docForEvent = doc; // move only non placeless document // currently we don't trash placeless document DocumentRef parentRef = doc.getParentRef(); if (!Boolean.TRUE.equals(doc.getContextData(DISABLE_TRASH_RENAMING)) && parentRef != null) { String newName = unmangleName(doc); if (!newName.equals(doc.getName())) { session.move(docRef, parentRef, newName); docForEvent = session.getDocument(docRef); docForEvent.copyContextData(doc); } } session.setDocumentSystemProp(docRef, SYSPROP_IS_TRASHED, Boolean.FALSE); notifyEvent(session, DOCUMENT_UNTRASHED, docForEvent); if (processChildren && session.hasChildren(doc.getRef())) { trashDescendants(doc, Boolean.FALSE); } Set<DocumentRef> docRefs = new HashSet<>(); docRefs.add(docRef); // now untrash the parent if needed if (parentRef != null && session.isTrashed(parentRef)) { DocumentModel parent = session.getDocument(parentRef); Set<DocumentRef> ancestorDocRefs = doUntrashDocument(parent, false); docRefs.addAll(ancestorDocRefs); } return docRefs; }
if (session.hasChildren(doc.getRef())) { trashDescendants(doc, Boolean.TRUE);