Search in sources :

Example 21 with NamedContainerImpl

use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.

the class DocumentPoolWebDAVMergeSource method addTemplates.

private VFSContainer addTemplates(TaxonomyTreeNode taxonomyNode, Taxonomy taxonomy) {
    VFSContainer documents = taxonomyService.getDocumentsLibrary(taxonomy);
    SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
    TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(taxonomyNode, subscriptionCtx);
    System.out.println(taxonomyNode.isCanWrite());
    documents.setLocalSecurityCallback(secCallback);
    return new NamedContainerImpl(taxonomyNode.getTitle(), documents);
}
Also used : TaxonomyVFSSecurityCallback(org.olat.modules.taxonomy.ui.component.TaxonomyVFSSecurityCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 22 with NamedContainerImpl

use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.

the class CourseRuntimeController method doCourseFolder.

private FolderRunController doCourseFolder(UserRequest ureq) {
    if (delayedClose == Delayed.courseFolder || requestForClose(ureq)) {
        removeCustomCSS();
        // Folder for course with custom link model to jump to course nodes
        ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
        VFSContainer courseContainer;
        if (overrideReadOnly) {
            courseContainer = course.getCourseFolderContainer(overrideReadOnly);
        } else {
            courseContainer = course.getCourseFolderContainer();
        }
        VFSContainer namedCourseFolder = new NamedContainerImpl(translate("command.coursefolder"), courseContainer);
        CustomLinkTreeModel customLinkTreeModel = new CourseInternalLinkTreeModel(course.getEditorTreeModel());
        FolderRunController ctrl = new FolderRunController(namedCourseFolder, true, true, true, true, ureq, getWindowControl(), null, customLinkTreeModel, null);
        ctrl.addLoggingResourceable(LoggingResourceable.wrap(course));
        courseFolderCtrl = pushController(ureq, translate("command.coursefolder"), ctrl);
        setActiveTool(folderLink);
        currentToolCtr = courseFolderCtrl;
    } else {
        delayedClose = Delayed.courseFolder;
    }
    return courseFolderCtrl;
}
Also used : CustomLinkTreeModel(org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel) VFSContainer(org.olat.core.util.vfs.VFSContainer) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ICourse(org.olat.course.ICourse) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) CourseInternalLinkTreeModel(org.olat.course.tree.CourseInternalLinkTreeModel)

Example 23 with NamedContainerImpl

use of org.olat.core.util.vfs.NamedContainerImpl in project OpenOLAT by OpenOLAT.

the class PFManager method provideCoachContainer.

/**
 * Provide coach view in webdav.
 *
 * @param pfNode
 * @param courseEnv
 * @param identity
 * @return the VFSContainer
 */
