Search in sources :

Example 6 with FullAccessWithQuotaCallback

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

Example 7 with FullAccessWithQuotaCallback

use of org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback 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 8 with FullAccessWithQuotaCallback

use of org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback 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 9 with FullAccessWithQuotaCallback

use of org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback 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 10 with FullAccessWithQuotaCallback

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

Aggregations

FullAccessWithQuotaCallback (org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback)14 Quota (org.olat.core.util.vfs.Quota)12 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)8 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)6 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)4 File (java.io.File)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 QuotaManager (org.olat.core.util.vfs.QuotaManager)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 FullAccessWithLazyQuotaCallback (org.olat.core.util.vfs.callbacks.FullAccessWithLazyQuotaCallback)2 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)2 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)2 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)2 CPEditMainController (org.olat.ims.cp.ui.CPEditMainController)2 Property (org.olat.properties.Property)2