rhoconnect 4.0.0.beta.10 → 4.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/Gemfile.lock +6 -6
  3. data/Rakefile +1 -1
  4. data/commands/generators/controller.rb +1 -1
  5. data/commands/generators/model.rb +1 -1
  6. data/doc/deploying.txt +41 -38
  7. data/doc/source-adapters-js.txt +263 -0
  8. data/generators/templates/application/controllers/js/application_controller.js +6 -4
  9. data/generators/templates/source/controllers/js/controller.js +4 -4
  10. data/generators/templates/source/models/js/model.js +3 -1
  11. data/install.sh +76 -6
  12. data/installer/utils/constants.rb +4 -4
  13. data/js-adapters/ballroom.js +6 -7
  14. data/js-adapters/node_channel.rb +14 -8
  15. data/js-adapters/request.js +7 -8
  16. data/js-adapters/response.js +10 -2
  17. data/js-adapters/rhoconnect_helpers.js +34 -33
  18. data/js-adapters/router.js +15 -12
  19. data/lib/rhoconnect/controller/js_base.rb +2 -7
  20. data/lib/rhoconnect/document.rb +1 -1
  21. data/lib/rhoconnect/model/base.rb +25 -10
  22. data/lib/rhoconnect/model/js_base.rb +4 -3
  23. data/lib/rhoconnect/source.rb +15 -1
  24. data/lib/rhoconnect/version.rb +1 -1
  25. data/spec/apps/rhotestapp/models/js/js_sample.js +61 -14
  26. data/spec/apps/rhotestapp/models/ruby/sample_adapter.rb +5 -0
  27. data/spec/controllers/js_base_spec.rb +16 -11
  28. data/spec/models/js_model_spec.rb +68 -7
  29. data/spec/server/server_spec.rb +28 -0
  30. data/spec/source_adapter_spec.rb +0 -11
  31. data/spec/source_spec.rb +39 -0
  32. data/spec/spec_helper.rb +11 -0
  33. metadata +4 -44
  34. data/lib/rhoconnect/api/app/ans_login.rb +0 -3
  35. data/lib/rhoconnect/api/app/bulk_data.rb +0 -10
  36. data/lib/rhoconnect/api/app/fast_delete.rb +0 -11
  37. data/lib/rhoconnect/api/app/fast_insert.rb +0 -11
  38. data/lib/rhoconnect/api/app/fast_update.rb +0 -11
  39. data/lib/rhoconnect/api/app/login.rb +0 -5
  40. data/lib/rhoconnect/api/app/push_deletes.rb +0 -12
  41. data/lib/rhoconnect/api/app/push_objects.rb +0 -12
  42. data/lib/rhoconnect/api/app/query.rb +0 -8
  43. data/lib/rhoconnect/api/app/queue_updates.rb +0 -98
  44. data/lib/rhoconnect/api/app/search.rb +0 -8
  45. data/lib/rhoconnect/api/client/client_get_db_doc.rb +0 -5
  46. data/lib/rhoconnect/api/client/client_set_db_doc.rb +0 -8
  47. data/lib/rhoconnect/api/client/create.rb +0 -7
  48. data/lib/rhoconnect/api/client/get_client_params.rb +0 -4
  49. data/lib/rhoconnect/api/client/list_client_docs.rb +0 -17
  50. data/lib/rhoconnect/api/client/register.rb +0 -12
  51. data/lib/rhoconnect/api/client/reset.rb +0 -5
  52. data/lib/rhoconnect/api/readstate/set_refresh_time.rb +0 -9
  53. data/lib/rhoconnect/api/source/get_source_params.rb +0 -4
  54. data/lib/rhoconnect/api/source/list_sources.rb +0 -16
  55. data/lib/rhoconnect/api/source/update_source_params.rb +0 -6
  56. data/lib/rhoconnect/api/store/get_db_doc.rb +0 -4
  57. data/lib/rhoconnect/api/store/set_db_doc.rb +0 -7
  58. data/lib/rhoconnect/api/system/get_adapter.rb +0 -4
  59. data/lib/rhoconnect/api/system/get_license_info.rb +0 -9
  60. data/lib/rhoconnect/api/system/login.rb +0 -15
  61. data/lib/rhoconnect/api/system/reset.rb +0 -11
  62. data/lib/rhoconnect/api/system/save_adapter.rb +0 -4
  63. data/lib/rhoconnect/api/system/stats.rb +0 -22
  64. data/lib/rhoconnect/api/user/create_user.rb +0 -7
  65. data/lib/rhoconnect/api/user/delete_client.rb +0 -6
  66. data/lib/rhoconnect/api/user/delete_user.rb +0 -11
  67. data/lib/rhoconnect/api/user/list_clients.rb +0 -4
  68. data/lib/rhoconnect/api/user/list_source_docs.rb +0 -11
  69. data/lib/rhoconnect/api/user/list_users.rb +0 -3
  70. data/lib/rhoconnect/api/user/ping.rb +0 -3
  71. data/lib/rhoconnect/api/user/show_user.rb +0 -3
  72. data/lib/rhoconnect/api/user/update_user.rb +0 -5
  73. data/lib/rhoconnect/api/user/user_get_db_doc.rb +0 -5
  74. data/lib/rhoconnect/api/user/user_set_db_doc.rb +0 -10
