Search in sources :

Example 1 with FolderNodeCallback

use of org.olat.course.nodes.bc.FolderNodeCallback in project OpenOLAT by OpenOLAT.

the class BCCourseNode method getSecurisedNodeFolderContainer.

public static OlatNamedContainerImpl getSecurisedNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv, IdentityEnvironment ienv) {
    boolean isOlatAdmin = ienv.getRoles().isOLATAdmin();
    boolean isGuestOnly = ienv.getRoles().isGuestOnly();
    UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
    NodeEvaluation ne = node.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
    OlatNamedContainerImpl container = getNodeFolderContainer(node, courseEnv);
    VFSSecurityCallback secCallback = new FolderNodeCallback(container.getRelPath(), ne, isOlatAdmin, isGuestOnly, null);
    container.setLocalSecurityCallback(secCallback);
    return container;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FolderNodeCallback(org.olat.course.nodes.bc.FolderNodeCallback) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 2 with FolderNodeCallback

use of org.olat.course.nodes.bc.FolderNodeCallback in project openolat by klemens.

the class BCCourseNode method getSecurisedNodeFolderContainer.

public static OlatNamedContainerImpl getSecurisedNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv, IdentityEnvironment ienv) {
    boolean isOlatAdmin = ienv.getRoles().isOLATAdmin();
    boolean isGuestOnly = ienv.getRoles().isGuestOnly();
    UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
    NodeEvaluation ne = node.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
    OlatNamedContainerImpl container = getNodeFolderContainer(node, courseEnv);
    VFSSecurityCallback secCallback = new FolderNodeCallback(container.getRelPath(), ne, isOlatAdmin, isGuestOnly, null);
    container.setLocalSecurityCallback(secCallback);
    return container;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FolderNodeCallback(org.olat.course.nodes.bc.FolderNodeCallback) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 3 with FolderNodeCallback

use of org.olat.course.nodes.bc.FolderNodeCallback 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 4 with FolderNodeCallback

use of org.olat.course.nodes.bc.FolderNodeCallback 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)

Aggregations

VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)4 FolderNodeCallback (org.olat.course.nodes.bc.FolderNodeCallback)4 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)2 NodeEvaluation (org.olat.course.run.userview.NodeEvaluation)2 TreeEvaluation (org.olat.course.run.userview.TreeEvaluation)2 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)2 VisibleTreeFilter (org.olat.course.run.userview.VisibleTreeFilter)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryManager (org.olat.repository.RepositoryManager)2