private VFSContainer provideCoachContainer(PFCourseNode pfNode, CourseEnvironment courseEnv, Identity identity, boolean admin) {
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage());
    Translator translator = Util.createPackageTranslator(PFRunController.class, locale);
    SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
    List<Identity> participants = getParticipants(identity, courseEnv, admin);
    String path = courseEnv.getCourseBaseContainer().getRelPath() + "/" + FILENAME_PARTICIPANTFOLDER;
    VFSContainer courseElementBaseContainer = new OlatRootFolderImpl(path, null);
    VirtualContainer namedCourseFolder = new VirtualContainer(translator.translate("participant.folder"));
    for (Identity participant : participants) {
        Path relPath = Paths.get(pfNode.getIdent(), getIdFolderName(participant));
        VFSContainer userBaseContainer = VFSManager.resolveOrCreateContainerFromPath(courseElementBaseContainer, relPath.toString());
        String participantfoldername = userManager.getUserDisplayName(participant);
        VirtualContainer participantFolder = new VirtualContainer(participantfoldername);
        namedCourseFolder.addItem(participantFolder);
        if (pfNode.hasParticipantBoxConfigured()) {
            VFSContainer dropContainer = new NamedContainerImpl(translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
            // if coach is also participant, can user his/her webdav folder with participant rights
            if (identity.equals(participant)) {
                VFSContainer dropbox = resolveOrCreateDropFolder(courseEnv, pfNode, identity);
                VFSSecurityCallback callback = calculateCallback(courseEnv, pfNode, dropbox, true);
                dropContainer.setLocalSecurityCallback(callback);
            } else {
                dropContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
            }
            participantFolder.addItem(dropContainer);
        }
        if (pfNode.hasCoachBoxConfigured()) {
            VFSContainer returnContainer = new NamedContainerImpl(translator.translate("return.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_RETURNBOX));
            returnContainer.setLocalSecurityCallback(new ReadWriteDeleteCallback(nodefolderSubContext));
            participantFolder.addItem(returnContainer);
        }
    }
    return namedCourseFolder;
}
Also used : Locale(java.util.Locale) Path(java.nio.file.Path) VFSContainer(org.olat.core.util.vfs.VFSContainer) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Translator(org.olat.core.gui.translator.Translator) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 24 with NamedContainerImpl

use of org.olat.core.util.vfs.NamedContainerImpl in project OpenOLAT by OpenOLAT.

the class MergedCourseContainer method addFolders.

private void addFolders(PersistingCourseImpl course, MergeSource nodesContainer, TreeNode courseNode) {
    if (courseNode == null)
        return;
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        TreeNode child = (TreeNode) courseNode.getChildAt(i);
        NodeEvaluation nodeEval;
        if (child.getUserObject() instanceof NodeEvaluation) {
            nodeEval = (NodeEvaluation) child.getUserObject();
        } else {
            continue;
        }
        if (nodeEval != null && nodeEval.getCourseNode() != null) {
            CourseNode courseNodeChild = nodeEval.getCourseNode();
            String folderName = RequestUtil.normalizeFilename(courseNodeChild.getShortTitle());
            if (courseNodeChild instanceof BCCourseNode) {
                final BCCourseNode bcNode = (BCCourseNode) courseNodeChild;
                // add folder not to merge source. Use name and node id to have unique name
                VFSContainer rootFolder = getBCContainer(course, bcNode, nodeEval, false);
                boolean canDownload = nodeEval.isCapabilityAccessible("download");
                if (canDownload && rootFolder != null) {
                    if (courseReadOnly) {
                        rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
                    } else if (nodeEval.isCapabilityAccessible("upload")) {
                    // inherit the security callback from the course as for author
                    } else {
                        rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
                    }
                    folderName = getFolderName(nodesContainer, bcNode, folderName);
                    // Create a container for this node content and wrap it with a merge source which is attached to tree
                    VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
                    MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
                    courseNodeContainer.addContainersChildren(nodeContentContainer, true);
                    nodesContainer.addContainer(courseNodeContainer);
                    // Do recursion for all children
                    addFolders(course, courseNodeContainer, child);
                } else {
                    // For non-folder course nodes, add merge source (no files to show) ...
                    MergeSource courseNodeContainer = new MergeSource(null, folderName);
                    // , then do recursion for all children ...
                    addFolders(course, courseNodeContainer, child);
                    // ... but only add this container if it contains any children with at least one BC course node
                    if (courseNodeContainer.getItems().size() > 0) {
                        nodesContainer.addContainer(courseNodeContainer);
                    }
                }
            } else if (courseNodeChild instanceof PFCourseNode) {
                final PFCourseNode pfNode = (PFCourseNode) courseNodeChild;
                // add folder not to merge source. Use name and node id to have unique name
                PFManager pfManager = CoreSpringFactory.getImpl(PFManager.class);
                folderName = getFolderName(nodesContainer, pfNode, folderName);
                MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
                UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
                VFSContainer rootFolder = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, identityEnv.getIdentity(), courseReadOnly);
                VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
                courseNodeContainer.addContainersChildren(nodeContentContainer, true);
                addFolders(course, courseNodeContainer, child);
                nodesContainer.addContainer(courseNodeContainer);
            } else {
                // For non-folder course nodes, add merge source (no files to show) ...
                MergeSource courseNodeContainer = new MergeSource(null, folderName);
                // , then do recursion for all children ...
                addFolders(course, courseNodeContainer, child);
                // ... but only add this container if it contains any children with at least one BC course node
                if (courseNodeContainer.getItems().size() > 0) {
                    nodesContainer.addContainer(courseNodeContainer);
                }
            }
        }
    }
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) PFManager(org.olat.course.nodes.pf.manager.PFManager) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) BCCourseNode(org.olat.course.nodes.BCCourseNode) MergeSource(org.olat.core.util.vfs.MergeSource) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) TreeNode(org.olat.core.gui.components.tree.TreeNode) PFCourseNode(org.olat.course.nodes.PFCourseNode) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 25 with NamedContainerImpl

