class Tilia::CardDav::AddressBookHome

AddressBook Home class

This collection contains a list of addressbooks associated with one user.

Attributes

carddav_backend[RW]

carddavBackend

@var BackendBackendInterface

principal_uri[RW]

Principal uri

@var array

Public Class Methods

new(carddav_backend, principal_uri) click to toggle source

Constructor

@param BackendBackendInterface carddav_backend @param string principal_uri

# File lib/tilia/card_dav/address_book_home.rb, line 28
def initialize(carddav_backend, principal_uri)
  @carddav_backend = carddav_backend
  @principal_uri = principal_uri
end

Public Instance Methods

acl() click to toggle source

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.

@return array

# File lib/tilia/card_dav/address_book_home.rb, line 152
def acl
  [
    {
      'privilege' => '{DAV:}read',
      'principal' => @principal_uri,
      'protected' => true
    },
    {
      'privilege' => '{DAV:}write',
      'principal' => @principal_uri,
      'protected' => true
    }
  ]
end
acl=(_acl) click to toggle source

Updates the ACL

This method will receive a list of new ACE's.

@param array acl @return void

# File lib/tilia/card_dav/address_book_home.rb, line 173
def acl=(_acl)
  fail Dav::Exception::MethodNotAllowed, 'Changing ACL is not yet supported'
end
child(name) click to toggle source

Returns a single addressbook, by name

@param string name @todo needs optimizing @return AddressBook

# File lib/tilia/card_dav/address_book_home.rb, line 89
def child(name)
  children.each do |child|
    return child if name == child.name
  end

  fail Dav::Exception::NotFound, "Addressbook with name '#{name}' could not be found"
end
children() click to toggle source

Returns a list of addressbooks

@return array

# File lib/tilia/card_dav/address_book_home.rb, line 100
def children
  addressbooks = @carddav_backend.address_books_for_user(@principal_uri)

  objs = []
  addressbooks.each do |addressbook|
    objs << AddressBook.new(@carddav_backend, addressbook)
  end
  objs
end
create_directory(_filename) click to toggle source

Creates a new directory under this object.

This is currently not allowed.

@param string filename @return void

# File lib/tilia/card_dav/address_book_home.rb, line 80
def create_directory(_filename)
  fail Dav::Exception::MethodNotAllowed, 'Creating new collections in this collection is not supported'
end
create_extended_collection(name, mk_col) click to toggle source

Creates a new address book.

@param string name @param MkCol mk_col @throws DAVExceptionInvalidResourceType @return void

# File lib/tilia/card_dav/address_book_home.rb, line 116
def create_extended_collection(name, mk_col)
  fail Dav::Exception::InvalidResourceType, 'Unknown resourceType for this collection' unless mk_col.resource_type?("{#{Plugin::NS_CARDDAV}}addressbook")

  properties = mk_col.remaining_values
  mk_col.remaining_result_code = 201
  @carddav_backend.create_address_book(@principal_uri, name, properties)
end
create_file(_filename, _data = nil) click to toggle source

Creates a new file under this object.

This is currently not allowed

@param string filename @param resource data @return void

# File lib/tilia/card_dav/address_book_home.rb, line 70
def create_file(_filename, _data = nil)
  fail Dav::Exception::MethodNotAllowed, 'Creating new files in this collection is not supported'
end
delete() click to toggle source

Deletes this object

@return void

# File lib/tilia/card_dav/address_book_home.rb, line 52
def delete
  fail Dav::Exception::MethodNotAllowed
end
group() click to toggle source

Returns a group principal

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

@return string|null

# File lib/tilia/card_dav/address_book_home.rb, line 138
def group
  nil
end
last_modified() click to toggle source

Returns the last modification date

@return int

# File lib/tilia/card_dav/address_book_home.rb, line 59
def last_modified
  nil
end
name() click to toggle source

Returns the name of this object

@return string

# File lib/tilia/card_dav/address_book_home.rb, line 36
def name
  name = Uri.split(@principal_uri)[1]
  name
end
name=(_name) click to toggle source

Updates the name of this object

@param string name @return void

# File lib/tilia/card_dav/address_book_home.rb, line 45
def name=(_name)
  fail Dav::Exception::MethodNotAllowed
end
owner() click to toggle source

Returns the owner principal

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

@return string|null

# File lib/tilia/card_dav/address_book_home.rb, line 129
def owner
  @principal_uri
end
supported_privilege_set() click to toggle source

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.

@return array|null

# File lib/tilia/card_dav/address_book_home.rb, line 187
def supported_privilege_set
  nil
end