* @param identity the identity
* @param notify if true, then the
* @return a Map containing nodeident+"_"+ e.g. PASSED as key, Boolean (for PASSED), Float (for SCORE), or Integer (for ATTEMPTS) as values
*/
private Map<String, Serializable> getOrLoadScorePassedAttemptsMap(Identity identity, boolean prepareForNewData) {
CacheWrapper cw = getCacheWrapperFor(identity);
synchronized(cw) { // o_clusterOK by:fj : we sync on the cache to protect access within the monitor "one user in a course".
// a user is only active on one node at the same time.
Map<String, Serializable> m = (Map<String, Serializable>) cw.get(FULLUSERSET);
if (m == null) {
// cache entry (=all data of the given identity in this course) has expired or has never been stored yet into the cache.
// or has been invalidated (in cluster mode when puts occurred from an other node for the same cache)
m = new HashMap<String, Serializable>();
// load data
List properties = loadPropertiesFor(identity);
for (Iterator iter = properties.iterator(); iter.hasNext();) {
Property property = (Property) iter.next();
addPropertyToCache(m, property);
}
// we use a putSilent here (no invalidation notifications to other cluster nodes), since
// we did not generate new data, but simply asked to reload it.
if (prepareForNewData) {
cw.update(FULLUSERSET, (Serializable) m);
} else {
cw.put(FULLUSERSET, (Serializable) m);
}
} else {
// still in cache.
if (prepareForNewData) { // but we need to notify that data has changed: we reput the data into the cache - a little hacky yes
cw.update(FULLUSERSET, (Serializable) m);
}
}
return m;
}
}