use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class QuotaManagerImpl method listCustomQuotasKB.
/**
* Get a list of all objects which have an individual quota.
*
* @return list of quotas.
*/
@Override
public List<Quota> listCustomQuotasKB() {
if (defaultQuotas == null) {
throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
}
List<Quota> results = new ArrayList<Quota>();
PropertyManager pm = PropertyManager.getInstance();
List<Property> props = pm.listProperties(null, null, quotaResource, QUOTA_CATEGORY, null);
if (props == null || props.size() == 0)
return results;
for (Iterator<Property> iter = props.iterator(); iter.hasNext(); ) {
Property prop = iter.next();
results.add(parseQuota(prop));
}
return results;
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
fStorageBase = new File(WebappHelper.getUserDataRoot(), "calendars");
if (!fStorageBase.exists()) {
if (!fStorageBase.mkdirs())
throw new OLATRuntimeException("Error creating calendar base directory at: " + fStorageBase.getAbsolutePath(), null);
}
// create the directories
String[] dirs = new String[] { TYPE_USER, TYPE_GROUP, TYPE_COURSE };
for (String dir : dirs) {
File fDirectory = new File(fStorageBase, dir);
if (!fDirectory.exists()) {
fDirectory.mkdirs();
}
}
// set parser to relax (needed for allday events
// see http://sourceforge.net/forum/forum.php?thread_id=1253735&forum_id=368291
// made in module System.setProperty("ical4j.unfolding.relaxed", "true");
// initialize timezone
tz = calendarModule.getDefaultTimeZone();
calendarCache = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(CalendarManager.class.getSimpleName(), "calendar");
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class ICalServlet method outputCalendar.
private void outputCalendar(CalendarFileInfos fileInfos, Writer out, Agent agent, Set<String> timezoneIds) throws IOException {
try {
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
Calendar calendar = calendarManager.readCalendar(fileInfos.getCalendarFile());
updateUrlProperties(calendar);
String prefix = fileInfos.getType() + "-" + fileInfos.getCalendarId() + "-";
updateUUID(calendar, prefix);
outputCalendarComponents(calendar, out, agent, timezoneIds);
} catch (IOException | OLATRuntimeException e) {
log.error("", e);
}
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class ICalServlet method outputCalendarComponents.
private void outputCalendarComponents(Calendar calendar, Writer out, Agent agent, Set<String> timezoneIds) throws IOException {
try {
ComponentList events = calendar.getComponents();
for (final Iterator<?> i = events.iterator(); i.hasNext(); ) {
Object comp = i.next();
String event = comp.toString();
if (agent == Agent.outlook && comp instanceof VEvent) {
event = quoteTimeZone(event, (VEvent) comp, timezoneIds);
}
if (agent == Agent.googleCalendar) {
event = event.replace("CLASS:PRIVATE" + Strings.LINE_SEPARATOR, "");
event = event.replace("X-OLAT-MANAGED:all" + Strings.LINE_SEPARATOR, "");
event = event.replace("DESCRIPTION:" + Strings.LINE_SEPARATOR, "");
event = event.replace("LOCATION:" + Strings.LINE_SEPARATOR, "");
}
out.write(event);
}
} catch (IOException | OLATRuntimeException e) {
log.error("", e);
}
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class CoreSpringFactory method getBean.
/**
* @param beanName
* The bean name to check for. Be sure the bean does exist,
* otherwise an NoSuchBeanDefinitionException will be thrown
* @return The bean
*/
public static Object getBean(Class<?> interfaceName) {
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(CoreSpringFactory.servletContext);
Map<String, ?> m = context.getBeansOfType(interfaceName);
if (m.size() > 1) {
// more than one bean found -> excecption
throw new OLATRuntimeException("found more than one bean for: " + interfaceName + ". Calling this method should only find one bean!", null);
} else if (m.size() == 1) {
return new ArrayList<Object>(m.values()).get(0);
}
// fallback for beans named like the fully qualified path (legacy)
Object o = context.getBean(interfaceName.getName());
return o;
}
Aggregations