/** * Builds up the node properties for a given Calendar Entry * Doesn't handle tags, those must be done in the service itself. */ protected static Map<QName,Serializable> toNodeProperties(CalendarEntry entry) { Map<QName,Serializable> properties = new HashMap<QName, Serializable>(); properties.put(CalendarModel.PROP_WHAT, entry.getTitle()); properties.put(CalendarModel.PROP_DESCRIPTION, entry.getDescription()); properties.put(CalendarModel.PROP_WHERE, entry.getLocation()); properties.put(CalendarModel.PROP_FROM_DATE, entry.getStart()); properties.put(CalendarModel.PROP_TO_DATE, entry.getEnd()); properties.put(CalendarModel.PROP_RECURRENCE_RULE, entry.getRecurrenceRule()); properties.put(CalendarModel.PROP_RECURRENCE_LAST_MEETING, entry.getLastRecurrence()); properties.put(CalendarModel.PROP_IS_OUTLOOK, entry.isOutlook()); properties.put(CalendarModel.PROP_OUTLOOK_UID, entry.getOutlookUID()); properties.put(CalendarModel.PROP_DOC_FOLDER, entry.getSharePointDocFolder()); // properties.put(CalendarModel.PROP_COLOR, entry.getColor(); return properties; }
@Override public void deleteCalendarEntry(CalendarEntry entry) { if (entry.getNodeRef() == null) { throw new IllegalArgumentException("Can't delete a calendar entry that was never persisted"); } nodeService.deleteNode(entry.getNodeRef()); }
/** * For the given Calendar Entry, return its subsequent Recurrence on or after * the specified date, until the given limit. If it doesn't have any recurrences * on or after the start date (either no recurrence rules, or the last recurrence * date is before then), null will be returned. (The onOrAfter and until dates * are treat as inclusive) * If requested, can stop after the first hit * @return The next recurrence on or after the given date, or null if there aren't any */ public static List<Date> getRecurrencesOnOrAfter(CalendarEntry entry, Date onOrAfter, Date until, boolean firstOnly, Set<Date> ignoredDates) { return getRecurrencesOnOrAfter( entry.getRecurrenceRule(), entry.getStart(), entry.getEnd(), entry.getLastRecurrence(), onOrAfter, until, firstOnly, ignoredDates); }
public void retrieve() { try { CalendarService myService = new CalendarService("QuanticoShootingclub"); myService.setUserCredentials("calendar@quanticoshootingclub.com", "washington13"); URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/owncalendars/full"); CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class); System.out.println("Your calendars:"); System.out.println(); for (int i = 0; i < resultFeed.getEntries().size(); i++) { CalendarEntry entry = resultFeed.getEntries().get(i); System.out.println("\t" + entry.getTitle().getPlainText()); System.out.println("\t\t" + entry.getId()); } } catch (Exception e) { e.printStackTrace(); } }
entry.setOutlook(true); entry.setOutlookUID("12345LookOut!"); entry = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), entry); assertEquals("Title", entry.getTitle()); assertEquals("Description", entry.getDescription()); assertEquals("Location", entry.getLocation()); assertEquals(1, entry.getStart().getTime()); assertEquals(1234, entry.getEnd().getTime()); assertEquals(null, entry.getRecurrenceRule()); assertEquals(null, entry.getLastRecurrence()); assertEquals(true, entry.isOutlook()); assertEquals("12345LookOut!", entry.getOutlookUID()); entry.setTitle("New Title"); entry.setStart(new Date(1234567)); entry.setEnd(new Date(1294567)); entry.setRecurrenceRule("1w"); entry.setLastRecurrence(new Date(1234567)); entry.setOutlook(false); entry.setOutlookUID(null); entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), entry.getSystemName()); assertEquals("New Title", entry.getTitle()); assertEquals("Description", entry.getDescription()); assertEquals("Location", entry.getLocation()); assertEquals(1234567, entry.getStart().getTime()); assertEquals(1294567, entry.getEnd().getTime()); assertEquals("1w", entry.getRecurrenceRule());
entry.setOutlook(true); entry.setOutlookUID("12345LookOut!"); assertEquals(null, entry.getSystemName()); assertEquals(null, entry.getNodeRef()); assertNotNull(entry.getNodeRef()); assertNotNull(entry.getSystemName()); NodeRef container = PUBLIC_NODE_SERVICE.getPrimaryParent(entry.getNodeRef()).getParentRef(); NodeRef site = PUBLIC_NODE_SERVICE.getPrimaryParent(container).getParentRef(); assertEquals(CALENDAR_SITE.getNodeRef(), site); testNodesToTidy.add(entry.getNodeRef()); assertEquals("Title", entry.getTitle()); assertEquals("Description", entry.getDescription()); assertEquals("Location", entry.getLocation()); assertEquals(1, entry.getStart().getTime()); assertEquals(1234, entry.getEnd().getTime()); assertEquals(null, entry.getRecurrenceRule()); assertEquals(null, entry.getLastRecurrence()); assertEquals(true, entry.isOutlook()); assertEquals("12345LookOut!", entry.getOutlookUID()); assertNotNull(entry.getCreatedAt()); assertNotNull(entry.getModifiedAt()); entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), entry.getSystemName());
assertEquals(c3.getSystemName(), filtered.get(0).getName()); assertEquals(c3.getStart(), ISO8601DateFormat.parse(filtered.get(0).getFromDate(),utc)); assertEquals(c3.getEnd(), ISO8601DateFormat.parse(filtered.get(0).getToDate(),utc)); assertEquals(c3.getRecurrenceRule(), filtered.get(0).getRecurrenceRule()); assertEquals(null, filtered.get(0).getRecurrenceLastMeeting()); assertEquals(c1.getSystemName(), filtered.get(1).getName()); assertEquals(c1.getStart(), ISO8601DateFormat.parse(filtered.get(1).getFromDate(),utc)); assertEquals(c1.getEnd(), ISO8601DateFormat.parse(filtered.get(1).getToDate(),utc)); assertEquals(c1.getRecurrenceRule(), filtered.get(1).getRecurrenceRule()); assertEquals(null, filtered.get(1).getRecurrenceLastMeeting()); assertEquals(c2.getSystemName(), filtered.get(2).getName()); assertEquals(c2.getStart(), ISO8601DateFormat.parse(filtered.get(2).getFromDate(),utc)); assertEquals(c2.getEnd(), ISO8601DateFormat.parse(filtered.get(2).getToDate(),utc)); assertEquals(c2.getRecurrenceRule(), filtered.get(2).getRecurrenceRule()); assertEquals(null, filtered.get(2).getRecurrenceLastMeeting()); assertEquals(c3.getSystemName(), filtered.get(0).getName()); assertEquals(c1.getSystemName(), filtered.get(1).getName()); c3.setRecurrenceRule("FREQ=WEEKLY;BYDAY=TH;INTERVAL=1"); c3.setLastRecurrence(new Date(1303431400)); CALENDAR_SERVICE.updateCalendarEntry(c3); assertEquals(c3.getSystemName(), filtered.get(0).getName()); assertEquals(c3.getStart(), ISO8601DateFormat.parse(filtered.get(0).getFromDate(),utc)); assertEquals(c3.getEnd(), ISO8601DateFormat.parse(filtered.get(0).getToDate(),utc)); assertEquals(c3.getLastRecurrence(), ISO8601DateFormat.parse(filtered.get(0).getRecurrenceLastMeeting(),utc));
LOGGER.debug("'All Day' Calendar event has been detected: [title: " + entry.getTitle() + ", start: " + entry.getStart() + ", end: " + entry.getEnd() + ", isOutlook: " + entry.isOutlook() + "]"); nodeService.setProperty(entry.getNodeRef(), CalendarModel.PROP_TO_DATE, adjustOldDate(entry.getEnd())); nodeService.setProperty(entry.getNodeRef(), CalendarModel.PROP_FROM_DATE, adjustOldDate(entry.getStart()));
if (entry.getNodeRef() == null) for (Map.Entry<QName,Serializable> prop : nodeService.getProperties(entry.getNodeRef()).entrySet()) nodeService.setProperties(entry.getNodeRef(), properties); taggingService.setTags(entry.getNodeRef(), entry.getTags()); (Date)nodeService.getProperty(entry.getNodeRef(), ContentModel.PROP_MODIFIED) ); return getCalendarEntry(entry.getNodeRef(), entry.getSystemName(), entry.getContainerNodeRef());
CalendarEntry entryC = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( "TitleC", "Description", "Location", new Date(1302435000), new Date(1302442200))); testNodesToTidy.add(entryA.getNodeRef()); testNodesToTidy.add(entryB.getNodeRef()); testNodesToTidy.add(entryC.getNodeRef()); assertEquals("TitleA", results.getPage().get(0).getTitle()); assertEquals("TitleB", results.getPage().get(1).getTitle()); assertEquals("TitleC", results.getPage().get(2).getTitle()); testNodesToTidy.add(entryD.getNodeRef()); assertEquals("TitleD", results.getPage().get(0).getTitle()); assertEquals("TitleA", results.getPage().get(1).getTitle()); assertEquals("TitleB", results.getPage().get(2).getTitle()); assertEquals("TitleC", results.getPage().get(0).getTitle()); results = CALENDAR_SERVICE.listOutlookCalendarEntries(CALENDAR_SITE.getShortName(), null, paging); assertEquals(2, results.getPage().size()); assertEquals("TitleB", results.getPage().get(0).getTitle()); assertEquals("TitleC", results.getPage().get(1).getTitle()); results = CALENDAR_SERVICE.listOutlookCalendarEntries(CALENDAR_SITE.getShortName(), uidB, paging); assertEquals(1, results.getPage().size()); assertEquals("TitleB", results.getPage().get(0).getTitle()); assertEquals("TitleC", results.getPage().get(0).getTitle());
"Title", "Description", "Location", new Date(1), new Date(1234)); entry = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), entry); testNodesToTidy.add(entry.getNodeRef()); assertEquals(0, entry.getTags().size()); entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), entry.getSystemName()); assertEquals(0, entry.getTags().size()); entry.getTags().add(TAG_1); entry.getTags().add(TAG_2); entry.getTags().add(TAG_1); assertEquals(3, entry.getTags().size()); CALENDAR_SERVICE.updateCalendarEntry(entry); when(TAGGING_SERVICE.getTags(entry.getNodeRef())).thenReturn(Arrays.asList(TAG_1, TAG_2)); entry = CALENDAR_SERVICE.getCalendarEntry(CALENDAR_SITE.getShortName(), entry.getSystemName()); assertEquals(2, entry.getTags().size()); assertEquals(true, entry.getTags().contains(TAG_1)); assertEquals(true, entry.getTags().contains(TAG_2)); assertEquals(false, entry.getTags().contains(TAG_3)); entry.getTags().remove(TAG_2); entry.getTags().add(TAG_3); entry.getTags().add(TAG_1); CALENDAR_SERVICE.updateCalendarEntry(entry); assertEquals(3, entry.getTags().size()); // Includes duplicate tag until re-loaded assertEquals(true, entry.getTags().contains(TAG_1));
// Create a CalenderService and authenticate CalendarService myService = new CalendarService("exampleCo-exampleApp-1"); myService.setUserCredentials("jo@gmail.com", "mypassword"); // Send the request and print the response URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/allcalendars/full"); CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class); System.out.println("Your calendars:"); System.out.println(); for (int i = 0; i<resultFeed.getEntries().size(); i++) { CalendarEntry entry = resultFeed.getEntries().get(i); System.out.println("\t" + entry.getTitle().getPlainText()); }
@Override public CalendarEntry createCalendarEntry(String siteShortName, CalendarEntry entry) if (entry.getNodeRef() != null) entryImpl.setTags(entry.getTags()); taggingService.setTags(nodeRef, entry.getTags());
/** * Returns the parsed calendar recurrence rule * WARNING - Alfresco use only. Return type will likely shift to * a real object in the near future */ public static Map<String,String> extractRecurrenceRule(CalendarEntry entry) { return extractRecurrenceRule(entry.getRecurrenceRule()); }
LOGGER.debug("'All Day' Calendar event has been detected: [title: " + entry.getTitle() + ", start: " + entry.getStart() + ", end: " + entry.getEnd() + ", isOutlook: " + entry.isOutlook() + "]"); nodeService.setProperty(entry.getNodeRef(), CalendarModel.PROP_TO_DATE, adjustOldDate(entry.getEnd())); nodeService.setProperty(entry.getNodeRef(), CalendarModel.PROP_FROM_DATE, adjustOldDate(entry.getStart()));
/** * For the given Calendar Entry, return its subsequent Recurrence on or after * the specified date, until the given limit. If it doesn't have any recurrences * on or after the start date (either no recurrence rules, or the last recurrence * date is before then), null will be returned. (The onOrAfter and until dates * are treat as inclusive) * If requested, can stop after the first hit * @return The next recurrence on or after the given date, or null if there aren't any */ public static List<Date> getRecurrencesOnOrAfter(CalendarEntry entry, Date onOrAfter, Date until, boolean firstOnly, Set<Date> ignoredDates) { return getRecurrencesOnOrAfter( entry.getRecurrenceRule(), entry.getStart(), entry.getEnd(), entry.getLastRecurrence(), onOrAfter, until, firstOnly, ignoredDates); }
if (entry.getNodeRef() == null) for (Map.Entry<QName,Serializable> prop : nodeService.getProperties(entry.getNodeRef()).entrySet()) nodeService.setProperties(entry.getNodeRef(), properties); taggingService.setTags(entry.getNodeRef(), entry.getTags()); (Date)nodeService.getProperty(entry.getNodeRef(), ContentModel.PROP_MODIFIED) ); return getCalendarEntry(entry.getNodeRef(), entry.getSystemName(), entry.getContainerNodeRef());
)).getNodeRef(); NodeRef c2 = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( "TitleB", "Description", "Location", new Date(1302435000), new Date(1302435000) )).getNodeRef(); NodeRef c3 = CALENDAR_SERVICE.createCalendarEntry(CALENDAR_SITE.getShortName(), new CalendarEntryDTO( "TitleC", "Description", "Location", new Date(1302431400), new Date(1302435000) )).getNodeRef(); testNodesToTidy.add(c1); testNodesToTidy.add(c2); assertEquals("TitleC", results.getPage().get(0).getTitle()); // Same start as A, earlier end assertEquals("TitleA", results.getPage().get(1).getTitle()); assertEquals("TitleB", results.getPage().get(2).getTitle()); NodeRef ca1 = CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO( "PrivateTitleA", "Description", "Location", new Date(1302131400), new Date(1302135000) )).getNodeRef(); NodeRef ca2 = CALENDAR_SERVICE.createCalendarEntry(ALTERNATE_CALENDAR_SITE.getShortName(), new CalendarEntryDTO( "PrivateTitleB", "Description", "Location", new Date(1302731400), new Date(1302472200) )).getNodeRef(); AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER); testNodesToTidy.add(ca1); assertEquals("PrivateTitleA", results.getPage().get(0).getTitle()); assertEquals("TitleC", results.getPage().get(1).getTitle()); assertEquals("TitleA", results.getPage().get(2).getTitle()); assertEquals("TitleB", results.getPage().get(3).getTitle()); assertEquals("PrivateTitleB", results.getPage().get(4).getTitle());