Search in sources :

Example 21 with Quota

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

the class AbstractBusinessGroupListController method doConfiguration.

/**
 * @param ureq
 * @param items
 */
private void doConfiguration(UserRequest ureq, List<? extends BusinessGroupRef> selectedItems) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (selectedItems == null || selectedItems.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    final List<BusinessGroup> groups = toBusinessGroups(ureq, selectedItems, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (selectedItems.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    if (CollaborationToolsFactory.getInstance().getAvailableTools() == null) {
        // init the available tools
        CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(groups.get(0));
    }
    StringBuilder managedNames = new StringBuilder();
    for (BusinessGroup group : groups) {
        String gname = group.getName() == null ? "???" : group.getName();
        if (BusinessGroupManagedFlag.isManaged(group, BusinessGroupManagedFlag.resources) || BusinessGroupManagedFlag.isManaged(group, BusinessGroupManagedFlag.tools)) {
            if (managedNames.length() > 0)
                managedNames.append(", ");
            managedNames.append(gname);
        }
    }
    if (managedNames.length() > 0) {
        showWarning("error.managed.group", managedNames.toString());
        return;
    }
    boolean isAuthor = ureq.getUserSession().getRoles().isAuthor() || ureq.getUserSession().getRoles().isInstitutionalResourceManager();
    Step start = new BGConfigToolsStep(ureq, isAuthor);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            // configuration
            BGConfigBusinessGroup configuration = (BGConfigBusinessGroup) runContext.get("configuration");
            if (!configuration.getToolsToEnable().isEmpty() || !configuration.getToolsToDisable().isEmpty()) {
                for (BusinessGroup group : groups) {
                    CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
                    for (String enabledTool : configuration.getToolsToEnable()) {
                        tools.setToolEnabled(enabledTool, true);
                        if (CollaborationTools.TOOL_FOLDER.equals(enabledTool)) {
                            tools.saveFolderAccess(new Long(configuration.getFolderAccess()));
                            Quota quota = configuration.getQuota();
                            if (quota != null) {
                                String path = tools.getFolderRelPath();
                                Quota fQuota = QuotaManager.getInstance().createQuota(path, quota.getQuotaKB(), quota.getUlLimitKB());
                                QuotaManager.getInstance().setCustomQuotaKB(fQuota);
                            }
                        } else if (CollaborationTools.TOOL_CALENDAR.equals(enabledTool)) {
                            tools.saveCalendarAccess(new Long(configuration.getCalendarAccess()));
                        }
                    }
                    for (String disabledTool : configuration.getToolsToDisable()) {
                        tools.setToolEnabled(disabledTool, false);
                    }
                }
            }
            if (configuration.getResources() != null && !configuration.getResources().isEmpty()) {
                businessGroupService.addResourcesTo(groups, configuration.getResources());
            }
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("config.group"), "o_sel_groups_config_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Quota(org.olat.core.util.vfs.Quota) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) CollaborationTools(org.olat.collaboration.CollaborationTools) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 22 with Quota

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

the class BriefcaseWebDAVMergeSource method getLocalSecurityCallback.

@Override
public VFSSecurityCallback getLocalSecurityCallback() {
    if (super.getLocalSecurityCallback() == null) {
        // set quota for this merge source
        QuotaManager qm = QuotaManager.getInstance();
        Quota quota = qm.getCustomQuotaOrDefaultDependingOnRole(identity, PersonalFolderManager.getInstance().getRootPathFor(identity));
        FullAccessWithQuotaCallback secCallback = new FullAccessWithQuotaCallback(quota);
        setLocalSecurityCallback(secCallback);
    }
    return super.getLocalSecurityCallback();
}
Also used : FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) QuotaManager(org.olat.core.util.vfs.QuotaManager)

Example 23 with Quota

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

the class DropboxController method getUploadLimit.

/**
 * Get upload limit for dropbox of a certain user. The upload can be limited
 * by available-folder space, max folder size or configurated upload-limit.
 * @param ureq
 * @return max upload limit in KB
 */
private int getUploadLimit() {
    String dropboxPath = getRelativeDropBoxFilePath(getIdentity());
    Quota dropboxQuota = QuotaManager.getInstance().getCustomQuota(dropboxPath);
    if (dropboxQuota == null) {
        dropboxQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
    }
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getRelativeDropBoxFilePath(getIdentity()), null);
    VFSContainer dropboxContainer = new OlatNamedContainerImpl(getIdentity().getName(), rootFolder);
    FullAccessWithQuotaCallback secCallback = new FullAccessWithQuotaCallback(dropboxQuota);
    rootFolder.setLocalSecurityCallback(secCallback);
    return QuotaManager.getInstance().getUploadLimitKB(dropboxQuota.getQuotaKB(), dropboxQuota.getUlLimitKB(), dropboxContainer);
}
Also used : 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) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 24 with Quota

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

the class TaskFolderCallback method initTaskFolderQuota.

private void initTaskFolderQuota(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 25 with Quota

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

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)

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