use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class I18nManager method getPropertiesFile.
/**
* Get the property file for a given locale and bundle. If the locale is null,
* the metadata for this bundle are returned instead.
*
* @param locale the locale or NULL to get the bundle metadata file
* @param bundleName
* @param sourceDir the source directory where to search for the properties
* file
* @return a file object. The file might not exist, but the mehod never return
* NULL!
*/
public File getPropertiesFile(Locale locale, String bundleName, File sourceDir) {
if (bundleName == null)
throw new AssertException("getPropertyFile(): bundleName can not be null");
if (sourceDir == null)
throw new AssertException("getPropertyFile(): sourceDir can not be null");
// Create relative path to sourceDir
bundleName = bundleName.replace('.', '/');
String fileName = (locale == null ? METADATA_FILENAME : buildI18nFilename(locale));
String relPath = "/" + bundleName + "/" + I18N_DIRNAME + "/" + fileName;
// Load file from path
File f = new File(sourceDir, relPath);
if (f.exists() || i18nModule.isTransToolEnabled()) {
return f;
}
return f;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class TreeHelper method resolveTreeNode.
public static TreeNode resolveTreeNode(String treePath, TreeModel treeModel) {
// even for the root node, our parameter may not be the empty string, therefore the prefix to be chopped here
treePath = treePath.substring(1);
TreeNode cur = treeModel.getRootNode();
if (!treePath.equals("")) {
// if we are not the root node
String[] res = treePath.split("_");
for (int i = res.length - 1; i >= 0; i--) {
String spos = res[i];
Integer chdPos = Integer.parseInt(spos);
TreeNode chd = (TreeNode) cur.getChildAt(chdPos);
if (chd == null)
throw new AssertException("cannot find: " + treePath);
cur = chd;
}
}
return cur;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class OLATResourceableEvent method targetEquals.
/**
* @param ores the OLATResourceable to test against.
* @param exceptIfFalse if true = throw an exception if the target does not match ores
* @return True on equality.
*/
public boolean targetEquals(OLATResourceable ores, boolean exceptIfFalse) {
String derived = OresHelper.createStringRepresenting(ores);
boolean res = derived.equals(derivedOres);
if (!res && exceptIfFalse)
throw new AssertException("expected ores to be the same as target, but failed: ores =" + ores.getResourceableTypeName() + " / " + ores.getResourceableId() + ", but event was for " + derived);
return res;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method loadCourse.
public static ICourse loadCourse(final Long resourceableId) {
if (resourceableId == null)
throw new AssertException("No resourceable ID found.");
PersistingCourseImpl course = loadedCourses.get(resourceableId);
if (course == null) {
// o_clusterOK by:ld - load and put in cache in doInSync block to ensure
// that no invalidate cache event was missed
OLATResource resource = OLATResourceManager.getInstance().findResourceable(resourceableId, "CourseModule");
PersistingCourseImpl theCourse = new PersistingCourseImpl(resource);
theCourse.load();
PersistingCourseImpl cachedCourse = loadedCourses.putIfAbsent(resourceableId, theCourse);
if (cachedCourse != null) {
course = cachedCourse;
} else {
course = theCourse;
}
}
return course;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method clearCalenderSubscriptions.
/**
* Checks all learning group calendars and the course calendar for publishers (of subscriptions)
* and sets their state to "1" which indicates that the ressource is deleted.
*/
private static void clearCalenderSubscriptions(OLATResourceable res, ICourse course) {
// set Publisher state to 1 (= ressource is deleted) for all calendars of the course
CalendarManager calMan = CoreSpringFactory.getImpl(CalendarManager.class);
CalendarNotificationManager notificationManager = CoreSpringFactory.getImpl(CalendarNotificationManager.class);
NotificationsManager nfm = NotificationsManager.getInstance();
if (course != null) {
CourseGroupManager courseGroupManager = course.getCourseEnvironment().getCourseGroupManager();
List<BusinessGroup> learningGroups = courseGroupManager.getAllBusinessGroups();
// all learning and right group calendars
for (BusinessGroup bg : learningGroups) {
KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
SubscriptionContext subsContext = notificationManager.getSubscriptionContext(calRenderWrapper);
Publisher pub = nfm.getPublisher(subsContext);
if (pub != null) {
// int 0 is OK -> all other is not OK
pub.setState(1);
}
}
}
// the course calendar
try {
/**
* TODO:gs 2010-01-26
* OLAT-4947: if we do not have an repo entry we get an exception here.
* This is normal in the case of courseimport and click canceling.
*/
KalendarRenderWrapper courseCalendar = calMan.getCalendarForDeletion(res);
if (courseCalendar != null) {
SubscriptionContext subContext = notificationManager.getSubscriptionContext(courseCalendar, res);
OLATResourceable oresToDelete = OresHelper.createOLATResourceableInstance(subContext.getResName(), subContext.getResId());
nfm.deletePublishersOf(oresToDelete);
}
} catch (AssertException e) {
// if we have a broken course (e.g. canceled import or no repo entry somehow) skip calendar deletion...
}
}
Aggregations