Search in sources :

Example 31 with Quota

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

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

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

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

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

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

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

the class ModifyCourseEvent method copyCourse.

/**
 * Copies a course. More specifically, the run and editor structures and the
 * course folder will be copied to create a new course.
 *
 * @param sourceRes
 * @param ureq
 * @return copy of the course.
 */
public static OLATResourceable copyCourse(OLATResourceable sourceRes, OLATResource targetRes) {
    PersistingCourseImpl sourceCourse = (PersistingCourseImpl) loadCourse(sourceRes);
    PersistingCourseImpl targetCourse = new PersistingCourseImpl(targetRes);
    File fTargetCourseBasePath = targetCourse.getCourseBaseContainer().getBasefile();
    // close connection before file copy
    DBFactory.getInstance().commitAndCloseSession();
    synchronized (sourceCourse) {
        // o_clusterNOK - cannot be solved with doInSync since could take too long (leads to error: "Lock wait timeout exceeded")
        // copy configuration
        CourseConfig courseConf = CourseConfigManagerImpl.getInstance().copyConfigOf(sourceCourse);
        targetCourse.setCourseConfig(courseConf);
        // save structures
        targetCourse.setRunStructure((Structure) XStreamHelper.xstreamClone(sourceCourse.getRunStructure()));
        targetCourse.saveRunStructure();
        targetCourse.setEditorTreeModel((CourseEditorTreeModel) XStreamHelper.xstreamClone(sourceCourse.getEditorTreeModel()));
        targetCourse.saveEditorTreeModel();
        // copy course folder
        File fSourceCourseFolder = sourceCourse.getIsolatedCourseBaseFolder();
        if (fSourceCourseFolder.exists())
            FileUtils.copyDirToDir(fSourceCourseFolder, fTargetCourseBasePath, false, "copy course folder");
        // copy folder nodes directories
        File fSourceFoldernodesFolder = new File(FolderConfig.getCanonicalRoot() + BCCourseNode.getFoldernodesPathRelToFolderBase(sourceCourse.getCourseEnvironment()));
        if (fSourceFoldernodesFolder.exists())
            FileUtils.copyDirToDir(fSourceFoldernodesFolder, fTargetCourseBasePath, false, "copy folder nodes directories");
        // copy task folder directories
        File fSourceTaskfoldernodesFolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFoldersPathRelToFolderRoot(sourceCourse.getCourseEnvironment()));
        if (fSourceTaskfoldernodesFolder.exists())
            FileUtils.copyDirToDir(fSourceTaskfoldernodesFolder, fTargetCourseBasePath, false, "copy task folder directories");
        // update references
        List<Reference> refs = referenceManager.getReferences(sourceCourse);
        int count = 0;
        for (Reference ref : refs) {
            referenceManager.addReference(targetCourse, ref.getTarget(), ref.getUserdata());
            if (count % 20 == 0) {
                DBFactory.getInstance().intermediateCommit();
            }
        }
        // set quotas
        Quota sourceQuota = VFSManager.isTopLevelQuotaContainer(sourceCourse.getCourseFolderContainer());
        Quota targetQuota = VFSManager.isTopLevelQuotaContainer(targetCourse.getCourseFolderContainer());
        if (sourceQuota != null && targetQuota != null) {
            QuotaManager qm = QuotaManager.getInstance();
            if (sourceQuota.getQuotaKB() != qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_COURSE).getQuotaKB()) {
                targetQuota = qm.createQuota(targetQuota.getPath(), sourceQuota.getQuotaKB(), sourceQuota.getUlLimitKB());
                qm.setCustomQuotaKB(targetQuota);
            }
        }
    }
    return targetRes;
}
Also used : Quota(org.olat.core.util.vfs.Quota) Reference(org.olat.resource.references.Reference) QuotaManager(org.olat.core.util.vfs.QuotaManager) File(java.io.File) CourseConfig(org.olat.course.config.CourseConfig)

Example 35 with Quota

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

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)

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