Search in sources :

Example 26 with NamedContainerImpl

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

the class SimpleVersionConfig method versionEnabled.

public boolean versionEnabled(VFSContainer container) {
    int versionsAllowed = getVersionAllowed();
    if (versionsAllowed == 0) {
        return false;
    }
    if (container instanceof NamedContainerImpl) {
        container = ((NamedContainerImpl) container).getDelegate();
    }
    if (container instanceof MergeSource) {
        container = ((MergeSource) container).getRootWriteContainer();
    }
    if (container instanceof LocalFolderImpl) {
        try {
            LocalFolderImpl folderImpl = (LocalFolderImpl) container;
            String path = folderImpl.getBasefile().getCanonicalPath();
            List<String> excludedRoots = getExcludedRoots();
            for (String excludedRoot : excludedRoots) {
                if (path.startsWith(excludedRoot)) {
                    return false;
                }
            }
            String root = getCourseRoot();
            if (path.startsWith(root)) {
                for (String exclusion : EXCLUSIONS_IN_COURSE_PATH) {
                    if (path.indexOf(exclusion) > 0) {
                        return false;
                    }
                }
            }
            return getVersionAllowed() != 0;
        } catch (IOException e) {
        // fail silently;
        }
    }
    return false;
}
Also used : MergeSource(org.olat.core.util.vfs.MergeSource) IOException(java.io.IOException) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 27 with NamedContainerImpl

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

the class PFManager method provideAdminContainer.

/**
 * Provide admin view for webdav, contains all participants of the course.
 *
 * @param pfNode the pf node
 * @param courseEnv the course env
 * @return the VFS container
 */
public VFSContainer provideAdminContainer(PFCourseNode pfNode, CourseEnvironment courseEnv) {
    Translator translator = Util.createPackageTranslator(PFRunController.class, I18nModule.getDefaultLocale());
    SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
    RepositoryEntry re = courseEnv.getCourseGroupManager().getCourseEntry();
    List<Identity> participants = repositoryEntryRelationDao.getMembers(re, RepositoryEntryRelationType.both, GroupRoles.participant.name());
    participants = new ArrayList<>(new HashSet<>(participants));
    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);
        participantFolder.setParentContainer(namedCourseFolder);
        namedCourseFolder.addItem(participantFolder);
        if (pfNode.hasParticipantBoxConfigured()) {
            VFSContainer dropContainer = new NamedContainerImpl(translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
            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 : Path(java.nio.file.Path) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) 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) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) HashSet(java.util.HashSet) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 28 with NamedContainerImpl

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

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

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

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

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

the class DocumentPoolWebDAVMergeSource method addDocument.

private VFSContainer addDocument(TaxonomyTreeNode taxonomyNode) {
    VFSContainer documents = taxonomyService.getDocumentsLibrary(taxonomyNode.getTaxonomyLevel());
    SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
    TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(taxonomyNode, subscriptionCtx);
    documents.setLocalSecurityCallback(secCallback);
    return new NamedContainerImpl("_documents", documents);
}
Also used : TaxonomyVFSSecurityCallback(org.olat.modules.taxonomy.ui.component.TaxonomyVFSSecurityCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

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