Search in sources :

Example 41 with Quota

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

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

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

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

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

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

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

the class QuotaManagerImpl method parseQuota.

/**
 * @param name Path of the quota
 * @param s
 * @return Parsed quota object.
 */
private Quota parseQuota(String name, String s) {
    int delim = s.indexOf(':');
    if (delim == -1)
        return null;
    Quota q = null;
    try {
        Long quotaKB = new Long(s.substring(0, delim));
        Long ulLimitKB = new Long(s.substring(delim + 1));
        q = createQuota(name, quotaKB, ulLimitKB);
    } catch (NumberFormatException e) {
    // will return null if quota parsing failed
    }
    return q;
}
Also used : Quota(org.olat.core.util.vfs.Quota)

Example 45 with Quota

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

the class FolderRunController method enableDisableQuota.

private void enableDisableQuota(UserRequest ureq) {
    // prevent a timing condition if the user logout while a thumbnail is generated
    UserSession usess = ureq.getUserSession();
    if (usess == null || usess.getRoles() == null) {
        return;
    }
    Boolean newEditQuota = Boolean.FALSE;
    if (usess.getRoles().isOLATAdmin() || usess.getRoles().isInstitutionalResourceManager()) {
        // Only sys admins or institutonal resource managers can have the quota button
        Quota q = VFSManager.isTopLevelQuotaContainer(folderComponent.getCurrentContainer());
        newEditQuota = (q == null) ? Boolean.FALSE : Boolean.TRUE;
    }
    Boolean currentEditQuota = (Boolean) folderContainer.contextGet("editQuota");
    // not make the component dirty after asynchronous thumbnail loading
    if (currentEditQuota == null || !currentEditQuota.equals(newEditQuota)) {
        folderContainer.contextPut("editQuota", newEditQuota);
    }
}
Also used : Quota(org.olat.core.util.vfs.Quota) CmdEditQuota(org.olat.core.commons.modules.bc.commands.CmdEditQuota) UserSession(org.olat.core.util.UserSession)

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