Search in sources :

Example 26 with Quota

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

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

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

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)

Example 28 with Quota

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

the class LearningGroupWebService 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;
    VFSSecurityCallback 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) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) Path(javax.ws.rs.Path)

Example 29 with Quota

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

the class ItemFormController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    String name = file.getUploadFileName();
    if (name != null) {
        if (!validateFilename(name)) {
            allOk = false;
        } else {
            flc.setDirty(true);
        }
        // quota check whole feed
        if (baseDir.getLocalSecurityCallback() == null || baseDir.getLocalSecurityCallback().getQuota() != null) {
            Quota feedQuota = baseDir.getLocalSecurityCallback().getQuota();
            Long remainingQuotaKb = feedQuota.getRemainingSpace();
            if (remainingQuotaKb != -1 && file.getUploadFile().length() / 1024 > remainingQuotaKb) {
                String supportAddr = WebappHelper.getMailConfig("mailQuota");
                Long uploadLimitKB = feedQuota.getUlLimitKB();
                file.setErrorKey("ULLimitExceeded", new String[] { Formatter.roundToString(uploadLimitKB.floatValue() / 1000f, 1), supportAddr });
                allOk = false;
            }
        }
    }
    String width = widthEl.getValue();
    if (StringHelper.containsNonWhitespace(width)) {
        try {
            Integer.parseInt(width);
        } catch (NumberFormatException e) {
            widthEl.setErrorKey("feed.item.file.size.error", null);
            allOk = false;
        }
    }
    String height = heightEl.getValue();
    if (StringHelper.containsNonWhitespace(height)) {
        try {
            Integer.parseInt(height);
        } catch (NumberFormatException e) {
            heightEl.setErrorKey("feed.item.file.size.error", null);
            allOk = false;
        }
    }
    return allOk & super.validateFormLogic(ureq);
}
Also used : Quota(org.olat.core.util.vfs.Quota)

Example 30 with Quota

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

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