Skip to content

Commit

Permalink
Merge branch 'develop' into RemoveNamespacesDuringXmlParsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hndrkp committed Jul 25, 2019
2 parents e5bb99d + 0c591c9 commit abb471b
Show file tree
Hide file tree
Showing 45 changed files with 318 additions and 23 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ A Smalltalk implementation of WebDAV and CalDAV

## Setup

Run this command in workspace, to load all required packages.

Metacello new
baseline: 'DAV';
repository: 'github://hpi-swa-teaching/DAV-smalltalk:master/repository';
load.
## Architecture
To get an overview of the library, the following pictures can help.

### WebDAV

Current features:

- object representation of WebDAV queries (PROPFIND, REPORT) and wrapper objects for standard http queries (GET, PUT, DELETE) extending WebRequest
- WebDAVClient extending WebClient providing convinience methods for sending WebDAV requests

General structure of WebDAV package:
![image has been removed](https://owncloud.hpi.de/s/gd43fYnczuRjJNZ/download)

WebDAV Query Structure:
![image has been removed](https://owncloud.hpi.de/s/iOtt6N7VY0I5ter/download)

### CalDAV
Structure of CalDAV package:
![image has been removed](https://owncloud.hpi.de/s/KTee6neBJmFiwca/download)


## Connection to calendar servers

Currently, only SabreClient and Google Client are supported.

### Google Client
In order to get the Google client to work, you need to provide your client id and secret as described here: https://developers.google.com/google-apps/calendar/caldav/v2/guide

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
events handling
addEvent: anEvent

self eventsDictionary add: anEvent url schemeSpecificPart asSymbol -> anEvent.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ removeDeletedEvents: updateInformation
difference: (updateInformation collect: [:info | info at: #urlLocalPart asSymbol])).

urlsToRemove do: [ :elem |
self eventsDictionary at: elem setDirty.
self eventsDictionary removeKey: elem ifAbsent: [].
].
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
events handling
removeEvent: anEvent

| key |

self client deleteEvent: anEvent.
key := anEvent url schemeSpecificPart asSymbol.
self eventsDictionary removeKey: key ifAbsent: [].
anEvent setDirty.
self removeEventLocal: anEvent.

^ anEvent

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
events handling
removeEventLocal: anEvent

| key |

key := anEvent url schemeSpecificPart asSymbol.
self eventsDictionary removeKey: key ifAbsent: [].
anEvent setDirty.

^ anEvent

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ updating
updateOrCreateEventsFrom: iCalData

iCalData do: [ :elem |
| url etag object iCalendar |
| url etag event iCalendar |
url := self buildUrlFor: (elem at: #urlLocalPart).
etag := elem at: #'d:getetag'.
object := self eventsDictionary at: (elem at: #urlLocalPart ) ifAbsent: [
iCalendar := elem at: #calendarData.

event := self eventsDictionary at: (elem at: #urlLocalPart ) ifAbsent: [
CalDavEvent newIn: self withUrl: url.].
iCalendar := elem at: #calendarData.
object etag: etag.
object serverCalendar: iCalendar.
object serverData: iCalendar events first.

self addEvent: object.
event etag: etag.
event serverCalendar: iCalendar.
event serverData: iCalendar events first.
event setClean.
self addEvent: event.
].
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
"initialize" : "TSP 7/9/2019 13:46",
"newEvent" : "TSP 7/9/2019 15:00",
"printEvents" : "c a 7/6/2019 20:16",
"removeDeletedEvents:" : "TSP 7/9/2019 13:45",
"removeEvent:" : "TSP 7/9/2019 15:15",
"removeDeletedEvents:" : "TSP 7/24/2019 17:24",
"removeEvent:" : "TSP 7/24/2019 18:30",
"removeEventLocal:" : "TSP 7/24/2019 18:30",
"syncToken" : "TSP 7/2/2019 12:01",
"syncToken:" : "TSP 7/2/2019 12:01",
"updateCalendar" : "TSP 7/2/2019 13:08",
"updateEvents" : "ph 6/26/2019 16:26",
"updateOrAddEvents:" : "TSP 6/17/2019 16:01",
"updateOrCreateEventsFrom:" : "TSP 6/17/2019 16:10",
"updateOrCreateEventsFrom:" : "TSP 7/24/2019 17:29",
"url" : "pre 1/20/2017 10:43",
"url:" : "pre 1/20/2017 15:53" } }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
calendar: anObject
calendar := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
calendar
^ calendar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
helpers
calendarUrl

^ 'https//calendarUrl/remote'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
client: anObject
client := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
client
^ client
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
setup
setUp

super setUp.

self calendar: (CalDavCalendar new url: self calendarUrl asUrl).
self client: SabreCalDavClient new.
CalDavClient registerClient: client for: self calendarUrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tests - handling events
testAddEvent

| event key |

event := self calendar newEvent.
key := event url schemeSpecificPart asSymbol.
self calendar addEvent: event.

self assert: (self calendar eventsDictionary keys includes: key)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tests - handling events
testCreateEvent

| summary startDate endDate event |

summary := 'aSummary'.
startDate := (DateAndTime year: 2019 month: #July day: 15 hour: 14 minute: 30).
endDate := (DateAndTime year: 2019 month: #July day: 15 hour: 17 minute: 0).

event := self calendar createEvent: summary
StartDate: startDate
EndDate: endDate.

self assert: summary equals: event summary.
self assert: startDate equals: event start.
self assert: endDate equals: event end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
tests - handling events
testCreateEventWithRecurrence

| summary startDate endDate recurrence event |

summary := 'aSummary'.
startDate := (DateAndTime year: 2019 month: #July day: 15 hour: 14 minute: 30).
endDate := (DateAndTime year: 2019 month: #July day: 15 hour: 17 minute: 0).
recurrence := ICRecurrenceRule weekly.

event := self calendar createEvent: summary
StartDate: startDate
EndDate: endDate
Recurrence: recurrence.

self assert: summary equals: event summary.
self assert: startDate equals: event start.
self assert: endDate equals: event end.
self assert: (event recurrenceRules includes: recurrence)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests - handling events
testCreateFullDayEvent

| summary date event |

summary := 'aSummary'.
date := (DateAndTime year: 2019 month: #July day: 15 hour: 14 minute: 30).

event := self calendar createFullDayEvent: summary
Date: date.

self assert: summary equals: event summary.
self assert: date equals: event start.
self assert: (date + 1 day) equals: event end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tests - handling events
testCreateFullDayEventWithRecurrence

| summary date event recurrence |

summary := 'aSummary'.
date := (DateAndTime year: 2019 month: #July day: 15 hour: 14 minute: 30).
recurrence := ICRecurrenceRule weekly.

event := self calendar createFullDayEvent: summary
Date: date
Recurrence: recurrence.

self assert: summary equals: event summary.
self assert: date equals: event start.
self assert: (date + 1 day) equals: event end.
self assert: (event recurrenceRules includes: recurrence)

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests - handling events
testRemoveEvent

| event key |

event := self calendar newEvent.
key := event url schemeSpecificPart asSymbol.
self calendar addEvent: event.
self calendar removeEventLocal: event.

self assert: ((self calendar eventsDictionary keys includes: key) not)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"class" : {
},
"instance" : {
"calendar" : "TSP 7/24/2019 18:15",
"calendar:" : "TSP 7/24/2019 18:15",
"calendarUrl" : "TSP 7/24/2019 18:14",
"client" : "TSP 7/24/2019 18:14",
"client:" : "TSP 7/24/2019 18:14",
"setUp" : "TSP 7/24/2019 18:15",
"testAddEvent" : "TSP 7/24/2019 18:28",
"testCreateEvent" : "TSP 7/24/2019 18:23",
"testCreateEventWithRecurrence" : "TSP 7/24/2019 18:23",
"testCreateFullDayEvent" : "TSP 7/24/2019 18:33",
"testCreateFullDayEventWithRecurrence" : "TSP 7/24/2019 18:34",
"testRemoveEvent" : "TSP 7/24/2019 18:30" } }
15 changes: 15 additions & 0 deletions repository/DAV.package/CalDavCalendarTest.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"category" : "DAV-Cal-Tests",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"client",
"calendar" ],
"name" : "CalDavCalendarTest",
"pools" : [
],
"super" : "WebClientServerTest",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
calendar: anObject
calendar := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
calendar
^ calendar
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ setUp
super setUp.
self client: CalDavClient new.
self query: DAVGetQuery new.
self calendar: CalDavCalendar new.
self setUpDefaultRouteOnMockedServer.
self setUpCalendarRouteOnMockedServer.
self setUpEventRouteOnMockedServer
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"class" : {
},
"instance" : {
"calendar" : "TSP 7/24/2019 17:02",
"calendar:" : "TSP 7/24/2019 17:02",
"calendarUrlOnMockedServer" : "JB 6/27/2019 15:33",
"calendarUrlOnRealServer" : "JB 6/27/2019 14:54",
"calendarXml" : "GL 7/2/2019 11:55",
Expand Down Expand Up @@ -33,7 +35,7 @@
"regexForFetchEventICalDataQueryWithHrefs" : "JB 6/24/2019 16:05",
"regexForFetchEventsDataFromFor" : "GL 7/2/2019 11:12",
"regexForFetchEventsDataQuery" : "JB 6/24/2019 15:05",
"setUp" : "GL 7/3/2019 15:32",
"setUp" : "TSP 7/24/2019 17:02",
"setUpCalendarRouteOnMockedServer" : "JB 6/27/2019 22:21",
"setUpClientForMockedServer" : "JB 6/27/2019 14:52",
"setUpClientForRealServer" : "JB 6/27/2019 14:55",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"commentStamp" : "",
"instvars" : [
"client",
"query" ],
"query",
"calendar" ],
"name" : "CalDavClientTest",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
manipulating
accessing
setClean

dirty := false.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
manipulating
accessing
setDirty

dirty := true.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"etag" : "pre 3/15/2017 14:19",
"etag:" : "pre 3/15/2017 14:19",
"forceSave" : "TSP 7/9/2019 15:02",
"initialize" : "TSP 7/9/2019 14:59",
"initialize" : "TSP 7/24/2019 17:47",
"initializeServerData" : "c a 6/15/2019 15:55",
"isDirty" : "pre 4/6/2017 12:44",
"newServerData" : "pre 4/11/2017 11:18",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
calendar: anObject
calendar := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
calendar
^ calendar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
helpers
calendarUrl

^ 'https//calendarUrl/remote'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
client: anObject
client := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
client
^ client
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
setup
setUp

super setUp.

self calendar: (CalDavCalendar new url: self calendarUrl asUrl).
self client: SabreCalDavClient new.
CalDavClient registerClient: client for: self calendarUrl
Loading

0 comments on commit abb471b

Please sign in to comment.