Skip to content
Snippets Groups Projects
Commit 19e641a0 authored by srosse's avatar srosse
Browse files

OO-1873: only load the key of the resource and not the whole object

parent fa98e41d
No related branches found
No related tags found
No related merge requests found
...@@ -22,11 +22,8 @@ package org.olat.core.commons.services.notifications.manager; ...@@ -22,11 +22,8 @@ package org.olat.core.commons.services.notifications.manager;
import org.olat.core.commons.services.notifications.Publisher; import org.olat.core.commons.services.notifications.Publisher;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.resource.OresHelper; import org.olat.core.util.resource.OresHelper;
import org.olat.course.CourseModule; import org.olat.course.CourseModule;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryManager;
/** /**
...@@ -38,16 +35,14 @@ import org.olat.repository.RepositoryManager; ...@@ -38,16 +35,14 @@ import org.olat.repository.RepositoryManager;
* @author srosse, stephane.rosse@frentix.com * @author srosse, stephane.rosse@frentix.com
*/ */
public class NotificationsUpgradeHelper { public class NotificationsUpgradeHelper {
static OLog log = Tracing.createLoggerFor(NotificationsUpgradeHelper.class);
public static boolean checkOLATResourceable(Publisher publisher) { public static boolean checkOLATResourceable(Publisher publisher) {
Long resId = publisher.getResId(); Long resId = publisher.getResId();
try { try {
OLATResourceable ores = OresHelper.createOLATResourceableInstance(publisher.getResName(), resId); OLATResourceable ores = OresHelper.createOLATResourceableInstance(publisher.getResName(), resId);
if(ores == null) return false; if(ores == null) return false;
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, true); Long reKey = RepositoryManager.getInstance().lookupRepositoryEntryKey(ores, true);
if(re == null) return false; return reKey != null;
return true;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
...@@ -58,23 +53,10 @@ public class NotificationsUpgradeHelper { ...@@ -58,23 +53,10 @@ public class NotificationsUpgradeHelper {
try { try {
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resId); OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resId);
if(ores == null) return false; if(ores == null) return false;
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, true); Long reKey = RepositoryManager.getInstance().lookupRepositoryEntryKey(ores, true);
if(re == null) return false; return reKey != null;
return true;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
} }
public static String getCourseNodePath(Publisher publisher) {
String businessPath = null;
try {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance(CourseModule.class, publisher.getResId()), true);
businessPath = "[RepositoryEntry:" + re.getKey() + "][CourseNode:" + publisher.getSubidentifier() + "]";
} catch (Exception e) {
//if something went wrong...
log.warn("error while processing resid: "+publisher.getResId(), e);
}
return businessPath;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment