killbill 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/VERSION +1 -1
  2. data/gen_config/api.conf +42 -0
  3. data/gen_config/plugin_api.conf +14 -0
  4. data/lib/killbill.rb +3 -3
  5. data/lib/killbill/gen/{account.rb → api/account.rb} +0 -0
  6. data/lib/killbill/gen/{account_api_exception.rb → api/account_api_exception.rb} +0 -0
  7. data/lib/killbill/gen/{account_data.rb → api/account_data.rb} +0 -0
  8. data/lib/killbill/gen/{account_email.rb → api/account_email.rb} +0 -0
  9. data/lib/killbill/gen/{account_user_api.rb → api/account_user_api.rb} +19 -16
  10. data/lib/killbill/gen/{audit_user_api.rb → api/audit_user_api.rb} +25 -0
  11. data/lib/killbill/gen/{billing_exception_base.rb → api/billing_exception_base.rb} +0 -0
  12. data/lib/killbill/gen/{blockable.rb → api/blockable.rb} +0 -0
  13. data/lib/killbill/gen/{blocking_api_exception.rb → api/blocking_api_exception.rb} +0 -0
  14. data/lib/killbill/gen/{blocking_state.rb → api/blocking_state.rb} +0 -0
  15. data/lib/killbill/gen/{call_context.rb → api/call_context.rb} +0 -0
  16. data/lib/killbill/gen/{catalog.rb → api/catalog.rb} +0 -0
  17. data/lib/killbill/gen/{catalog_api_exception.rb → api/catalog_api_exception.rb} +0 -0
  18. data/lib/killbill/gen/{catalog_user_api.rb → api/catalog_user_api.rb} +2 -0
  19. data/lib/killbill/gen/{column_info.rb → api/column_info.rb} +0 -0
  20. data/lib/killbill/gen/{control_tag.rb → api/control_tag.rb} +0 -0
  21. data/lib/killbill/gen/{currency_value_null.rb → api/currency_value_null.rb} +0 -0
  22. data/lib/killbill/gen/{custom_field.rb → api/custom_field.rb} +0 -0
  23. data/lib/killbill/gen/{custom_field_api_exception.rb → api/custom_field_api_exception.rb} +0 -0
  24. data/lib/killbill/gen/{custom_field_user_api.rb → api/custom_field_user_api.rb} +10 -0
  25. data/lib/killbill/gen/{database_export_output_stream.rb → api/database_export_output_stream.rb} +0 -0
  26. data/lib/killbill/gen/{duration.rb → api/duration.rb} +0 -0
  27. data/lib/killbill/gen/{entitlement_user_api.rb → api/entitlement_user_api.rb} +31 -0
  28. data/lib/killbill/gen/{entitlement_user_api_exception.rb → api/entitlement_user_api_exception.rb} +0 -0
  29. data/lib/killbill/gen/{entity.rb → api/entity.rb} +0 -0
  30. data/lib/killbill/gen/{illegal_plan_change.rb → api/illegal_plan_change.rb} +0 -0
  31. data/lib/killbill/gen/{international_price.rb → api/international_price.rb} +2 -2
  32. data/lib/killbill/gen/{invalid_config_exception.rb → api/invalid_config_exception.rb} +0 -0
  33. data/lib/killbill/gen/{invoice.rb → api/invoice.rb} +12 -12
  34. data/lib/killbill/gen/{invoice_api_exception.rb → api/invoice_api_exception.rb} +0 -0
  35. data/lib/killbill/gen/{invoice_creation_event.rb → api/invoice_creation_event.rb} +0 -0
  36. data/lib/killbill/gen/api/invoice_formatter.rb +278 -0
  37. data/lib/killbill/gen/{invoice_item.rb → api/invoice_item.rb} +4 -4
  38. data/lib/killbill/gen/api/invoice_item_formatter.rb +213 -0
  39. data/lib/killbill/gen/{invoice_payment.rb → api/invoice_payment.rb} +2 -2
  40. data/lib/killbill/gen/{invoice_payment_api.rb → api/invoice_payment_api.rb} +23 -2
  41. data/lib/killbill/gen/{invoice_user_api.rb → api/invoice_user_api.rb} +85 -8
  42. data/lib/killbill/gen/{junction_api.rb → api/junction_api.rb} +2 -0
  43. data/lib/killbill/gen/{limit.rb → api/limit.rb} +0 -0
  44. data/lib/killbill/gen/{listing.rb → api/listing.rb} +0 -0
  45. data/lib/killbill/gen/{migration_plan.rb → api/migration_plan.rb} +0 -0
  46. data/lib/killbill/gen/{mutable_account_data.rb → api/mutable_account_data.rb} +0 -0
  47. data/lib/killbill/gen/api/osgi_killbill.rb +175 -0
  48. data/lib/killbill/gen/{external_bus.rb → api/osgi_plugin_properties.rb} +3 -3
  49. data/lib/killbill/gen/{payment.rb → api/payment.rb} +4 -4
  50. data/lib/killbill/gen/{payment_api.rb → api/payment_api.rb} +63 -4
  51. data/lib/killbill/gen/{payment_api_exception.rb → api/payment_api_exception.rb} +0 -0
  52. data/lib/killbill/gen/{payment_attempt.rb → api/payment_attempt.rb} +0 -0
  53. data/lib/killbill/gen/{payment_method.rb → api/payment_method.rb} +0 -0
  54. data/lib/killbill/gen/{payment_method_kv_info.rb → api/payment_method_kv_info.rb} +0 -0
  55. data/lib/killbill/gen/{payment_method_plugin.rb → api/payment_method_plugin.rb} +0 -0
  56. data/lib/killbill/gen/{plan.rb → api/plan.rb} +0 -0
  57. data/lib/killbill/gen/{plan_change_result.rb → api/plan_change_result.rb} +0 -0
  58. data/lib/killbill/gen/{plan_phase.rb → api/plan_phase.rb} +0 -0
  59. data/lib/killbill/gen/{plan_phase_specifier.rb → api/plan_phase_specifier.rb} +0 -0
  60. data/lib/killbill/gen/{plan_specifier.rb → api/plan_specifier.rb} +0 -0
  61. data/lib/killbill/gen/api/plugin_config_service_api.rb +64 -0
  62. data/lib/killbill/gen/{price.rb → api/price.rb} +2 -2
  63. data/lib/killbill/gen/{price_list.rb → api/price_list.rb} +0 -0
  64. data/lib/killbill/gen/{price_list_set.rb → api/price_list_set.rb} +0 -0
  65. data/lib/killbill/gen/{product.rb → api/product.rb} +0 -0
  66. data/lib/killbill/gen/{record_id_api.rb → api/record_id_api.rb} +3 -0
  67. data/lib/killbill/gen/{refund.rb → api/refund.rb} +2 -2
  68. data/lib/killbill/gen/api/require_gen.rb +107 -0
  69. data/lib/killbill/gen/api/rolled_up_usage.rb +101 -0
  70. data/lib/killbill/gen/{static_catalog.rb → api/static_catalog.rb} +0 -0
  71. data/lib/killbill/gen/{subscription.rb → api/subscription.rb} +0 -0
  72. data/lib/killbill/gen/{subscription_bundle.rb → api/subscription_bundle.rb} +0 -0
  73. data/lib/killbill/gen/{subscription_status_dry_run.rb → api/subscription_status_dry_run.rb} +0 -0
  74. data/lib/killbill/gen/{subscription_transition.rb → api/subscription_transition.rb} +0 -0
  75. data/lib/killbill/gen/{tag.rb → api/tag.rb} +0 -0
  76. data/lib/killbill/gen/{tag_api_exception.rb → api/tag_api_exception.rb} +0 -0
  77. data/lib/killbill/gen/{tag_definition.rb → api/tag_definition.rb} +0 -0
  78. data/lib/killbill/gen/{tag_definition_api_exception.rb → api/tag_definition_api_exception.rb} +0 -0
  79. data/lib/killbill/gen/{tag_user_api.rb → api/tag_user_api.rb} +34 -0
  80. data/lib/killbill/gen/{tenant.rb → api/tenant.rb} +0 -0
  81. data/lib/killbill/gen/{tenant_api_exception.rb → api/tenant_api_exception.rb} +0 -0
  82. data/lib/killbill/gen/{tenant_context.rb → api/tenant_context.rb} +0 -0
  83. data/lib/killbill/gen/{tenant_data.rb → api/tenant_data.rb} +0 -0
  84. data/lib/killbill/gen/{tenant_kv.rb → api/tenant_kv.rb} +0 -0
  85. data/lib/killbill/gen/{tenant_user_api.rb → api/tenant_user_api.rb} +11 -0
  86. data/lib/killbill/gen/{unit.rb → api/unit.rb} +0 -0
  87. data/lib/killbill/gen/api/usage_user_api.rb +89 -0
  88. data/lib/killbill/gen/{ext_bus_event.rb → plugin-api/ext_bus_event.rb} +0 -0
  89. data/lib/killbill/gen/plugin-api/notification_plugin_api.rb +61 -0
  90. data/lib/killbill/gen/{payment_info_plugin.rb → plugin-api/payment_info_plugin.rb} +2 -2
  91. data/lib/killbill/gen/{payment_method_info_plugin.rb → plugin-api/payment_method_info_plugin.rb} +0 -0
  92. data/lib/killbill/gen/plugin-api/payment_plugin_api.rb +356 -0
  93. data/lib/killbill/gen/{payment_plugin_api_exception.rb → plugin-api/payment_plugin_api_exception.rb} +0 -0
  94. data/lib/killbill/gen/{refund_info_plugin.rb → plugin-api/refund_info_plugin.rb} +2 -2
  95. data/lib/killbill/gen/plugin-api/require_gen.rb +32 -0
  96. data/lib/killbill/jplugin.rb +0 -71
  97. data/lib/killbill/killbill_api.rb +0 -7
  98. data/spec/killbill/killbillapi_spec.rb +1 -1
  99. data/spec/killbill/notification_plugin_api_spec.rb +22 -0
  100. data/spec/killbill/payment_plugin_api_spec.rb +122 -0
  101. data/spec/killbill/payment_test.rb +1 -1
  102. metadata +100 -107
  103. data/lib/killbill/enum.rb +0 -72
  104. data/lib/killbill/gen/account_service.rb +0 -55
  105. data/lib/killbill/gen/beatrix_service.rb +0 -55
  106. data/lib/killbill/gen/catalog_service.rb +0 -69
  107. data/lib/killbill/gen/default_mutable_account_data.rb +0 -180
  108. data/lib/killbill/gen/entitlement_service.rb +0 -55
  109. data/lib/killbill/gen/entity_persistence_exception.rb +0 -66
  110. data/lib/killbill/gen/export_user_api.rb +0 -17
  111. data/lib/killbill/gen/invoice_migration_api.rb +0 -66
  112. data/lib/killbill/gen/invoice_notifier.rb +0 -51
  113. data/lib/killbill/gen/invoice_service.rb +0 -55
  114. data/lib/killbill/gen/migration_account_data.rb +0 -228
  115. data/lib/killbill/gen/no_op_payment_plugin_api.rb +0 -254
  116. data/lib/killbill/gen/payment_plugin_api.rb +0 -232
  117. data/lib/killbill/gen/payment_service.rb +0 -62
  118. data/lib/killbill/gen/require_gen.rb +0 -120
  119. data/lib/killbill/gen/tenant_service.rb +0 -55
  120. data/lib/killbill/jpayment.rb +0 -107
  121. data/spec/killbill/jnotification_spec.rb +0 -39
  122. data/spec/killbill/jpayment_spec.rb +0 -126
  123. data/tools/java2ruby.rb +0 -440
