Search in sources :

Example 36 with Quota

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

the class BCCourseNodeEditController method doOpenFolder.

private void doOpenFolder(UserRequest ureq) {
    VFSContainer namedContainer = null;
    if (bcNode.getModuleConfiguration().getBooleanSafe(CONFIG_AUTO_FOLDER)) {
        OlatNamedContainerImpl directory = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
        directory.setLocalSecurityCallback(getSecurityCallbackWithQuota(directory.getRelPath()));
        namedContainer = directory;
    } else {
        VFSContainer courseContainer = course.getCourseFolderContainer();
        String path = bcNode.getModuleConfiguration().getStringValue(CONFIG_SUBPATH, "");
        VFSItem pathItem = courseContainer.resolve(path);
        if (pathItem instanceof VFSContainer) {
            namedContainer = (VFSContainer) pathItem;
            if (bcNode.isSharedFolder()) {
                if (course.getCourseConfig().isSharedFolderReadOnlyMount()) {
                    namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
                } else {
                    String relPath = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment()).getRelPath();
                    namedContainer.setLocalSecurityCallback(getSecurityCallbackWithQuota(relPath));
                }
            } else {
                VFSContainer inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(namedContainer);
                if (inheritingContainer != null && inheritingContainer.getLocalSecurityCallback() != null && inheritingContainer.getLocalSecurityCallback().getQuota() != null) {
                    Quota quota = inheritingContainer.getLocalSecurityCallback().getQuota();
                    namedContainer.setLocalSecurityCallback(new FullAccessWithQuotaCallback(quota));
                } else {
                    namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
                }
            }
        }
    }
    folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
    listenTo(folderCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
    listenTo(cmc);
    cmc.activate();
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) Quota(org.olat.core.util.vfs.Quota) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 37 with Quota

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

the class BCCourseNodeEditController method getSecurityCallbackWithQuota.

private VFSSecurityCallback getSecurityCallbackWithQuota(String relPath) {
    Quota quota = quotaManager.getCustomQuota(relPath);
    if (quota == null) {
        Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
        quota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    return new FullAccessWithQuotaCallback(quota);
}
Also used : FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota)

Example 38 with Quota

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

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

the class SharedFolderSecurityCallback method initSharedFolderQuota.

/**
 * Node folder quota has to be ionitialized only once for all of the paths.
 *
 * @param path
 */
private void initSharedFolderQuota(String path) {
    QuotaManager qm = QuotaManager.getInstance();
    sharedFolderQuota = qm.getCustomQuota(path);
    if (sharedFolderQuota == null) {
        Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_COURSE);
        sharedFolderQuota = QuotaManager.getInstance().createQuota(path, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
}
Also used : Quota(org.olat.core.util.vfs.Quota) QuotaManager(org.olat.core.util.vfs.QuotaManager)

Example 40 with Quota

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

the class CourseGroupWebService method getFolder.

@Path("{groupKey}/folder")
public VFSWebservice getFolder(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
    if (bg == null) {
        return null;
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return null;
        }
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (!collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
        return null;
    }
    String relPath = collabTools.getFolderRelPath();
    QuotaManager qm = QuotaManager.getInstance();
    Quota folderQuota = qm.getCustomQuota(relPath);
    if (folderQuota == null) {
        Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS);
        folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    SubscriptionContext subsContext = null;
    VFSWebServiceSecurityCallback secCallback = new VFSWebServiceSecurityCallback(true, true, true, folderQuota, subsContext);
    OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(relPath, null);
    rootContainer.setLocalSecurityCallback(secCallback);
    return new VFSWebservice(rootContainer);
}
Also used : VFSWebServiceSecurityCallback(org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Quota(org.olat.core.util.vfs.Quota) BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) QuotaManager(org.olat.core.util.vfs.QuotaManager) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) Path(javax.ws.rs.Path)

Aggregations

Quota (org.olat.core.util.vfs.Quota)50 QuotaManager (org.olat.core.util.vfs.QuotaManager)18 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)12 FullAccessWithQuotaCallback (org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback)12 CollaborationTools (org.olat.collaboration.CollaborationTools)6 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)6 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)6 BusinessGroup (org.olat.group.BusinessGroup)6 Property (org.olat.properties.Property)6 Path (javax.ws.rs.Path)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 Identity (org.olat.core.id.Identity)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VFSWebServiceSecurityCallback (org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback)4 VFSWebservice (org.olat.core.util.vfs.restapi.VFSWebservice)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 File (java.io.File)2