Search in sources :

Example 11 with VirtualContainer

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

the class DocumentPoolWebDAVMergeSource method loadRecursiveMergedContainers.

private VFSContainer loadRecursiveMergedContainers(Taxonomy taxonomy, INode node) {
    VFSContainer container = null;
    if (node instanceof TaxonomyTreeNode) {
        TaxonomyTreeNode taxonomyNode = (TaxonomyTreeNode) node;
        String name = RequestUtil.normalizeFilename(taxonomyNode.getTitle());
        VirtualContainer levelContainer = new VirtualContainer(name);
        levelContainer.setLocalSecurityCallback(new DefaultVFSSecurityCallback());
        boolean hasDocuments = false;
        if (taxonomyNode.getType() == TaxonomyTreeNodeType.templates) {
            // the templates
            return addTemplates(taxonomyNode, taxonomy);
        } else if (taxonomyNode.getTaxonomyLevel() != null && taxonomyNode.isDocumentsLibraryEnabled() && taxonomyNode.isCanRead()) {
            // the real thing
            levelContainer.addItem(addDocument(taxonomyNode));
            hasDocuments = true;
        }
        for (int i = 0; i < node.getChildCount(); i++) {
            VFSContainer childContainer = loadRecursiveMergedContainers(taxonomy, node.getChildAt(i));
            if (childContainer != null) {
                levelContainer.addItem(childContainer);
                hasDocuments = true;
            }
        }
        container = hasDocuments ? levelContainer : null;
    }
    return container;
}
Also used : DefaultVFSSecurityCallback(org.olat.core.util.vfs.callbacks.DefaultVFSSecurityCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 12 with VirtualContainer

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

the class WebDAVManagerImpl method getWebDAVRoot.

@Override
public WebResourceRoot getWebDAVRoot(HttpServletRequest req) {
    UserSession usess = getUserSession(req);
    if (usess == null || usess.getIdentity() == null) {
        return createEmptyRoot(usess);
    }
    usess.getSessionInfo().setLastClickTime();
    VFSResourceRoot fdc = (VFSResourceRoot) usess.getEntry("_DIRCTX");
    if (fdc != null) {
        return fdc;
    }
    IdentityEnvironment identityEnv = usess.getIdentityEnvironment();
    VFSContainer webdavContainer = getMountableRoot(identityEnv);
    // create the / folder
    VirtualContainer rootContainer = new VirtualContainer("");
    rootContainer.addItem(webdavContainer);
    rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
    fdc = new VFSResourceRoot(identityEnv.getIdentity(), rootContainer);
    usess.putEntry("_DIRCTX", fdc);
    return fdc;
}
Also used : ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) UserSession(org.olat.core.util.UserSession) VFSContainer(org.olat.core.util.vfs.VFSContainer) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 13 with VirtualContainer

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

the class WebDAVManagerImpl method createEmptyRoot.

private WebResourceRoot createEmptyRoot(UserSession usess) {
    // create the / folder
    VirtualContainer rootContainer = new VirtualContainer("");
    rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
    return new VFSResourceRoot(usess.getIdentity(), rootContainer);
}
Also used : ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 14 with VirtualContainer

use of org.olat.core.util.vfs.VirtualContainer 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 15 with VirtualContainer

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

the class WebDAVManagerImpl method getWebDAVRoot.

@Override
public WebResourceRoot getWebDAVRoot(HttpServletRequest req) {
    UserSession usess = getUserSession(req);
    if (usess == null || usess.getIdentity() == null) {
        return createEmptyRoot(usess);
    }
    usess.getSessionInfo().setLastClickTime();
    VFSResourceRoot fdc = (VFSResourceRoot) usess.getEntry("_DIRCTX");
    if (fdc != null) {
        return fdc;
    }
    IdentityEnvironment identityEnv = usess.getIdentityEnvironment();
    VFSContainer webdavContainer = getMountableRoot(identityEnv);
    // create the / folder
    VirtualContainer rootContainer = new VirtualContainer("");
    rootContainer.addItem(webdavContainer);
    rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
    fdc = new VFSResourceRoot(identityEnv.getIdentity(), rootContainer);
    usess.putEntry("_DIRCTX", fdc);
    return fdc;
}
Also used : ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) UserSession(org.olat.core.util.UserSession) VFSContainer(org.olat.core.util.vfs.VFSContainer) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Aggregations

VirtualContainer (org.olat.core.util.vfs.VirtualContainer)20 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)10 Path (java.nio.file.Path)8 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)8 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)8 Translator (org.olat.core.gui.translator.Translator)6 Identity (org.olat.core.id.Identity)6 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 Locale (java.util.Locale)4 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaInfoFactory (org.olat.core.commons.modules.bc.meta.MetaInfoFactory)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 License (org.olat.core.commons.services.license.License)2 LicenseRenderer (org.olat.core.commons.services.license.ui.LicenseRenderer)2