@Override public DocumentModel getParentFolderForNewModel(CoreSession session, DocumentModel instance) { UserWorkspaceService service = Framework.getService(UserWorkspaceService.class); return service.getCurrentUserPersonalWorkspace(session, instance); }
@Override public void handleEvent(Event event) { EventContext ec = event.getContext(); if (!(ec instanceof DocumentEventContext)) { return; } String evtName = event.getName(); if (!DocumentEventTypes.DOCUMENT_REMOVED.equals(evtName) && !TrashService.DOCUMENT_TRASHED.equals(evtName) && !TrashService.DOCUMENT_UNTRASHED.equals(evtName)) { return; } DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); Path path = doc.getPath(); if (path == null) { // Placeless document return; } if (path.segmentCount() == 1) { // the document is under root like are the domains // we need to invalidate user workspace location Framework.getService(UserWorkspaceService.class).invalidate(); } }
@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; } }
@Override @Factory(value = "isInsidePersonalWorkspace", scope = ScopeType.EVENT) public boolean isShowingPersonalWorkspace() { if (!initialized) { initialize(); } if (mainTabsActions.isOnMainTab(DOCUMENT_MANAGEMENT_ACTION)) { DocumentModel currentDoc = navigationContext.getCurrentDocument(); showingPersonalWorkspace = getUserWorkspaceService().isUnderUserWorkspace(currentUser, null, currentDoc); } return showingPersonalWorkspace; }
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
public DocumentModel getCurrentUserPersonalWorkspace() { if (!initialized) { initialize(); } // protection in case we have not yet chosen a repository. if not // repository, then there is no documentManager(session) if (documentManager == null) { return null;// this is ok because it eventually will be // dealt with by setCurrentDocument, which will deal with // the lack of a documentManager } return getUserWorkspaceService().getCurrentUserPersonalWorkspace(documentManager, navigationContext.getCurrentDocument()); }
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
@OperationMethod public DocumentModel run(Blob blob) throws OperationException, IOException { DocumentModel userws = userWorkspace.getCurrentUserPersonalWorkspace(session, getCurrentDocument()); FileImporterContext fileImporterContext = FileImporterContext.builder(session, blob, userws.getPathAsString()) .build(); return fileManager.createOrUpdateDocument(fileImporterContext); }
@Override public void handleEvent(Event event) { DocumentEventContext ctx = (DocumentEventContext) event.getContext(); DocumentModel userProfileDocument = ctx.getSourceDocument(); // The document should be the current user profile doc if (!userProfileDocument.hasFacet("UserProfile")) { return; } // No need to sync Seam session for system user if (ctx.getPrincipal() instanceof SystemPrincipal) { log.debug("Skip locale update for system user"); return; } // if the profile does not belong to the current user // => no need to sync Seam session UserWorkspaceService uws = Framework.getService(UserWorkspaceService.class); DocumentModel userWorkspace = uws.getCurrentUserPersonalWorkspace(ctx.getCoreSession(), userProfileDocument); if (!userProfileDocument.getPathAsString().startsWith(userWorkspace.getPathAsString())) { return; } // performing the locale update LocaleStartup localeStartup = LocaleStartup.instance(); if (localeStartup == null) { log.warn("Locale Startup not available. Can't set locale"); return; } localeStartup.setupLocale(userProfileDocument); }
@Override public DocumentModel getUserProfileDocument(CoreSession session) { DocumentModel userWorkspace = getUserWorkspaceService().getCurrentUserPersonalWorkspace(session, null); if (userWorkspace == null) { return null; } String uid = profileUidCache.getIfPresent(session.getPrincipal().getName()); 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(session.getPrincipal().getName(), profile.getId()); return profile; } }
DocumentModel uws = userWorkspaceService.getCurrentUserPersonalWorkspace(session);
public DocumentModel saveSearch(CoreSession session, ContentViewState searchContentViewState, String title) { UserWorkspaceService userWorkspaceService = Framework.getService(UserWorkspaceService.class); DocumentModel uws = userWorkspaceService.getCurrentUserPersonalWorkspace(session, null);