gi_cat_driver 0.2.10 → 0.2.11
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/lib/gi_cat_driver.rb +22 -22
- data/lib/gi_cat_driver/version.rb +1 -1
- metadata +1 -1
data/lib/gi_cat_driver.rb
CHANGED
@@ -19,8 +19,8 @@ module GiCatDriver
|
|
19
19
|
OPENSEARCH_NAMESPACE = { "opensearch" => "http://a9.com/-/spec/opensearch/1.1/" }
|
20
20
|
RELEVANCE_NAMESPACE = { "relevance" => "http://a9.com/-/opensearch/extensions/relevance/1.0/" }
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
@standard_headers = { :content_type => "application/xml" }
|
23
|
+
@authorization_headers = { :content_type => "*/*", :Accept => "application/xml" }
|
24
24
|
|
25
25
|
attr_accessor :base_url
|
26
26
|
|
@@ -29,7 +29,7 @@ module GiCatDriver
|
|
29
29
|
@admin_username = username
|
30
30
|
@admin_password = password
|
31
31
|
|
32
|
-
|
32
|
+
@authorization_headers = @authorization_headers.merge({:Authorization => self.basic_auth_string})
|
33
33
|
end
|
34
34
|
|
35
35
|
# Basic Authorization used in the request headers
|
@@ -47,7 +47,7 @@ module GiCatDriver
|
|
47
47
|
response = Faraday.post do |req|
|
48
48
|
req.url "#{@base_url}/services/conf/brokerConfigurations/newBroker"
|
49
49
|
req.body = "inputNewName=#{profile_name}&nameBrokerCopy=%20"
|
50
|
-
req.headers =
|
50
|
+
req.headers = @authorization_headers.merge({'enctype' => 'multipart/form-data',:content_type => 'application/x-www-form-urlencoded'})
|
51
51
|
end
|
52
52
|
|
53
53
|
profile_id = response.body
|
@@ -59,7 +59,7 @@ module GiCatDriver
|
|
59
59
|
profile_id = find_profile_id( profile_name )
|
60
60
|
response = Faraday.get do |req|
|
61
61
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}", { :opts => 'delete', :random => generate_random_number }
|
62
|
-
req.headers =
|
62
|
+
req.headers = @authorization_headers.merge({'enctype'=>'multipart/form-data'})
|
63
63
|
end
|
64
64
|
|
65
65
|
profile_id = response.body
|
@@ -71,7 +71,7 @@ module GiCatDriver
|
|
71
71
|
def find_profile_id( profile_name )
|
72
72
|
response = Faraday.get do |req|
|
73
73
|
req.url "#{@base_url}/services/conf/brokerConfigurations", :nameRepository => 'gicat'
|
74
|
-
req.headers =
|
74
|
+
req.headers = @authorization_headers
|
75
75
|
end
|
76
76
|
|
77
77
|
profile_id = parse_profile_element(profile_name, response.body)
|
@@ -83,7 +83,7 @@ module GiCatDriver
|
|
83
83
|
def get_active_profile_id
|
84
84
|
response = Faraday.get do |req|
|
85
85
|
req.url "#{@base_url}/services/conf/giconf/configuration"
|
86
|
-
req.headers =
|
86
|
+
req.headers = @standard_headers
|
87
87
|
end
|
88
88
|
|
89
89
|
profile_id = response.body
|
@@ -94,7 +94,7 @@ module GiCatDriver
|
|
94
94
|
def enable_profile( profile_name )
|
95
95
|
Faraday.get do |req|
|
96
96
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{find_profile_id(profile_name)}?opts=active"
|
97
|
-
req.headers =
|
97
|
+
req.headers = @authorization_headers
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -156,7 +156,7 @@ module GiCatDriver
|
|
156
156
|
|
157
157
|
response = Faraday.post do |req|
|
158
158
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/distributors/#{distributor_id}"
|
159
|
-
req.headers =
|
159
|
+
req.headers = @authorization_headers.merge({:enctype=>'multipart/form-data', :content_type=>'application/x-www-form-urlencoded'})
|
160
160
|
req.body = accessor_configuration
|
161
161
|
end
|
162
162
|
|
@@ -177,7 +177,7 @@ module GiCatDriver
|
|
177
177
|
|
178
178
|
Faraday.get do |req|
|
179
179
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/harvesters/#{harvester_id}", { :delete => 'true', :random => generate_random_number }
|
180
|
-
req.headers =
|
180
|
+
req.headers = @authorization_headers.merge({:enctype=>'multipart/form-data'})
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
@@ -188,7 +188,7 @@ module GiCatDriver
|
|
188
188
|
|
189
189
|
response = Faraday.post do |req|
|
190
190
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/profilers/"
|
191
|
-
req.headers =
|
191
|
+
req.headers = @authorization_headers.merge({:enctype=>'multipart/form-data', :content_type=>'application/x-www-form-urlencoded'})
|
192
192
|
req.body = interface_configuration
|
193
193
|
end
|
194
194
|
|
@@ -200,7 +200,7 @@ module GiCatDriver
|
|
200
200
|
|
201
201
|
Faraday.get do |req|
|
202
202
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/profilers/#{interface_name}", { :delete => 'true', :random => generate_random_number }
|
203
|
-
req.headers =
|
203
|
+
req.headers = @authorization_headers.merge({:enctype=>'multipart/form-data', :content_type=>'application/x-www-form-urlencoded'})
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -213,13 +213,13 @@ module GiCatDriver
|
|
213
213
|
Faraday.put do |req|
|
214
214
|
req.url enable_lucene_request
|
215
215
|
req.body = enabled.to_s
|
216
|
-
req.headers =
|
216
|
+
req.headers = @authorization_headers
|
217
217
|
req.options[:timeout] = 300
|
218
218
|
end
|
219
219
|
|
220
220
|
activate_profile_request = "#{@base_url}/services/conf/brokerConfigurations/#{get_active_profile_id}"
|
221
221
|
Faraday.get(activate_profile_request, { :opts => "active" },
|
222
|
-
|
222
|
+
@authorization_headers)
|
223
223
|
end
|
224
224
|
|
225
225
|
# Retrieve the harvester id given a profile name and accessor name
|
@@ -238,7 +238,7 @@ module GiCatDriver
|
|
238
238
|
active_profile_request = "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}"
|
239
239
|
response = Faraday.get do |req|
|
240
240
|
req.url active_profile_request
|
241
|
-
req.headers =
|
241
|
+
req.headers = @authorization_headers
|
242
242
|
end
|
243
243
|
distributor_id = Nokogiri.XML(response.body).css("component id").text
|
244
244
|
return distributor_id
|
@@ -249,7 +249,7 @@ module GiCatDriver
|
|
249
249
|
harvester_request = "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/distributors/#{distributor_id}"
|
250
250
|
response = Faraday.get do |req|
|
251
251
|
req.url harvester_request
|
252
|
-
req.headers =
|
252
|
+
req.headers = @authorization_headers
|
253
253
|
end
|
254
254
|
harvester_id = Nokogiri.XML(response.body).css("component id").text
|
255
255
|
return harvester_id
|
@@ -260,7 +260,7 @@ module GiCatDriver
|
|
260
260
|
accessor_request = "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/harvesters/#{harvester_id}"
|
261
261
|
response = Faraday.get do |req|
|
262
262
|
req.url accessor_request
|
263
|
-
req.headers =
|
263
|
+
req.headers = @authorization_headers
|
264
264
|
end
|
265
265
|
accessor_id = Nokogiri.XML(response.body).css("component id").text
|
266
266
|
return accessor_id
|
@@ -270,7 +270,7 @@ module GiCatDriver
|
|
270
270
|
accessor_request = "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/accessors/#{accessor_id}"
|
271
271
|
response = Faraday.get do |req|
|
272
272
|
req.url accessor_request
|
273
|
-
req.headers =
|
273
|
+
req.headers = @authorization_headers
|
274
274
|
end
|
275
275
|
accessor = Nokogiri.XML(response.body).css("accessor name").text
|
276
276
|
return accessor
|
@@ -282,7 +282,7 @@ module GiCatDriver
|
|
282
282
|
harvest_resource_request = "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/distributors/#{id}"
|
283
283
|
response = Faraday.get do |req|
|
284
284
|
req.url harvest_resource_request
|
285
|
-
req.headers =
|
285
|
+
req.headers = @authorization_headers
|
286
286
|
end
|
287
287
|
doc = Nokogiri::XML(response.body)
|
288
288
|
harvestersinfo_array = {}
|
@@ -296,7 +296,7 @@ module GiCatDriver
|
|
296
296
|
def harvest_resource_for_active_configuration(harvesterid, harvestername = "n/a")
|
297
297
|
response = Faraday.get do |req|
|
298
298
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{self.get_active_profile_id}/harvesters/#{harvesterid}/start"
|
299
|
-
req.headers =
|
299
|
+
req.headers = @authorization_headers
|
300
300
|
end
|
301
301
|
|
302
302
|
if response.status == 200
|
@@ -317,7 +317,7 @@ module GiCatDriver
|
|
317
317
|
|
318
318
|
response = Faraday.get do |req|
|
319
319
|
req.url request
|
320
|
-
req.headers =
|
320
|
+
req.headers = @authorization_headers
|
321
321
|
end
|
322
322
|
|
323
323
|
status = parse_status_xml(response.body, harvester_name)
|
@@ -372,7 +372,7 @@ module GiCatDriver
|
|
372
372
|
def update_accessor_configuration( profile_id, accessor_id, accessor_configuration )
|
373
373
|
response = Faraday.post do |req|
|
374
374
|
req.url "#{@base_url}/services/conf/brokerConfigurations/#{profile_id}/accessors/#{accessor_id}/update"
|
375
|
-
req.headers =
|
375
|
+
req.headers = @authorization_headers.merge({:enctype=>'multipart/form-data', :content_type=>'application/x-www-form-urlencoded'})
|
376
376
|
req.body = accessor_configuration
|
377
377
|
end
|
378
378
|
return response.body
|