infopark_cloud_connector 6.8.0.72.d18d096 → 6.8.0.110.6570b45

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,7 +54,7 @@ module RailsConnector
54
54
  private
55
55
 
56
56
  def url
57
- "#{@options[:url]}/revisions/#{Revision.current.id}/objs/search"
57
+ "#{@options[:url]}/revisions/#{Workspace.current.revision_id}/objs/search"
58
58
  end
59
59
 
60
60
  def query
@@ -3,7 +3,9 @@ module RailsConnector
3
3
  class CmsBackend
4
4
 
5
5
  def self.current
6
- @current ||= DynamoCmsBackend.new
6
+ @current ||=
7
+ DynamoCmsBackend.new
8
+ # ServiceCmsBackend.new
7
9
  end
8
10
 
9
11
  def self.begin_caching
@@ -14,8 +16,8 @@ module RailsConnector
14
16
  current.end_caching
15
17
  end
16
18
 
17
- def self.find_obj_data_by(revision, index, keys)
18
- current.find_obj_data_by(revision, index, keys)
19
+ def self.find_obj_data_by(workspace, index, keys)
20
+ current.find_obj_data_by(workspace, index, keys)
19
21
  end
20
22
 
21
23
  def self.caching?
@@ -0,0 +1,16 @@
1
+ class ConnectorService
2
+
3
+ def self.query(path, payload)
4
+ MultiJson.load(RestClient::Request.execute(
5
+ :method => :post,
6
+ # FIXME
7
+ :url => "localhost:3001/#{path}",
8
+ :headers => {
9
+ :content_type => :json,
10
+ :accept => :json,
11
+ },
12
+ :payload => MultiJson.dump(payload)
13
+ ))
14
+ end
15
+
16
+ end
@@ -12,7 +12,8 @@ module RailsConnector
12
12
  @editable_cache = @read_only_cache = nil
13
13
  end
14
14
 
15
- def find_obj_data_by(revision, index, keys)
15
+ def find_obj_data_by(workspace, index, keys)
16
+ revision = workspace.revision
16
17
  raw_data =
17
18
  if caching?
18
19
  find_obj_data_from_cache_or_database_by(revision, index, keys)
@@ -99,7 +99,7 @@ module RailsConnector
99
99
  # accepts the name of an "obj_by" - view and a list of keys.
100
100
  # returns a list of lists of Objs: a list of Objs for each given keys.
101
101
  def self.find_objs_by(view, keys) # :nodoc:
102
- CmsBackend.find_obj_data_by(Revision.current, view, keys).map do |list|
102
+ CmsBackend.find_obj_data_by(Workspace.current, view, keys).map do |list|
103
103
  list.map { |obj_data| Obj.instantiate(obj_data) }
104
104
  end
105
105
  end
@@ -434,7 +434,7 @@ module RailsConnector
434
434
  # Notice that the ruby class of this Obj instance will NOT change,
435
435
  # even if the obj_class in the database has changed.
436
436
  def reload
437
- obj_data = CmsBackend.find_obj_data_by(Revision.current, :id, [id.to_s]).first.first
437
+ obj_data = CmsBackend.find_obj_data_by(Workspace.current, :id, [id.to_s]).first.first
438
438
  update_data(obj_data)
439
439
  end
440
440
 
@@ -6,6 +6,10 @@ module RailsConnector
6
6
  value_and_type_of(attribute_name).first
7
7
  end
8
8
 
9
+ def type_of(attribute_name)
10
+ value_and_type_of(attribute_name).second
11
+ end
12
+
9
13
  def value_and_type_of(attribute_name)
10
14
  raise "implement in subclass"
11
15
  end
@@ -28,6 +32,8 @@ module RailsConnector
28
32
  "date"
29
33
  when "title"
30
34
  "html"
35
+ else
36
+ nil
31
37
  end
32
38
  end
33
39
 
@@ -0,0 +1,50 @@
1
+ module RailsConnector
2
+
3
+ class ObjDataFromService < ObjData
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ def value_and_type_of(attribute_name)
9
+ value_and_type = @data[attribute_name]
10
+
11
+ if value_and_type.blank?
12
+ if INTERNAL_KEYS.include?(attribute_name)
13
+ type = type_of_internal(attribute_name)
14
+ [default_attribute_value(type), type]
15
+ else
16
+ raise "Illegal attribute name #{attribute_name}"
17
+ end
18
+ elsif value_and_type.length == 1
19
+ [value_and_type.first, type_of_internal(attribute_name)]
20
+ else
21
+ value_and_type
22
+ end
23
+ end
24
+
25
+ def has_custom_attribute?(attribute_name)
26
+ !!@data[attribute_name]
27
+ end
28
+
29
+ private
30
+
31
+ internal_key_list = %w[
32
+ last_changed
33
+ sort_key1
34
+ sort_key2
35
+ sort_key3
36
+ sort_order
37
+ sort_type1
38
+ sort_type2
39
+ sort_type3
40
+ suppress_export
41
+ text_links
42
+ valid_from
43
+ valid_until
44
+ ]
45
+
46
+ INTERNAL_KEYS = Set.new(internal_key_list.map { |name| "_#{name}" } )
47
+
48
+ end
49
+
50
+ end
@@ -10,17 +10,12 @@ module RailsConnector
10
10
  property :content_cache_id
