public Object[] getElements(Object input) { if (input instanceof Repository) { return new DocumentModel[] { session.getRootDocument() }; } else { // may be a document return getChildren(input); } }
/** * @since 5.4 * @return a list containing a DocumentTreeNode for the Root document */ public List<DocumentTreeNode> getRootNode() { return getTreeRoots(true, documentManager.getRootDocument()); }
@Override public void run() throws NuxeoException { Filter noDomainParent = new Filter() { private static final long serialVersionUID = 1L; @Override public boolean accept(DocumentModel docModel) { DocumentModel domain = ToutaticeDocumentHelper.getDomain(session, docModel, true); return domain == null; } }; DocumentModel repo = this.session.getRootDocument(); StringBuffer query = new StringBuffer().append("select * from ").append(ToutaticeNuxeoStudioConst.CST_DOC_TYPE_WEB_CONFIGURATION) .append(" where ecm:ancestorId = '").append(repo.getId()) .append("' and wconf:enabled=1 AND ecm:mixinType != 'HiddenInNavigation' AND ecm:currentLifeCycleState <> 'deleted'"); webConfs = this.session.query(query.toString(), noDomainParent); }
protected void batchRemoveDocuments(IterableQueryResult results) { String rootDocumentId = session.getRootDocument().getId(); List<DocumentRef> ids = new ArrayList<>(); for (Map<String, Serializable> result : results) { String id = (String) result.get("ecm:uuid"); if (id.equals(rootDocumentId)) { continue; } ids.add(new IdRef(id)); if (ids.size() >= 100) { batchRemoveDocuments(ids); ids.clear(); } } if (!ids.isEmpty()) { batchRemoveDocuments(ids); } }
/** * The regex of getDocsByPath doesn't catch the case of the root document. * * @param adapterName * @return * @since 5.8 */ @Path("path/@{adapterName}") public Object getRootPathAdapter(@PathParam("adapterName") String adapterName) { DocumentModel rootDocument = getContext().getCoreSession().getRootDocument(); return ctx.newAdapter(newObject("Document", rootDocument), adapterName); }
@Override @WebMethod public DocumentDescriptor getRootDocument(@WebParam(name = "sessionId") String sessionId) { logDeprecation(); WSRemotingSession rs = initSession(sessionId); DocumentModel doc = rs.getDocumentManager().getRootDocument(); return doc != null ? new DocumentDescriptor(doc) : null; }
/** * Return the Nuxeo repository * * Note: the nuxeo repository is cached since: * <li> the cost to build the instance is high </li> * <li> it is common to all sessions </li> * * @param session the current session * @throws ToutaticeException if failed to obtain the repository */ private void getRepository(CoreSession session) throws ToutaticeException { try { if (repository == null) { String rootDocId = session.getRootDocument().getId(); repository = new NuxeoRepository(session.getRepositoryName(), rootDocId); } } catch (NuxeoException e) { if (log.isErrorEnabled()) { log.error("Failed to obtain the repository, error: " + e.getMessage()); } throw new ToutaticeException(e); } }
@Override public void doInitializeRepository(CoreSession session) { // This method gets called as a system user // so we have all needed rights to do the check and the creation DocumentModel root = session.getRootDocument(); ContentTemplateService service = Framework.getService(ContentTemplateService.class); service.executeFactoryForType(root); // Allow queries to see changes during // postContentCreationHandler executions session.save(); service.executePostContentCreationHandlers(session); session.save(); }
@Override public DocumentModel getUserProfileDocument(String userName, CoreSession session) { DocumentModel userWorkspace = getUserWorkspaceService().getUserPersonalWorkspace(userName, session.getRootDocument()); if (userWorkspace == null) { return null; } String uid = profileUidCache.getIfPresent(userName); final IdRef ref = new IdRef(uid); if (uid != null && session.exists(ref)) { return session.getDocument(ref); } else { DocumentModel profile = new UserProfileDocumentGetter(session, userWorkspace).getOrCreate(); profileUidCache.put(userName, profile.getId()); return profile; } }
UserWorkspaceService userWorkspaceService = Framework.getLocalService(UserWorkspaceService.class); if (null != userWorkspaceService) { DocumentModel adminUserWorkspace = userWorkspaceService.getUserPersonalWorkspace(administrators.get(0), this.session.getRootDocument()); String query = "SELECT * FROM " + ToutaticeNuxeoStudioConst.CST_DOC_TYPE_MAINTENANCE
UserWorkspaceService userWorkspaceService = Framework.getLocalService(UserWorkspaceService.class); if (null != userWorkspaceService) { DocumentModel adminUserWorkspace = userWorkspaceService.getUserPersonalWorkspace(administrators.get(0), this.session.getRootDocument()); String query = "SELECT * FROM " + NuxeoStudioConst.CST_DOC_TYPE_MAINTENANCE
PageProvider<?> pp = pps.getPageProvider(LATEST_AUDITED_CREATED_USERS_OR_GROUPS_PROVIDER, null, getPageSize(), getCurrentPageIndex(), getProperties(), coreSession != null ? coreSession.getRootDocument().getId() : new Object[] { null }); @SuppressWarnings("unchecked") List<LogEntry> entries = (List<LogEntry>) pp.getCurrentPage();
public String navigateToOverallWorkspace() { if (!initialized) { initialize(); } String returnView = DOCUMENT_VIEW; // force return to Documents tab webActions.setCurrentTabIds(DOCUMENT_MANAGEMENT_TAB); if (lastAccessedDocument != null) { navigationContext.setCurrentDocument(lastAccessedDocument); } else if (navigationContext.getCurrentDomain() != null) { navigationContext.setCurrentDocument(navigationContext.getCurrentDomain()); } else if (documentManager.hasPermission(documentManager.getRootDocument().getRef(), SecurityConstants.READ_CHILDREN)) { navigationContext.setCurrentDocument(documentManager.getRootDocument()); } else { navigationContext.setCurrentDocument(null); returnView = dashboardNavigationHelper.navigateToDashboard(); } showingPersonalWorkspace = false; Events.instance().raiseEvent(EventNames.GO_HOME); return returnView; }
protected void initializeSession(FeaturesRunner runner) { if (cleaned) { // reinitialize repositories content RepositoryService repositoryService = Framework.getService(RepositoryService.class); repositoryService.initRepositories(); cleaned = false; } CoreScope.INSTANCE.enter(); createCoreSession(); if (repositoryInit != null) { repositoryInit.populate(session); session.save(); waitForAsyncCompletion(); } // save current root acp DocumentModel root = session.getRootDocument(); rootAcp = root.getACP(); }
DocumentModel root = session.getRootDocument(); root.setACP(rootAcp, true);
/** * Switches to a new server location by updating the context and updating to the CoreSession (DocumentManager). */ @Override public void setCurrentServerLocation(RepositoryLocation serverLocation) { if (serverLocation == null) { log.warn("Setting ServerLocation to null, is this normal ?"); } RepositoryLocation currentServerLocation = serverLocation; getServerLocator().setRepositoryLocation(serverLocation); resetCurrentContext(); Contexts.getEventContext().set("currentServerLocation", currentServerLocation); // update the documentManager documentManager = null; documentManager = getOrCreateDocumentManager(); Events.instance().raiseEvent(EventNames.LOCATION_SELECTION_CHANGED); DocumentModel rootDocument = documentManager.getRootDocument(); if (documentManager.hasPermission(rootDocument.getRef(), SecurityConstants.READ)) { currentDocument = rootDocument; updateContextVariables(); } }
if (currentDocument == null) { parentDocumentPath = documentManager.getRootDocument().getPathAsString(); } else { parentDocumentPath = navigationContext.getCurrentDocument().getPathAsString();
/** * Finds the first domain by name, and creates under it the root container for the structure containing the route * instances. */ protected DocumentModel createDocumentRoutesStructure(String routeStructureDocType, String id, CoreSession session) { DocumentModel root = session.createDocumentModel(session.getRootDocument().getPathAsString(), id, routeStructureDocType); root.setPropertyValue(DC_TITLE, routeStructureDocType); root = session.createDocument(root); ACP acp = session.getACP(root.getRef()); ACL acl = acp.getOrCreateACL(ACL.LOCAL_ACL); acl.addAll(getACEs()); session.setACP(root.getRef(), acp, true); return root; }
DocumentModel rootDocument = documentManager.getRootDocument(); if (!documentManager.hasPermission(rootDocument.getRef(), SecurityConstants.READ_CHILDREN)) {
@Override public Annotation createAnnotation(CoreSession session, Annotation annotation) { ConfigurationService configurationService = Framework.getService(ConfigurationService.class); boolean annotationPlaceless = configurationService.isBooleanPropertyTrue( ANNOTATIONS_PLACELESS_STORAGE_PROPERTY); return CoreInstance.doPrivileged(session, s -> { String path = null; if (!annotationPlaceless) { // Create or retrieve the folder to store the annotation. // 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(annotation.getDocumentId())); String parentPath = s.getRootDocument().getPathAsString(); if (annotatedDoc.getPath().segmentCount() > 1) { parentPath += annotatedDoc.getPath().segment(0); } PathRef ref = new PathRef(parentPath, ANNOTATION_FOLDER_NAME); DocumentModel annotationFolderDoc = s.createDocumentModel(parentPath, ANNOTATION_FOLDER_NAME, HIDDEN_FOLDER_TYPE); s.getOrCreateDocument(annotationFolderDoc); s.save(); path = ref.toString(); } DocumentModel annotationModel = s.createDocumentModel(path, ANNOTATION_NAME, ANNOTATION_DOC_TYPE); setAnnotationProperties(annotationModel, annotation); annotationModel = s.createDocument(annotationModel); return new AnnotationImpl(annotationModel); }); }