use of org.olat.properties.PropertyManager in project OpenOLAT by OpenOLAT.
the class DBTest method testDBUTF8capable.
@Test
public void testDBUTF8capable() {
PropertyManager pm = PropertyManager.getInstance();
String uuid = UUID.randomUUID().toString();
String unicodetest = "a-greek a\u03E2a\u03EAa\u03E8 arab \u0630a\u0631 chinese:\u3150a\u3151a\u3152a\u3153a\u3173a\u3110-z";
Property p = pm.createPropertyInstance(null, null, null, null, uuid, null, null, unicodetest, null);
pm.saveProperty(p);
// forget session cache etc.
dbInstance.closeSession();
Property p2 = pm.findProperty(null, null, null, null, uuid);
String lStr = p2.getStringValue();
assertEquals(unicodetest, lStr);
}
use of org.olat.properties.PropertyManager in project openolat by klemens.
the class CollaborationTools method createOrUpdateProperty.
/**
* creates the property if non-existing, or updates the existing property to
* the supplied values. Real changes are made persistent immediately.
*
* @param selectedTool
* @param toolValue
*/
private void createOrUpdateProperty(final String selectedTool, final boolean toolValue) {
Boolean cv = cacheToolStates.get(selectedTool);
if (cv != null && cv.booleanValue() == toolValue) {
// nice, cache saved a needless update
return;
}
// handle Boolean Values via String Field in Property DB Table
final String toolValueStr = toolValue ? TRUE : FALSE;
final PropertyManager pm = PropertyManager.getInstance();
coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
@Override
public void execute() {
// was: synchronized (CollaborationTools.class) {
Property property = getPropertyOf(selectedTool);
if (property == null) {
// not existing -> create it
property = pm.createPropertyInstance(null, null, ores, PROP_CAT_BG_COLLABTOOLS, selectedTool, null, null, toolValueStr, null);
} else {
// if existing -> update to desired value
property.setStringValue(toolValueStr);
}
// create a room if needed
if (toolValue && TOOL_OPENMEETINGS.equals(selectedTool)) {
openOpenMeetingsRoom();
}
// property becomes persistent
pm.saveProperty(property);
}
});
this.dirty = true;
cacheToolStates.put(selectedTool, Boolean.valueOf(toolValue));
}
use of org.olat.properties.PropertyManager in project openolat by klemens.
the class CollaborationTools method getPropertyOf.
Property getPropertyOf(String selectedTool) {
PropertyManager pm = PropertyManager.getInstance();
Property property = pm.findProperty(null, null, ores, PROP_CAT_BG_COLLABTOOLS, selectedTool);
Boolean res;
if (property == null) {
// meaning false
res = Boolean.FALSE;
} else {
String val = property.getStringValue();
res = val.equals(TRUE) ? Boolean.TRUE : Boolean.FALSE;
}
cacheToolStates.put(selectedTool, res);
return property;
}
use of org.olat.properties.PropertyManager in project openolat by klemens.
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.PropertyManager in project openolat by klemens.
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;
}
Aggregations