Search in sources :

Example 46 with Quota

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

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 47 with Quota

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

the class FolderCallback method initFolderQuota.

private void initFolderQuota(String relPath) {
    QuotaManager qm = QuotaManager.getInstance();
    folderQuota = qm.getCustomQuota(relPath);
    if (folderQuota == null) {
        Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_POWER);
        folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
}
Also used : Quota(org.olat.core.util.vfs.Quota) QuotaManager(org.olat.core.util.vfs.QuotaManager)

Example 48 with Quota

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

the class TaskFolderCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (log.isDebug())
        log.debug("event source=" + source + " " + event.toString());
    if (source == btfButton) {
        // check if there are already assigned tasks
        CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
        List<Property> assignedProps = cpm.listCourseNodeProperties(node, null, null, TaskController.PROP_ASSIGNED);
        if (assignedProps.size() == 0) {
            // no task assigned
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
            frc = new FolderRunController(namedFolder, false, ureq, getWindowControl());
            // listenTo(frc);
            frc.addControllerListener(this);
            CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            cmc.activate();
        } else {
            // already assigned task => open dialog with warn
            String[] args = new String[] { new Integer(assignedProps.size()).toString() };
            dialogBoxController = activateOkCancelDialog(ureq, "", getTranslator().translate("taskfolder.overwriting.confirm", args), dialogBoxController);
        }
    } else if (source == vfButton) {
        // switch to new dialog
        OlatNamedContainerImpl namedContainer = TACourseNode.getNodeFolderContainer(node, course.getCourseEnvironment());
        Quota quota = QuotaManager.getInstance().getCustomQuota(namedContainer.getRelPath());
        if (quota == null) {
            Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
            quota = QuotaManager.getInstance().createQuota(namedContainer.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
        }
        SubscriptionContext subContext = SolutionFileUploadNotificationHandler.getSubscriptionContext(course.getCourseEnvironment(), node);
        VFSSecurityCallback secCallback = new FullAccessWithQuotaCallback(quota, subContext);
        namedContainer.setLocalSecurityCallback(secCallback);
        FolderRunController folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
        CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
        cmc.activate();
    } else if (source == editScoringConfigButton) {
        scoringController.setDisplayOnly(false);
        editScoring.contextPut("isOverwriting", new Boolean(true));
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Property(org.olat.properties.Property) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 49 with Quota

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

the class BGConfigToolsStepController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean first = true;
    String containerPage = velocity_root + "/tool_config_container.html";
    String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
    for (String k : availableTools) {
        if (k.equals(CollaborationTools.TOOL_CHAT) || k.equals(CollaborationTools.TOOL_NEWS)) {
            continue;
        }
        String[] keys = new String[] { "on" };
        String[] values = new String[] { translate("collabtools.named." + k) };
        String i18n = first ? "config.tools.desc" : null;
        MultipleSelectionElement selectEl = uifactory.addCheckboxesHorizontal(k, i18n, formLayout, keys, values);
        selectEl.addActionListener(FormEvent.ONCHANGE);
        toolList.add(selectEl);
        ToolConfig config = new ToolConfig(k);
        config.configContainer = FormLayoutContainer.createCustomFormLayout("config.container." + k, getTranslator(), containerPage);
        config.configContainer.contextPut("tool", k);
        config.configContainer.setVisible(false);
        config.configContainer.setRootForm(mainForm);
        formLayout.add(config.configContainer);
        config.enableEl = uifactory.addRadiosHorizontal("config.enable." + k, null, config.configContainer, enableKeys, enableValues);
        config.enableEl.addActionListener(FormEvent.ONCHANGE);
        config.enableEl.select("off", true);
        enableList.add(config.enableEl);
        config.enableEl.setUserObject(config);
        if (k.equals(CollaborationTools.TOOL_CALENDAR)) {
            config.calendarCtrl = new CalendarToolSettingsController(ureq, getWindowControl(), mainForm, CollaborationTools.CALENDAR_ACCESS_OWNERS);
            config.configContainer.add("calendar", config.calendarCtrl.getInitialFormItem());
            config.calendarCtrl.getInitialFormItem().setVisible(false);
        } else if (k.equals(CollaborationTools.TOOL_FOLDER)) {
            // add folder access configuration
            config.folderCtrl = new FolderToolSettingsController(ureq, getWindowControl(), mainForm, CollaborationTools.FOLDER_ACCESS_OWNERS);
            config.configContainer.add("folder", config.folderCtrl.getInitialFormItem());
            config.folderCtrl.getInitialFormItem().setVisible(false);
            // add quota configuration for admin only
            if (ureq.getUserSession().getRoles().isOLATAdmin()) {
                Quota quota = quotaManager.createQuota(null, null, null);
                config.quotaCtrl = new BGConfigQuotaController(ureq, getWindowControl(), quota, mainForm);
                config.configContainer.add("quota", config.quotaCtrl.getInitialFormItem());
                config.quotaCtrl.getInitialFormItem().setVisible(false);
            }
        }
        selectEl.setUserObject(config);
        first = false;
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Quota(org.olat.core.util.vfs.Quota) FolderToolSettingsController(org.olat.collaboration.FolderToolSettingsController) CalendarToolSettingsController(org.olat.collaboration.CalendarToolSettingsController)

Example 50 with Quota

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

the class BGConfigToolsStepController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    BGConfigBusinessGroup configuration = new BGConfigBusinessGroup();
    for (MultipleSelectionElement toolEl : toolList) {
        if (toolEl.isAtLeastSelected(1)) {
            ToolConfig config = (ToolConfig) toolEl.getUserObject();
            String tool = config.getToolKey();
            boolean enabled = config.enableEl.isSelected(0);
            if (enabled) {
                configuration.getToolsToEnable().add(tool);
            } else {
                configuration.getToolsToDisable().add(tool);
            }
            if (tool.equals(CollaborationTools.TOOL_CALENDAR)) {
                configuration.setCalendarAccess(config.calendarCtrl.getCalendarAccess());
            } else if (tool.equals(CollaborationTools.TOOL_FOLDER)) {
                configuration.setFolderAccess(config.folderCtrl.getFolderAccess());
                // only admin are allowed to configure quota
                if (ureq.getUserSession().getRoles().isOLATAdmin() && config.quotaCtrl != null) {
                    Long quotaKB = config.quotaCtrl.getQuotaKB();
                    Long ulLimit = config.quotaCtrl.getULLimit();
                    Quota quota = quotaManager.createQuota(null, quotaKB, ulLimit);
                    configuration.setQuota(quota);
                }
            }
        }
    }
    addToRunContext("configuration", configuration);
    fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Quota(org.olat.core.util.vfs.Quota)

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