Class: Tilia::DavAcl::Fs::Collection

Inherits:
Tilia::Dav::FsExt::Directory show all
Includes:
IAcl
Defined in:
lib/tilia/dav_acl/fs/collection.rb

Overview

This is an ACL-enabled collection.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Tilia::Dav::INode

#delete, #last_modified, #name, #name=

Methods inherited from Tilia::Dav::FsExt::Directory

#child_exists, #children, #create_directory, #create_file, #delete, #move_into, #quota_info

Methods included from Tilia::Dav::IMoveTarget

#move_into

Methods included from Tilia::Dav::ICollection

#child_exists, #children, #create_directory, #create_file

Methods included from Tilia::Dav::IQuota

#quota_info

Methods inherited from Tilia::Dav::Fs::Node

#last_modified, #name, #name=

Constructor Details

#initialize(path, acl, owner = nil) ⇒ Collection

Constructor

Parameters:

  • string

    path on-disk path.

  • array

    acl ACL rules.

  • string|null

    owner principal owner string.



27
28
29
30
31
# File 'lib/tilia/dav_acl/fs/collection.rb', line 27

def initialize(path, acl, owner = nil)
  super(path)
  @acl = acl
  @owner = owner
end

Instance Attribute 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



13
14
15
# File 'lib/tilia/dav_acl/fs/collection.rb', line 13

def acl
  @acl
end

#ownerObject

Returns the owner principal

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

Returns:

  • string|null



18
19
20
# File 'lib/tilia/dav_acl/fs/collection.rb', line 18

def owner
  @owner
end

Instance Method Details

#child(name) ⇒ Object

Returns a specific child node, referenced by its name

This method must throw SabreDAVExceptionNotFound if the node does not exist.

Parameters:

  • string

    name

Returns:

  • DAVINode



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/tilia/dav_acl/fs/collection.rb', line 41

def child(name)
  path = "#{@path}/#{name}"

  fail Dav::Exception::NotFound, 'File could not be located' unless ::File.exist?(path)
  fail Dav::Exception::Forbidden, 'Permission denied to . and ..' if name == '.' || name == '..'

  if ::File.directory?(path)
    return Collection.new(path, @acl.deep_dup, @owner)
  else
    return File.new(path, @acl.deep_dup, @owner)
  end
end

#groupObject

Returns a group principal

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

Returns:

  • string|null



66
67
68
# File 'lib/tilia/dav_acl/fs/collection.rb', line 66

def group
  nil
end

#supported_privilege_setObject

Returns the list of supported privileges for this node.

The returned data structure is a list of nested privileges. See Tilia::DavAcl::Plugin::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



102
103
104
# File 'lib/tilia/dav_acl/fs/collection.rb', line 102

def supported_privilege_set
  nil
end