Search in sources :

Example 11 with NamedContainerImpl

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

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 12 with NamedContainerImpl

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

the class QTIEditorPackageImpl method getBaseDir.

@Override
public VFSContainer getBaseDir() {
    VFSContainer localDir = new LocalFolderImpl(packageDir);
    if (secCallback != null) {
        localDir.setLocalSecurityCallback(secCallback);
    }
    String dirName = translator.translate("qti.basedir.displayname");
    NamedContainerImpl namedBaseDir = new NamedContainerImpl(dirName, localDir);
    return namedBaseDir;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 13 with NamedContainerImpl

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

the class GroupfoldersWebDAVMergeSource method getGroupContainer.

private VFSContainer getGroupContainer(String name, BusinessGroup group, boolean isOwner) {
    String folderPath = collaborationManager.getFolderRelPath(group);
    // create container and set quota
    OlatRootFolderImpl localImpl = new OlatRootFolderImpl(folderPath, this);
    // already done in OlatRootFolderImpl localImpl.getBasefile().mkdirs(); // lazy initialize dirs
    String containerName = RequestUtil.normalizeFilename(name);
    NamedContainerImpl grpContainer = new GroupNamedContainer(containerName, localImpl);
    boolean writeAccess;
    if (!isOwner) {
        // check if participants have read/write access
        int folderAccess = CollaborationTools.FOLDER_ACCESS_ALL;
        Long lFolderAccess = collaborationManager.lookupFolderAccess(group);
        if (lFolderAccess != null) {
            folderAccess = lFolderAccess.intValue();
        }
        writeAccess = (folderAccess == CollaborationTools.FOLDER_ACCESS_ALL);
    } else {
        writeAccess = true;
    }
    VFSSecurityCallback secCallback;
    if (writeAccess) {
        SubscriptionContext sc = new SubscriptionContext(group, "toolfolder");
        secCallback = new FullAccessWithLazyQuotaCallback(folderPath, QuotaConstants.IDENTIFIER_DEFAULT_GROUPS, sc);
    } else {
        secCallback = new ReadOnlyCallback();
    }
    grpContainer.setLocalSecurityCallback(secCallback);
    return grpContainer;
}
Also used : FullAccessWithLazyQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithLazyQuotaCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 14 with NamedContainerImpl

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

the class PFManager method provideParticipantFolder.

/**
 * Provide participant folder in GUI.
 *
 * @param pfNode
 * @param pfView
 * @param courseEnv
 * @param identity
 * @param isCoach
 * @return the VFS container
 */
public VFSContainer provideParticipantFolder(PFCourseNode pfNode, PFView pfView, Translator translator, CourseEnvironment courseEnv, Identity identity, boolean isCoach, boolean readOnly) {
    SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
    String path = courseEnv.getCourseBaseContainer().getRelPath() + "/" + FILENAME_PARTICIPANTFOLDER;
    VFSContainer courseElementBaseContainer = new OlatRootFolderImpl(path, null);
    Path relPath = Paths.get(pfNode.getIdent(), getIdFolderName(identity));
    VFSContainer userBaseContainer = VFSManager.resolveOrCreateContainerFromPath(courseElementBaseContainer, relPath.toString());
    String baseContainerName = userManager.getUserDisplayName(identity);
    VirtualContainer namedCourseFolder = new VirtualContainer(baseContainerName);
    namedCourseFolder.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
    VFSContainer dropContainer = new NamedContainerImpl(PFView.onlyDrop.equals(pfView) || PFView.onlyReturn.equals(pfView) ? baseContainerName : translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
    if (pfNode.hasParticipantBoxConfigured()) {
        namedCourseFolder.addItem(dropContainer);
    }
    VFSContainer returnContainer = new NamedContainerImpl(PFView.onlyDrop.equals(pfView) || PFView.onlyReturn.equals(pfView) ? baseContainerName : translator.translate("return.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_RETURNBOX));
    if (pfNode.hasCoachBoxConfigured()) {
        namedCourseFolder.addItem(returnContainer);
    }
    if (readOnly) {
        dropContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
        returnContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
    } else {
        if (isCoach) {
            dropContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
            returnContainer.setLocalSecurityCallback(new ReadWriteDeleteCallback(nodefolderSubContext));
        } else {
            VFSContainer dropbox = resolveOrCreateDropFolder(courseEnv, pfNode, identity);
            VFSSecurityCallback callback = calculateCallback(courseEnv, pfNode, dropbox, false);
            dropContainer.setLocalSecurityCallback(callback);
            returnContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
        }
    }
    VFSContainer folderRunContainer;
    switch(pfView) {
        case dropAndReturn:
            folderRunContainer = namedCourseFolder;
            break;
        case onlyDrop:
            folderRunContainer = dropContainer;
            break;
        case onlyReturn:
            folderRunContainer = returnContainer;
            break;
        default:
            folderRunContainer = namedCourseFolder;
            break;
    }
    return folderRunContainer;
}
Also used : Path(java.nio.file.Path) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 15 with NamedContainerImpl

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

the class PFManager method provideParticipantContainer.

/**
 * Provide participant view in webdav.
 *
 * @param pfNode
 * @param courseEnv
 * @param identity
 * @return the VFS container
 */
private VFSContainer provideParticipantContainer(PFCourseNode pfNode, CourseEnvironment courseEnv, Identity identity, boolean courseReadOnly) {
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage());
    Translator translator = Util.createPackageTranslator(PFRunController.class, locale);
    SubscriptionContext subsContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
    String path = courseEnv.getCourseBaseContainer().getRelPath() + "/" + FILENAME_PARTICIPANTFOLDER;
    VFSContainer courseElementBaseContainer = new OlatRootFolderImpl(path, null);
    VirtualContainer namedCourseFolder = new VirtualContainer(identity.getName());
    Path relPath = Paths.get(pfNode.getIdent(), getIdFolderName(identity));
    VFSContainer userBaseContainer = VFSManager.resolveOrCreateContainerFromPath(courseElementBaseContainer, relPath.toString());
    if (pfNode.hasParticipantBoxConfigured()) {
        VFSContainer dropContainer = new NamedContainerImpl(translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
        if (courseReadOnly) {
            dropContainer.setLocalSecurityCallback(new ReadOnlyCallback(subsContext));
        } else {
            VFSContainer dropbox = resolveOrCreateDropFolder(courseEnv, pfNode, identity);
            VFSSecurityCallback callback = calculateCallback(courseEnv, pfNode, dropbox, true);
            dropContainer.setLocalSecurityCallback(callback);
        }
        namedCourseFolder.addItem(dropContainer);
    }
    if (pfNode.hasCoachBoxConfigured()) {
        VFSContainer returnContainer = new NamedContainerImpl(translator.translate("return.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_RETURNBOX));
        returnContainer.setLocalSecurityCallback(new ReadOnlyCallback(subsContext));
        namedCourseFolder.addItem(returnContainer);
    }
    return namedCourseFolder;
}
Also used : Locale(java.util.Locale) Path(java.nio.file.Path) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Translator(org.olat.core.gui.translator.Translator) VFSContainer(org.olat.core.util.vfs.VFSContainer) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

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