sword2ruby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/LICENCE +35 -0
- data/README.md +43 -0
- data/Rakefile +53 -0
- data/doc/Atom/Collection.html +837 -0
- data/doc/Atom/Element.html +197 -0
- data/doc/Atom/Entry.html +1795 -0
- data/doc/Atom/Feed.html +297 -0
- data/doc/Atom/Service.html +363 -0
- data/doc/Atom.html +158 -0
- data/doc/Gemfile.html +125 -0
- data/doc/Object.html +165 -0
- data/doc/REXML/Element.html +493 -0
- data/doc/REXML.html +158 -0
- data/doc/Rakefile.html +123 -0
- data/doc/Sword2Ruby/Atom.html +169 -0
- data/doc/Sword2Ruby/AutoDiscover.html +327 -0
- data/doc/Sword2Ruby/Connection.html +274 -0
- data/doc/Sword2Ruby/DepositReceipt.html +331 -0
- data/doc/Sword2Ruby/Exception.html +168 -0
- data/doc/Sword2Ruby/SwordAccept.html +169 -0
- data/doc/Sword2Ruby/SwordStatementOAIORE.html +277 -0
- data/doc/Sword2Ruby/User.html +272 -0
- data/doc/Sword2Ruby/Utility.html +1101 -0
- data/doc/Sword2Ruby.html +213 -0
- data/doc/created.rid +29 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +118 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +543 -0
- data/doc/spec/fixtures/example_txt.html +125 -0
- data/doc/table_of_contents.html +267 -0
- data/lib/sword2ruby/auto_discover.rb +71 -0
- data/lib/sword2ruby/collection.rb +261 -0
- data/lib/sword2ruby/connection.rb +37 -0
- data/lib/sword2ruby/constant.rb +35 -0
- data/lib/sword2ruby/deposit_receipt.rb +52 -0
- data/lib/sword2ruby/element.rb +12 -0
- data/lib/sword2ruby/entry.rb +602 -0
- data/lib/sword2ruby/exception.rb +7 -0
- data/lib/sword2ruby/feed.rb +34 -0
- data/lib/sword2ruby/rexml_element.rb +79 -0
- data/lib/sword2ruby/service.rb +79 -0
- data/lib/sword2ruby/sword_accept.rb +10 -0
- data/lib/sword2ruby/sword_statement_oai_ore.rb +38 -0
- data/lib/sword2ruby/user.rb +25 -0
- data/lib/sword2ruby/utility.rb +232 -0
- data/lib/sword2ruby/version.rb +4 -0
- data/lib/sword2ruby.rb +32 -0
- data/spec/auto_discover_spec.rb +30 -0
- data/spec/collection_spec.rb +33 -0
- data/spec/connection_spec.rb +21 -0
- data/spec/end_to_end_spec.rb +235 -0
- data/spec/fixtures/example.txt +3 -0
- data/spec/fixtures/snowflake.png +0 -0
- data/spec/fixtures/zip-test.zip +0 -0
- data/spec/service_spec.rb +38 -0
- data/spec/statement_spec.rb +53 -0
- data/spec/test_constants.rb +32 -0
- data/sword2ruby.gemspec +42 -0
- data/sword2ruby.tmproj +27 -0
- metadata +197 -0
@@ -0,0 +1,602 @@
|
|
1
|
+
require 'atom/entry'
|
2
|
+
|
3
|
+
module Sword2Ruby
|
4
|
+
#Extensions to the atom-tools[https://github.com/bct/atom-tools/wiki] Atom::Entry class to support Sword2 operations.
|
5
|
+
#These methods are additive to those supplied by the atom-tools gem.
|
6
|
+
#
|
7
|
+
#Please see the {atom-tools documentation}[http://rdoc.info/github/bct/atom-tools/master/frames] for a complete list of attributes and methods.
|
8
|
+
class ::Atom::Entry < ::Atom::Element
|
9
|
+
|
10
|
+
#Deposit Receipt tags
|
11
|
+
|
12
|
+
#This method returns the URI string of the <link rel="alternate"> tag (usually contained in the DepositReceipt Entry),
|
13
|
+
#or nil if it is not defined.
|
14
|
+
def alternate_uri
|
15
|
+
Utility.find_link_uri(links, "alternate")
|
16
|
+
end
|
17
|
+
|
18
|
+
#This method returns the URI string of the <b>\Atom \Entry Edit</b> <link rel="edit"> tag (usually contained in the DepositReceipt Entry),
|
19
|
+
#or nil if it is not defined. It is also known as the Media \Entry URI or Edit-URI.
|
20
|
+
def entry_edit_uri #media_entry_uri
|
21
|
+
Utility.find_link_uri(links, "edit")
|
22
|
+
end
|
23
|
+
alias :media_entry_uri :entry_edit_uri
|
24
|
+
|
25
|
+
#This method returns an array of Atom::Links for the <b>\Atom Edit Media</b> <link rel="edit-media"> tags (usually contained in the DepositReceipt Entry),
|
26
|
+
#or an empty array [ ] if none are defined. They are also known as the Media Resource URIs or EM-URIs.
|
27
|
+
def edit_media_links #media_resource_links
|
28
|
+
Utility.find_links_all_types(links, "edit-media")
|
29
|
+
end
|
30
|
+
alias :media_resource_links :edit_media_links
|
31
|
+
|
32
|
+
#This method returns the URI string of the <b>sword edit</b> <link rel="http://purl.org/net/sword/terms/add"> tag (usually contained in the DepositReceipt Entry),
|
33
|
+
#or nil if it is not defined.
|
34
|
+
def sword_edit_uri
|
35
|
+
Utility.find_link_uri(links, "http://purl.org/net/sword/terms/add")
|
36
|
+
end
|
37
|
+
|
38
|
+
#This method returns the URI string of the package or file deposited, as specified in the <link rel="http://purl.org/net/sword/terms/originalDeposit"> tag (usually contained in the DepositReceipt Entry),
|
39
|
+
#or nil if it is not defined.
|
40
|
+
def sword_original_deposit_uri
|
41
|
+
Utility.find_link_uri(links, "http://purl.org/net/sword/terms/originalDeposit")
|
42
|
+
end
|
43
|
+
|
44
|
+
#This method returns an array of Atom::Links for the <b>derived resource</b> <link rel="http://purl.org/net/sword/terms/derivedResource"> tags (usually contained in the DepositReceipt Entry),
|
45
|
+
#or an empty array [ ] if none are defined.
|
46
|
+
def sword_derived_resource_links
|
47
|
+
Utility.find_links_all_types(links, "http://purl.org/net/sword/terms/derivedResource")
|
48
|
+
end
|
49
|
+
|
50
|
+
#This method returns an array of Atom::Links for the <b>sword statements</b>, from the <link rel="http://purl.org/net/sword/terms/statement"> tags (usually contained in the DepositReceipt Entry),
|
51
|
+
#or an empty array [ ] if none are defined.
|
52
|
+
def sword_statement_links
|
53
|
+
Utility.find_links_all_types(links, "http://purl.org/net/sword/terms/statement")
|
54
|
+
end
|
55
|
+
|
56
|
+
#This method returns an array of string values for the <b>sword packagings</b>, from the <sword:packaging> tags (usually contained in the DepositReceipt Entry),
|
57
|
+
#or an empty array [ ] if none are defined.
|
58
|
+
def sword_packagings
|
59
|
+
Utility.find_elements_text(extensions, "sword:packaging")
|
60
|
+
end
|
61
|
+
|
62
|
+
#This method returns the string value of the <b>sword treatment</b> <sword:treatment> tag (usually contained in the DepositReceipt Entry),
|
63
|
+
#or nil if it is not defined.
|
64
|
+
def sword_treatment
|
65
|
+
Utility.find_element_text(extensions, "sword:treatment")
|
66
|
+
end
|
67
|
+
|
68
|
+
#This method returns the string value of the <b>sword verbose description</b> <sword:verboseDescription> tag (usually contained in the DepositReceipt Entry),
|
69
|
+
#or nil if it is not defined.
|
70
|
+
def sword_verbose_description
|
71
|
+
Utility.find_element_text(extensions, "sword:verboseDescription")
|
72
|
+
end
|
73
|
+
|
74
|
+
#This method returns an array of the Dublin Core elements (usually contained in the DepositReceipt Entry),
|
75
|
+
#or an empty array [ ] if none are defined.
|
76
|
+
#
|
77
|
+
#For more information, see the {Dublin Core Metadata Terms specification}[http://dublincore.org/documents/dcmi-terms/].
|
78
|
+
def dublin_core_extensions
|
79
|
+
Utility.find_elements_by_namespace(extensions, "http://purl.org/dc/terms/")
|
80
|
+
end
|
81
|
+
|
82
|
+
#This method adds a new Dublin Core element to the entry,
|
83
|
+
#===Parameters
|
84
|
+
#name:: a valid Dublin Core Term Name, e.g. "abstract", "title" or "publisher" etc
|
85
|
+
#value:: the string value of the new Dublin Core element, e.g. "A report on Burritos", "History of Burritos" or "Burrito King" etc
|
86
|
+
#
|
87
|
+
#For more information, see the {Dublin Core Metadata Terms specification}[http://dublincore.org/documents/dcmi-terms/].
|
88
|
+
def add_dublin_core_extension!(name, value)
|
89
|
+
extension = REXML::Element.new(name)
|
90
|
+
extension.add_namespace("http://purl.org/dc/terms/")
|
91
|
+
extension.text = value
|
92
|
+
extensions << extension
|
93
|
+
end
|
94
|
+
|
95
|
+
#This method searches for the specified Dublin Core term in the entry and removes it where found.
|
96
|
+
#===Parameters
|
97
|
+
#name:: a valid Dublin Core Term Name, e.g. "isReferencedBy", "title" or "accrualPolicy" etc
|
98
|
+
#
|
99
|
+
#For more information, see the {Dublin Core Metadata Terms specification}[http://dublincore.org/documents/dcmi-terms/].
|
100
|
+
def delete_dublin_core_extension!(name)
|
101
|
+
extensions.delete_if {|e| e.namespace == "http://purl.org/dc/terms/" && e.name == name}
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
#Sword Statement tags
|
108
|
+
|
109
|
+
#This method returns the time value of the <sword:depositedOn> tag (usually contained in the Sword Statement Atom Feed),
|
110
|
+
#or nil if it is not defined.
|
111
|
+
def sword_deposited_on
|
112
|
+
Utility.find_element_time(extensions, "sword:depositedOn")
|
113
|
+
end
|
114
|
+
|
115
|
+
#This method returns the string value of the <sword:depositedBy> tag (usually contained in the Sword Statement Atom Feed),
|
116
|
+
#or nil if it is not defined.
|
117
|
+
def sword_deposited_by
|
118
|
+
Utility.find_element_text(extensions, "sword:depositedBy")
|
119
|
+
end
|
120
|
+
|
121
|
+
#This method returns the string value of the <sword:depositedOnBehalfOf> tag (usually contained in the Sword Statement Atom Feed),
|
122
|
+
#or nil if it is not defined.
|
123
|
+
def sword_deposited_on_behalf_of
|
124
|
+
Utility.find_element_text(extensions, "sword:depositedOnBehalfOf")
|
125
|
+
end
|
126
|
+
|
127
|
+
#This method returns the Atom::Category of the original deposit (usually contained in the Sword Statement Atom Feed),
|
128
|
+
#or nil if it is not defined.
|
129
|
+
def sword_original_deposit_category
|
130
|
+
Utility.find_element_by_scheme_and_term(categories, "http://purl.org/net/sword/terms/", "http://purl.org/net/sword/terms/originalDeposit")
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
#CRUD methods
|
135
|
+
|
136
|
+
#This method posts a new entry to an existing entry's sword-edit URI, adding to the existing entry's metadata (i.e. not overwriting existing metadata).
|
137
|
+
#It <i>does not</i> create a new entry in the collection.
|
138
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
139
|
+
#===Parameters (passed as a hash collection)
|
140
|
+
#:entry:: (optional) a new Atom::Entry with metadata to be added to an existing Atom::Entry. If not supplied, this will default to itself.
|
141
|
+
#:\sword_edit_uri:: (optional) an override to the existing entry's sword-edit URI. If not supplied, this will default to the existing entry's sword-edit URI.
|
142
|
+
#:in_progress:: (optional) boolean value indicating whether the existing entry will be completed at a later date.
|
143
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed.
|
144
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
145
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
146
|
+
#
|
147
|
+
#===Example BROKEN
|
148
|
+
# # feed = collection.feed # assuming that you have retrieved a collection from the service document
|
149
|
+
# # feed.update! # get all the entry data
|
150
|
+
# # existing_entry = feed.entries.first
|
151
|
+
# additional_entry = Atom::Entry.new()
|
152
|
+
# additional_entry.title = "The Improved Burrito"
|
153
|
+
# additional_entry.summary = "Adding some extra metadata to the existing entry"
|
154
|
+
# additional_entry.add_dublin_core_extension!("publisher", "Burrito King")
|
155
|
+
# deposit_receipt = existing_entry.post!(:entry => additional_entry, :in_progress => true)
|
156
|
+
# feed.updated! #flag that the feed has been updated
|
157
|
+
# feed.update! #get the updates
|
158
|
+
#For more information, see the Sword2 specification: {section 6.7.2. "Adding New Metadata to a Container"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_addingcontent_metadata].
|
159
|
+
def post!(params = {})
|
160
|
+
Utility.check_argument_class('params', params, Hash)
|
161
|
+
defaults = {
|
162
|
+
:entry => self,
|
163
|
+
:sword_edit_uri => sword_edit_uri,
|
164
|
+
:in_progress => nil,
|
165
|
+
:on_behalf_of => nil,
|
166
|
+
:connection => @http
|
167
|
+
}
|
168
|
+
options = defaults.merge(params)
|
169
|
+
|
170
|
+
#Validate parameters
|
171
|
+
Utility.check_argument_class(':entry', options[:entry], ::Atom::Entry)
|
172
|
+
Utility.check_argument_class(':sword_edit_uri', options[:sword_edit_uri], String)
|
173
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
174
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
175
|
+
|
176
|
+
headers = {"Content-Type" => "application/atom+xml;type=entry" }
|
177
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
178
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
179
|
+
response = options[:connection].post(options[:sword_edit_uri], options[:entry].to_s, headers)
|
180
|
+
if response.is_a? Net::HTTPSuccess
|
181
|
+
return DepositReceipt.new(response, options[:connection])
|
182
|
+
else
|
183
|
+
raise Sword2Ruby::Exception.new("Failed to do post!(#{options[:sword_edit_uri]}): server returned code #{response.code} #{response.message}")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
#This method posts a file to an existing entry's edit-media URI, adding to the existing entry's media resources (i.e. not overwriting existing media resources).
|
188
|
+
#It <i>does not</i> create a new entry in the collection.
|
189
|
+
#An MD5-digest will be calculated automatically from the file and sent to the server with the request.
|
190
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
191
|
+
#===Parameters (passed as a hash collection)
|
192
|
+
#:filepath:: a filepath string indicating the file to be posted. The file must be readable by the process.
|
193
|
+
#:content_type:: the mime content-type string of the file, e.g. "application/zip" or "text/plain"
|
194
|
+
#:packaging:: (optional) the Sword packaging string of the file, e.g. "http://purl.org/net/sword/package/METSDSpaceSIP"
|
195
|
+
#:\edit_media_uri:: (optional) an override to the existing entry's edit media URI (media resource URI). If not supplied, this will default to the existing entry's <b>first</b> edit media URI (as there can be multiple edit media URIs).
|
196
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed
|
197
|
+
#:metadata_relevant:: (optional) boolean value indicating whether the server should consider the file or package a potential source of metadata.
|
198
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
199
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
200
|
+
#
|
201
|
+
#For more information, see the Sword2 specification: {section 6.7.1. "Adding Content to the Media Resource"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_addingcontent_mediaresource].
|
202
|
+
def post_media!(params = {})
|
203
|
+
Utility.check_argument_class('params', params, Hash)
|
204
|
+
defaults = {
|
205
|
+
:filepath => nil,
|
206
|
+
:content_type => nil,
|
207
|
+
:packaging => nil,
|
208
|
+
:edit_media_uri => edit_media_links.first.href,
|
209
|
+
:on_behalf_of => nil,
|
210
|
+
:metadata_relevant => nil,
|
211
|
+
:connection => @http
|
212
|
+
}
|
213
|
+
options = defaults.merge(params)
|
214
|
+
|
215
|
+
#Validate parameters
|
216
|
+
Utility.check_argument_class(':filepath', options[:filepath], String)
|
217
|
+
Utility.check_argument_class(':content_type', options[:content_type], String)
|
218
|
+
Utility.check_argument_class(':packaging', options[:packaging], String) if options[:packaging]
|
219
|
+
Utility.check_argument_class(':edit_media_uri', options[:edit_media_uri], String)
|
220
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
221
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
222
|
+
|
223
|
+
filename, md5, data = Utility.read_file(options[:filepath])
|
224
|
+
|
225
|
+
headers = {"Content-Type" => options[:content_type]}
|
226
|
+
headers["Content-Disposition"] = "attachment; filename=#{filename}"
|
227
|
+
headers["Content-MD5"] = md5
|
228
|
+
headers["Packaging"] = options[:packaging] if options[:packaging]
|
229
|
+
headers["Metadata-Relevant"] = options[:metadata_relevant].to_s.downcase if (options[:metadata_relevant] == true || options[:metadata_relevant] == false)
|
230
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
231
|
+
|
232
|
+
response = options[:connection].post(options[:edit_media_uri], data, headers)
|
233
|
+
|
234
|
+
if response.is_a? Net::HTTPSuccess
|
235
|
+
return DepositReceipt.new(response, options[:connection])
|
236
|
+
else
|
237
|
+
raise Sword2Ruby::Exception.new("Failed to do post_media!(#{options[:edit_media_uri]}): server returned #{response.code} #{response.message}")
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
#This method posts an entry and a file to an existing entry's sword-edit URI, adding to the existing entry's metadata and media resources (i.e. not overwriting existing metadata and media resources).
|
244
|
+
#It <i>does not</i> create a new entry in the collection.
|
245
|
+
#An MD5-digest will be calculated automatically from the file and sent to the server with the request.
|
246
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
247
|
+
#===Parameters (passed as a hash collection)
|
248
|
+
#:entry:: (optional) a new Atom::Entry with metadata to be added to an existing Atom::Entry. If not supplied, this will default to itself.
|
249
|
+
#:filepath:: a filepath string indicating the file to be posted. The file must be readable by the process.
|
250
|
+
#:content_type:: the mime content-type string of the file, e.g. "application/zip" or "text/plain"
|
251
|
+
#:packaging:: (optional) the Sword packaging string of the file, e.g. "http://purl.org/net/sword/package/METSDSpaceSIP"
|
252
|
+
#:\sword_edit_uri:: (optional) an override to the existing entry's sword edit URI. If not supplied, this will default to the existing entry's sword edit URI.
|
253
|
+
#:in_progress:: (optional) boolean value indicating whether the existing entry will be completed at a later date.
|
254
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed
|
255
|
+
#:metadata_relevant:: (optional) boolean value indicating whether the server should consider the file or package a potential source of metadata.
|
256
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
257
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
258
|
+
#
|
259
|
+
#For more information, see the Sword2 specification: {section 6.7.3. "Adding Content to the Media Resource"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_addingcontent_multipart].
|
260
|
+
def post_multipart!(params = {})
|
261
|
+
Utility.check_argument_class('params', params, Hash)
|
262
|
+
defaults = {
|
263
|
+
:entry => self,
|
264
|
+
:filepath => nil,
|
265
|
+
:content_type => nil,
|
266
|
+
:packaging => nil,
|
267
|
+
:sword_edit_uri => sword_edit_uri,
|
268
|
+
:in_progress => nil,
|
269
|
+
:on_behalf_of => nil,
|
270
|
+
:metadata_relevant => nil,
|
271
|
+
:connection => @http
|
272
|
+
}
|
273
|
+
options = defaults.merge(params)
|
274
|
+
|
275
|
+
#Validate parameters
|
276
|
+
Utility.check_argument_class(':entry', options[:entry], ::Atom::Entry)
|
277
|
+
Utility.check_argument_class(':filepath', options[:filepath], String)
|
278
|
+
Utility.check_argument_class(':content_type', options[:content_type], String)
|
279
|
+
Utility.check_argument_class(':packaging', options[:packaging], String) if options[:packaging]
|
280
|
+
Utility.check_argument_class(':sword_edit_uri', options[:sword_edit_uri], String)
|
281
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
282
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
283
|
+
|
284
|
+
tmp = ""
|
285
|
+
boundary = "========" + Time.now.to_i.to_s + "=="
|
286
|
+
filename, md5, data = Utility.read_file(options[:filepath])
|
287
|
+
|
288
|
+
|
289
|
+
headers = {"Content-Type" => 'multipart/related; boundary="' + boundary + '"; type="application/atom+xml"'}
|
290
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
291
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
292
|
+
headers["MIME-Version"] = "1.0"
|
293
|
+
|
294
|
+
|
295
|
+
# write boundary identifer to temp
|
296
|
+
tmp << "--#{boundary}\r\n"
|
297
|
+
|
298
|
+
# write entry relevant headers to temp
|
299
|
+
tmp << "Content-Type: application/atom+xml; charset=\"utf-8\"\r\n"
|
300
|
+
tmp << "Content-Disposition: attachment; name=atom\r\n"
|
301
|
+
tmp << "MIME-Version: 1.0\r\n\r\n"
|
302
|
+
|
303
|
+
# write entry to temp
|
304
|
+
tmp << options[:entry].to_s + "\r\n"
|
305
|
+
|
306
|
+
# write boundary identifier to temp
|
307
|
+
tmp << "--#{boundary}\r\n"
|
308
|
+
|
309
|
+
# write media part relevant headers to temp
|
310
|
+
tmp << "Content-Type: #{options[:content_type]}\r\n"
|
311
|
+
tmp << "Content-Disposition: attachment; name=payload; filename=#{filename}\r\n"
|
312
|
+
tmp << "Content-MD5: #{md5}\r\n"
|
313
|
+
tmp << "Packaging: #{options[:packaging]}\r\n" if options[:packaging]
|
314
|
+
tmp << "Metadata-Relevant: #{options[:metadata_relevant].to_s.downcase}\r\n" if (options[:metadata_relevant] == true || options[:metadata_relevant] == false)
|
315
|
+
tmp << "MIME-Version: 1.0\r\n\r\n"
|
316
|
+
|
317
|
+
# write the file base64 encoded to temp
|
318
|
+
tmp << Base64.encode64(data)
|
319
|
+
|
320
|
+
# write boundary identifier to temp
|
321
|
+
tmp << "--#{boundary}--\r\n" #The last two dashes (--) are important!
|
322
|
+
|
323
|
+
response = options[:connection].post(options[:sword_edit_uri], tmp, headers)
|
324
|
+
|
325
|
+
if response.is_a? Net::HTTPSuccess
|
326
|
+
return DepositReceipt.new(response, options[:connection])
|
327
|
+
else
|
328
|
+
raise Sword2Ruby::Exception.new("Failed to do post_multipart!(#{options[:sword_edit_uri]}): server returned #{response.code} #{response.message}")
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
|
333
|
+
#This method replaces an existing entry's metadata by performing a Put on the entry-edit URI.
|
334
|
+
#It <i>does not</i> create a new entry in the collection.
|
335
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
336
|
+
#
|
337
|
+
#===Example
|
338
|
+
# feed = collection.feed # assuming that you have retrieved a collection from the service document
|
339
|
+
# feed.update! # get all the entry data
|
340
|
+
# existing_entry = feed.entries.first
|
341
|
+
# existing_entry.title = "The Improved Burrito"
|
342
|
+
# existing_entry.summary = "Replacing the metadata of an existing entry"
|
343
|
+
# existing_entry.add_dublin_core_extension!("publisher", "Burrito King")
|
344
|
+
# existing_entry.put!
|
345
|
+
#
|
346
|
+
#===Parameters (passed as a hash collection)
|
347
|
+
#:entry:: (optional) a new Atom::Entry with metadata to replace an existing Atom::Entry. If not supplied, this will default to itself.
|
348
|
+
#:entry_edit_uri:: (optional) an override to the existing entry's entry-edit URI. If not supplied, this will default to the existing entry's entry-edit URI.
|
349
|
+
#:in_progress:: (optional) boolean value indicating whether the existing entry will be completed at a later date.
|
350
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed.
|
351
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
352
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
353
|
+
#
|
354
|
+
#For more information, see the Sword2 specification: {section 6.5.2. "Replacing the Metadata of a Resource"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_editingcontent_metadata].
|
355
|
+
def put!(params = {})
|
356
|
+
Utility.check_argument_class('params', params, Hash)
|
357
|
+
defaults = {
|
358
|
+
:entry => self,
|
359
|
+
:entry_edit_uri => entry_edit_uri,
|
360
|
+
:in_progress => nil,
|
361
|
+
:on_behalf_of => nil,
|
362
|
+
:connection => @http
|
363
|
+
}
|
364
|
+
options = defaults.merge(params)
|
365
|
+
|
366
|
+
#Validate parameters
|
367
|
+
Utility.check_argument_class(':entry', options[:entry], ::Atom::Entry)
|
368
|
+
Utility.check_argument_class(':entry_edit_uri', options[:entry_edit_uri], String)
|
369
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
370
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
371
|
+
|
372
|
+
headers = {"Content-Type" => "application/atom+xml;type=entry" }
|
373
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
374
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
375
|
+
response = options[:connection].put(options[:entry_edit_uri], options[:entry].to_s, headers)
|
376
|
+
if response.is_a? Net::HTTPSuccess
|
377
|
+
return DepositReceipt.new(response, options[:connection])
|
378
|
+
else
|
379
|
+
raise Sword2Ruby::Exception.new("Failed to do put!(#{options[:entry_edit_uri]}): server returned code #{response.code} #{response.message}")
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
|
384
|
+
#This method replaces an existing entry's file content of a resource by performing a Put on the edit-media URI.
|
385
|
+
#It <i>does not</i> create a new entry in the collection.
|
386
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
387
|
+
#
|
388
|
+
#===Parameters (passed as a hash collection)
|
389
|
+
#:filepath:: a filepath string indicating the file to be sent. The file must be readable by the process.
|
390
|
+
#:content_type:: the mime content-type string of the file, e.g. "application/zip" or "text/plain"
|
391
|
+
#:packaging:: (optional) the Sword packaging string of the file, e.g. "http://purl.org/net/sword/package/METSDSpaceSIP"
|
392
|
+
#:edit_media_uri:: (optional) an override to the existing entry's edit-media URI. If not supplied, this will default to the existing entry's first edit-media URI.
|
393
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed.
|
394
|
+
#:metadata_relevant:: (optional) boolean value indicating whether the server should consider the file or package a potential source of metadata.
|
395
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
396
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
397
|
+
#
|
398
|
+
#For more information, see the Sword2 specification: {section 6.5.1. "Replacing the File Content of a Resource"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_editingcontent_binary].
|
399
|
+
def put_media!(params = {})
|
400
|
+
Utility.check_argument_class('params', params, Hash)
|
401
|
+
defaults = {
|
402
|
+
:filepath => nil,
|
403
|
+
:content_type => nil,
|
404
|
+
:packaging => nil,
|
405
|
+
:edit_media_uri => edit_media_links.first.href,
|
406
|
+
:on_behalf_of => nil,
|
407
|
+
:metadata_relevant => nil,
|
408
|
+
:connection => @http
|
409
|
+
}
|
410
|
+
options = defaults.merge(params)
|
411
|
+
|
412
|
+
#Validate parameters
|
413
|
+
Utility.check_argument_class(':filepath', options[:filepath], String)
|
414
|
+
Utility.check_argument_class(':content_type', options[:content_type], String)
|
415
|
+
Utility.check_argument_class(':packaging', options[:packaging], String) if options[:packaging]
|
416
|
+
Utility.check_argument_class(':edit_media_uri', options[:edit_media_uri], String)
|
417
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
418
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
419
|
+
|
420
|
+
filename, md5, data = Utility.read_file(options[:filepath])
|
421
|
+
|
422
|
+
headers = {"Content-Type" => options[:content_type]}
|
423
|
+
headers["Content-Disposition"] = "attachment; filename=#{filename}"
|
424
|
+
headers["Content-MD5"] = md5
|
425
|
+
headers["Packaging"] = options[:packaging] if options[:packaging]
|
426
|
+
headers["Metadata-Relevant"] = options[:metadata_relevant].to_s.downcase if (options[:metadata_relevant] == true || options[:metadata_relevant] == false)
|
427
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
428
|
+
|
429
|
+
response = options[:connection].put(options[:edit_media_uri], data, headers)
|
430
|
+
|
431
|
+
if response.is_a? Net::HTTPSuccess
|
432
|
+
return DepositReceipt.new(response, options[:connection])
|
433
|
+
else
|
434
|
+
raise Sword2Ruby::Exception.new("Failed to do put_media!(#{options[:edit_media_uri]}): server returned #{response.code} #{response.message}")
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
#This method replaces an existing entry's metadata and file content of a resource by performing a Put on the entry-edit URI.
|
441
|
+
#It <i>does not</i> create a new entry in the collection.
|
442
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
443
|
+
#
|
444
|
+
#===Parameters (passed as a hash collection)
|
445
|
+
#:entry:: (optional) a new Atom::Entry with metadata to replace an existing Atom::Entry. If not supplied, this will default to itself.
|
446
|
+
#:filepath:: a filepath string indicating the file to be sent. The file must be readable by the process.
|
447
|
+
#:content_type:: the mime content-type string of the file, e.g. "application/zip" or "text/plain"
|
448
|
+
#:packaging:: (optional) the Sword packaging string of the file, e.g. "http://purl.org/net/sword/package/METSDSpaceSIP"
|
449
|
+
#:entry_edit_uri:: (optional) an override to the existing entry's entry-edit URI. If not supplied, this will default to the existing entry's entry-edit URI.
|
450
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed.
|
451
|
+
#:metadata_relevant:: (optional) boolean value indicating whether the server should consider the file or package a potential source of metadata.
|
452
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
453
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
454
|
+
#
|
455
|
+
#For more information, see the Sword2 specification: {section 6.5.3. "Replacing the Metadata and File Content of a Resource"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_editingcontent_multipart].
|
456
|
+
def put_multipart!(params = {})
|
457
|
+
Utility.check_argument_class('params', params, Hash)
|
458
|
+
defaults = {
|
459
|
+
:entry => self,
|
460
|
+
:filepath => nil,
|
461
|
+
:content_type => nil,
|
462
|
+
:packaging => nil,
|
463
|
+
:entry_edit_uri => entry_edit_uri,
|
464
|
+
:in_progress => nil,
|
465
|
+
:on_behalf_of => nil,
|
466
|
+
:metadata_relevant => nil,
|
467
|
+
:connection => @http
|
468
|
+
}
|
469
|
+
options = defaults.merge(params)
|
470
|
+
|
471
|
+
#Validate parameters
|
472
|
+
Utility.check_argument_class(':entry', options[:entry], ::Atom::Entry)
|
473
|
+
Utility.check_argument_class(':filepath', options[:filepath], String)
|
474
|
+
Utility.check_argument_class(':content_type', options[:content_type], String)
|
475
|
+
Utility.check_argument_class(':packaging', options[:packaging], String) if options[:packaging]
|
476
|
+
Utility.check_argument_class(':entry_edit_uri', options[:entry_edit_uri], String)
|
477
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
478
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
479
|
+
|
480
|
+
tmp = ""
|
481
|
+
boundary = "========" + Time.now.to_i.to_s + "=="
|
482
|
+
filename, md5, data = Utility.read_file(options[:filepath])
|
483
|
+
|
484
|
+
|
485
|
+
headers = {"Content-Type" => 'multipart/related; boundary="' + boundary + '"; type="application/atom+xml"'}
|
486
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
487
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
488
|
+
headers["MIME-Version"] = "1.0"
|
489
|
+
|
490
|
+
# write boundary identifer to temp
|
491
|
+
tmp << "--#{boundary}\r\n"
|
492
|
+
|
493
|
+
# write entry relevant headers to temp
|
494
|
+
tmp << "Content-Type: application/atom+xml; charset=\"utf-8\"\r\n"
|
495
|
+
tmp << "Content-Disposition: attachment; name=atom\r\n"
|
496
|
+
tmp << "MIME-Version: 1.0\r\n\r\n"
|
497
|
+
|
498
|
+
# write entry to temp
|
499
|
+
tmp << options[:entry].to_s + "\r\n"
|
500
|
+
|
501
|
+
# write boundary identifier to temp
|
502
|
+
tmp << "--#{boundary}\r\n"
|
503
|
+
|
504
|
+
# write media part relevant headers to temp
|
505
|
+
tmp << "Content-Type: #{options[:content_type]}\r\n"
|
506
|
+
tmp << "Content-Disposition: attachment; name=payload; filename=#{filename}\r\n"
|
507
|
+
tmp << "Content-MD5: #{md5}\r\n"
|
508
|
+
tmp << "Packaging: #{options[:packaging]}\r\n" if options[:packaging]
|
509
|
+
tmp << "MIME-Version: 1.0\r\n\r\n"
|
510
|
+
|
511
|
+
# write the file base64 encoded to temp
|
512
|
+
tmp << Base64.encode64(data)
|
513
|
+
|
514
|
+
# write boundary identifier to temp
|
515
|
+
tmp << "--#{boundary}--\r\n" #The last two dashes (--) are important!
|
516
|
+
|
517
|
+
response = options[:connection].put(options[:entry_edit_uri], tmp, headers)
|
518
|
+
|
519
|
+
if response.is_a? Net::HTTPSuccess
|
520
|
+
return DepositReceipt.new(response, options[:connection])
|
521
|
+
else
|
522
|
+
raise Sword2Ruby::Exception.new("Failed to do put_multipart!(#{options[:entry_edit_uri]}): server returned #{response.code} #{response.message}")
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
|
527
|
+
#This method removes the container by performing a Delete on the entry-edit URI.
|
528
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
529
|
+
#
|
530
|
+
#===Parameters (passed as a hash collection)
|
531
|
+
#:entry_edit_uri:: (optional) an override to the existing entry's entry-edit URI. If not supplied, this will default to the existing entry's entry-edit URI.
|
532
|
+
#:on_behalf_of:: (optional) username on whos behalf the operation is being performed.
|
533
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
534
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
535
|
+
#
|
536
|
+
#For more information, see the Sword2 specification: {section 6.8. "Deleting the Container"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_deleteconteiner].
|
537
|
+
def delete!(params = {})
|
538
|
+
Utility.check_argument_class('params', params, Hash)
|
539
|
+
defaults = {
|
540
|
+
:entry_edit_uri => entry_edit_uri,
|
541
|
+
:on_behalf_of => nil,
|
542
|
+
:connection => @http
|
543
|
+
}
|
544
|
+
options = defaults.merge(params)
|
545
|
+
|
546
|
+
#Validate parameters
|
547
|
+
Utility.check_argument_class(':entry_edit_uri', options[:entry_edit_uri], String)
|
548
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
549
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
550
|
+
|
551
|
+
headers = {}
|
552
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
553
|
+
|
554
|
+
response = options[:connection].delete(options[:entry_edit_uri], nil, headers)
|
555
|
+
|
556
|
+
if response.is_a? Net::HTTPSuccess
|
557
|
+
return DepositReceipt.new(response, options[:connection])
|
558
|
+
else
|
559
|
+
raise Sword2Ruby::Exception.new("Failed to do delete!(#{options[:entry_edit_uri]}): server returned #{response.code} #{response.message}")
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
|
564
|
+
#This method removes all the content of a resource (without removing the resource itself) by performing a Delete on the edit-media URI.
|
565
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
566
|
+
#
|
567
|
+
#===Parameters (passed as a hash collection)
|
568
|
+
#:edit_media_uri:: (optional) an override to the existing entry's edit-media URI. If not supplied, this will default to the existing entry's first edit-media URI.
|
569
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed.
|
570
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing entry's connection will be used.
|
571
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
572
|
+
#
|
573
|
+
#For more information, see the Sword2 specification: {section 6.6. "Deleting the content of a Resource"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_deletingcontent].
|
574
|
+
def delete_media!(params = {})
|
575
|
+
Utility.check_argument_class('params', params, Hash)
|
576
|
+
defaults = {
|
577
|
+
:edit_media_uri => edit_media_links.first.href,
|
578
|
+
:on_behalf_of => nil,
|
579
|
+
:connection => @http
|
580
|
+
}
|
581
|
+
options = defaults.merge(params)
|
582
|
+
|
583
|
+
#Validate parameters
|
584
|
+
Utility.check_argument_class(':edit_media_uri', options[:edit_media_uri], String)
|
585
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
586
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
587
|
+
|
588
|
+
headers = {}
|
589
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
590
|
+
|
591
|
+
response = options[:connection].delete(options[:edit_media_uri], nil, headers)
|
592
|
+
|
593
|
+
if response.is_a? Net::HTTPSuccess
|
594
|
+
return DepositReceipt.new(response, options[:connection])
|
595
|
+
else
|
596
|
+
raise Sword2Ruby::Exception.new("Failed to do delete_media!(#{options[:edit_media_uri]}): server returned #{response.code} #{response.message}")
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
|
601
|
+
end
|
602
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'atom/feed'
|
2
|
+
|
3
|
+
module Sword2Ruby
|
4
|
+
|
5
|
+
#Extend existing Atom::Service with Sword methods
|
6
|
+
class ::Atom::Feed < ::Atom::Element
|
7
|
+
|
8
|
+
#This method returns an array of Atom::Categories of the original deposit (usually contained in the Sword Statement Atom Feed),
|
9
|
+
#or an empty array [ ] if none are defined.
|
10
|
+
#
|
11
|
+
#For more information, see the Sword2 specification: {section 11.4. "Atom Serialisation"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#statement_atom].
|
12
|
+
def sword_state_categories
|
13
|
+
Utility.find_elements_by_scheme(categories, "http://purl.org/net/sword/terms/state")
|
14
|
+
end
|
15
|
+
|
16
|
+
#This method returns the string href of the <sword:state> tag (usually contained in the Sword Statement Atom Feed),
|
17
|
+
#or nil if it is not defined.
|
18
|
+
#
|
19
|
+
#For more information, see the Sword2 specification: {section 11.1.2. "sword:state"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#statement_predicates_state].
|
20
|
+
def sword_state
|
21
|
+
Utility.find_element_attribute_value(extensions, "sword:state", "href")
|
22
|
+
end
|
23
|
+
|
24
|
+
#This method returns the string value of the <sword:stateDescription> tag (usually contained in the Sword Statement Atom Feed),
|
25
|
+
#or nil if it is not defined.
|
26
|
+
#
|
27
|
+
#For more information, see the Sword2 specification: {section 11.1.7. "sword:state"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#statement_predicates_description].
|
28
|
+
def sword_state_description
|
29
|
+
swordstate = Utility.find_element_by_name(extensions, "sword:state")
|
30
|
+
swordstate.nil? ? nil : Utility.find_element_text(swordstate.elements, "sword:stateDescription")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|