use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class AdminModule method initializeSystemTokenProperty.
/**
* Check if system property for maintenance message exists, create one if it
* doesn't
* This generated token is used by the remote http maintenance message
* setting mechanism, see method below
* @param tokenPropertyName
*/
private void initializeSystemTokenProperty(String tokenPropertyName) {
Property p = propertyManager.findProperty(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName);
if (p == null) {
String token = RandomStringUtils.randomAlphanumeric(8);
p = propertyManager.createPropertyInstance(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName, null, null, token, null);
propertyManager.saveProperty(p);
}
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class QuotaManagerImpl method deleteCustomQuota.
/**
* @param quota to be deleted
* @return true if quota successfully deleted or no such quota, false if quota
* not deleted because it was a default quota that can not be deleted
*/
@Override
public boolean deleteCustomQuota(Quota quota) {
if (defaultQuotas == null) {
throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
}
// do not allow to delete default quotas!
if (quota.getPath().startsWith(QuotaConstants.IDENTIFIER_DEFAULT)) {
return false;
}
PropertyManager pm = PropertyManager.getInstance();
Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath());
if (p != null)
pm.deleteProperty(p);
return true;
}
use of org.olat.properties.Property 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.properties.Property in project OpenOLAT by OpenOLAT.
the class QuotaManagerImpl method setCustomQuotaKB.
/**
* Sets or updates the quota (in KB) for this path. Important: Must provide a
* path with a valid base.
*
* @param quota
*/
@Override
public void setCustomQuotaKB(Quota quota) {
if (defaultQuotas == null) {
throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
}
PropertyManager pm = PropertyManager.getInstance();
Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath());
if (p == null) {
// create new entry
p = pm.createPropertyInstance(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath(), null, null, assembleQuota(quota), null);
pm.saveProperty(p);
} else {
p.setStringValue(assembleQuota(quota));
pm.updateProperty(p);
}
// if the quota is a default quota, rebuild the default quota list
if (quota.getPath().startsWith(QuotaConstants.IDENTIFIER_DEFAULT)) {
initDefaultQuotas();
}
}
use of org.olat.properties.Property 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;
}
Aggregations