use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.

the class MergedCourseContainer method addFoldersForAdmin.

/**
 * Internal method to recursively add all course building blocks of type
 * BC to a given VFS container. This should only be used for an author view,
 * it does not test for security.
 *
 * @param course
 * @param nodesContainer
 * @param courseNode
 * @return container for the current course node
 */
private void addFoldersForAdmin(PersistingCourseImpl course, MergeSource nodesContainer, CourseNode courseNode) {
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        String folderName = RequestUtil.normalizeFilename(child.getShortTitle());
        if (child instanceof BCCourseNode) {
            final BCCourseNode bcNode = (BCCourseNode) child;
            // add folder not to merge source. Use name and node id to have unique name
            VFSContainer rootFolder = getBCContainer(course, bcNode, null, true);
            if (courseReadOnly) {
                rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
            }
            folderName = getFolderName(nodesContainer, bcNode, folderName);
            if (rootFolder != null) {
                // Create a container for this node content and wrap it with a merge source which is attached to tree
                VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
                MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
                courseNodeContainer.addContainersChildren(nodeContentContainer, true);
                nodesContainer.addContainer(courseNodeContainer);
                // Do recursion for all children
                addFoldersForAdmin(course, courseNodeContainer, child);
            }
        } else if (child instanceof PFCourseNode) {
            final PFCourseNode pfNode = (PFCourseNode) child;
            // add folder not to merge source. Use name and node id to have unique name
            PFManager pfManager = CoreSpringFactory.getImpl(PFManager.class);
            folderName = getFolderName(nodesContainer, pfNode, folderName);
            MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
            VFSContainer rootFolder = pfManager.provideAdminContainer(pfNode, course.getCourseEnvironment());
            VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
            courseNodeContainer.addContainersChildren(nodeContentContainer, true);
            nodesContainer.addContainer(courseNodeContainer);
            // Do recursion for all children
            addFoldersForAdmin(course, courseNodeContainer, child);
        } else {
            // For non-folder course nodes, add merge source (no files to show) ...
            MergeSource courseNodeContainer = new MergeSource(null, folderName);
            // , then do recursion for all children ...
            addFoldersForAdmin(course, courseNodeContainer, child);
            // ... but only add this container if it contains any children with at least one BC course node
            if (!courseNodeContainer.getItems().isEmpty()) {
                nodesContainer.addContainer(courseNodeContainer);
            }
        }
    }
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) PFManager(org.olat.course.nodes.pf.manager.PFManager) BCCourseNode(org.olat.course.nodes.BCCourseNode) MergeSource(org.olat.core.util.vfs.MergeSource) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) PFCourseNode(org.olat.course.nodes.PFCourseNode) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Aggregations

NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)30 VFSContainer (org.olat.core.util.vfs.VFSContainer)24 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)14 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)12 VirtualContainer (org.olat.core.util.vfs.VirtualContainer)10 Path (java.nio.file.Path)8 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)8 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)8 Translator (org.olat.core.gui.translator.Translator)6 MergeSource (org.olat.core.util.vfs.MergeSource)6 BCCourseNode (org.olat.course.nodes.BCCourseNode)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 Locale (java.util.Locale)4 Identity (org.olat.core.id.Identity)4 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)4 CourseNode (org.olat.course.nodes.CourseNode)4 PFCourseNode (org.olat.course.nodes.PFCourseNode)4 PFManager (org.olat.course.nodes.pf.manager.PFManager)4 TaxonomyVFSSecurityCallback (org.olat.modules.taxonomy.ui.component.TaxonomyVFSSecurityCallback)4 IOException (java.io.IOException)2