class Tilia::Dav::PropertyStorage::Plugin

PropertyStorage Plugin.

Adding this plugin to your server allows clients to store any arbitrary WebDAV property.

See:

http://sabre.io/dav/property-storage/

for more information.

Attributes

path_filter[RW]

If you only want this plugin to store properties for a limited set of paths, you can use a pathFilter to do this.

The pathFilter should be a callable. The callable retrieves a path as its argument, and should return true or false wether it allows properties to be stored.

@var callable

Public Class Methods

new(backend) click to toggle source

Creates the plugin

@param BackendBackendInterface backend

# File lib/tilia/dav/property_storage/plugin.rb, line 27
def initialize(backend)
  @backend = backend
end

Public Instance Methods

after_move(source, destination) click to toggle source

Called after a node is moved.

This allows the backend to move all the associated properties.

@param string source @param string destination @return void

# File lib/tilia/dav/property_storage/plugin.rb, line 93
def after_move(source, destination)
  return nil if path_filter && !path_filter.call(source)
  # If the destination is filtered, afterUnbind will handle cleaning up
  # the properties.
  return nil if path_filter && !path_filter(destination)

  @backend.move(source, destination)
end
after_unbind(path) click to toggle source

Called after a node is deleted.

This allows the backend to clean up any properties still in the database.

@param string path @return void

# File lib/tilia/dav/property_storage/plugin.rb, line 81
def after_unbind(path)
  return nil if path_filter && !path_filter.call(path)
  @backend.delete(path)
end
plugin_info() click to toggle source

Returns a bunch of meta-data about the plugin.

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.

@return array

# File lib/tilia/dav/property_storage/plugin.rb, line 121
def plugin_info
  {
    'name'        => plugin_name,
    'description' => 'This plugin allows any arbitrary WebDAV property to be set on any resource.',
    'link'        => 'http://sabre.io/dav/property-storage/'
  }
end
plugin_name() click to toggle source

Returns a plugin name.

Using this name other plugins will be able to access other plugins using SabreDAVServer::getPlugin

@return string

# File lib/tilia/dav/property_storage/plugin.rb, line 108
def plugin_name
  'property-storage'
end
prop_find(prop_find, _node) click to toggle source

Called during PROPFIND operations.

If there's any requested properties that don't have a value yet, this plugin will look in the property storage backend to find them.

@param PropFind prop_find @param INode node @return void

# File lib/tilia/dav/property_storage/plugin.rb, line 55
def prop_find(prop_find, _node)
  path = prop_find.path
  return nil if path_filter && !path_filter.call(path)
  @backend.prop_find(prop_find.path, prop_find)
end
prop_patch(path, prop_patch) click to toggle source

Called during PROPPATCH operations

If there's any updated properties that haven't been stored, the propertystorage backend can handle it.

@param string path @param PropPatch prop_patch @return void

# File lib/tilia/dav/property_storage/plugin.rb, line 69
def prop_patch(path, prop_patch)
  return nil if path_filter && !path_filter.call(path)
  @backend.prop_patch(path, prop_patch)
end
setup(server) click to toggle source

This initializes the plugin.

This function is called by SabreDAVServer, after addPlugin is called.

This method should set up the required event subscriptions.

@param Server server @return void

# File lib/tilia/dav/property_storage/plugin.rb, line 40
def setup(server)
  server.on('propFind',    method(:prop_find), 130)
  server.on('propPatch',   method(:prop_patch), 300)
  server.on('afterMove',   method(:after_move))
  server.on('afterUnbind', method(:after_unbind))
end