use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class NotificationsManagerImpl method processSubscribersByEmail.
private void processSubscribersByEmail(Identity ident) {
if (ident.getStatus().compareTo(Identity.STATUS_VISIBLE_LIMIT) >= 0) {
// send only to active user
return;
}
String userInterval = getUserIntervalOrDefault(ident);
if ("never".equals(userInterval)) {
return;
}
long start = System.currentTimeMillis();
Date compareDate = getCompareDateFromInterval(userInterval);
Property p = propertyManager.findProperty(ident, null, null, null, LATEST_EMAIL_USER_PROP);
if (p != null) {
Date latestEmail = new Date(p.getLongValue());
if (latestEmail.after(compareDate)) {
// nothing to do
return;
}
}
Date defaultCompareDate = getDefaultCompareDate();
List<Subscriber> subscribers = getSubscribers(ident);
if (subscribers.isEmpty()) {
return;
}
String langPrefs = null;
if (ident.getUser() != null && ident.getUser().getPreferences() != null) {
langPrefs = ident.getUser().getPreferences().getLanguage();
}
Locale locale = I18nManager.getInstance().getLocaleOrDefault(langPrefs);
boolean veto = false;
Subscriber latestSub = null;
List<SubscriptionItem> items = new ArrayList<>();
List<Subscriber> subsToUpdate = new ArrayList<>();
for (Subscriber sub : subscribers) {
Date latestEmail = sub.getLatestEmailed();
SubscriptionItem subsitem = null;
if (latestEmail == null || compareDate.after(latestEmail)) {
// no notif. ever sent until now
if (latestEmail == null) {
latestEmail = defaultCompareDate;
} else if (latestEmail.before(defaultCompareDate)) {
// no notification older than a month
latestEmail = defaultCompareDate;
}
subsitem = createSubscriptionItem(sub, locale, SubscriptionInfo.MIME_HTML, SubscriptionInfo.MIME_HTML, latestEmail);
} else if (latestEmail != null && latestEmail.after(compareDate)) {
// already send an email within the user's settings interval
// veto = true;
}
if (subsitem != null) {
items.add(subsitem);
subsToUpdate.add(sub);
}
latestSub = sub;
}
Translator translator = Util.createPackageTranslator(NotificationSubscriptionController.class, locale);
notifySubscribersByEmail(latestSub, items, subsToUpdate, translator, start, veto);
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class DBPersistentLockManager method aquirePersistentLock.
/**
* @see org.olat.core.util.locks.PersistentLockManager#aquirePersistentLock(org.olat.core.id.OLATResourceable,
* org.olat.core.id.Identity, java.lang.String)
*/
@Override
public LockResult aquirePersistentLock(OLATResourceable ores, Identity ident, String locksubkey) {
// synchronisation is solved in the LockManager
LockResult lres;
PropertyManager pm = PropertyManager.getInstance();
String derivedLockString = OresHelper.createStringRepresenting(ores, locksubkey);
long aqTime;
Identity lockOwner;
boolean success;
Property p;
p = pm.findProperty(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString);
if (p == null) {
// no persistent lock acquired yet
// save a property: cat = o_lock, key = derivedLockString, Longvalue = key
// of identity acquiring the lock
Property newp = pm.createPropertyInstance(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString, null, ident.getKey(), null, null);
pm.saveProperty(newp);
aqTime = System.currentTimeMillis();
lockOwner = ident;
success = true;
} else {
// already acquired, but check on reaquiring
aqTime = p.getLastModified().getTime();
Long lockOwnerKey = p.getLongValue();
if (ident.getKey().equals(lockOwnerKey)) {
// reaquire ok
success = true;
} else {
// already locked by an other person
success = false;
}
// FIXME:fj:c find a better way to retrieve information about the
// lock-holder
lockOwner = BaseSecurityManager.getInstance().loadIdentityByKey(lockOwnerKey);
}
LockEntry le = new LockEntry(derivedLockString, aqTime, lockOwner);
lres = new LockResultImpl(success, le);
return lres;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class CourseNodePasswordManagerImpl method deleteAllPasswordsFor.
/**
* @see de.bps.course.nodes.CourseNodePasswordManager#deleteAllPasswordsFor(java.lang.Long)
*/
public void deleteAllPasswordsFor(OLATResourceable ores) {
PropertyManager pm = PropertyManager.getInstance();
List<Property> properties = pm.listProperties(null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, ores.getResourceableId(), null);
for (Property p : properties) {
Long nodeId = p.getResourceTypeId();
Long courseId = p.getLongValue();
removeAnswers(nodeId, courseId);
pm.deleteProperty(p);
}
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class UserDeletionManager method setProperty.
private void setProperty(String propertyName, int value) {
List<Property> properties = PropertyManager.getInstance().findProperties(null, null, null, PROPERTY_CATEGORY, propertyName);
Property property = null;
if (properties.size() == 0) {
property = PropertyManager.getInstance().createPropertyInstance(null, null, null, PROPERTY_CATEGORY, propertyName, null, new Long(value), null, null);
} else {
property = properties.get(0);
property.setLongValue(new Long(value));
}
PropertyManager.getInstance().saveProperty(property);
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class InfoMessageManager method setInfoMessageNodeOnly.
/**
* set info message on node level only, no need to sync
* @param message
*/
public void setInfoMessageNodeOnly(String message) {
PropertyManager pm = PropertyManager.getInstance();
Property p = pm.findProperty(null, null, null, "_o3_", INFO_MSG_NODE_ONLY + nodeId);
if (p == null) {
p = pm.createPropertyInstance(null, null, null, "_o3_", INFO_MSG_NODE_ONLY + nodeId, null, null, null, "");
pm.saveProperty(p);
}
p.setTextValue(message);
// set Message in RAM
InfoMessageManager.infoMessageNodeOnly = message;
pm.updateProperty(p);
}
Aggregations