Class: ZenaNodeResource
Instance Attribute Summary collapse
Instance Method Summary
collapse
#secure_scope, #secure_write_scope, #visitor=
#construct_id_map, #secure_result
Constructor Details
Returns a new instance of ZenaNodeResource.
60
61
62
|
# File 'lib/zena/webdav_adapter.rb', line 60
def initialize(node)
@node = node
end
|
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
53
54
55
|
# File 'lib/zena/webdav_adapter.rb', line 53
def node
@node
end
|
Instance Method Details
#children ⇒ Object
103
104
105
106
107
108
|
# File 'lib/zena/webdav_adapter.rb', line 103
def children
res = (@node.children || []).map { |p| ZenaNodeResource.new(p) }
puts "CHILDREN OF #{@node.fullpath}: #{res.map { |r| r.get_href }.inspect }"
res
end
|
#collection? ⇒ Boolean
99
100
101
|
# File 'lib/zena/webdav_adapter.rb', line 99
def collection?
return !@node.kind_of?(Document) && !@node.kind_of?(Note)
end
|
#copy!(dest_path, depth) ⇒ Object
91
92
93
|
# File 'lib/zena/webdav_adapter.rb', line 91
def copy! (dest_path, depth)
end
|
#creationdate ⇒ Object
118
119
120
|
# File 'lib/zena/webdav_adapter.rb', line 118
def creationdate
@node.created_at.httpdate
end
|
#data ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/zena/webdav_adapter.rb', line 161
def data
if @node.kind_of?(Note)
@node.text
elsif @node.kind_of?(Document)
f = @node.file
puts f
f
else
0
end
end
|
#delete! ⇒ Object
79
80
81
|
# File 'lib/zena/webdav_adapter.rb', line 79
def delete!
end
|
#displayname ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'lib/zena/webdav_adapter.rb', line 64
def displayname
if @node.kind_of?(Note)
@node.name + '.txt'
elsif @node.kind_of?(Document)
@node.name + '.' + @node.ext
else
@node.name
end
end
|
#getcontentlength ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/zena/webdav_adapter.rb', line 149
def getcontentlength
if @node.kind_of?(Note)
@node.text.length
elsif @node.kind_of?(Document)
s = @node.file.stat.size
puts "SIZE #{@node.name} = #{s}"
s
else
0
end
end
|
#getcontenttype ⇒ Object
139
140
141
142
143
144
145
146
147
|
# File 'lib/zena/webdav_adapter.rb', line 139
def getcontenttype
if @node.kind_of?(Note)
"text/plain"
elsif @node.kind_of?(Document)
@node.content_type
else
"httpd/unix-directory"
end
end
|
#getetag ⇒ Object
135
136
137
|
# File 'lib/zena/webdav_adapter.rb', line 135
def getetag
end
|
#getlastmodified ⇒ Object
122
123
124
|
# File 'lib/zena/webdav_adapter.rb', line 122
def getlastmodified
@node.updated_at.httpdate
end
|
#href ⇒ Object
74
75
76
77
|
# File 'lib/zena/webdav_adapter.rb', line 74
def href
return '/' if @node.fullpath.blank?
'/' + (@node.fullpath.split('/')[0..-2] + [self.displayname]).join('/')
end
|
#move!(dest_path, depth) ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/zena/webdav_adapter.rb', line 83
def move! (dest_path, depth)
parent_path = dest_path.split('/')[0..-2]
parent = secure!(Node) { Node.find_by_path(parent_path.join('/')) }
raise WebDavErrors::ConflictError unless @node.update_attributes(:parent_id => parent[:id])
rescue ActiveRecord::RecordNotFound
raise WebDavErrors::ForbiddenError
end
|
#set_displayname(value) ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/zena/webdav_adapter.rb', line 110
def set_displayname(value)
if @node.update_attributes(:name => value)
gen_status(200, "OK").to_s
else
gen_status(409, "Conflict").to_s
end
end
|
#set_getlastmodified(value) ⇒ Object
126
127
128
129
130
131
132
|
# File 'lib/zena/webdav_adapter.rb', line 126
def set_getlastmodified(value)
if @node.update_attributes(:updated_at => value)
gen_status(200, "OK").to_s
else
gen_status(409, "Conflict").to_s
end
end
|
#status ⇒ Object
95
96
97
|
# File 'lib/zena/webdav_adapter.rb', line 95
def status
gen_status(200, "OK").to_s
end
|
#visitor ⇒ Object
56
57
58
|
# File 'lib/zena/webdav_adapter.rb', line 56
def visitor
@node.visitor
end
|