11
11
  property :editable
12
12
 
13
- # Selects the revision with the given id as current revision
14
13
  def self.current=(revision_or_proc)
15
- @current = revision_or_proc
14
+ raise "Do not use Revision.current=, use Workspace.current= instead."
16
15
  end
17
16
 
18
17
  def self.current
19
- if @current.respond_to? :call
20
- @current = @current.call
21
- else
22
- @current || default
23
- end
18
+ raise "Do not use Revision.current, use Workspace.current instead."
24
19
  end
25
20
 
26
21
  def self.find_by_label(label_name)
@@ -28,10 +23,6 @@ module RailsConnector
28
23
  find(workspace.revision_id)
29
24
  end
30
25
 
31
- def self.default
32
- find_by_label("published")
33
- end
34
-
35
26
  def chain
36
27
  @chain ||= Chain.build_for(self, content_cache)
37
28
  end
@@ -0,0 +1,48 @@
1
+ require 'rest_client'
2
+
3
+ module RailsConnector
4
+
5
+ # connects the cloud connector to the connector service
6
+ class ServiceCmsBackend < CmsBackend
7
+
8
+ def begin_caching
9
+ # TODO
10
+ end
11
+
12
+ def end_caching
13
+ # TODO
14
+ end
15
+
16
+ def caching?
17
+ # TODO
18
+ end
19
+
20
+ def find_obj_data_by(workspace, index, keys)
21
+ raw_data = ConnectorService.query(
22
+ "objs/query",
23
+ :queries => keys.map do |key|
24
+ { :type => index, :param => key }
25
+ end,
26
+ :workspace => workspace.id,
27
+ :revision => workspace.revision.id
28
+ )
29
+
30
+ objs = {}
31
+ raw_data["objs"].each do |obj|
32
+ objs[obj["_id"].first] = obj
33
+ end
34
+
35
+ raw_data["results"].map do |query|
36
+ query["refs"].map do |obj_ref|
37
+ id = obj_ref["id"]
38
+
39
+ # TODO fetch missing ObjData from Service
40
+ raw_obj_data = objs[id] or raise "Data for Obj with id #{id} missing!"
41
+ ObjDataFromService.new(raw_obj_data)
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -6,6 +6,30 @@ class Workspace < CmsBaseModel
6
6
 
7
7
  property :revision_id
8
8
 
9
+ def self.current=(workspace_or_proc)
10
+ @current = workspace_or_proc
11
+ end
12
+
13
+ def self.current
14
+ if @current.respond_to? :call
15
+ @current = @current.call
16
+ else
17
+ @current || default
18
+ end
19
+ end
20
+
21
+ def self.default
22
+ find("published")
23
+ end
24
+
25
+ def revision
26
+ @revision ||= Revision.find(revision_id)
27
+ end
28
+
29
+ def content_cache_id=(cc)
30
+ revision.content_cache_id = cc
31
+ end
32
+
9
33
  end
10
34
 
11
35
  end
@@ -2,8 +2,8 @@
2
2
  module RailsConnector
3
3
 
4
4
  class WorkspaceSelectionMiddleware
5
- CURRENT_WORKSPACE_SESSION_KEY = "infopark_rails_connector-current_workspace_id"
6
- CURRENT_WORKSPACE_PARAMS_KEY = "infopark_rails_connector-current_workspace_id"
5
+ CURRENT_WORKSPACE_SESSION_KEY = '_rc-ws'
6
+ CURRENT_WORKSPACE_PARAMS_KEY = '_rc-ws'
7
7
 
8
8
  def initialize(app)
9
9
  @app = app
@@ -11,9 +11,17 @@ class WorkspaceSelectionMiddleware
11
11
 
12
12
  def call(env)
13
13
  handle_workspace_parameter(env)
14
- preview_workspace = session(env)[CURRENT_WORKSPACE_SESSION_KEY]
15
- Revision.current = proc do
16
- preview_workspace ? Revision.find(preview_workspace) : Revision.default
14
+ workspace_id = session(env)[CURRENT_WORKSPACE_SESSION_KEY]
15
+ Workspace.current = proc do
16
+ if workspace_id
17
+ begin
18
+ Workspace.find(workspace_id)
19
+ rescue Kvom::NotFound
20
+ Workspace.default
21
+ end
22
+ else
23
+ Workspace.default
24
+ end
17
25
  end