data/tools/java2ruby.rb DELETED
@@ -1,440 +0,0 @@
1
- require 'rubygems'
2
- require 'optparse'
3
-
4
-
5
- # Relative path from Killbill repo
6
- API_DIR_SRC="api/src/main/java"
7
-
8
- # Interfaces to consider
9
- INTERFACES = ["Account",
10
- "AccountData",
11
- "AccountEmail",
12
- "BlockingState",
13
- "ExtBusEvent",
14
- "ExtBusEventType",
15
- "ObjectType",
16
- "Subscription",
17
- "SubscriptionState",
18
- "SubscriptionSourceType",
19
- "SubscriptionBundle",
20
- "Invoice",
21
- "InvoiceItem",
22
- "InvoicePayment",
23
- "InvoicePaymentType",
24
- "Payment",
25
- "PaymentAttempt",
26
- "Refund",
27
- "AuditLog",
28
- "CallContext",
29
- "CallOrigin",
30
- "UserType",
31
- "TenantContext",
32
- "CustomField",
33
- "Tag",
34
- "TagDefinition",
35
- "Currency",
36
- "PaymentInfoPlugin",
37
- "PaymentPluginStatus",
38
- "RefundInfoPlugin",
39
- "RefundPluginStatus",
40
- "PaymentMethodKVInfo",
41
- "PaymentMethodPlugin",
42
- "PaymentMethodInfoPlugin"]
43
-
44
-
45
- class String
46
- def snake_case
47
- return downcase if match(/\A[A-Z]+\z/)
48
- gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
49
- gsub(/([a-z])([A-Z])/, '\1_\2').
50
- downcase
51
- end
52
- end
53
-
54
- class Pojo
55
-
56
- attr_accessor :name, :package, :fields
57
-
58
- def initialize(dummy=nil)
59
- @name = nil
60
- @package = nil
61
- @fields = []
62
- end
63
- end
64
-
65
- =begin
66
- class ObjectType
67
-
68
- @@admissible_values = [:ACCOUNT, :ACCOUNT_EMAIL]
69
- attr_reader :enum
70
-
71
- def initialize(value)
72
- @enum = value
73
- end
74
-
75
- def self.is_admissible_value(value)
76
- @@admissible_values.include?(value)
77
- end
78
-
79
- def self.admissible_values
80
- @@admissible_values
81
- end
82
- =end
83
-
84
- class PojoEnum < Pojo
85
-
86
- def initialize
87
- super
88
- end
89
-
90
- def generate(out)
91
- out.write("\n")
92
- out.write("\#\n")
93
- out.write("\# Ruby classes automatically generated from java classes-- don't edit\n")
94
- out.write("\#\n")
95
- out.write("module Killbill\n")
96
- out.write(" module Plugin\n")
97
- out.write(" module Model\n")
98
- out.write("\n")
99
- out.write(" class #{name}\n")
100
- out.write("\n")
101
- out.write(" @@admissible_values = #{@fields.collect {|e| e.to_sym }}\n")
102
- out.write(" attr_reader :enum\n")
103
- out.write("\n")
104
- out.write(" def initialize(value)\n")
105
- out.write(" raise ArgumentError.new(\"Enum #{name} does not have such value : \#{value}\") if ! #{name}.is_admissible_value?(value)\n")
106
- out.write(" @enum = value\n")
107
- out.write(" end\n")
108
- out.write("\n")
109
- out.write(" def ==(other)\n")
110
- out.write(" return false if other.nil?\n")
111
- out.write(" self.enum == other.enum\n")
112
- out.write(" end\n")
113
- out.write("\n")
114
- out.write(" def self.is_admissible_value?(value)\n")
115
- out.write(" @@admissible_values.include?(value)\n")
116
- out.write(" end\n")
117
- out.write("\n")
118
- out.write(" def self.admissible_values \n")
119
- out.write(" @@admissible_values\n")
120
- out.write(" end\n")
121
- out.write(" end\n")
122
- out.write(" end\n")
123
- out.write(" end\n")
124
- out.write("end\n")
125
- out.flush
126
- end
127
-
128
- def export(output_dir, parents_pojo)
129
- @fields.uniq!
130
- File.open("#{output_dir}/#{name.snake_case}.rb", "w+") do |f|
131
- generate(f)
132
- end
133
- end
134
-
135
-
136
-
137
- end
138
-
139
- class PojoIfceOrClass < Pojo
140
-
141
- attr_accessor :interface, :parents
142
-
143
- def initialize(is_interface)
144
- super
145
- @interface = is_interface
146
- @parents = []
147
- end
148
-
149
- def generate(out)
150
- out.write("\n")
151
- out.write("\#\n")
152
- out.write("\# Ruby classes automatically generated from java classes-- don't edit\n")
153
- out.write("\#\n")
154
- out.write("module Killbill\n")
155
- out.write(" module Plugin\n")
156
- out.write(" module Model\n")
157
- out.write("\n")
158
- out.write(" class #{name}\n")
159
- out.write("\n")
160
- if @interface
161
- out.write(" include #{@package}.#{@name}\n")
162
- out.write("\n")
163
- end
164
- out.write(" attr_reader #{fields.collect { |i| ":#{i}"}.join(", ")}\n")
165
- out.write("\n")
166
- out.write(" def initialize(#{@fields.join(", ")})\n")
167
- fields.each do |f|
168
- out.write(" @#{f} = #{f}\n")
169
- end
170
- out.write(" end\n")
171
- out.write(" end\n")
172
- out.write(" end\n")
173
- out.write(" end\n")
174
- out.write("end\n")
175
- out.flush
176
- end
177
-
178
- def export(output_dir, parents_pojo)
179
- parents.each do |p|
180
- if ! parents_pojo[p].nil?
181
- (@fields.unshift(parents_pojo[p].fields)).flatten!
182
- end
183
- end
184
- @fields.uniq!
185
- File.open("#{output_dir}/#{name.snake_case}.rb", "w+") do |f|
186
- generate(f)
187
- end
188
- end
189
-
190
- def to_s
191
- "#{@name} : #{@fields.join(",")}"
192
- end
193
-
194
-
195
- end
196
-
197
-
198
- class Visitor
199
-
200
- attr_reader :pojo
201
-
202
- def initialize
203
- @pojo = nil
204
- end
205
-
206
- def create_interface(name, package)
207
- @pojo = PojoIfceOrClass.new(true)
208
- @pojo.name = name
209
- @pojo.package = package
210
- end
211
-
212
- def create_class(name, package)
213
- @pojo = PojoIfceOrClass.new(false)
214
- @pojo.name = name
215
- @pojo.package = package
216
- end
217
-
218
- def create_enum(name, package)
219
- @pojo = PojoEnum.new
220
- @pojo.name = name
221
- @pojo.package = package
222
- end
223
-
224
- def add_parents(parents)
225
- (@pojo.parents << parents).flatten!
226
- end
227
-
228
- def add_getter(getter)
229
- @pojo.fields << getter.snake_case
230
- end
231
-
232
- def add_enum_field(enum_field)
233
- @pojo.fields << enum_field
234
- end
235
- end
236
-
237
- class Generator
238
-
239
- attr_reader :output_dir, :finder, :files
240
-
241
- def initialize(output_dir, interfaces, finder)
242
- @output_dir = output_dir
243
- @finder = finder
244
- @files = finder.search(interfaces)
245
- end
246
-
247
- def generate_all
248
-
249
- pojos = []
250
- @files.each do |i|
251
- generate_file(i) do |pojo|
252
- pojos << pojo
253
- end
254
- end
255
-
256
- parent_pojos = {}
257
-
258
- parent_ifces = []
259
- pojos.each do |pojo|
260
- if pojo.is_a? PojoIfceOrClass
261
- (parent_ifces << pojo.parents).flatten!
262
- end
263
- end
264
- parent_ifces.uniq!
265
-
266
- puts "UNIQ PARENTS = #{parent_ifces.to_s}"
267
-
268
- parent_files = finder.search(parent_ifces)
269
- puts "PARENT FILES = #{parent_files}"
270
- parent_files.each do |i|
271
- puts "Starting processing parent file #{i}"
272
- generate_file(i) do |pojo|
273
- parent_pojos[pojo.name] = pojo
274
- end
275
- end
276
-
277
- pojos.each do |pojo|
278
- puts "Starting processing file #{pojo.name}"
279
-
280
- pojo.export(@output_dir, parent_pojos)
281
-
282
- File.open("#{output_dir}/require_gen.rb", "w+") do |f|
283
- pojos.each do |pojo|
284
- f.write("require \'killbill/gen/#{pojo.name.snake_case}\'\n")
285
- end
286
- end
287
- puts "Completing processing file #{pojo.name}"
288
- end
289
- end
290
-
291
- private
292
-
293
-
294
- def generate_file(file)
295
- visitor = Visitor.new
296
- File.open(file, "r") do |f|
297
-
298
- is_enum = false
299
- is_interface = false
300
- is_class = false
301
- package = nil
302
- while (line = f.gets)
303
-
304
- # Package
305
- re = /\s*package\s+((?:\w|\.)+)\s*;/
306
- if re.match(line)
307
- package = $1
308
- end
309
-
310
- # Interface
311
- re = /public\s+(interface|class)\s+(\w+)\s+(extends(?:\w|,|\s|<|>)+){0,1}\s*{\s*/
312
- if re.match(line)
313
- is_interface = ($1 == "interface")
314
- is_class = ($1 == "class")
315
- name = $2
316
- visitor.create_interface(name, package) if is_interface
317
- visitor.create_class(name, package) if is_class
318
- if ! $3.nil?
319
- re = /\s*extends\s+(.*)/
320
- extends_ifces = $3
321
- if re.match(extends_ifces)
322
- # extract each parent and remove trailing, leading space
323
- parents = $1.split(",").collect { |e| e.strip}
324
- # remove generics
325
- re = /(\w+)(?:<\w+>){0,1}/
326
- parents.collect! { |e| re.match(e); $1 }
327
- visitor.add_parents(parents)
328
- end
329
- end
330
- end
331
-
332
- # Enum
333
- re = /public\s+enum\s+(\w+)\s+/
334
- if re.match(line)
335
- enum_name = $1
336
- visitor.create_enum(enum_name, package)
337
- is_enum = true
338
- is_enum_complete = false
339
- end
340
-
341
- # Non static getters for interfaces
342
- re = /(?:public){0,1}\s+(?:static\s+(?:\w|<|>)+)\s+(?:get|is).*/
343
- if (is_interface || is_class) && !re.match(line)
344
- re = /(?:public){0,1}\s+(?:(?:\w|<|>)+)\s+get(\w+)()\s*/
345
- if re.match(line)
346
- visitor.add_getter($1)
347
- end
348
- re = /(?:public){0,1}\s+(?:(?:\w|<|>)+)\s+(is\w+)()\s*/
349
- if re.match(line)
350
- visitor.add_getter($1)
351
- end
352
- end
353
-
354
- # Enum fields
355
- re = /\s+((?:\w|_)+)(?:\((?:\w|\s|\")+\)){0,1}\s*(,|;){1}/
356
- if !is_enum_complete && is_enum && re.match(line)
357
- visitor.add_enum_field($1.strip)
358
- if $2 == ';'
359
- is_enum_complete = true
360
- end
361
- end
362
- end
363
- end
364
- yield(visitor.pojo)
365
- end
366
- end
367
-
368
-
369
- class Finder
370
-
371
- attr_reader :interfaces, :src_dir
372
-
373
- def initialize(src_dir)
374
- @interfaces = interfaces
375
- @src_dir = src_dir
376
- end
377
-
378
- def search(interfaces)
379
- res = []
380
- if !interfaces.nil? && interfaces.size > 0
381
- Dir.chdir(@src_dir)
382
- Dir.glob("**/*") do |e|
383
- if File.file?(e)
384
- basename = File.basename(e, ".java")
385
- if interfaces.include? basename
386
- res << e
387
- end
388
- end
389
- end
390
- end
391
- res
392
- end
393
- end
394
-
395
-
396
- class CommandParser
397
-
398
- attr_reader :options, :args, :interfaces, :src_relative_path
399
-
400
- def initialize(args, interfaces, src_relative_path)
401
- @options = {}
402
- @args = args
403
- @interfaces = interfaces
404
- @src_relative_path = src_relative_path
405
- end
406
-
407
-
408
- def run
409
- parse
410
- puts "Generating ruby classes under: #{@options[:output]}"
411
- finder = Finder.new("#{@options[:src]}/#{@src_relative_path}")
412
- gen = Generator.new(@options[:output], @interfaces, finder)
413
- gen.generate_all
414
- end
415
-
416
- private
417
-
418
- def parse()
419
- optparse = OptionParser.new do |opts|
420
- opts.banner = "Usage: java2ruby.rb [options]"
421
-
422
- opts.separator ""
423
-
424
- opts.on("-o", "--output OUTPUT",
425
- "Output directory") do |o|
426
- @options[:output] = o
427
- end
428
-
429
- opts.on("-s", "--src SRC",
430
- "Killbill source directory") do |s|
431
- @options[:src] = s
432
- end
433
- end
434
- optparse.parse!(@args)
435
- end
436
-
437
- end
438
-
439
- parser = CommandParser.new(ARGV, INTERFACES, API_DIR_SRC)
440
- parser.run