Search in sources :

Example 11 with Quota

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

the class QuotaManagerImpl method initDefaultQuota.

/**
 * @param quotaIdentifier
 * @param factor Multiplier for some long running resources as blogs
 * @return
 */
private Quota initDefaultQuota(String quotaIdentifier) {
    Quota q = null;
    Property p = propertyManager.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quotaIdentifier);
    if (p != null)
        q = parseQuota(p);
    if (q != null)
        return q;
    // initialize default quota
    q = createQuota(quotaIdentifier, new Long(FolderConfig.getDefaultQuotaKB()), new Long(FolderConfig.getLimitULKB()));
    setCustomQuotaKB(q);
    return q;
}
Also used : Quota(org.olat.core.util.vfs.Quota) Property(org.olat.properties.Property)

Example 12 with Quota

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

the class QuotaManagerImpl method listCustomQuotasKB.

/**
 * Get a list of all objects which have an individual quota.
 *
 * @return list of quotas.
 */
@Override
public List<Quota> listCustomQuotasKB() {
    if (defaultQuotas == null) {
        throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
    }
    List<Quota> results = new ArrayList<Quota>();
    PropertyManager pm = PropertyManager.getInstance();
    List<Property> props = pm.listProperties(null, null, quotaResource, QUOTA_CATEGORY, null);
    if (props == null || props.size() == 0)
        return results;
    for (Iterator<Property> iter = props.iterator(); iter.hasNext(); ) {
        Property prop = iter.next();
        results.add(parseQuota(prop));
    }
    return results;
}
Also used : Quota(org.olat.core.util.vfs.Quota) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) PropertyManager(org.olat.properties.PropertyManager) ArrayList(java.util.ArrayList) Property(org.olat.properties.Property)

Example 13 with Quota

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

the class QuotaController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == quotaEditCtr) {
        if (event == Event.CHANGED_EVENT) {
            quotaTableModel.refresh();
            tableCtr.setTableDataModel(quotaTableModel);
        }
        // else cancel event. in any case set content to list
        main.setContent(myContent);
    }
    if (source == tableCtr && event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
        TableEvent te = (TableEvent) event;
        Quota q = quotaTableModel.getRowData(te.getRowId());
        if (te.getActionId().equals("qf.edit")) {
            // clean up old controller first
            // start edit workflow in dedicated quota edit controller
            removeAsListenerAndDispose(quotaEditCtr);
            quotaEditCtr = new GenericQuotaEditController(ureq, getWindowControl(), q);
            listenTo(quotaEditCtr);
            main.setContent(quotaEditCtr.getInitialComponent());
        } else if (te.getActionId().equals("qf.del")) {
            // try to delete quota
            boolean deleted = QuotaManager.getInstance().deleteCustomQuota(q);
            if (deleted) {
                quotaTableModel.refresh();
                tableCtr.setTableDataModel(quotaTableModel);
                showInfo("qf.deleted", q.getPath());
            } else {
                // default quotas can not be deleted
                showError("qf.cannot.del.default");
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) Quota(org.olat.core.util.vfs.Quota)

Example 14 with Quota

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

the class FullAccessWithLazyQuotaCallback method getQuota.

@Override
public Quota getQuota() {
    if (super.getQuota() == null) {
        QuotaManager qm = QuotaManager.getInstance();
        Quota q = qm.getCustomQuota(folderPath);
        if (q == null) {
            Quota defQuota = qm.getDefaultQuota(defaultQuota);
            q = QuotaManager.getInstance().createQuota(folderPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
        }
        super.setQuota(q);
    }
    return super.getQuota();
}
Also used : Quota(org.olat.core.util.vfs.Quota) QuotaManager(org.olat.core.util.vfs.QuotaManager)

Example 15 with Quota

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

the class FeedManagerImpl method getQuota.

@Override
public Quota getQuota(OLATResourceable feed) {
    OlatRootFolderImpl container = feedFileStorage.getResourceContainer(feed);
    Quota quota = QuotaManager.getInstance().getCustomQuota(container.getRelPath());
    if (quota == null) {
        Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_FEEDS);
        quota = QuotaManager.getInstance().createQuota(container.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    return quota;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) 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