backlog 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Rakefile +2 -1
- data/app/controllers/application.rb +55 -8
- data/app/controllers/groups_controller.rb +62 -0
- data/app/controllers/periods_controller.rb +13 -55
- data/app/controllers/tasks_controller.rb +9 -5
- data/app/controllers/works_controller.rb +43 -6
- data/app/helpers/application_helper.rb +20 -2
- data/app/helpers/groups_helper.rb +2 -0
- data/app/models/backlog.rb +19 -10
- data/app/models/estimate.rb +2 -1
- data/app/models/group.rb +11 -0
- data/app/models/party.rb +3 -0
- data/app/models/period.rb +43 -6
- data/app/models/task.rb +27 -14
- data/app/models/user.rb +37 -8
- data/app/models/work.rb +4 -6
- data/app/views/backlogs/_name_list.rhtml +5 -0
- data/app/views/backlogs/show.rhtml +4 -4
- data/app/views/groups/_form.rhtml +7 -0
- data/app/views/groups/edit.rhtml +31 -0
- data/app/views/groups/list.rhtml +27 -0
- data/app/views/groups/new.rhtml +8 -0
- data/app/views/layouts/wide.rhtml +2 -2
- data/app/views/periods/_burn_down_chart.rhtml +1 -1
- data/app/views/periods/_form.rhtml +13 -9
- data/app/views/periods/_show_active.rhtml +6 -12
- data/app/views/periods/_title.rhtml +4 -5
- data/app/views/periods/edit.rhtml +1 -1
- data/app/views/periods/new.rhtml +1 -1
- data/app/views/periods/show.rhtml +10 -6
- data/app/views/tasks/_backlog_header.rhtml +22 -0
- data/app/views/tasks/_description_list.rhtml +5 -0
- data/app/views/tasks/_form.rhtml +26 -7
- data/app/views/tasks/_task.rhtml +4 -4
- data/app/views/tasks/edit.rhtml +2 -3
- data/app/views/tasks/list_started.rhtml +1 -0
- data/app/views/tasks/new.rhtml +2 -2
- data/app/views/works/_buttons.rhtml +3 -0
- data/app/views/works/_form.rhtml +15 -10
- data/app/views/works/daily_work_sheet.rhtml +30 -18
- data/app/views/works/edit.rhtml +4 -4
- data/app/views/works/list.rhtml +2 -2
- data/app/views/works/new.rhtml +3 -2
- data/app/views/works/weekly_work_sheet.rhtml +2 -2
- data/bin/backlog +2 -0
- data/bin/backlog_init.d_kubosch_production +27 -0
- data/bin/copy_production2development.rb +33 -0
- data/config/database.yml +13 -7
- data/config/deploy_kubosch.rb +1 -0
- data/config/environment.rb +2 -0
- data/config/environments/development_mysql.rb +27 -0
- data/config/environments/kubosch_production_mysql.rb +21 -0
- data/config/routes.rb +1 -1
- data/db/migrate/{001_tasks.rb → 001_create_tasks.rb} +1 -1
- data/db/migrate/{002_backlogs.rb → 002_create_backlogs.rb} +2 -2
- data/db/migrate/003_add_estimation_points.rb +1 -1
- data/db/migrate/004_add_period.rb +2 -2
- data/db/migrate/013_create_estimates.rb +1 -1
- data/db/migrate/015_add_user_option.rb +9 -5
- data/db/migrate/017_insert_datek_projects.rb +13 -10
- data/db/migrate/018_create_groups.rb +115 -0
- data/db/schema.rb +72 -12
- data/lang/en.yaml +7 -0
- data/lang/no.yaml +7 -0
- data/lib/big_decimal_yaml_fix.rb +27 -0
- data/lib/class_table_inheritance.rb +163 -0
- data/lib/tasks/backup.rake +92 -0
- data/public/images/person.org.png +0 -0
- data/public/images/person.png +0 -0
- data/public/stylesheets/backlog.css +3 -1
- data/public/stylesheets/mwrt002.css +1 -1
- data/test/fixtures/groups.yml +6 -0
- data/test/fixtures/parties.yml +31 -0
- data/test/fixtures/periods.yml +2 -2
- data/test/fixtures/tasks.yml +2 -0
- data/test/fixtures/users.yml +6 -6
- data/test/functional/backlogs_controller_test.rb +1 -1
- data/test/functional/groups_controller_test.rb +120 -0
- data/test/functional/periods_controller_test.rb +1 -1
- data/test/functional/tasks_controller_test.rb +16 -1
- data/test/functional/user_controller_test.rb +8 -2
- data/test/test_helper.rb +5 -0
- data/test/unit/big_decimal_yaml_fix_test.rb +14 -0
- data/test/unit/estimate_test.rb +1 -1
- data/test/unit/group_test.rb +10 -0
- data/test/unit/user_test.rb +56 -44
- data/tmp/sessions/ruby_sess.22dec3e9df47fb4e +0 -0
- data/tmp/sessions/ruby_sess.8037e0ab58cbcf1a +0 -0
- data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +35 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
- data/vendor/rails/{actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml → railties/configs/empty.log} +0 -0
- metadata +36 -105
- data/backlog.gemspec +0 -21
- data/vendor/rails/actionwebservice/CHANGELOG +0 -265
- data/vendor/rails/actionwebservice/MIT-LICENSE +0 -21
- data/vendor/rails/actionwebservice/README +0 -364
- data/vendor/rails/actionwebservice/Rakefile +0 -171
- data/vendor/rails/actionwebservice/TODO +0 -32
- data/vendor/rails/actionwebservice/examples/googlesearch/README +0 -143
- data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_api.rb +0 -50
- data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_controller.rb +0 -57
- data/vendor/rails/actionwebservice/examples/googlesearch/delegated/google_search_service.rb +0 -108
- data/vendor/rails/actionwebservice/examples/googlesearch/delegated/search_controller.rb +0 -7
- data/vendor/rails/actionwebservice/examples/googlesearch/direct/google_search_api.rb +0 -50
- data/vendor/rails/actionwebservice/examples/googlesearch/direct/search_controller.rb +0 -58
- data/vendor/rails/actionwebservice/examples/metaWeblog/README +0 -17
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_api.rb +0 -60
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_service.rb +0 -34
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_api.rb +0 -67
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb +0 -48
- data/vendor/rails/actionwebservice/examples/metaWeblog/controllers/xmlrpc_controller.rb +0 -16
- data/vendor/rails/actionwebservice/install.rb +0 -30
- data/vendor/rails/actionwebservice/lib/action_web_service.rb +0 -66
- data/vendor/rails/actionwebservice/lib/action_web_service/api.rb +0 -301
- data/vendor/rails/actionwebservice/lib/action_web_service/base.rb +0 -42
- data/vendor/rails/actionwebservice/lib/action_web_service/casting.rb +0 -138
- data/vendor/rails/actionwebservice/lib/action_web_service/client.rb +0 -3
- data/vendor/rails/actionwebservice/lib/action_web_service/client/base.rb +0 -28
- data/vendor/rails/actionwebservice/lib/action_web_service/client/soap_client.rb +0 -113
- data/vendor/rails/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb +0 -58
- data/vendor/rails/actionwebservice/lib/action_web_service/container.rb +0 -3
- data/vendor/rails/actionwebservice/lib/action_web_service/container/action_controller_container.rb +0 -93
- data/vendor/rails/actionwebservice/lib/action_web_service/container/delegated_container.rb +0 -86
- data/vendor/rails/actionwebservice/lib/action_web_service/container/direct_container.rb +0 -69
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher.rb +0 -2
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +0 -207
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +0 -379
- data/vendor/rails/actionwebservice/lib/action_web_service/invocation.rb +0 -202
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol.rb +0 -4
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/abstract.rb +0 -112
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb +0 -37
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +0 -176
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +0 -235
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +0 -122
- data/vendor/rails/actionwebservice/lib/action_web_service/scaffolding.rb +0 -283
- data/vendor/rails/actionwebservice/lib/action_web_service/struct.rb +0 -68
- data/vendor/rails/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb +0 -26
- data/vendor/rails/actionwebservice/lib/action_web_service/support/signature_types.rb +0 -226
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb +0 -65
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb +0 -6
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb +0 -29
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb +0 -30
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/test_invoke.rb +0 -110
- data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +0 -9
- data/vendor/rails/actionwebservice/setup.rb +0 -1379
- data/vendor/rails/actionwebservice/test/abstract_client.rb +0 -183
- data/vendor/rails/actionwebservice/test/abstract_dispatcher.rb +0 -551
- data/vendor/rails/actionwebservice/test/abstract_unit.rb +0 -45
- data/vendor/rails/actionwebservice/test/api_test.rb +0 -102
- data/vendor/rails/actionwebservice/test/apis/auto_load_api.rb +0 -3
- data/vendor/rails/actionwebservice/test/apis/broken_auto_load_api.rb +0 -2
- data/vendor/rails/actionwebservice/test/base_test.rb +0 -42
- data/vendor/rails/actionwebservice/test/casting_test.rb +0 -86
- data/vendor/rails/actionwebservice/test/client_soap_test.rb +0 -153
- data/vendor/rails/actionwebservice/test/client_xmlrpc_test.rb +0 -152
- data/vendor/rails/actionwebservice/test/container_test.rb +0 -73
- data/vendor/rails/actionwebservice/test/dispatcher_action_controller_soap_test.rb +0 -137
- data/vendor/rails/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb +0 -59
- data/vendor/rails/actionwebservice/test/fixtures/db_definitions/mysql.sql +0 -8
- data/vendor/rails/actionwebservice/test/fixtures/users.yml +0 -12
- data/vendor/rails/actionwebservice/test/gencov +0 -3
- data/vendor/rails/actionwebservice/test/invocation_test.rb +0 -185
- data/vendor/rails/actionwebservice/test/run +0 -6
- data/vendor/rails/actionwebservice/test/scaffolded_controller_test.rb +0 -146
- data/vendor/rails/actionwebservice/test/struct_test.rb +0 -52
- data/vendor/rails/actionwebservice/test/test_invoke_test.rb +0 -112
@@ -1,202 +0,0 @@
|
|
1
|
-
module ActionWebService # :nodoc:
|
2
|
-
module Invocation # :nodoc:
|
3
|
-
class InvocationError < ActionWebService::ActionWebServiceError # :nodoc:
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.included(base) # :nodoc:
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
base.send(:include, ActionWebService::Invocation::InstanceMethods)
|
9
|
-
end
|
10
|
-
|
11
|
-
# Invocation interceptors provide a means to execute custom code before
|
12
|
-
# and after method invocations on ActionWebService::Base objects.
|
13
|
-
#
|
14
|
-
# When running in _Direct_ dispatching mode, ActionController filters
|
15
|
-
# should be used for this functionality instead.
|
16
|
-
#
|
17
|
-
# The semantics of invocation interceptors are the same as ActionController
|
18
|
-
# filters, and accept the same parameters and options.
|
19
|
-
#
|
20
|
-
# A _before_ interceptor can also cancel execution by returning +false+,
|
21
|
-
# or returning a <tt>[false, "cancel reason"]</tt> array if it wishes to supply
|
22
|
-
# a reason for canceling the request.
|
23
|
-
#
|
24
|
-
# === Example
|
25
|
-
#
|
26
|
-
# class CustomService < ActionWebService::Base
|
27
|
-
# before_invocation :intercept_add, :only => [:add]
|
28
|
-
#
|
29
|
-
# def add(a, b)
|
30
|
-
# a + b
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# private
|
34
|
-
# def intercept_add
|
35
|
-
# return [false, "permission denied"] # cancel it
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# Options:
|
40
|
-
# [<tt>:except</tt>] A list of methods for which the interceptor will NOT be called
|
41
|
-
# [<tt>:only</tt>] A list of methods for which the interceptor WILL be called
|
42
|
-
module ClassMethods
|
43
|
-
# Appends the given +interceptors+ to be called
|
44
|
-
# _before_ method invocation.
|
45
|
-
def append_before_invocation(*interceptors, &block)
|
46
|
-
conditions = extract_conditions!(interceptors)
|
47
|
-
interceptors << block if block_given?
|
48
|
-
add_interception_conditions(interceptors, conditions)
|
49
|
-
append_interceptors_to_chain("before", interceptors)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Prepends the given +interceptors+ to be called
|
53
|
-
# _before_ method invocation.
|
54
|
-
def prepend_before_invocation(*interceptors, &block)
|
55
|
-
conditions = extract_conditions!(interceptors)
|
56
|
-
interceptors << block if block_given?
|
57
|
-
add_interception_conditions(interceptors, conditions)
|
58
|
-
prepend_interceptors_to_chain("before", interceptors)
|
59
|
-
end
|
60
|
-
|
61
|
-
alias :before_invocation :append_before_invocation
|
62
|
-
|
63
|
-
# Appends the given +interceptors+ to be called
|
64
|
-
# _after_ method invocation.
|
65
|
-
def append_after_invocation(*interceptors, &block)
|
66
|
-
conditions = extract_conditions!(interceptors)
|
67
|
-
interceptors << block if block_given?
|
68
|
-
add_interception_conditions(interceptors, conditions)
|
69
|
-
append_interceptors_to_chain("after", interceptors)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Prepends the given +interceptors+ to be called
|
73
|
-
# _after_ method invocation.
|
74
|
-
def prepend_after_invocation(*interceptors, &block)
|
75
|
-
conditions = extract_conditions!(interceptors)
|
76
|
-
interceptors << block if block_given?
|
77
|
-
add_interception_conditions(interceptors, conditions)
|
78
|
-
prepend_interceptors_to_chain("after", interceptors)
|
79
|
-
end
|
80
|
-
|
81
|
-
alias :after_invocation :append_after_invocation
|
82
|
-
|
83
|
-
def before_invocation_interceptors # :nodoc:
|
84
|
-
read_inheritable_attribute("before_invocation_interceptors")
|
85
|
-
end
|
86
|
-
|
87
|
-
def after_invocation_interceptors # :nodoc:
|
88
|
-
read_inheritable_attribute("after_invocation_interceptors")
|
89
|
-
end
|
90
|
-
|
91
|
-
def included_intercepted_methods # :nodoc:
|
92
|
-
read_inheritable_attribute("included_intercepted_methods") || {}
|
93
|
-
end
|
94
|
-
|
95
|
-
def excluded_intercepted_methods # :nodoc:
|
96
|
-
read_inheritable_attribute("excluded_intercepted_methods") || {}
|
97
|
-
end
|
98
|
-
|
99
|
-
private
|
100
|
-
def append_interceptors_to_chain(condition, interceptors)
|
101
|
-
write_inheritable_array("#{condition}_invocation_interceptors", interceptors)
|
102
|
-
end
|
103
|
-
|
104
|
-
def prepend_interceptors_to_chain(condition, interceptors)
|
105
|
-
interceptors = interceptors + read_inheritable_attribute("#{condition}_invocation_interceptors")
|
106
|
-
write_inheritable_attribute("#{condition}_invocation_interceptors", interceptors)
|
107
|
-
end
|
108
|
-
|
109
|
-
def extract_conditions!(interceptors)
|
110
|
-
return nil unless interceptors.last.is_a? Hash
|
111
|
-
interceptors.pop
|
112
|
-
end
|
113
|
-
|
114
|
-
def add_interception_conditions(interceptors, conditions)
|
115
|
-
return unless conditions
|
116
|
-
included, excluded = conditions[:only], conditions[:except]
|
117
|
-
write_inheritable_hash("included_intercepted_methods", condition_hash(interceptors, included)) && return if included
|
118
|
-
write_inheritable_hash("excluded_intercepted_methods", condition_hash(interceptors, excluded)) if excluded
|
119
|
-
end
|
120
|
-
|
121
|
-
def condition_hash(interceptors, *methods)
|
122
|
-
interceptors.inject({}) {|hash, interceptor| hash.merge(interceptor => methods.flatten.map {|method| method.to_s})}
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
module InstanceMethods # :nodoc:
|
127
|
-
def self.included(base)
|
128
|
-
base.class_eval do
|
129
|
-
alias_method_chain :perform_invocation, :interception
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def perform_invocation_with_interception(method_name, params, &block)
|
134
|
-
return if before_invocation(method_name, params, &block) == false
|
135
|
-
return_value = perform_invocation_without_interception(method_name, params)
|
136
|
-
after_invocation(method_name, params, return_value)
|
137
|
-
return_value
|
138
|
-
end
|
139
|
-
|
140
|
-
def perform_invocation(method_name, params)
|
141
|
-
send(method_name, *params)
|
142
|
-
end
|
143
|
-
|
144
|
-
def before_invocation(name, args, &block)
|
145
|
-
call_interceptors(self.class.before_invocation_interceptors, [name, args], &block)
|
146
|
-
end
|
147
|
-
|
148
|
-
def after_invocation(name, args, result)
|
149
|
-
call_interceptors(self.class.after_invocation_interceptors, [name, args, result])
|
150
|
-
end
|
151
|
-
|
152
|
-
private
|
153
|
-
|
154
|
-
def call_interceptors(interceptors, interceptor_args, &block)
|
155
|
-
if interceptors and not interceptors.empty?
|
156
|
-
interceptors.each do |interceptor|
|
157
|
-
next if method_exempted?(interceptor, interceptor_args[0].to_s)
|
158
|
-
result = case
|
159
|
-
when interceptor.is_a?(Symbol)
|
160
|
-
self.send(interceptor, *interceptor_args)
|
161
|
-
when interceptor_block?(interceptor)
|
162
|
-
interceptor.call(self, *interceptor_args)
|
163
|
-
when interceptor_class?(interceptor)
|
164
|
-
interceptor.intercept(self, *interceptor_args)
|
165
|
-
else
|
166
|
-
raise(
|
167
|
-
InvocationError,
|
168
|
-
"Interceptors need to be either a symbol, proc/method, or a class implementing a static intercept method"
|
169
|
-
)
|
170
|
-
end
|
171
|
-
reason = nil
|
172
|
-
if result.is_a?(Array)
|
173
|
-
reason = result[1] if result[1]
|
174
|
-
result = result[0]
|
175
|
-
end
|
176
|
-
if result == false
|
177
|
-
block.call(reason) if block && reason
|
178
|
-
return false
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def interceptor_block?(interceptor)
|
185
|
-
interceptor.respond_to?("call") && (interceptor.arity == 3 || interceptor.arity == -1)
|
186
|
-
end
|
187
|
-
|
188
|
-
def interceptor_class?(interceptor)
|
189
|
-
interceptor.respond_to?("intercept")
|
190
|
-
end
|
191
|
-
|
192
|
-
def method_exempted?(interceptor, method_name)
|
193
|
-
case
|
194
|
-
when self.class.included_intercepted_methods[interceptor]
|
195
|
-
!self.class.included_intercepted_methods[interceptor].include?(method_name)
|
196
|
-
when self.class.excluded_intercepted_methods[interceptor]
|
197
|
-
self.class.excluded_intercepted_methods[interceptor].include?(method_name)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
module ActionWebService # :nodoc:
|
2
|
-
module Protocol # :nodoc:
|
3
|
-
class ProtocolError < ActionWebServiceError # :nodoc:
|
4
|
-
end
|
5
|
-
|
6
|
-
class AbstractProtocol # :nodoc:
|
7
|
-
def setup(controller)
|
8
|
-
end
|
9
|
-
|
10
|
-
def decode_action_pack_request(action_pack_request)
|
11
|
-
end
|
12
|
-
|
13
|
-
def encode_action_pack_request(service_name, public_method_name, raw_body, options={})
|
14
|
-
klass = options[:request_class] || SimpleActionPackRequest
|
15
|
-
request = klass.new
|
16
|
-
request.request_parameters['action'] = service_name.to_s
|
17
|
-
request.env['RAW_POST_DATA'] = raw_body
|
18
|
-
request.env['REQUEST_METHOD'] = 'POST'
|
19
|
-
request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
|
20
|
-
request
|
21
|
-
end
|
22
|
-
|
23
|
-
def decode_request(raw_request, service_name, protocol_options={})
|
24
|
-
end
|
25
|
-
|
26
|
-
def encode_request(method_name, params, param_types)
|
27
|
-
end
|
28
|
-
|
29
|
-
def decode_response(raw_response)
|
30
|
-
end
|
31
|
-
|
32
|
-
def encode_response(method_name, return_value, return_type, protocol_options={})
|
33
|
-
end
|
34
|
-
|
35
|
-
def protocol_client(api, protocol_name, endpoint_uri, options)
|
36
|
-
end
|
37
|
-
|
38
|
-
def register_api(api)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class Request # :nodoc:
|
43
|
-
attr :protocol
|
44
|
-
attr_accessor :method_name
|
45
|
-
attr_accessor :method_params
|
46
|
-
attr :service_name
|
47
|
-
attr_accessor :api
|
48
|
-
attr_accessor :api_method
|
49
|
-
attr :protocol_options
|
50
|
-
|
51
|
-
def initialize(protocol, method_name, method_params, service_name, api=nil, api_method=nil, protocol_options=nil)
|
52
|
-
@protocol = protocol
|
53
|
-
@method_name = method_name
|
54
|
-
@method_params = method_params
|
55
|
-
@service_name = service_name
|
56
|
-
@api = api
|
57
|
-
@api_method = api_method
|
58
|
-
@protocol_options = protocol_options || {}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class Response # :nodoc:
|
63
|
-
attr :body
|
64
|
-
attr :content_type
|
65
|
-
attr :return_value
|
66
|
-
|
67
|
-
def initialize(body, content_type, return_value)
|
68
|
-
@body = body
|
69
|
-
@content_type = content_type
|
70
|
-
@return_value = return_value
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class SimpleActionPackRequest < ActionController::AbstractRequest # :nodoc:
|
75
|
-
def initialize
|
76
|
-
@env = {}
|
77
|
-
@qparams = {}
|
78
|
-
@rparams = {}
|
79
|
-
@cookies = {}
|
80
|
-
reset_session
|
81
|
-
end
|
82
|
-
|
83
|
-
def query_parameters
|
84
|
-
@qparams
|
85
|
-
end
|
86
|
-
|
87
|
-
def request_parameters
|
88
|
-
@rparams
|
89
|
-
end
|
90
|
-
|
91
|
-
def env
|
92
|
-
@env
|
93
|
-
end
|
94
|
-
|
95
|
-
def host
|
96
|
-
''
|
97
|
-
end
|
98
|
-
|
99
|
-
def cookies
|
100
|
-
@cookies
|
101
|
-
end
|
102
|
-
|
103
|
-
def session
|
104
|
-
@session
|
105
|
-
end
|
106
|
-
|
107
|
-
def reset_session
|
108
|
-
@session = {}
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module ActionWebService # :nodoc:
|
2
|
-
module Protocol # :nodoc:
|
3
|
-
module Discovery # :nodoc:
|
4
|
-
def self.included(base)
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
base.send(:include, ActionWebService::Protocol::Discovery::InstanceMethods)
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods # :nodoc:
|
10
|
-
def register_protocol(klass)
|
11
|
-
write_inheritable_array("web_service_protocols", [klass])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module InstanceMethods # :nodoc:
|
16
|
-
private
|
17
|
-
def discover_web_service_request(action_pack_request)
|
18
|
-
(self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
|
19
|
-
protocol = protocol.create(self)
|
20
|
-
request = protocol.decode_action_pack_request(action_pack_request)
|
21
|
-
return request unless request.nil?
|
22
|
-
end
|
23
|
-
nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_web_service_client(api, protocol_name, endpoint_uri, options)
|
27
|
-
(self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
|
28
|
-
protocol = protocol.create(self)
|
29
|
-
client = protocol.protocol_client(api, protocol_name, endpoint_uri, options)
|
30
|
-
return client unless client.nil?
|
31
|
-
end
|
32
|
-
nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
require 'action_web_service/protocol/soap_protocol/marshaler'
|
2
|
-
require 'soap/streamHandler'
|
3
|
-
require 'action_web_service/client/soap_client'
|
4
|
-
|
5
|
-
module ActionWebService # :nodoc:
|
6
|
-
module API # :nodoc:
|
7
|
-
class Base # :nodoc:
|
8
|
-
def self.soap_client(endpoint_uri, options={})
|
9
|
-
ActionWebService::Client::Soap.new self, endpoint_uri, options
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module Protocol # :nodoc:
|
15
|
-
module Soap # :nodoc:
|
16
|
-
def self.included(base)
|
17
|
-
base.register_protocol(SoapProtocol)
|
18
|
-
base.class_inheritable_option(:wsdl_service_name)
|
19
|
-
base.class_inheritable_option(:wsdl_namespace)
|
20
|
-
end
|
21
|
-
|
22
|
-
class SoapProtocol < AbstractProtocol # :nodoc:
|
23
|
-
AWSEncoding = 'UTF-8'
|
24
|
-
XSDEncoding = 'UTF8'
|
25
|
-
|
26
|
-
attr :marshaler
|
27
|
-
|
28
|
-
def initialize(namespace=nil)
|
29
|
-
namespace ||= 'urn:ActionWebService'
|
30
|
-
@marshaler = SoapMarshaler.new namespace
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.create(controller)
|
34
|
-
SoapProtocol.new(controller.wsdl_namespace)
|
35
|
-
end
|
36
|
-
|
37
|
-
def decode_action_pack_request(action_pack_request)
|
38
|
-
return nil unless soap_action = has_valid_soap_action?(action_pack_request)
|
39
|
-
service_name = action_pack_request.parameters['action']
|
40
|
-
input_encoding = parse_charset(action_pack_request.env['HTTP_CONTENT_TYPE'])
|
41
|
-
protocol_options = {
|
42
|
-
:soap_action => soap_action,
|
43
|
-
:charset => input_encoding
|
44
|
-
}
|
45
|
-
decode_request(action_pack_request.raw_post, service_name, protocol_options)
|
46
|
-
end
|
47
|
-
|
48
|
-
def encode_action_pack_request(service_name, public_method_name, raw_body, options={})
|
49
|
-
request = super
|
50
|
-
request.env['HTTP_SOAPACTION'] = '/soap/%s/%s' % [service_name, public_method_name]
|
51
|
-
request
|
52
|
-
end
|
53
|
-
|
54
|
-
def decode_request(raw_request, service_name, protocol_options={})
|
55
|
-
envelope = SOAP::Processor.unmarshal(raw_request, :charset => protocol_options[:charset])
|
56
|
-
unless envelope
|
57
|
-
raise ProtocolError, "Failed to parse SOAP request message"
|
58
|
-
end
|
59
|
-
request = envelope.body.request
|
60
|
-
method_name = request.elename.name
|
61
|
-
params = request.collect{ |k, v| marshaler.soap_to_ruby(request[k]) }
|
62
|
-
Request.new(self, method_name, params, service_name, nil, nil, protocol_options)
|
63
|
-
end
|
64
|
-
|
65
|
-
def encode_request(method_name, params, param_types)
|
66
|
-
param_types.each{ |type| marshaler.register_type(type) } if param_types
|
67
|
-
qname = XSD::QName.new(marshaler.namespace, method_name)
|
68
|
-
param_def = []
|
69
|
-
if param_types
|
70
|
-
params = param_types.zip(params).map do |type, param|
|
71
|
-
param_def << ['in', type.name, marshaler.lookup_type(type).mapping]
|
72
|
-
[type.name, marshaler.ruby_to_soap(param)]
|
73
|
-
end
|
74
|
-
else
|
75
|
-
params = []
|
76
|
-
end
|
77
|
-
request = SOAP::RPC::SOAPMethodRequest.new(qname, param_def)
|
78
|
-
request.set_param(params)
|
79
|
-
envelope = create_soap_envelope(request)
|
80
|
-
SOAP::Processor.marshal(envelope)
|
81
|
-
end
|
82
|
-
|
83
|
-
def decode_response(raw_response)
|
84
|
-
envelope = SOAP::Processor.unmarshal(raw_response)
|
85
|
-
unless envelope
|
86
|
-
raise ProtocolError, "Failed to parse SOAP request message"
|
87
|
-
end
|
88
|
-
method_name = envelope.body.request.elename.name
|
89
|
-
return_value = envelope.body.response
|
90
|
-
return_value = marshaler.soap_to_ruby(return_value) unless return_value.nil?
|
91
|
-
[method_name, return_value]
|
92
|
-
end
|
93
|
-
|
94
|
-
def encode_response(method_name, return_value, return_type, protocol_options={})
|
95
|
-
if return_type
|
96
|
-
return_binding = marshaler.register_type(return_type)
|
97
|
-
marshaler.annotate_arrays(return_binding, return_value)
|
98
|
-
end
|
99
|
-
qname = XSD::QName.new(marshaler.namespace, method_name)
|
100
|
-
if return_value.nil?
|
101
|
-
response = SOAP::RPC::SOAPMethodResponse.new(qname, nil)
|
102
|
-
else
|
103
|
-
if return_value.is_a?(Exception)
|
104
|
-
detail = SOAP::Mapping::SOAPException.new(return_value)
|
105
|
-
response = SOAP::SOAPFault.new(
|
106
|
-
SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']),
|
107
|
-
SOAP::SOAPString.new(return_value.to_s),
|
108
|
-
SOAP::SOAPString.new(self.class.name),
|
109
|
-
marshaler.ruby_to_soap(detail))
|
110
|
-
else
|
111
|
-
if return_type
|
112
|
-
param_def = [['retval', 'return', marshaler.lookup_type(return_type).mapping]]
|
113
|
-
response = SOAP::RPC::SOAPMethodResponse.new(qname, param_def)
|
114
|
-
response.retval = marshaler.ruby_to_soap(return_value)
|
115
|
-
else
|
116
|
-
response = SOAP::RPC::SOAPMethodResponse.new(qname, nil)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
envelope = create_soap_envelope(response)
|
121
|
-
|
122
|
-
# FIXME: This is not thread-safe, but StringFactory_ in SOAP4R only
|
123
|
-
# reads target encoding from the XSD::Charset.encoding variable.
|
124
|
-
# This is required to ensure $KCODE strings are converted
|
125
|
-
# correctly to UTF-8 for any values of $KCODE.
|
126
|
-
previous_encoding = XSD::Charset.encoding
|
127
|
-
XSD::Charset.encoding = XSDEncoding
|
128
|
-
response_body = SOAP::Processor.marshal(envelope, :charset => AWSEncoding)
|
129
|
-
XSD::Charset.encoding = previous_encoding
|
130
|
-
|
131
|
-
Response.new(response_body, "text/xml; charset=#{AWSEncoding}", return_value)
|
132
|
-
end
|
133
|
-
|
134
|
-
def protocol_client(api, protocol_name, endpoint_uri, options={})
|
135
|
-
return nil unless protocol_name == :soap
|
136
|
-
ActionWebService::Client::Soap.new(api, endpoint_uri, options)
|
137
|
-
end
|
138
|
-
|
139
|
-
def register_api(api)
|
140
|
-
api.api_methods.each do |name, method|
|
141
|
-
method.expects.each{ |type| marshaler.register_type(type) } if method.expects
|
142
|
-
method.returns.each{ |type| marshaler.register_type(type) } if method.returns
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
private
|
147
|
-
def has_valid_soap_action?(request)
|
148
|
-
return nil unless request.method == :post
|
149
|
-
soap_action = request.env['HTTP_SOAPACTION']
|
150
|
-
return nil unless soap_action
|
151
|
-
soap_action = soap_action.dup
|
152
|
-
soap_action.gsub!(/^"/, '')
|
153
|
-
soap_action.gsub!(/"$/, '')
|
154
|
-
soap_action.strip!
|
155
|
-
return nil if soap_action.empty?
|
156
|
-
soap_action
|
157
|
-
end
|
158
|
-
|
159
|
-
def create_soap_envelope(body)
|
160
|
-
header = SOAP::SOAPHeader.new
|
161
|
-
body = SOAP::SOAPBody.new(body)
|
162
|
-
SOAP::SOAPEnvelope.new(header, body)
|
163
|
-
end
|
164
|
-
|
165
|
-
def parse_charset(content_type)
|
166
|
-
return AWSEncoding if content_type.nil?
|
167
|
-
if /^text\/xml(?:\s*;\s*charset=([^"]+|"[^"]+"))$/i =~ content_type
|
168
|
-
$1
|
169
|
-
else
|
170
|
-
AWSEncoding
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|