spiderfw 0.6.32 → 0.6.33
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.
- checksums.yaml +5 -5
- data/CHANGELOG +12 -0
- data/VERSION +1 -1
- data/apps/cas_server/config/options.rb +1 -0
- data/apps/cas_server/controllers/mixins/cas_login_mixin.rb +48 -13
- data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.js +8 -3
- data/apps/core/components/public/js/spider.js +4 -1
- data/apps/core/components/widgets/search_table/search_table.rb +4 -0
- data/apps/core/components/widgets/table/table.shtml +5 -5
- data/apps/core/forms/widgets/inputs/file_input/file_input.rb +1 -1
- data/apps/messenger/controllers/mixins/messenger_helper.rb +14 -6
- data/lib/spiderfw/http/adapters/rack.rb +9 -4
- data/lib/spiderfw/http/adapters/webrick.rb +2 -2
- data/lib/spiderfw/http/server.rb +4 -2
- data/lib/spiderfw/model/base_model.rb +25 -2
- data/lib/spiderfw/model/storage/db/adapters/oracle.rb +15 -3
- data/lib/spiderfw/setup/spider_setup_wizard.rb +106 -3
- data/lib/spiderfw/utils/monkey/object.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA1:
|
3
|
-
data.tar.gz: ed9ddb5b4c1865b4c31b437e6bb1460d3f5f5392
|
4
|
-
metadata.gz: bde80c29ac3242b2ece307d7d44c5ff87bc68c94
|
5
2
|
SHA512:
|
6
|
-
|
7
|
-
|
3
|
+
metadata.gz: 4873d682965b148d70ade3af10f990ce93457765fda2938ee24581e26aed8610763b6bc9c6e07f5d945c53fdaf4fa60283d8d0ec98bd4e69f6532531f45eee38
|
4
|
+
data.tar.gz: 5fdaa46959c9faceae5a35c09dc82bbfb5f1c2de98225b040a4d22193280f7a58645f3f50de5a1443d760b256408f3d8e1c5a4a1f63c53decfffa5c17f2c3ab9
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: 29e74e4cba2547d4454dafb8a774f87038a09c15
|
7
|
+
data.tar.gz: 04caf2f5945b4807d75f4c6843a25a05a2e50dea
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 0.6.33
|
2
|
+
* Modifiche per problemi con accenti e chiamate json
|
3
|
+
* Encode aggiunto su funzione inspect
|
4
|
+
* Corretto problemi in search_table che mantiene il parametro per la ricerca
|
5
|
+
* Fatta conversione per invio delle mail con dati nella scene accentati
|
6
|
+
* Usato force_encoding per invio della mail su tutti i campi della scene
|
7
|
+
* Settato a true il single sign out del Cas
|
8
|
+
* Fatto metodo ricorsivo per convertire un oggetto ruby in utf8 e cambiato il messenger helper
|
9
|
+
* Aggiunto a livello di classe Object un metodo per convertire ricorsivamente in utf8 le stringhe nell'oggetto passato
|
10
|
+
* Implementato metodo logout_cas in cas_login_mixin
|
11
|
+
* Modifiche per CAS, cambiato lambda con Proc.new
|
12
|
+
|
1
13
|
== 0.6.32
|
2
14
|
* Correzioni per gestione transazioni e metodi per lista per mod cms
|
3
15
|
* Aggiunto il force_encoding sui campi della mail per problemi con accenti
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.33
|
@@ -6,6 +6,7 @@ module Spider
|
|
6
6
|
config_option 'cas.proxy_granting_ticket_expiry', :type => Fixnum, :default => 48*60*60
|
7
7
|
config_option 'cas.ticket_granting_ticket_expiry', :type => Fixnum, :default => 48*60*60
|
8
8
|
config_option 'cas.saml1_1_compatible', :type => Spider::DataTypes::Bool, :default => false
|
9
|
+
config_option 'cas.enable_single_sign_out', :type => Spider::DataTypes::Bool, :default => true
|
9
10
|
config_option 'cas.saml_compliant_tickets', :type => String, :choices => [false, '1', '2', '4'], :default => lambda{
|
10
11
|
Spider.conf.get('cas.saml1_1_compatible') ? '1' : false
|
11
12
|
}
|
@@ -185,19 +185,6 @@ module Spider; module CASServer
|
|
185
185
|
$LOG.debug("Deleting #{tgt.class.name} '#{tgt}' for user '#{tgt.username}'")
|
186
186
|
tgt.delete
|
187
187
|
|
188
|
-
if Spider.conf.get('cas.enable_single_sign_out')
|
189
|
-
$LOG.debug("Deleting Service/Proxy Tickets for '#{tgt}' for user '#{tgt.username}'")
|
190
|
-
tgt.service_tickets.each do |st|
|
191
|
-
send_logout_notification_for_service_ticket(st)
|
192
|
-
# TODO: Maybe we should do some special handling if send_logout_notification_for_service_ticket fails?
|
193
|
-
# (the above method returns false if the POST results in a non-200 HTTP response).
|
194
|
-
$LOG.debug "Deleting #{st.class.name} #{st.ticket.inspect}."
|
195
|
-
st.delete
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
$LOG.debug("Deleting #{tgt.class.name} '#{tgt}' for user '#{tgt.username}'")
|
200
|
-
tgt.delete
|
201
188
|
end
|
202
189
|
|
203
190
|
$LOG.info("User '#{tgt.username}' logged out.")
|
@@ -214,6 +201,54 @@ module Spider; module CASServer
|
|
214
201
|
end
|
215
202
|
end
|
216
203
|
|
204
|
+
#metodo chiamato dal logout del portale
|
205
|
+
def logout_cas(username)
|
206
|
+
tgt_qs = TicketGrantingTicket.where(:username => username)
|
207
|
+
if tgt_qs
|
208
|
+
tgt_qs.each{ |tgt|
|
209
|
+
#inizio la transazione
|
210
|
+
TicketGrantingTicket.storage.start_transaction
|
211
|
+
begin
|
212
|
+
# cancello i ServiceTicket
|
213
|
+
service_tickets = tgt.service_tickets
|
214
|
+
unless service_tickets.blank?
|
215
|
+
service_tickets.each { |st|
|
216
|
+
send_logout_notification_for_service_ticket(st)
|
217
|
+
$LOG.debug "Deleting #{st.class.name} #{st.ticket.inspect}."
|
218
|
+
st.delete
|
219
|
+
}
|
220
|
+
end
|
221
|
+
$LOG.info("User '#{tgt.username}' logged out.")
|
222
|
+
TicketGrantingTicket.storage.commit
|
223
|
+
rescue Exception => exc
|
224
|
+
TicketGrantingTicket.storage.rollback
|
225
|
+
Spider.logger.error "** Errore logout cas"
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
}
|
230
|
+
#cancello i TicketGrantingTicket
|
231
|
+
TicketGrantingTicket.storage.start_transaction
|
232
|
+
begin
|
233
|
+
tgt_qs.each{ |tgt|
|
234
|
+
tgt.delete
|
235
|
+
}
|
236
|
+
TicketGrantingTicket.storage.commit
|
237
|
+
rescue Exception => exc
|
238
|
+
TicketGrantingTicket.storage.rollback
|
239
|
+
Spider.logger.error "** Errore logout cas"
|
240
|
+
end
|
241
|
+
@request.cookies['tgt'] = nil
|
242
|
+
|
243
|
+
else
|
244
|
+
$LOG.warn("User tried to log out without a valid ticket-granting ticket")
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
217
252
|
def validate
|
218
253
|
@service = clean_service_url(@request.params['service'])
|
219
254
|
@ticket = @request.params['ticket']
|
@@ -183,9 +183,14 @@
|
|
183
183
|
* Select the first item of the new select
|
184
184
|
*/
|
185
185
|
selectFirstItem: function() {
|
186
|
-
|
187
|
-
|
188
|
-
|
186
|
+
$('option:eq(0)', this.$select).attr('selected', 'selected');
|
187
|
+
/* tolto la modifica del commit e3a8027037d4d02601d910f40794f103968088c2
|
188
|
+
per mettere selected su select dei permessi, rendeva lo stato bianco in modifica utente da admin */
|
189
|
+
/*
|
190
|
+
setTimeout(function(){
|
191
|
+
$('option:eq(0)', this.$select).attr('selected', 'selected');
|
192
|
+
}, 1000);
|
193
|
+
*/
|
189
194
|
},
|
190
195
|
|
191
196
|
/**
|
@@ -525,7 +525,10 @@ Spider.Controller = Class.extend({
|
|
525
525
|
params = null;
|
526
526
|
}
|
527
527
|
if (!callback) callback = function(){};
|
528
|
-
var url = this.url+'/'+method
|
528
|
+
var url = this.url+'/'+method;
|
529
|
+
if( options == null || options['dataType'] == null || options['dataType'] == 'json'){
|
530
|
+
url = url+'.json';
|
531
|
+
}
|
529
532
|
var defaults = {
|
530
533
|
url: url,
|
531
534
|
type: 'POST',
|
@@ -32,20 +32,20 @@
|
|
32
32
|
<div sp:if="!@pages.blank? && @pages > 1" class="pagination">
|
33
33
|
<ul>
|
34
34
|
<li sp:if="@page > 1">
|
35
|
-
<a class="prev" href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page-1 }">← _(Previous)</a>
|
35
|
+
<a class="prev" href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page-1 }{ ( @query.blank? ? nil : '&_w'+@widget[:param]+'[q]='+@query ) }">← _(Previous)</a>
|
36
36
|
</li>
|
37
37
|
<li sp:if="@page == 1" class="disabled">
|
38
38
|
<a class="prev disabled">← _(Previous)</a>
|
39
39
|
</li>
|
40
40
|
<sp:pass sp:if="@paginate_first > 1">
|
41
41
|
<li>
|
42
|
-
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]=1" class="page">1</a>
|
42
|
+
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]=1{ ( @query.blank? ? nil : '&_w'+@widget[:param]+'[q]='+@query ) }" class="page">1</a>
|
43
43
|
</li>
|
44
44
|
<li class="disabled"><a>...</a></li>
|
45
45
|
</sp:pass>
|
46
46
|
<sp:pass sp:each="(@paginate_first..@paginate_last) |i|" >
|
47
47
|
<li sp:if="i != @page">
|
48
|
-
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ i }" class="page">
|
48
|
+
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ i }{ ( @query.blank? ? nil : '&_w'+@widget[:param]+'[q]='+@query ) }" class="page">
|
49
49
|
{ i }
|
50
50
|
</a>
|
51
51
|
</li>
|
@@ -58,11 +58,11 @@
|
|
58
58
|
<a>...</a>
|
59
59
|
</li>
|
60
60
|
<li>
|
61
|
-
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @pages }" class="page">{ @pages }</a>
|
61
|
+
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @pages }{ ( @query.blank? ? nil : '&_w'+@widget[:param]+'[q]='+@query ) }" class="page">{ @pages }</a>
|
62
62
|
</li>
|
63
63
|
</sp:pass>
|
64
64
|
<li sp:if="@has_more">
|
65
|
-
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page+1 }">_(Next) →</a>
|
65
|
+
<a href="{ @request[:path] }?_w{ @widget[:param] }[page]={ @page+1 }{ ( @query.blank? ? nil : '&_w'+@widget[:param]+'[q]='+@query ) }">_(Next) →</a>
|
66
66
|
</li>
|
67
67
|
<li sp:if="!@has_more" class="disabled">
|
68
68
|
<a class="next disabled">_(Next) →</a>
|
@@ -7,7 +7,7 @@ module Spider; module Forms
|
|
7
7
|
|
8
8
|
class FileInput < Input
|
9
9
|
tag 'file'
|
10
|
-
is_attr_accessor :save_path, :type => String, :default =>
|
10
|
+
is_attr_accessor :save_path, :type => String, :default => Proc.new{ Spider.paths[:var]+'/data/uploaded_files' }
|
11
11
|
|
12
12
|
def needs_multipart?
|
13
13
|
true
|
@@ -33,25 +33,33 @@ module Spider; module Messenger
|
|
33
33
|
msg
|
34
34
|
end
|
35
35
|
|
36
|
+
|
37
|
+
|
38
|
+
|
36
39
|
def self.send_email(klass, template, scene, from, to, headers={}, attachments=[], params={})
|
37
40
|
path_txt = klass.find_resource_path(:email, template+'.txt')
|
38
41
|
path_txt = nil unless path_txt && File.exist?(path_txt)
|
39
42
|
path_html = klass.find_resource_path(:email, template+'.html')
|
40
43
|
path_html = nil unless path_html && File.exist?(path_html)
|
44
|
+
|
45
|
+
#converte l'intera scene con ricorsione in utf-8 per evitare problemi in invio mail
|
46
|
+
scene.convert_object
|
47
|
+
|
41
48
|
scene_binding = scene.instance_eval{ binding }
|
42
49
|
if (path_txt || path_html)
|
43
|
-
text = ERB.new(IO.read(path_txt)).result(scene_binding) if path_txt
|
44
|
-
html = ERB.new(IO.read(path_html)).result(scene_binding) if path_html
|
50
|
+
text = ERB.new( IO.read(path_txt) ).result(scene_binding) if path_txt
|
51
|
+
html = ERB.new( IO.read(path_html) ).result(scene_binding) if path_html
|
45
52
|
else
|
46
53
|
path = klass.find_resource_path(:email, template)
|
47
|
-
text = ERB.new(IO.read(path)).result(scene_binding)
|
54
|
+
text = ERB.new( IO.read(path) ).result(scene_binding)
|
48
55
|
end
|
56
|
+
|
49
57
|
mail = Mail.new
|
50
|
-
mail[:to] =
|
51
|
-
mail[:from] =
|
58
|
+
mail[:to] = to.convert_object
|
59
|
+
mail[:from] = from.convert_object
|
52
60
|
mail.charset = "UTF-8"
|
53
61
|
headers.each do |key, value|
|
54
|
-
mail[key] =
|
62
|
+
mail[key] = value.convert_object
|
55
63
|
end
|
56
64
|
|
57
65
|
if html
|
@@ -32,8 +32,13 @@ module Spider; module HTTP
|
|
32
32
|
def write(msg)
|
33
33
|
send_headers unless @headers_sent
|
34
34
|
#workaround per ruby 1.9.3, problemi su parte di admin, faccio force encoding a utf8
|
35
|
-
|
36
|
-
|
35
|
+
unless msg.to_s.blank?
|
36
|
+
msg_dup = msg.to_s.dup
|
37
|
+
@w.write(msg_dup.respond_to?(:force_encoding) ? msg_dup.force_encoding('UTF-8') : msg_dup)
|
38
|
+
else
|
39
|
+
@w.write(msg)
|
40
|
+
end
|
41
|
+
|
37
42
|
end
|
38
43
|
|
39
44
|
def send_headers
|
@@ -104,8 +109,8 @@ module Spider; module HTTP
|
|
104
109
|
|
105
110
|
controller = nil
|
106
111
|
controller_done = false
|
107
|
-
|
108
|
-
run_block =
|
112
|
+
|
113
|
+
run_block = Proc.new do
|
109
114
|
begin
|
110
115
|
controller = ::Spider::HTTPController.new(controller_request, controller_response)
|
111
116
|
controller.extend(Spider::FirstResponder)
|
@@ -127,8 +127,8 @@ module Spider; module HTTP
|
|
127
127
|
|
128
128
|
|
129
129
|
controller_done = false
|
130
|
-
|
131
|
-
run_block =
|
130
|
+
|
131
|
+
run_block = Proc.new do
|
132
132
|
begin
|
133
133
|
controller = ::Spider::HTTPController.new(controller_request, controller_response)
|
134
134
|
controller.extend(Spider::FirstResponder)
|
data/lib/spiderfw/http/server.rb
CHANGED
@@ -114,14 +114,16 @@ module Spider; module HTTP
|
|
114
114
|
ssl_server = ssl_rack.server if ssl_rack
|
115
115
|
end
|
116
116
|
end
|
117
|
-
do_shutdown =
|
117
|
+
do_shutdown = Proc.new{
|
118
118
|
Debugger.post_mortem = false if defined?(Debugger)
|
119
119
|
server.shutdown if server
|
120
120
|
ssl_server.shutdown if ssl_server
|
121
|
+
|
121
122
|
pid_file = File.join(Spider.paths[:var], 'run/server.pid')
|
122
123
|
begin
|
123
124
|
File.unlink(pid_file)
|
124
125
|
rescue Errno::ENOENT
|
126
|
+
Spider.logger.info "Unlink del pid file non riuscito"
|
125
127
|
end
|
126
128
|
}
|
127
129
|
Spider.on_shutdown(&do_shutdown)
|
@@ -205,7 +207,7 @@ module Spider; module HTTP
|
|
205
207
|
|
206
208
|
unless @already_forked
|
207
209
|
Spider.main_process_startup
|
208
|
-
exit_spawner =
|
210
|
+
exit_spawner = Proc.new{
|
209
211
|
Spider.logger.debug "Spawner exiting"
|
210
212
|
Process.kill 'KILL', @monitor_thread[:spawner_child_pid]
|
211
213
|
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
require 'spiderfw/model/mixins/state_machine'
|
2
3
|
require 'spiderfw/model/element'
|
3
4
|
require 'spiderfw/model/integrated_element'
|
@@ -2382,9 +2383,24 @@ module Spider; module Model
|
|
2382
2383
|
# A compact representation of the object.
|
2383
2384
|
# Note: inspect will not autoload the object.
|
2384
2385
|
def inspect
|
2386
|
+
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') if RUBY_VERSION =~ /1.8/
|
2387
|
+
enc = Spider.conf.get('storages')['default']['encoding']
|
2388
|
+
enc ||= 'UTF-8'
|
2389
|
+
|
2385
2390
|
self.class.name+': {' +
|
2386
2391
|
self.class.elements_array.select{ |el| (element_loaded?(el) || element_has_value?(el)) && !el.hidden? } \
|
2387
|
-
.map{ |el|
|
2392
|
+
.map{ |el|
|
2393
|
+
val = get(el.name).to_s
|
2394
|
+
if RUBY_VERSION =~ /1.8/
|
2395
|
+
val = ic.iconv(val + ' ')[0..-2]
|
2396
|
+
else
|
2397
|
+
begin
|
2398
|
+
val = ((val+' ').encode('UTF-8', enc, :invalid => :replace, :undef => :replace))[0..-2] if val
|
2399
|
+
rescue EncodingError
|
2400
|
+
val = ''
|
2401
|
+
end
|
2402
|
+
end
|
2403
|
+
":#{el.name} => #{val}"}.join(',') + '}'
|
2388
2404
|
end
|
2389
2405
|
|
2390
2406
|
# Returns a JSON representation of the object.
|
@@ -2427,11 +2443,18 @@ module Spider; module Model
|
|
2427
2443
|
val ? "#{name.to_json}: #{val.to_json}" : nil
|
2428
2444
|
else
|
2429
2445
|
val = get(name)
|
2446
|
+
enc = Spider.conf.get('storages')['default']['encoding']
|
2447
|
+
enc ||= 'UTF-8'
|
2448
|
+
|
2430
2449
|
if (el.type == String || el.type == Text)
|
2431
2450
|
if RUBY_VERSION =~ /1.8/
|
2432
2451
|
val = ic.iconv(val + ' ')[0..-2]
|
2433
2452
|
else
|
2434
|
-
|
2453
|
+
begin
|
2454
|
+
val = ((val+' ').encode('UTF-8', enc, :invalid => :replace, :undef => :replace))[0..-2] if val
|
2455
|
+
rescue EncodingError
|
2456
|
+
val = ''
|
2457
|
+
end
|
2435
2458
|
end
|
2436
2459
|
end
|
2437
2460
|
val = val.to_json
|
@@ -21,8 +21,22 @@ module Spider; module Model; module Storage; module Db
|
|
21
21
|
super << Spider::DataTypes::Binary
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.parse_url(url)
|
25
|
+
# db:oracle://<username:password>:connect_role@<database>
|
26
|
+
# where database is
|
27
|
+
# the net8 connect descriptor (TNS) or
|
28
|
+
# for Oracle client 10g or later, hostname_or_ip:port_no/oracle_sid
|
29
|
+
if (url =~ /.+:\/\/(?:(.+):(.+)(?::(.+))?@)?(.+)/)
|
30
|
+
@user = $1
|
31
|
+
@pass = $2
|
32
|
+
@role = $3
|
33
|
+
@dbname = $4
|
34
|
+
else
|
35
|
+
raise ArgumentError, "Oracle url '#{url}' is invalid"
|
36
|
+
end
|
37
|
+
@connection_params = [@user, @pass, @dbname, @role]
|
38
|
+
end
|
24
39
|
|
25
|
-
|
26
40
|
def parse_url(url)
|
27
41
|
# db:oracle://<username:password>:connect_role@<database>
|
28
42
|
# where database is
|
@@ -39,8 +53,6 @@ module Spider; module Model; module Storage; module Db
|
|
39
53
|
@connection_params = [@user, @pass, @dbname, @role]
|
40
54
|
end
|
41
55
|
|
42
|
-
|
43
|
-
|
44
56
|
def value_for_condition(type, value)
|
45
57
|
return value if value.nil?
|
46
58
|
super
|
@@ -16,7 +16,7 @@ module Spider
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def ask_error
|
19
|
-
res = ask?
|
19
|
+
res = (ask? _("Do you want to change your settings?"), :default => true)
|
20
20
|
!res
|
21
21
|
end
|
22
22
|
|
@@ -69,7 +69,7 @@ module Spider
|
|
69
69
|
|
70
70
|
print prompt
|
71
71
|
|
72
|
-
res = $stdin.gets.strip
|
72
|
+
res = $stdin.gets.strip
|
73
73
|
|
74
74
|
good = true
|
75
75
|
if options[:type] == Spider::Bool
|
@@ -181,13 +181,14 @@ module Spider
|
|
181
181
|
|
182
182
|
end
|
183
183
|
|
184
|
+
|
184
185
|
class SpiderSetupWizard < Wizard
|
185
186
|
attr_accessor :first_run
|
186
187
|
|
187
188
|
def run
|
188
189
|
|
189
190
|
if ask? _("Do you want to configure a database?"), :default => (@first_run ? true : nil)
|
190
|
-
ask _("Which database do you want to configure?"), :db_label, :default => 'default'
|
191
|
+
ask _("Which database do you want to configure?"), :db_label, :choices => ['default', 'civiliaopen', 'tracciatointermedio'], :default => 'default'
|
191
192
|
conf = Spider.conf.get("storages.#{@db_label}")
|
192
193
|
url_db_type = nil
|
193
194
|
if conf && conf["url"]
|
@@ -372,6 +373,108 @@ module Spider
|
|
372
373
|
end
|
373
374
|
|
374
375
|
class OracleSetupWizard < Wizard
|
376
|
+
def run
|
377
|
+
|
378
|
+
require 'rubygems'
|
379
|
+
require 'rubygems/command.rb'
|
380
|
+
require 'rubygems/dependency_installer.rb'
|
381
|
+
unless Spider.gem_available?('ruby-oci8')
|
382
|
+
if ask? _("Oracle gem is not available. Install?")
|
383
|
+
ok = false
|
384
|
+
while !ok
|
385
|
+
inst = Gem::DependencyInstaller.new
|
386
|
+
begin
|
387
|
+
inst.install 'ruby-oci8'
|
388
|
+
rescue
|
389
|
+
error _("Installation of oracle gem failed.")
|
390
|
+
puts _(
|
391
|
+
"The oracle gem failed to compile, so the pure-ruby version was installed.
|
392
|
+
You should install the compiled version manually for better performance.")
|
393
|
+
end
|
394
|
+
end
|
395
|
+
else
|
396
|
+
error _("Can't configure oracle without the ruby-oci8 gem.")
|
397
|
+
return
|
398
|
+
end
|
399
|
+
end
|
400
|
+
require 'oci8'
|
401
|
+
|
402
|
+
ok = false
|
403
|
+
while !ok
|
404
|
+
if (ask _("Do you want to connect via tns or direct connection?"),
|
405
|
+
:choices => ['tns', 'direct']) == 'tns'
|
406
|
+
ask! _("Tns:"), :tns, :default => 'ORCL'
|
407
|
+
ask _("Username"), :user
|
408
|
+
ask _("Password"), :pass
|
409
|
+
begin
|
410
|
+
m = ::OCI8.new(@user, @pass, @tns)
|
411
|
+
m.ping
|
412
|
+
m.logoff
|
413
|
+
connect_ok = true
|
414
|
+
ok = true
|
415
|
+
notify_partial("Ok.", true)
|
416
|
+
rescue => myerr
|
417
|
+
if myerr.exception.code == 1017
|
418
|
+
notify_partial("Connection failed.", true)
|
419
|
+
error _("Username or Password invalid.")
|
420
|
+
elsif myerr.exception.code == 12154
|
421
|
+
notify_partial("Connection failed.", true)
|
422
|
+
error _("Tns seems not responding.")
|
423
|
+
else
|
424
|
+
notify_partial("", true)
|
425
|
+
error _("Connection failed.")
|
426
|
+
end
|
427
|
+
ok = ask_error
|
428
|
+
end
|
429
|
+
else
|
430
|
+
ask _("Host:"), :host, :default => 'localhost'
|
431
|
+
ask _("Port:"), :port, :default => 1521
|
432
|
+
ask _("Tns:"), :tns, :default => 'ORCL'
|
433
|
+
ask _("Username"), :user
|
434
|
+
ask _("Password"), :pass
|
435
|
+
@db_name = "//#{@host}:#{@port}/#{@tns}"
|
436
|
+
begin
|
437
|
+
m = ::OCI8.new(@user, @pass, @db_name)
|
438
|
+
ok = true
|
439
|
+
m.logoff
|
440
|
+
rescue => myerr
|
441
|
+
if myerr.exception.code == 1017
|
442
|
+
notify_partial("Connection failed.", true)
|
443
|
+
error _("Username or Password invalid.")
|
444
|
+
elsif myerr.exception.code == 12154
|
445
|
+
notify_partial("Connection failed.", true)
|
446
|
+
error _("Server seems not responding.")
|
447
|
+
else
|
448
|
+
notify_partial("", true)
|
449
|
+
error _("Connection failed.")
|
450
|
+
end
|
451
|
+
ok = ask_error
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
def self.parse_db_name(db_name)
|
458
|
+
if (db_name =~ /(?:(.+):(.+))\/(?:(.+))/)
|
459
|
+
@host =$1
|
460
|
+
@port = $2
|
461
|
+
@tns = $3
|
462
|
+
else
|
463
|
+
@tns = db_name
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
def get_url
|
468
|
+
return "db:oracle://#{@user}:#{@pass}@#{@host}:#{@port}/#{@tns}" if @user && @pass && @host && @port && @tns
|
469
|
+
return "db:oracle://#{@user}:#{@pass}@#{@tns}" if @user && @pass && @tns
|
470
|
+
return nil
|
471
|
+
end
|
472
|
+
|
473
|
+
def parse_url(url)
|
474
|
+
@user, @pass, @db_name, @role = Spider::Model::Storage::Db::Oracle.parse_url(url)
|
475
|
+
self.class.parse_db_name(@db_name)
|
476
|
+
end
|
477
|
+
|
375
478
|
end
|
376
479
|
|
377
480
|
end
|
@@ -29,5 +29,37 @@ class Object
|
|
29
29
|
def blank?
|
30
30
|
respond_to?(:empty?) ? empty? : !self
|
31
31
|
end
|
32
|
+
|
33
|
+
#metodo ricorsivo per convertire in utf-8 tutto un oggetto con array o hash all'interno
|
34
|
+
def convert_object(encoding='UTF-8')
|
35
|
+
if self.respond_to?(:each_pair)
|
36
|
+
self.each_pair{ |chiave, valore|
|
37
|
+
valore.convert_object
|
38
|
+
}
|
39
|
+
elsif self.respond_to?(:each) && !self.is_a?(String)
|
40
|
+
#controllo se sto ciclando su un modello
|
41
|
+
if self.class < Spider::Model::BaseModel
|
42
|
+
#ritorna le chiavi degli elementi
|
43
|
+
|
44
|
+
self.class.elements.each_pair{ |chiave_hash_modello, valore_hash_modello|
|
45
|
+
self[chiave_hash_modello].convert_object unless self[chiave_hash_modello].respond_to?(:model)
|
46
|
+
}
|
47
|
+
else
|
48
|
+
#converto i singoli valori
|
49
|
+
self.each{ |valore_array|
|
50
|
+
valore_array.convert_object
|
51
|
+
}
|
52
|
+
end
|
53
|
+
elsif self.is_a?(String)
|
54
|
+
if RUBY_VERSION =~ /1.8/
|
55
|
+
require 'iconv'
|
56
|
+
self.replace(Iconv.iconv(encoding, encoding, self).first)
|
57
|
+
elsif RUBY_VERSION =~ /1.9/
|
58
|
+
self.replace(self.force_encoding(encoding))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
32
64
|
|
33
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spiderfw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Pirlik
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-19 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cmdparse
|