Class: Tilia::CalDav::Notifications::Node

Inherits:
Dav::File show all
Includes:
INode, DavAcl::IAcl
Defined in:
lib/tilia/cal_dav/notifications/node.rb

Overview

This node represents a single notification.

The signature is mostly identical to that of SabreDAVIFile, but the get method MUST return an xml document that matches the requirements of the ‘caldav-notifications.txt’ spec.

Instance Method Summary collapse

Methods included from Dav::INode

#last_modified, #name=

Methods inherited from Dav::File

#content_type, #get, #put, #size

Methods included from Dav::IFile

#content_type, #get, #put, #size

Methods inherited from Dav::Node

#last_modified, #name=

Constructor Details

#initialize(caldav_backend, principal_uri, notification) ⇒ Node

Constructor

Parameters:

  • CalDAV\Backend\NotificationSupport

    caldav_backend

  • string

    principal_uri

  • NotificationInterface

    notification



36
37
38
39
40
# File 'lib/tilia/cal_dav/notifications/node.rb', line 36

def initialize(caldav_backend, principal_uri, notification)
  @caldav_backend = caldav_backend
  @principal_uri = principal_uri
  @notification = notification
end

Instance Method Details

#aclObject

Returns a list of ACE’s for this node.

Each ACE has the following properties:

* 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  currently the only supported privileges
* 'principal', a url to the principal who owns the node
* 'protected' (optional), indicating that this ACE is not allowed to
   be updated.

Returns:

  • array



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tilia/cal_dav/notifications/node.rb', line 101

def acl
  [
    {
      'principal' => owner,
      'privilege' => '{DAV:}read',
      'protected' => true
    },
    {
      'principal' => owner,
      'privilege' => '{DAV:}write',
      'protected' => true
    }
  ]
end

#acl=(_acl) ⇒ Object

Updates the ACL

This method will receive a list of new ACE’s as an array argument.

Parameters:

  • array

    acl

Returns:

  • void



122
123
124
# File 'lib/tilia/cal_dav/notifications/node.rb', line 122

def acl=(_acl)
  fail Dav::Exception::NotImplemented, 'Updating ACLs is not implemented here'
end

#deleteObject

Deletes this notification

Returns:

  • void



69
70
71
# File 'lib/tilia/cal_dav/notifications/node.rb', line 69

def delete
  @caldav_backend.delete_notification(owner, @notification)
end

#etagObject

Returns the etag for the notification.

The etag must be surrounded by litteral double-quotes.

Returns:

  • string



54
55
56
# File 'lib/tilia/cal_dav/notifications/node.rb', line 54

def etag
  @notification.etag
end

#groupObject

Returns a group principal

This must be a url to a principal, or null if there’s no owner

Returns:

  • string|null



87
88
89
# File 'lib/tilia/cal_dav/notifications/node.rb', line 87

def group
  nil
end

#nameObject

Returns the path name for this notification

Returns:

  • id



45
46
47
# File 'lib/tilia/cal_dav/notifications/node.rb', line 45

def name
  @notification.id.to_s + '.xml'
end

#notification_typeObject

This method must return an xml element, using the SabreCalDAVNotificationsINotificationType classes.

Returns:

  • INotificationType



62
63
64
# File 'lib/tilia/cal_dav/notifications/node.rb', line 62

def notification_type
  @notification
end

#ownerObject

Returns the owner principal

This must be a url to a principal, or null if there’s no owner

Returns:

  • string|null



78
79
80
# File 'lib/tilia/cal_dav/notifications/node.rb', line 78

def owner
  @principal_uri
end

#supported_privilege_setObject

Returns the list of supported privileges for this node.

The returned data structure is a list of nested privileges. See SabreDAVACLPlugin::getDefaultSupportedPrivilegeSet for a simple standard structure.

If null is returned from this method, the default privilege set is used, which is fine for most common usecases.

Returns:

  • array|null



136
137
138
# File 'lib/tilia/cal_dav/notifications/node.rb', line 136

def supported_privilege_set
  nil
end