Search in sources :

Example 26 with ReadOnlyCallback

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

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 27 with ReadOnlyCallback

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

Example 28 with ReadOnlyCallback

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

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)

Example 29 with ReadOnlyCallback

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

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 30 with ReadOnlyCallback

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

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)

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