Search in sources :

Example 1 with NamedContainerImpl

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

the class BCCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (isLogDebugEnabled())
        logDebug("Index Briefcase...");
    BCCourseNode bcNode = (BCCourseNode) courseNode;
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, bcNode, TYPE);
    Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, bcNode);
    indexWriter.addDocument(document);
    VFSContainer bcContainer = null;
    if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
        bcContainer = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
    } else {
        String subpath = courseNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
        if (subpath != null) {
            VFSItem item = course.getCourseEnvironment().getCourseFolderContainer().resolve(subpath);
            if (item instanceof VFSContainer) {
                bcContainer = new NamedContainerImpl(courseNode.getShortTitle(), (VFSContainer) item);
            }
        }
    }
    if (bcContainer != null) {
        doIndexVFSContainer(courseNodeResourceContext, bcContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
    }
}
Also used : BCCourseNode(org.olat.course.nodes.BCCourseNode) SearchResourceContext(org.olat.search.service.SearchResourceContext) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 2 with NamedContainerImpl

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

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

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

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)

Example 4 with NamedContainerImpl

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

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

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

the class DocumentPoolWebDAVMergeSource method addTemplates.

private VFSContainer addTemplates(TaxonomyTreeNode taxonomyNode, Taxonomy taxonomy) {
    VFSContainer documents = taxonomyService.getDocumentsLibrary(taxonomy);
    SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
    TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(taxonomyNode, subscriptionCtx);
    System.out.println(taxonomyNode.isCanWrite());
    documents.setLocalSecurityCallback(secCallback);
    return new NamedContainerImpl(taxonomyNode.getTitle(), 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