Add support for supportedlock
This commit is contained in:
@@ -452,11 +452,11 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def displayname
|
||||
@name
|
||||
get_custom_property(:displayname) || @name
|
||||
end
|
||||
|
||||
def getcontentlanguage
|
||||
nil
|
||||
get_custom_property(:contentlanguage)
|
||||
end
|
||||
|
||||
def getcontentlength
|
||||
@@ -464,11 +464,12 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def getcontenttype
|
||||
nil
|
||||
get_custom_property(:contenttype)
|
||||
end
|
||||
|
||||
def getetag
|
||||
nil
|
||||
cache_key = ActiveSupport::Cache.expand_cache_key [@resource.etag, '']
|
||||
"W/\"#{Digest::MD5.hexdigest(cache_key)}\""
|
||||
end
|
||||
|
||||
def getlastmodified
|
||||
@@ -480,11 +481,14 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def resourcetype
|
||||
'collection'
|
||||
'collection' if collection?
|
||||
end
|
||||
|
||||
def supportedlock
|
||||
nil
|
||||
exclusive_write = lockentry_hash('exclusive', 'write')
|
||||
shared_write = lockentry_hash('shared', 'write')
|
||||
|
||||
JSON.generate [exclusive_write, shared_write]
|
||||
end
|
||||
|
||||
def get_custom_property(prop)
|
||||
|
||||
@@ -34,5 +34,9 @@ module Calligraphy
|
||||
def extract_lock_token(if_header)
|
||||
if_header.scan(Calligraphy::LOCK_TOKEN_REGEX)&.flatten[0]
|
||||
end
|
||||
|
||||
def lockentry_hash(scope, type)
|
||||
{ lockentry: { lockscope: scope, locktype: type } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,6 +101,24 @@ module Calligraphy::XML
|
||||
xml.status status_message status
|
||||
end
|
||||
|
||||
def supportedlock(xml, property)
|
||||
children = JSON.parse property.text, symbolize_names: true
|
||||
|
||||
xml[@dav_ns].supportedlock do
|
||||
children.each do |child|
|
||||
xml[@dav_ns].lockentry do
|
||||
xml[@dav_ns].lockscope do
|
||||
xml.text child[:lockentry][:lockscope]
|
||||
end
|
||||
|
||||
xml[@dav_ns].locktype do
|
||||
xml.text child[:lockentry][:locktype]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# NOTE: `xml[@dav_ns].send timeout` results in Timeout being called, so
|
||||
# we have this timeout method for convenience
|
||||
def timeout(xml, property)
|
||||
@@ -122,6 +140,8 @@ module Calligraphy::XML
|
||||
end
|
||||
elsif property.name == 'resourcetype'
|
||||
resourcetype xml, property
|
||||
elsif property.name == 'supportedlock'
|
||||
supportedlock xml, property
|
||||
elsif property.name == 'timeout'
|
||||
timeout xml, property
|
||||
elsif SUPPORTED_NS_TAGS.include? property.name
|
||||
|
||||
Reference in New Issue
Block a user