Search in sources :

Example 21 with ReadOnlyCallback

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

the class DocumentPoolMainController method doSelectTemplatesDirectory.

private DocumentDirectoryController doSelectTemplatesDirectory(UserRequest ureq, TaxonomyTreeNode node) {
    content.popUpToRootController(ureq);
    VFSContainer directory = node.getDirectory();
    VFSSecurityCallback secCallback = isTaxonomyAdmin ? new FullAccessCallback() : new ReadOnlyCallback();
    directory.setLocalSecurityCallback(secCallback);
    String name = translate("document.pool.templates");
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("Templates", 0l);
    WindowControl bwControl = addToHistory(ureq, ores, null);
    DocumentDirectoryController directoryCtrl = new DocumentDirectoryController(ureq, bwControl, directory, name);
    directoryCtrl.setAdditionalResourceURL("[Templates:0]");
    listenTo(directoryCtrl);
    content.pushController(name, directoryCtrl);
    return directoryCtrl;
}
Also used : FullAccessCallback(org.olat.core.util.vfs.callbacks.FullAccessCallback) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) OLATResourceable(org.olat.core.id.OLATResourceable) VFSContainer(org.olat.core.util.vfs.VFSContainer) WindowControl(org.olat.core.gui.control.WindowControl) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) TaxonomyVFSSecurityCallback(org.olat.modules.taxonomy.ui.component.TaxonomyVFSSecurityCallback)

Example 22 with ReadOnlyCallback

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

the class ReturnboxController method initReturnbox.

protected void initReturnbox(UserRequest ureq, WindowControl wControl, CourseNode node, UserCourseEnvironment userCourseEnv, boolean previewMode) {
    // returnbox display
    myContent = createVelocityContainer("returnbox");
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), null);
    String fullName = StringHelper.escapeHtml(userManager.getUserDisplayName(getIdentity()));
    OlatNamedContainerImpl namedContainer = new OlatNamedContainerImpl(fullName, rootFolder);
    namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
    returnboxFolderRunController = new FolderRunController(namedContainer, false, ureq, wControl);
    returnboxFolderRunController.addControllerListener(this);
    myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
    // notification
    if (!previewMode && !ureq.getUserSession().getRoles().isGuestOnly()) {
        // offer subscription, but not to guests
        subsContext = ReturnboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity());
        if (subsContext != null) {
            contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, wControl, getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), subsContext, ReturnboxController.class);
            myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
            myContent.contextPut("hasNotification", Boolean.TRUE);
        }
    } else {
        myContent.contextPut("hasNotification", Boolean.FALSE);
    }
    putInitialPanel(myContent);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController)

Example 23 with ReadOnlyCallback

use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback 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 24 with ReadOnlyCallback

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

the class MergedCourseContainer method getBCContainer.

private VFSContainer getBCContainer(ICourse course, BCCourseNode bcNode, NodeEvaluation nodeEval, boolean isOlatAdmin) {
    bcNode.updateModuleConfigDefaults(false);
    // add folder not to merge source. Use name and node id to have unique name
    VFSContainer rootFolder = null;
    String subpath = bcNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
    if (StringHelper.containsNonWhitespace(subpath)) {
        if (bcNode.isSharedFolder()) {
            // grab any shared folder that is configured
            OlatRootFolderImpl sharedFolder = null;
            String sfSoftkey = course.getCourseConfig().getSharedFolderSoftkey();
            if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
                RepositoryManager rm = RepositoryManager.getInstance();
                RepositoryEntry re = rm.lookupRepositoryEntryBySoftkey(sfSoftkey, false);
                if (re != null) {
                    sharedFolder = SharedFolderManager.getInstance().getSharedFolder(re.getOlatResource());
                    VFSContainer courseBase = sharedFolder;
                    subpath = subpath.replaceFirst("/_sharedfolder", "");
                    rootFolder = (VFSContainer) courseBase.resolve(subpath);
                    if (rootFolder != null && (course.getCourseConfig().isSharedFolderReadOnlyMount() || courseReadOnly)) {
                        rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
                    }
                }
            }
        } else {
            VFSContainer courseBase = course.getCourseBaseContainer();
            rootFolder = (VFSContainer) courseBase.resolve("/coursefolder" + subpath);
        }
    }
    if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
        String path = BCCourseNode.getFoldernodePathRelToFolderBase(course.getCourseEnvironment(), bcNode);
        rootFolder = new OlatRootFolderImpl(path, null);
        if (nodeEval != null) {
            rootFolder.setLocalSecurityCallback(new FolderNodeCallback(path, nodeEval, isOlatAdmin, false, null));
        } else {
            VFSSecurityCallback secCallback = VFSManager.findInheritedSecurityCallback(this);
            if (secCallback != null) {
                rootFolder.setLocalSecurityCallback(new OverrideQuotaSecurityCallback(path, secCallback));
            }
        }
    }
    return rootFolder;
}
Also used : FolderNodeCallback(org.olat.course.nodes.bc.FolderNodeCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 25 with ReadOnlyCallback

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

the class BCCourseNodeEditController method doOpenFolder.

private void doOpenFolder(UserRequest ureq) {
    VFSContainer namedContainer = null;
    if (bcNode.getModuleConfiguration().getBooleanSafe(CONFIG_AUTO_FOLDER)) {
        OlatNamedContainerImpl directory = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
        directory.setLocalSecurityCallback(getSecurityCallbackWithQuota(directory.getRelPath()));
        namedContainer = directory;
    } else {
        VFSContainer courseContainer = course.getCourseFolderContainer();
        String path = bcNode.getModuleConfiguration().getStringValue(CONFIG_SUBPATH, "");
        VFSItem pathItem = courseContainer.resolve(path);
        if (pathItem instanceof VFSContainer) {
            namedContainer = (VFSContainer) pathItem;
            if (bcNode.isSharedFolder()) {
                if (course.getCourseConfig().isSharedFolderReadOnlyMount()) {
                    namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
                } else {
                    String relPath = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment()).getRelPath();
                    namedContainer.setLocalSecurityCallback(getSecurityCallbackWithQuota(relPath));
                }
            } else {
                VFSContainer inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(namedContainer);
                if (inheritingContainer != null && inheritingContainer.getLocalSecurityCallback() != null && inheritingContainer.getLocalSecurityCallback().getQuota() != null) {
                    Quota quota = inheritingContainer.getLocalSecurityCallback().getQuota();
                    namedContainer.setLocalSecurityCallback(new FullAccessWithQuotaCallback(quota));
                } else {
                    namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
                }
            }
        }
    }
    folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
    listenTo(folderCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
    listenTo(cmc);
    cmc.activate();
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) Quota(org.olat.core.util.vfs.Quota) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) VFSItem(org.olat.core.util.vfs.VFSItem)

Aggregations

ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)30 VFSContainer (org.olat.core.util.vfs.VFSContainer)20 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)12 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)8 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)6 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)6 MergeSource (org.olat.core.util.vfs.MergeSource)6 BCCourseNode (org.olat.course.nodes.BCCourseNode)6 CourseNode (org.olat.course.nodes.CourseNode)6 PFCourseNode (org.olat.course.nodes.PFCourseNode)6 Path (javax.ws.rs.Path)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 WindowControl (org.olat.core.gui.control.WindowControl)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 VirtualContainer (org.olat.core.util.vfs.VirtualContainer)4 VFSWebservice (org.olat.core.util.vfs.restapi.VFSWebservice)4 CourseConfig (org.olat.course.config.CourseConfig)4