*/
public boolean correspondsTo(ContextEntry ce) {
if (ce==null) {
return false;
}
OLATResourceable ceResourceable = ce.getOLATResourceable();
if (ceResourceable==null) {
return false;
}
if (resourceable_!=null) {
if (ceResourceable.getResourceableTypeName().equals(resourceable_.getResourceableTypeName()) &&
ceResourceable.getResourceableId().equals(resourceable_.getResourceableId())) {
return true;
}
if (ceResourceable.equals(resourceable_)) {
return true;
}
try{
// last chance to get a 'true' as the result
//@TODO
//@TODO-OLAT-4924
//PREFACE: Notice that this code actually corresponds nicely to the olat3 version of this class!
//
// This 'hack' is necessary due to the fact that the GlossaryMainController is in the olatcore and has no
// access to olat3 code. Hence it has no access to RepositoryEntry or OLATResource etc which makes
// clean comparison here impossible.
// What happens here is: the GlossaryMainController is created with an OLATResourceImpl (from olat3)
// then passes this to the ThreadLocalUserActivityLogger via CoreLoggingResourceable.wrap().
// Then, when logging the 'LEARNING_RESOURCE_OPEN' action, the UserActivityLoggerImpl fetches the
// businesspath to go through that list and compares it with what it got in its resourceable list.
// Now, the businesspath contains a RepositoryEntry which *contains* an OLATResourceImpl representing the
// glossary.
// The resourceable list though, contains what was just added before, namely the OLATResourceImpl directly.
// The RepositoryEntry's OLATResourceImpl is in fact the same (==) as the one in the resourceable list.
// BUT: We can't find this out easily, i.e. we want to return true in this case but we can't do this
// since we are in the core here. So the 'hack' here is to get the 'getOlatResource' method
// via reflection (autsch!) - knowing that the ceResourceable here is actually the RepositoryEntry.
// that OlatResourceable (can't cast it to OLATResource since that is in the olat3 again..... :( )
// and then go compare the two and voila, find out that they are the same and return true.
java.lang.reflect.Method getOlatResource = ceResourceable.getClass().getDeclaredMethod("getOlatResource");
if (getOlatResource!=null) {
Object ceOlatResourceObj = getOlatResource.invoke(ceResourceable);
if (ceOlatResourceObj!=null && ceOlatResourceObj instanceof OLATResourceable) {
OLATResourceable ceOlatResource = (OLATResourceable)ceOlatResourceObj;
if (ceOlatResource.getResourceableTypeName().equals(resourceable_.getResourceableTypeName()) &&
ceOlatResource.getResourceableId().equals(resourceable_.getResourceableId())) {
return true;
}
if (ceOlatResource.equals(resourceable_)) {
return true;
}
}
}
} catch(Exception e) {