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