18
26
  @app.call(env)
19
27
  end
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_cloud_connector
3
3
  version: !ruby/object:Gem::Version
4
- hash: 300142121
5
- prerelease: 9
4
+ hash: 910834687
5
+ prerelease: 14
6
6
  segments:
7
7
  - 6
8
8
  - 8
9
9
  - 0
10
- - 72
11
- - d
12
- - 18
13
- - d
14
- - 96
15
- version: 6.8.0.72.d18d096
10
+ - 110
11
+ - 6570
12
+ - b
13
+ - 45
14
+ version: 6.8.0.110.6570b45
16
15
  platform: ruby
17
16
  authors:
18
17
  - Infopark AG
@@ -20,11 +19,10 @@ autorequire:
20
19
  bindir: bin
21
20
  cert_chain: []
22
21
 
23
- date: 2012-10-22 00:00:00 +02:00
22
+ date: 2012-10-26 00:00:00 +02:00
24
23
  default_executable:
25
24
  dependencies:
26
25
  - !ruby/object:Gem::Dependency
27
- type: :runtime
28
26
  requirement: &id001 !ruby/object:Gem::Requirement
29
27
  none: false
30
28
  requirements:
@@ -36,11 +34,11 @@ dependencies:
36
34
  - 3
37
35
  - 6
38
36
  version: 1.3.6
39
- name: aws-sdk
40
37
  version_requirements: *id001
38
+ name: aws-sdk
41
39
  prerelease: false
42
- - !ruby/object:Gem::Dependency
43
40
  type: :runtime
41
+ - !ruby/object:Gem::Dependency
44
42
  requirement: &id002 !ruby/object:Gem::Requirement
45
43
  none: false
46
44
  requirements:
@@ -51,30 +49,30 @@ dependencies:
51
49
  - 1
52
50
  - 6
53
51
  version: "1.6"
54
- name: rest-client
55
52
  version_requirements: *id002
53
+ name: rest-client
56
54
  prerelease: false
57
- - !ruby/object:Gem::Dependency
58
55
  type: :runtime
56
+ - !ruby/object:Gem::Dependency
59
57
  requirement: &id003 !ruby/object:Gem::Requirement
60
58
  none: false
61
59
  requirements:
62
60
  - - "="
63
61
  - !ruby/object:Gem::Version
64
- hash: 300142121
62
+ hash: 910834687
65
63
  segments:
66
64
  - 6
67
65
  - 8
68
66
  - 0
69
- - 72
70
- - d
71
- - 18
72
- - d
73
- - 96
74
- version: 6.8.0.72.d18d096
75
- name: kvom
67
+ - 110
68
+ - 6570
69
+ - b
70
+ - 45
71
+ version: 6.8.0.110.6570b45
76
72
  version_requirements: *id003
73
+ name: kvom
77
74
  prerelease: false
75
+ type: :runtime
78
76
  description: The Cloud Connector for Infopark CMS Fiona enables you to develop modern, dynamic Web 2.0 applications using Ruby on Rails and at the same time display CMS managed content.
79
77
  email: info@infopark.de
80
78
  executables: []
@@ -92,6 +90,7 @@ files:
92
90
  - lib/rails_connector/cms_api_search_request.rb
93
91
  - lib/rails_connector/cms_backend.rb
94
92
  - lib/rails_connector/cms_base_model.rb
93
+ - lib/rails_connector/connector_service.rb
95
94
  - lib/rails_connector/content_cache.rb
96
95
  - lib/rails_connector/controller_runtime.rb
97
96
  - lib/rails_connector/date_attribute.rb
@@ -108,11 +107,13 @@ files:
108
107
  - lib/rails_connector/obj_data.rb
109
108
  - lib/rails_connector/obj_data_from_database.rb
110
109
  - lib/rails_connector/obj_data_from_hash.rb
110
+ - lib/rails_connector/obj_data_from_service.rb
111
111
  - lib/rails_connector/path_conversion.rb
112
112
  - lib/rails_connector/permission.rb
113
113
  - lib/rails_connector/rack_middlewares.rb
114
114
  - lib/rails_connector/revision.rb
115
115
  - lib/rails_connector/s3_blob.rb
116
+ - lib/rails_connector/service_cms_backend.rb
116
117
  - lib/rails_connector/version.rb
117
118
  - lib/rails_connector/workspace.rb
118
119
  - lib/rails_connector/workspace_selection_middleware.rb