Search in sources :

Example 36 with VFSSecurityCallback

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

the class BCWebService method createFolderVO.

public static FolderVO createFolderVO(IdentityEnvironment ienv, ICourse course, BCCourseNode bcNode, Collection<String> subscribed) {
    OlatNamedContainerImpl container = BCCourseNode.getSecurisedNodeFolderContainer(bcNode, course.getCourseEnvironment(), ienv);
    VFSSecurityCallback secCallback = container.getLocalSecurityCallback();
    FolderVO folderVo = new FolderVO();
    folderVo.setName(course.getCourseTitle());
    folderVo.setDetailsName(bcNode.getShortTitle());
    if (subscribed != null && subscribed.contains(bcNode.getIdent())) {
        folderVo.setSubscribed(true);
    } else {
        folderVo.setSubscribed(false);
    }
    folderVo.setCourseKey(course.getResourceableId());
    folderVo.setCourseNodeId(bcNode.getIdent());
    folderVo.setWrite(secCallback.canWrite());
    folderVo.setRead(secCallback.canRead());
    folderVo.setDelete(secCallback.canDelete());
    folderVo.setList(secCallback.canList());
    return folderVo;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FolderVO(org.olat.restapi.support.vo.FolderVO) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 37 with VFSSecurityCallback

use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback 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 38 with VFSSecurityCallback

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

the class ImsCPHandler method createEditorController.

@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbar) {
    // only unzips, if not already unzipped
    OlatRootFolderImpl cpRoot = FileResourceManager.getInstance().unzipContainerResource(re.getOlatResource());
    Quota quota = QuotaManager.getInstance().getCustomQuota(cpRoot.getRelPath());
    if (quota == null) {
        Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_REPO);
        quota = QuotaManager.getInstance().createQuota(cpRoot.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    VFSSecurityCallback secCallback = new FullAccessWithQuotaCallback(quota);
    cpRoot.setLocalSecurityCallback(secCallback);
    return new CPEditMainController(ureq, wControl, toolbar, cpRoot, re.getOlatResource());
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) CPEditMainController(org.olat.ims.cp.ui.CPEditMainController)

Example 39 with VFSSecurityCallback

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

the class CollaborationTools method getSecuredFolder.

/**
 * Return the root VFS container with security callback set
 * @return
 */
public OlatRootFolderImpl getSecuredFolder(BusinessGroup businessGroup, SubscriptionContext subsContext, Identity identity, boolean isAdmin) {
    if (!isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
        return null;
    }
    boolean writeAccess;
    boolean isOwner = CoreSpringFactory.getImpl(BusinessGroupService.class).hasRoles(identity, businessGroup, GroupRoles.coach.name());
    if (!(isAdmin || isOwner)) {
        // check if participants have read/write access
        int folderAccess = CollaborationTools.FOLDER_ACCESS_ALL;
        Long lFolderAccess = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup).lookupFolderAccess();
        if (lFolderAccess != null) {
            folderAccess = lFolderAccess.intValue();
        }
        writeAccess = (folderAccess == CollaborationTools.CALENDAR_ACCESS_ALL);
    } else {
        writeAccess = true;
    }
    String relPath = getFolderRelPath();
    VFSSecurityCallback secCallback = new CollabSecCallback(writeAccess, relPath, subsContext);
    OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(relPath, null);
    rootContainer.setLocalSecurityCallback(secCallback);
    return rootContainer;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) BusinessGroupService(org.olat.group.BusinessGroupService) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 40 with VFSSecurityCallback

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

the class CmdEditMeta method notifyFinished.

private void notifyFinished(UserRequest ureq) {
    VFSContainer container = VFSManager.findInheritingSecurityCallbackContainer(folderComponent.getRootContainer());
    VFSSecurityCallback secCallback = container.getLocalSecurityCallback();
    if (secCallback != null) {
        SubscriptionContext subsContext = secCallback.getSubscriptionContext();
        if (subsContext != null) {
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
        }
    }
    fireEvent(ureq, FOLDERCOMMAND_FINISHED);
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Aggregations

VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)50 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)28 VFSContainer (org.olat.core.util.vfs.VFSContainer)26 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)24 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)10 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)8 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)8 Identity (org.olat.core.id.Identity)8 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)8 VFSItem (org.olat.core.util.vfs.VFSItem)8 Path (java.nio.file.Path)6 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)6 VirtualContainer (org.olat.core.util.vfs.VirtualContainer)6 Quota (org.olat.core.util.vfs.Quota)5 Locale (java.util.Locale)4 Path (javax.ws.rs.Path)4 WindowControl (org.olat.core.gui.control.WindowControl)4 MediaResource (org.olat.core.gui.media.MediaResource)4