@@ -1,8 +0,0 @@
1
- # Server.api4 :client_set_db_doc, :post, "/rc/#{Rhoconnect::API_VERSION}/clients/:client_id/sources/:source_id/docs/:doc", true, nil do |params,user|
2
- # c = Client.load(params[:client_id],{:source_name => params[:source_id]})
3
- # db_key = c.docname(params[:doc])
4
- # append_to_doc = params[:append]
5
- # append_to_doc ||= false
6
- # Store.set_db_doc(db_key,params[:data],append_to_doc)
7
- # ''
8
- # end
@@ -1,7 +0,0 @@
1
- # Server.api4 :clientcreate, :post, "/rc/#{Rhoconnect::API_VERSION}/clients", \
2
- # false, {:verb => :get, :url => ['/application/clientcreate', '/api/application/clientcreate']} do |params,user,server|
3
- # server.content_type :json
4
- # client = Client.create(:user_id => server.current_user.id,:app_id => server.current_app.id)
5
- # client.update_fields(params)
6
- # { "client" => { "client_id" => client.id.to_s } }.to_json
7
- # end
@@ -1,4 +0,0 @@
1
- # Server.api4 :get_client_params, :get, "/rc/#{Rhoconnect::API_VERSION}/clients/:client_id", \
2
- # true, {:verb => :post, :url => ['/api/get_client_params', '/api/client/get_client_params']} do |params,user|
3
- # Client.load(params[:client_id],{:source_name => '*'}).to_array.to_json
4
- # end
@@ -1,17 +0,0 @@
1
- # Server.api4 :list_client_docs, :get, "/rc/#{Rhoconnect::API_VERSION}/clients/:client_id/sources/:source_id/docnames", \
2
- # true, {:verb => :post, :url => ['/api/list_client_docs', '/api/client/list_client_docs']} do |params,user|
3
- # result = ""
4
- # Rhoconnect::Stats::Record.update('clientdocs') do
5
- # c = Client.load(params[:client_id],{:source_name => params[:source_id]})
6
- # res = {}
7
- # [:cd,:cd_size,:create,:update,:delete,
8
- # :page,:delete_page,:create_links,:create_links_page,:page_token,
9
- # :create_errors,:update_errors,:delete_errors,:login_error,:logoff_error,
10
- # :search,:search_token,:search_errors].each do |doc|
11
- # db_key = c.docname(doc)
12
- # res.merge!(doc => db_key)
13
- # end
14
- # result = res.to_json
15
- # end
16
- # result
17
- # end
@@ -1,12 +0,0 @@
1
- # Server.api4 :clientregister, :post, "/rc/#{Rhoconnect::API_VERSION}/clients/:client_id/register", \
2
- # false, {:verb => :post, :url => ['/application/clientregister', '/api/application/clientregister'] } do |params,user,server|
3
- # current_client = server.current_client
4
- # if current_client.nil? and server.current_user and server.current_app
5
- # fields = {:user_id => server.current_user.id}
6
- # fields[:id] = params[:client_id].to_s
7
- # fields[:app_id] = server.current_app.id
8
- # current_client = Client.create(fields)
9
- # end
10
- # current_client.update_fields(params)
11
- # server.status 200
12
- # end
@@ -1,5 +0,0 @@
1
- # Server.api4 :clientreset, :post, "/rc/#{Rhoconnect::API_VERSION}/clients/:client_id/reset", \
2
- # false, {:verb => :get, :url => ['/application/clientreset', '/api/application/clientreset']} do |params,user,server|
3
- # ClientSync.reset(server.current_client, params)
4
- # server.status 200
5
- # end
@@ -1,9 +0,0 @@
1
- # Server.api4 :set_refresh_time, :put, "/rc/#{Rhoconnect::API_VERSION}/readstate/users/:user_name/sources/:source_name", \
2
- # true, {:verb => :post, :url => ['/api/set_refresh_time', '/api/source/set_refresh_time']} do |params,user|
3
- # source = Source.load(params[:source_name],
4
- # {:app_id => APP_NAME, :user_id => params[:user_name]})
5
- # source.poll_interval = params[:poll_interval] if params[:poll_interval]
6
- # params[:refresh_time] ||= 0
7
- # source.read_state.refresh_time = Time.now.to_i + params[:refresh_time].to_i
8
- # ''
9
- # end
@@ -1,4 +0,0 @@
1
- # Server.api4 :get_source_params, :get, "/rc/#{Rhoconnect::API_VERSION}/sources/:source_id", \
2
- # true, {:verb => :post, :url => ['/api/get_source_params', '/api/source/get_source_params']} do |params,user|
3
- # Source.load(params[:source_id],{:app_id => APP_NAME,:user_id => '*'}).to_array.to_json
4
- # end
@@ -1,16 +0,0 @@
1
- # Server.api4 :list_sources, :get, "/rc/#{Rhoconnect::API_VERSION}/sources/type/:partition_type", \
2
- # true, {:verb => :post, :url => ['/api/list_sources', '/api/source/list_sources']} do |params,user|
3
- # sources = App.load(APP_NAME).sources
4
- # if params['partition_type'].nil? or params['partition_type'] == 'all'
5
- # sources.to_json
6
- # else
7
- # res = []
8
- # sources.each do |name|
9
- # s = Source.load(name,{:app_id => APP_NAME,:user_id => '*'})
10
- # if s and s.partition_type and s.partition_type == params['partition_type'].to_sym
11
- # res << name
12
- # end
13
- # end
14
- # res.to_json
15
- # end
16
- # end
@@ -1,6 +0,0 @@
1
- # Server.api4 :update_source_params, :put, "/rc/#{Rhoconnect::API_VERSION}/sources/:source_id", true, nil do |params,user|
2
- # source = Source.load(params[:source_id],
3
- # {:app_id => APP_NAME, :user_id => '*'})
4
- # source.update_fields(params[:data])
5
- # ''
6
- # end
@@ -1,4 +0,0 @@
1
- # Server.api4 :get_db_doc, :get, "/rc/#{Rhoconnect::API_VERSION}/store/:doc", \
2
- # true, {:verb => :post, :url => ['/api/get_db_doc', '/api/source/get_db_doc']} do |params,user|
3
- # Store.get_db_doc(params[:doc])
4
- # end
@@ -1,7 +0,0 @@
1
- # Server.api4 :set_db_doc, :post, "/rc/#{Rhoconnect::API_VERSION}/store/:doc", \
2
- # true, {:verb => :post, :url => ['/api/set_db_doc', '/api/source/set_db_doc'] } do |params,user|
3
- # append_to_doc = params[:append]
4
- # append_to_doc ||= false
5
- # Store.set_db_doc(params[:doc],params[:data],append_to_doc)
6
- # ''
7
- # end
@@ -1,4 +0,0 @@
1
- # Server.api4 :get_adapter, :get, "/rc/#{Rhoconnect::API_VERSION}/system/appserver", \
2
- # true, {:verb => :post, :url => ['/api/get_adapter', '/api/source/get_adapter']} do |params,user|
3
- # {:adapter_url => Rhoconnect.appserver}.to_json
4
- # end
@@ -1,9 +0,0 @@
1
- # Server.api4 :get_license_info, :get, "/rc/#{Rhoconnect::API_VERSION}/system/license", \
2
- # true, {:verb => :post, :url => ['/api/get_license_info', '/api/admin/get_license_info']} do |params,user|
3
- # {:rhoconnect_version => Rhoconnect.license.rhoconnect_version,
4
- # :licensee => Rhoconnect.license.licensee,
5
- # :seats => Rhoconnect.license.seats,
6
- # :issued => Rhoconnect.license.issued,
7
- # :available => Rhoconnect.license.available }.to_json
8
- # end
9
-
@@ -1,15 +0,0 @@
1
- # Server.api4 :login, :post, "/rc/#{Rhoconnect::API_VERSION}/system/login", true, {:verb => :post, :url => ['/login', '/api/admin/login']} do |params,user,server|
2
- # token = ''
3
- # server.logout
4
- # server.do_login
5
- # u = User.load(params[:login])
6
- # token = do_get_api_token(params, u)
7
- # end
8
- #
9
- # def do_get_api_token(params, user)
10
- # if user and user.admin == 1 and user.token
11
- # user.token.value
12
- # else
13
- # raise ApiException.new(422, "Invalid/missing API user")
14
- # end
15
- # end
@@ -1,11 +0,0 @@
1
- # Server.api4 :reset, :post, "/rc/#{Rhoconnect::API_VERSION}/system/reset", true, {:verb => :post, :url => ['/api/reset', '/api/admin/reset']} do |params,user|
2
- # keep_token = user.token.value
3
- # Store.flush_all
4
- # app_klass = Object.const_get(camelize(APP_NAME))
5
- # if app_klass.singleton_methods.map(&:to_sym).include?(:initializer)
6
- # app_klass.send :initializer, Rhoconnect.base_directory
7
- # end
8
- # # restoring previous token value after flushdb
9
- # user.token = keep_token
10
- # "DB reset"
11
- # end
@@ -1,4 +0,0 @@
1
- # Server.api4 :save_adapter, :post, "/rc/#{Rhoconnect::API_VERSION}/system/appserver", \
2
- # true, {:verb => :post, :url => ['/api/save_adapter', '/api/source/save_adapter']} do |params,user|
3
- # Rhoconnect.appserver = params['adapter_url'] || params[:attributes]['adapter_url']
4
- # end
@@ -1,22 +0,0 @@
1
- # Server.api4 :stats, :get, "/rc/#{Rhoconnect::API_VERSION}/system/stats", \
2
- # true, {:verb => :post, :url => ['/api/stats', '/api/admin/stats']} do |params,user|
3
- # if Rhoconnect.stats == true
4
- # names = params[:names]
5
- # if names
6
- # Rhoconnect::Stats::Record.keys(names).to_json
7
- # else
8
- # metric = params[:metric]
9
- # rtype = Rhoconnect::Stats::Record.rtype(metric)
10
- # if rtype == 'zset'
11
- # # returns [] if no results
12
- # Rhoconnect::Stats::Record.range(metric,params[:start],params[:finish]).to_json
13
- # elsif rtype == 'string'
14
- # Rhoconnect::Stats::Record.get_value(metric) || ''
15
- # else
16
- # raise ApiException.new(404, "Unknown metric")
17
- # end
18
- # end
19
- # else
20
- # raise ApiException.new(500, "Stats not enabled")
21
- # end
22
- # end
@@ -1,7 +0,0 @@
1
- # Server.api4 :create_user, :post, "/rc/#{Rhoconnect::API_VERSION}/users", true, {:verb => :post, :url => ['/api/create_user', '/api/user/create_user']} do |params,user|
2
- # app = App.load(APP_NAME)
3
- # u = User.create({:login => params[:attributes]['login']})
4
- # u.password = params[:attributes]['password']
5
- # app.users << u.login
6
- # "User created"
7
- # end
@@ -1,6 +0,0 @@
1
- # Server.api4 :delete_client, :delete, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id/clients/:client_id", \
2
- # true, {:verb => :post, :url => ['/api/delete_client', '/api/client/delete_client']} do |params,user|
3
- # Client.load(params[:client_id],{:source_name => '*'}).delete
4
- # User.load(params[:user_id]).clients.delete(params[:client_id])
5
- # "Client deleted"
6
- # end
@@ -1,11 +0,0 @@
1
- # Server.api4 :delete_user, :delete, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id", \
2
- # true, {:verb => :post, :url => ['/api/delete_user', '/api/user/delete_user']} do |params,user|
3
- # User.load(params[:user_id]).delete
4
- # App.load(APP_NAME).users.delete(params[:user_id])
5
- # params = {:app_id => APP_NAME,:user_id => params[:user_id]}
6
- # App.load(APP_NAME).sources.each{ |source|
7
- # Source.load(source, params).flush_store_data
8
- # }
9
- # "User deleted"
10
- # end
11
- #
@@ -1,4 +0,0 @@
1
- # Server.api4 :list_clients, :get, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id/clients", \
2
- # true, {:verb => :post, :url => ['/api/list_clients', '/api/client/list_clients']} do |params,user|
3
- # User.load(params[:user_id]).clients.members.to_json
4
- # end
@@ -1,11 +0,0 @@
1
- # Server.api4 :list_source_docs, :get, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id/sources/:source_id/docnames", \
2
- # true, {:verb => :post, :url => ['/api/list_source_docs', '/api/source/list_source_docs']} do |params,user|
3
- # res = {}
4
- # s = Source.load(params[:source_id], {:app_id => APP_NAME,:user_id => params[:user_id]})
5
- # [:md,:md_size,:md_copy,:errors].each do |doc|
6
- # db_key = s.docname(doc)
7
- # res.merge!(doc => db_key)
8
- # end
9
- # res.to_json
10
- # end
11
-
@@ -1,3 +0,0 @@
1
- # Server.api4 :list_users, :get, "/rc/#{Rhoconnect::API_VERSION}/users", true, {:verb => :post, :url => ['/api/list_users', '/api/user/list_users']} do |params,user|
2
- # App.load(APP_NAME).users.members.to_json
3
- # end
@@ -1,3 +0,0 @@
1
- # Server.api4 :ping, :post, "/rc/#{Rhoconnect::API_VERSION}/users/ping", true, {:verb => :post, :url => ['/api/ping', '/api/client/ping']} do |params,user|
2
- # User.ping(params)
3
- # end
@@ -1,3 +0,0 @@
1
- # Server.api4 :show_user, :get, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id", true, nil do |params,user|
2
- # User.load(params[:user_id]).to_array.to_json
3
- # end
@@ -1,5 +0,0 @@
1
- # Server.api4 :update_user, :put, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id", \
2
- # true, {:verb => :post, :url => ["/api/update_user", '/api/user/update_user']} do |params,user|
3
- # User.load(params[:user_id]).update(params[:attributes])
4
- # "User updated"
5
- # end
@@ -1,5 +0,0 @@
1
- # Server.api4 :user_get_db_doc, :get, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id/sources/:source_id/docs/:doc", true, nil do |params,user|
2
- # s = Source.load(params[:source_id], {:app_id => APP_NAME,:user_id => params[:user_id]})
3
- # db_key = s.docname(params[:doc])
4
- # Store.get_db_doc(db_key)
5
- # end
@@ -1,10 +0,0 @@
1
- # Server.api4 :user_set_db_doc, :post, "/rc/#{Rhoconnect::API_VERSION}/users/:user_id/sources/:source_id/docs/:doc", true, nil do |params,user|
2
- # throw :halt, [500, "Unknown user '#{params[:user_id]}'"] unless User.is_exist?(params[:user_id])
3
- #
4
- # s = Source.load(params[:source_id], {:app_id => APP_NAME,:user_id => params[:user_id]})
5
- # db_key = s.docname(params[:doc])
6
- # append_to_doc = params[:append]
7
- # append_to_doc ||= false
8
- # Store.set_db_doc(db_key,params[:data],append_to_doc)
9
- # ''
10
- # end