Skip to content
Snippets Groups Projects
Commit 9241d18b authored by srosse's avatar srosse
Browse files

OO-1645: output the aggregated calendar with the ICAL beautifier and with...

OO-1645: output the aggregated calendar with the ICAL beautifier and with UTF-8 encoding, fix NPE in print view, remove save and copy
parent a41e4556
No related branches found
No related tags found
No related merge requests found
......@@ -27,13 +27,14 @@
package org.olat.commons.calendar;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -48,6 +49,7 @@ import org.olat.core.logging.Tracing;
import org.olat.core.util.i18n.I18nManager;
import net.fortuna.ical4j.data.CalendarOutputter;
import net.fortuna.ical4j.data.FoldingWriter;
import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.ComponentList;
import net.fortuna.ical4j.model.PropertyList;
......@@ -170,6 +172,12 @@ public class ICalServlet extends HttpServlet {
log.warn("Type not supported: " + pathInfo);
return;
}
try {
response.setCharacterEncoding("UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
if(CalendarManager.TYPE_USER_AGGREGATED.equals(calendarType)) {
......@@ -208,23 +216,25 @@ public class ICalServlet extends HttpServlet {
List<CalendarFileInfos> iCalFiles = homeCalendarManager.getListOfCalendarsFiles(identity);
DBFactory.getInstance().commitAndCloseSession();
ServletOutputStream out = response.getOutputStream();
out.print(Calendar.BEGIN);
out.print(':');
out.println(Calendar.VCALENDAR);
PrintWriter responseWriter = response.getWriter();
FoldingWriter out = new FoldingWriter(responseWriter);
out.write(Calendar.BEGIN);
out.write(':');
out.write(Calendar.VCALENDAR);
int numOfFiles = iCalFiles.size();
for(int i=0; i<numOfFiles; i++) {
outputCalendar(iCalFiles.get(i), out);
}
out.print(Calendar.END);
out.print(':');
out.print(Calendar.VCALENDAR);
out.write(Calendar.END);
out.write(':');
out.write(Calendar.VCALENDAR);
}
}
private void outputCalendar(CalendarFileInfos fileInfos, ServletOutputStream out) throws IOException {
private void outputCalendar(CalendarFileInfos fileInfos, Writer out) throws IOException {
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
Calendar calendar = calendarManager.readCalendar(fileInfos.getCalendarFile());
updateUrlProperties(calendar);
......@@ -234,7 +244,8 @@ public class ICalServlet extends HttpServlet {
ComponentList events = calendar.getComponents();
for (final Iterator<?> i = events.iterator(); i.hasNext();) {
out.print(i.next().toString());
String event = i.next().toString();
out.write(event);
}
}
......
......@@ -48,7 +48,6 @@ import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
......@@ -402,7 +401,7 @@ public class CalendarEntryForm extends FormBasicController {
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton(SUBMIT_SINGLE, "cal.form.submitSingle", buttonLayout);
if (writeableCalendars.size() > 1) {
multi = uifactory.addFormLink("cal.form.submitMulti", buttonLayout, Link.BUTTON);
//multi = uifactory.addFormLink("cal.form.submitMulti", buttonLayout, Link.BUTTON);
}
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
......
......@@ -212,7 +212,7 @@ public class CalendarPrintMapper implements Mapper {
if (begin.before(dayStart)) {
begin = dayStart;
}
if (end.after(dayEnd)) {
if (end == null || end.after(dayEnd)) {
end = dayEnd;
}
sb.append(StringHelper.formatLocaleTime(begin, translator.getLocale()));
......
......@@ -129,7 +129,7 @@ public class HomeCalendarManager implements PersonalCalendarManager {
List<Object[]> resources = getCourses(identity);
for(Object[] resource:resources) {
RepositoryEntry courseEntry = (RepositoryEntry)resource[0];
String calendarId = courseEntry.getKey().toString();
String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
CalendarKey key = new CalendarKey(CalendarManager.TYPE_COURSE, calendarId);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if(calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
......
......@@ -253,11 +253,10 @@ public class OLATUpgrade_10_4_0 extends OLATUpgrade {
.getCalendarUserConfiguration(identity, cal.getCalendarID(), cal.getType());
if(userConfig == null) {
userConfig = calendarUserConfigurationDao.createCalendarUserConfiguration(cal, identity);
userConfig.setCssClass(config.getCss());
userConfig.setVisible(config.isVis());
userConfig = calendarUserConfigurationDao.update(userConfig);
}
userConfig.setCssClass(config.getCss());
userConfig.setVisible(config.isVis());
userConfig = calendarUserConfigurationDao.update(userConfig);
}
private boolean migrateImportedCalendars(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
......
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