Search in sources :

Example 16 with QuotaManager

use of org.olat.core.util.vfs.QuotaManager 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 17 with QuotaManager

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

the class GenericQuotaEditController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == quotaForm) {
        if (event == Event.DONE_EVENT) {
            QuotaManager qm = QuotaManager.getInstance();
            currentQuota = QuotaManager.getInstance().createQuota(quotaForm.getPath(), new Long(quotaForm.getQuotaKB()), new Long(quotaForm.getULLimit()));
            qm.setCustomQuotaKB(currentQuota);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
    }
}
Also used : QuotaManager(org.olat.core.util.vfs.QuotaManager)

Example 18 with QuotaManager

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

the class QuotaTableModel method refresh.

/**
 */
public void refresh() {
    QuotaManager qm = QuotaManager.getInstance();
    quotaList = qm.listCustomQuotasKB();
}
Also used : QuotaManager(org.olat.core.util.vfs.QuotaManager)

Example 19 with QuotaManager

use of org.olat.core.util.vfs.QuotaManager 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 20 with QuotaManager

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

Aggregations

QuotaManager (org.olat.core.util.vfs.QuotaManager)26 Quota (org.olat.core.util.vfs.Quota)18 Path (javax.ws.rs.Path)4 CollaborationTools (org.olat.collaboration.CollaborationTools)4 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)4 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 Identity (org.olat.core.id.Identity)4 VFSWebServiceSecurityCallback (org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback)4 VFSWebservice (org.olat.core.util.vfs.restapi.VFSWebservice)4 BusinessGroup (org.olat.group.BusinessGroup)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 File (java.io.File)2 OLATSecurityException (org.olat.core.logging.OLATSecurityException)2 FullAccessWithQuotaCallback (org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback)2 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)2 CourseConfig (org.olat.course.config.CourseConfig)2 Reference (org.olat.resource.references.Reference)2