From 05b02a43505416f7929e2b1465873a3ecead7126 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 19 Sep 2011 13:10:10 +0000 Subject: [PATCH] ALF-10318 Tweak iCAL ftl for recent changes, and add REST unit tests for the iCAL feed webscript git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30602 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../calendar/eventList.get.calendar.ftl | 14 ++++++------- .../scripts/calendar/CalendarRestApiTest.java | 21 ++++++++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.calendar.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.calendar.ftl index ae4226b365..574d7c737c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.calendar.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.calendar.ftl @@ -7,17 +7,17 @@ VERSION:2.0 PRODID:-//Alfresco Software//Calendar 1.1//EN <#list events as item> <#assign event = item.event> -<#assign from = event.properties["ia:fromDate"]> -<#assign to = event.properties["ia:toDate"]> -<#assign created = event.properties["cm:created"]> +<#assign from = event.start> +<#assign to = event.end> +<#assign created = event.createdAt> BEGIN:VEVENT -UID:${event.id} +UID:${event.nodeRef.id} DTSTART:${from?string(dateFormat)}T${from?string(timeFormat)}Z DTEND:${to?string(dateFormat)}T${to?string(timeFormat)}Z -SUMMARY:${event.properties["ia:whatEvent"]!""} +SUMMARY:${event.title!""} DTSTAMP:${created?string(dateFormat)}T${created?string(timeFormat)}Z -<#if event.properties["ia:descriptionEvent"]?exists> -DESCRIPTION:${event.properties["ia:descriptionEvent"]?replace("\\", "\\\\")?replace(",", "\\,")?replace(";", "\\;")?replace("\r?\n", "\\n", "r")} +<#if event.description?exists> +DESCRIPTION:${event.description?replace("\\", "\\\\")?replace(",", "\\,")?replace(";", "\\;")?replace("\r?\n", "\\n", "r")} END:VEVENT diff --git a/source/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java index 6aa166e0e9..ede4f5b93a 100644 --- a/source/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java @@ -70,7 +70,7 @@ public class CalendarRestApiTest extends BaseWebScriptTest private static final String URL_EVENT_BASE = "/calendar/event/" + SITE_SHORT_NAME_CALENDAR + "/"; private static final String URL_EVENTS_LIST = "/calendar/eventList"; - private static final String URL_EVENTS_LIST_ICS = "/calendar/eventList-" + SITE_SHORT_NAME_CALENDAR + ".ics"; + private static final String URL_EVENTS_LIST_ICS = "/calendar/eventList-" + SITE_SHORT_NAME_CALENDAR + ".ics?format=calendar"; private static final String URL_EVENT_CREATE = "/calendar/create"; private static final String URL_USER_EVENTS_LIST = "/calendar/events/user"; @@ -351,6 +351,12 @@ public class CalendarRestApiTest extends BaseWebScriptTest } } + private String getEntriesICAL() throws Exception + { + Response response = sendRequest(new GetRequest(URL_EVENTS_LIST_ICS), 200); + return response.getContentAsString(); + } + // Tests @@ -698,6 +704,19 @@ public class CalendarRestApiTest extends BaseWebScriptTest entries = dates.getJSONArray("6/28/2011"); assertEquals(1, entries.length()); assertEquals(EVENT_TITLE_THREE, entries.getJSONObject(0).getString("name")); + + + // Now check the ICS + String ical = getEntriesICAL(); + assertTrue("Invalid ICAL:\n" + ical, ical.contains("BEGIN:VCALENDAR")); + assertTrue("Invalid ICAL:\n" + ical, ical.contains("END:VCALENDAR")); + + // Should have the three entries + assertEquals(3+1, ical.split("BEGIN:VEVENT").length); + + assertTrue("Title not found:\n" + ical, ical.contains("SUMMARY:"+EVENT_TITLE_ONE)); + assertTrue("Title not found:\n" + ical, ical.contains("SUMMARY:"+EVENT_TITLE_TWO)); + assertTrue("Title not found:\n" + ical, ical.contains("SUMMARY:"+EVENT_TITLE_THREE)); } /**