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");
}
}
}
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations