infopark_cloud_connector 6.9.5 → 7.0.0
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 +8 -8
- data/app/controllers/rails_connector/default_cms_controller.rb +0 -1
- data/app/controllers/rails_connector/objs_controller.rb +31 -27
- data/app/helpers/rails_connector/cms_tag_helper.rb +20 -12
- data/app/views/rails_connector/objs/show_widget.html.erb +1 -0
- data/config/ca-bundle.crt +1 -1
- data/config/locales/de.rails_connector.views.yml +0 -3
- data/config/locales/en.rails_connector.views.yml +0 -3
- data/config/routes.rb +2 -1
- data/lib/assets/fonts/infopark_icons-webfont.eot +0 -0
- data/lib/assets/fonts/infopark_icons-webfont.ttf +0 -0
- data/lib/assets/fonts/infopark_icons-webfont.woff +0 -0
- data/lib/assets/javascripts/infopark_editing.js +84 -35
- data/lib/assets/stylesheets/infopark_editing.css +227 -33
- data/lib/generators/cms/migration/migration_generator.rb +1 -1
- data/lib/generators/cms/migration/templates/{migration.rb → migration.erb} +0 -0
- data/lib/rails_connector/attribute_content.rb +39 -40
- data/lib/rails_connector/basic_obj.rb +64 -56
- data/lib/rails_connector/basic_widget.rb +2 -0
- data/lib/rails_connector/cms_accessible.rb +0 -17
- data/lib/rails_connector/cms_backend.rb +2 -2
- data/lib/rails_connector/cms_env.rb +0 -5
- data/lib/rails_connector/cms_rest_api.rb +62 -30
- data/lib/rails_connector/configuration.rb +3 -3
- data/lib/rails_connector/connection_manager.rb +98 -0
- data/lib/rails_connector/content_service.rb +12 -94
- data/lib/rails_connector/content_state_caching.rb +3 -5
- data/lib/rails_connector/deprecation.rb +21 -0
- data/lib/rails_connector/link.rb +12 -22
- data/lib/rails_connector/migrations/cms_backend.rb +1 -1
- data/lib/rails_connector/migrations/migration.rb +1 -1
- data/lib/rails_connector/migrations/migration_dsl.rb +10 -101
- data/lib/rails_connector/named_link.rb +1 -1
- data/lib/rails_connector/obj_search_enumerator.rb +37 -49
- metadata +6 -5
- data/app/views/errors/410_gone.html.erb +0 -7
- data/app/views/rails_connector/objs/show.html.erb +0 -1
@@ -42,7 +42,7 @@ module RailsConnector
|
|
42
42
|
# Use this method to configure the directory that should be used to store cached data.
|
43
43
|
# By default, +RAILS_ROOT/tmp/infopark_cache+ will be used.
|
44
44
|
# @param path [String] Path to directory that should be used to store cached data.
|
45
|
-
# @example Configure +RailsConnector+ to store
|
45
|
+
# @example Configure +RailsConnector+ to store its cache under +/tmp/my_cache+.
|
46
46
|
# RailsConnector::Configuration.cache_path = '/tmp/my_cache'
|
47
47
|
# @api public
|
48
48
|
def cache_path=(path)
|
@@ -156,8 +156,8 @@ module RailsConnector
|
|
156
156
|
|
157
157
|
# Configure a callback to be invoked when the rails connector delivers the homepage.
|
158
158
|
# The given callback will receive the rack env
|
159
|
-
# and must return an Obj to be used as the homepage.
|
160
|
-
# If no callback is configured, Obj.homepage will be used as the default.
|
159
|
+
# and must return an {BasicObj Obj} to be used as the homepage.
|
160
|
+
# If no callback is configured, {BasicObj.homepage Obj.homepage} will be used as the default.
|
161
161
|
# @api public
|
162
162
|
def choose_homepage(&block)
|
163
163
|
self.choose_homepage_callback = block
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class ConnectionManager
|
3
|
+
SOCKET_ERRORS = [
|
4
|
+
EOFError,
|
5
|
+
Errno::ECONNABORTED,
|
6
|
+
Errno::ECONNREFUSED,
|
7
|
+
Errno::ECONNRESET,
|
8
|
+
Errno::EINVAL,
|
9
|
+
Errno::EPIPE,
|
10
|
+
Errno::ETIMEDOUT,
|
11
|
+
IOError,
|
12
|
+
SocketError,
|
13
|
+
Timeout::Error,
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
DEFAULT_TIMEOUT = 10.freeze
|
17
|
+
|
18
|
+
attr_reader :uri
|
19
|
+
|
20
|
+
def initialize(uri)
|
21
|
+
@uri = uri
|
22
|
+
end
|
23
|
+
|
24
|
+
def request(request, timeout=DEFAULT_TIMEOUT)
|
25
|
+
request['User-Agent'] = user_agent
|
26
|
+
|
27
|
+
retry_once_and_reset_connection do
|
28
|
+
ensure_started(uri, timeout)
|
29
|
+
connection.request(request)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_accessor :connection
|
36
|
+
|
37
|
+
def ensure_started(uri, timeout=DEFAULT_TIMEOUT)
|
38
|
+
if @connection && @connection.started?
|
39
|
+
configure_timeout(@connection, timeout)
|
40
|
+
else
|
41
|
+
conn = Net::HTTP.new(uri.host, uri.port)
|
42
|
+
if uri.scheme == 'https'
|
43
|
+
conn.use_ssl = true
|
44
|
+
conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
45
|
+
conn.ca_file = RailsConnector::Configuration.ca_file
|
46
|
+
end
|
47
|
+
configure_timeout(conn, timeout)
|
48
|
+
retry_twice_on_socket_error do
|
49
|
+
conn.start
|
50
|
+
end
|
51
|
+
@connection = conn
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def ensure_finished
|
56
|
+
@connection.finish if @connection && @connection.started?
|
57
|
+
@connection = nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def retry_once_and_reset_connection
|
61
|
+
retried = false
|
62
|
+
begin
|
63
|
+
yield
|
64
|
+
rescue *SOCKET_ERRORS => e
|
65
|
+
raise BackendNotAvailable.from_socket_error(e) if retried
|
66
|
+
ensure_finished
|
67
|
+
retried = true
|
68
|
+
retry
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def retry_twice_on_socket_error
|
73
|
+
attempt = 0
|
74
|
+
begin
|
75
|
+
yield
|
76
|
+
rescue *SOCKET_ERRORS => e
|
77
|
+
raise BackendNotAvailable.from_socket_error(e) if attempt == 2
|
78
|
+
attempt += 1
|
79
|
+
retry
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def configure_timeout(connection, timeout)
|
84
|
+
connection.open_timeout = timeout
|
85
|
+
connection.read_timeout = timeout
|
86
|
+
connection.ssl_timeout = timeout
|
87
|
+
end
|
88
|
+
|
89
|
+
def user_agent
|
90
|
+
@user_agent ||= (
|
91
|
+
gem_info = Gem.loaded_specs["infopark_cloud_connector"]
|
92
|
+
if gem_info
|
93
|
+
"#{gem_info.name}-#{gem_info.version}"
|
94
|
+
end
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -4,20 +4,7 @@ require 'net/http'
|
|
4
4
|
module RailsConnector
|
5
5
|
class ContentService
|
6
6
|
DEFAULT_PROTOCOL = 'https'.freeze
|
7
|
-
|
8
|
-
|
9
|
-
SOCKET_ERRORS = [
|
10
|
-
EOFError,
|
11
|
-
Errno::ECONNABORTED,
|
12
|
-
Errno::ECONNREFUSED,
|
13
|
-
Errno::ECONNRESET,
|
14
|
-
Errno::EINVAL,
|
15
|
-
Errno::EPIPE,
|
16
|
-
Errno::ETIMEDOUT,
|
17
|
-
IOError,
|
18
|
-
SocketError,
|
19
|
-
Timeout::Error,
|
20
|
-
].freeze
|
7
|
+
|
21
8
|
|
22
9
|
class Configuration
|
23
10
|
attr_accessor :url
|
@@ -70,16 +57,13 @@ class ContentService
|
|
70
57
|
@next_request_not_before = nil
|
71
58
|
|
72
59
|
def query(path, payload, options={})
|
73
|
-
timeout = options.fetch(:timeout, DEFAULT_TIMEOUT)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if @next_request_not_before && @next_request_not_before > (now = Time.now)
|
79
|
-
sleep @next_request_not_before - now
|
80
|
-
end
|
81
|
-
handle_response(ConnectionManager.connection(timeout).request(request))
|
60
|
+
timeout = options.fetch(:timeout, ConnectionManager::DEFAULT_TIMEOUT)
|
61
|
+
retry_until_timeout_on_rate_limit_exceeded do
|
62
|
+
request = build_request(path, payload)
|
63
|
+
if @next_request_not_before && @next_request_not_before > (now = Time.now)
|
64
|
+
sleep @next_request_not_before - now
|
82
65
|
end
|
66
|
+
handle_response(connection_manager.request(request, timeout))
|
83
67
|
end
|
84
68
|
end
|
85
69
|
|
@@ -88,20 +72,14 @@ class ContentService
|
|
88
72
|
@next_request_not_before = nil
|
89
73
|
end
|
90
74
|
|
91
|
-
|
75
|
+
attr_writer :connection_manager
|
92
76
|
|
93
|
-
def
|
94
|
-
|
95
|
-
begin
|
96
|
-
yield
|
97
|
-
rescue *SOCKET_ERRORS => e
|
98
|
-
raise BackendNotAvailable.from_socket_error(e) if retried
|
99
|
-
ConnectionManager.ensure_finished
|
100
|
-
retried = true
|
101
|
-
retry
|
102
|
-
end
|
77
|
+
def connection_manager
|
78
|
+
@connection_manager ||= ConnectionManager.new(uri)
|
103
79
|
end
|
104
80
|
|
81
|
+
private
|
82
|
+
|
105
83
|
def retry_until_timeout_on_rate_limit_exceeded
|
106
84
|
delay = Delay.new
|
107
85
|
begin
|
@@ -145,73 +123,13 @@ class ContentService
|
|
145
123
|
headers = {
|
146
124
|
'Content-Type' => 'application/json',
|
147
125
|
'Accept' => 'application/json',
|
148
|
-
'User-Agent' => user_agent,
|
149
126
|
}
|
150
127
|
if configuration.http_host
|
151
128
|
headers['Host'] = configuration.http_host
|
152
129
|
end
|
153
130
|
headers
|
154
131
|
end
|
155
|
-
|
156
|
-
def user_agent
|
157
|
-
@user_agent ||= (
|
158
|
-
gem_info = Gem.loaded_specs["infopark_cloud_connector"]
|
159
|
-
"#{gem_info.name}-#{gem_info.version}"
|
160
|
-
)
|
161
|
-
end
|
162
132
|
end
|
163
133
|
|
164
|
-
module ConnectionManager
|
165
|
-
def self.connection(timeout=DEFAULT_TIMEOUT)
|
166
|
-
configure_timeout(@connection, timeout) if @connection
|
167
|
-
@connection
|
168
|
-
end
|
169
|
-
|
170
|
-
def self.connection=(conn)
|
171
|
-
@connection = conn
|
172
|
-
end
|
173
|
-
|
174
|
-
def self.ensure_started(uri, timeout=DEFAULT_TIMEOUT)
|
175
|
-
return if @connection && @connection.started?
|
176
|
-
conn = Net::HTTP.new(uri.host, uri.port)
|
177
|
-
if uri.scheme == 'https'
|
178
|
-
conn.use_ssl = true
|
179
|
-
conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
180
|
-
conn.ca_file = RailsConnector::Configuration.ca_file
|
181
|
-
end
|
182
|
-
configure_timeout(conn, timeout)
|
183
|
-
retry_twice_on_socket_error do
|
184
|
-
conn.start
|
185
|
-
end
|
186
|
-
@connection = conn
|
187
|
-
end
|
188
|
-
|
189
|
-
def self.ensure_finished
|
190
|
-
@connection.finish if @connection && @connection.started?
|
191
|
-
@connection = nil
|
192
|
-
end
|
193
|
-
|
194
|
-
class << self
|
195
|
-
private
|
196
|
-
|
197
|
-
def retry_twice_on_socket_error
|
198
|
-
attempt = 0
|
199
|
-
begin
|
200
|
-
yield
|
201
|
-
rescue *ContentService::SOCKET_ERRORS => e
|
202
|
-
raise BackendNotAvailable.from_socket_error(e) if attempt == 2
|
203
|
-
attempt += 1
|
204
|
-
retry
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def configure_timeout(connection, timeout)
|
209
|
-
connection.open_timeout = timeout
|
210
|
-
connection.read_timeout = timeout
|
211
|
-
connection.ssl_timeout = timeout
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
215
|
-
end
|
216
134
|
end
|
217
135
|
end
|
@@ -2,7 +2,7 @@ module RailsConnector
|
|
2
2
|
|
3
3
|
# This module provides advances auto-invalidating caching mechanism for storing obj data.
|
4
4
|
#
|
5
|
-
# To keep it up-to-date
|
5
|
+
# To keep it up-to-date its caches and changes should be updated periodically
|
6
6
|
# It's changes should be updated every time a new workspace data has been fetched.
|
7
7
|
# It's caches should be updated every time a new obj data has been fetched.
|
8
8
|
module ContentStateCaching
|
@@ -16,15 +16,13 @@ module ContentStateCaching
|
|
16
16
|
|
17
17
|
# Updates caches with data from given workspace.
|
18
18
|
# Should be called every time a new OBJ data has been fetched.
|
19
|
-
def store_obj_data(
|
20
|
-
content_state = workspace_data.content_state
|
19
|
+
def store_obj_data(content_state, index, key, data)
|
21
20
|
content_state.save_obj_data(index, key, data) if content_state
|
22
21
|
end
|
23
22
|
|
24
23
|
# Fetches up-to-date obj data for given workspace, index and key.
|
25
24
|
# Returns nil if no up-to-date data found.
|
26
|
-
def find_obj_data(
|
27
|
-
return unless current_content_state = workspace_data.content_state
|
25
|
+
def find_obj_data(current_content_state , index, key)
|
28
26
|
if index == 'permalink'
|
29
27
|
current_content_state.find_obj_data(index, key)
|
30
28
|
else
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
class Deprecation
|
3
|
+
class << self
|
4
|
+
def warn(message, source = caller(1))
|
5
|
+
ActiveSupport::Deprecation.warn(message, source)
|
6
|
+
end
|
7
|
+
|
8
|
+
def warn_method(depricated_method_name, new_method_name = nil)
|
9
|
+
warn(warn_method_message(depricated_method_name, new_method_name), caller(1))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def warn_method_message(depricated_method_name, new_method_name = nil)
|
15
|
+
message = "The method #{depricated_method_name} will be removed from the CloudConnector. "
|
16
|
+
message << "Please use #{new_method_name} instead" if new_method_name
|
17
|
+
message
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/rails_connector/link.rb
CHANGED
@@ -10,7 +10,7 @@ module RailsConnector
|
|
10
10
|
# @api public
|
11
11
|
# @param [Hash] link_data
|
12
12
|
# @option link_data [String] url
|
13
|
-
# @option link_data [
|
13
|
+
# @option link_data [Obj] obj
|
14
14
|
# @option link_data [String] title
|
15
15
|
# @option link_data [String] query
|
16
16
|
# @option link_data [String] target
|
@@ -34,17 +34,17 @@ module RailsConnector
|
|
34
34
|
@link_data[:url] = value
|
35
35
|
end
|
36
36
|
|
37
|
-
# Returns the
|
37
|
+
# Returns the {BasicObj Obj} this link is referencing. May be nil if the
|
38
38
|
# link is external.
|
39
39
|
# @api public
|
40
40
|
def obj
|
41
41
|
@link_data[:obj]
|
42
42
|
end
|
43
43
|
|
44
|
-
# Set the
|
44
|
+
# Set the {BasicObj Obj} this link is referencing. May be nil if the
|
45
45
|
# link is external.
|
46
46
|
# @api public
|
47
|
-
# @param value [
|
47
|
+
# @param value [Obj] the obj this link should be referencing
|
48
48
|
def obj=(value)
|
49
49
|
@link_data[:obj] = value
|
50
50
|
end
|
@@ -131,11 +131,11 @@ module RailsConnector
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
# Returns the id of the Links'
|
134
|
+
# Returns the id of the Links' destination obj.
|
135
135
|
# @api public
|
136
136
|
# @deprecated use {#obj}.id instead
|
137
137
|
def destination_object_id
|
138
|
-
|
138
|
+
Deprecation.warn_method('Link#destination_object_id', 'obj.id')
|
139
139
|
obj.id
|
140
140
|
end
|
141
141
|
|
@@ -162,10 +162,12 @@ module RailsConnector
|
|
162
162
|
!internal?
|
163
163
|
end
|
164
164
|
|
165
|
-
# An internal Link is active if
|
165
|
+
# An internal Link is active if its destination obj is active.
|
166
166
|
# An external Link is always active.
|
167
167
|
# @api public
|
168
|
+
# @ deprecated this method will be removed without substitution
|
168
169
|
def active?
|
170
|
+
Deprecation.warn_method('Link#active?')
|
169
171
|
external? || (obj && obj.active?)
|
170
172
|
end
|
171
173
|
|
@@ -174,15 +176,15 @@ module RailsConnector
|
|
174
176
|
end
|
175
177
|
|
176
178
|
def resolved?
|
177
|
-
external? ||
|
179
|
+
external? || !obj.nil?
|
178
180
|
end
|
179
181
|
|
180
|
-
# Returns the destination
|
182
|
+
# Returns the destination obj ({BasicObj Obj}) of this Link. May be nil if the
|
181
183
|
# link is external or internal without an existing destination object.
|
182
184
|
# @api public
|
183
185
|
# @deprecated use {#obj} instead
|
184
186
|
def destination_object
|
185
|
-
|
187
|
+
Deprecation.warn_method('Link#destination_object', :obj)
|
186
188
|
obj
|
187
189
|
end
|
188
190
|
|
@@ -209,17 +211,5 @@ module RailsConnector
|
|
209
211
|
external_prefix? ? url.gsub(/external:/, '').strip : url
|
210
212
|
end
|
211
213
|
|
212
|
-
private
|
213
|
-
|
214
|
-
def resolved_internal?
|
215
|
-
internal? && !obj.nil?
|
216
|
-
end
|
217
|
-
|
218
|
-
def deprecation_warning(method, alternative)
|
219
|
-
ActiveSupport::Deprecation.warn(
|
220
|
-
"[DEPRECATION] The medod #{method} will be removed from the RailsConnector. Please use #{alternative} instead"
|
221
|
-
)
|
222
|
-
end
|
223
|
-
|
224
214
|
end
|
225
215
|
end
|
@@ -9,7 +9,7 @@ module RailsConnector
|
|
9
9
|
#
|
10
10
|
# class CreateTestAttribute < RailsConnector::Migrations::Migration
|
11
11
|
# def up
|
12
|
-
#
|
12
|
+
# add_attribute_to('homepage', :name => 'test', :type => 'string')
|
13
13
|
# end
|
14
14
|
# end
|
15
15
|
class Migration
|
@@ -3,26 +3,6 @@ module RailsConnector
|
|
3
3
|
module Migrations
|
4
4
|
# @api public
|
5
5
|
module MigrationDsl
|
6
|
-
# Creates a CMS attribute.
|
7
|
-
#
|
8
|
-
# @example Create "test" Attribute
|
9
|
-
#
|
10
|
-
# create_attribute(name: 'test', type: 'string')
|
11
|
-
#
|
12
|
-
# @param attributes [Hash] The attributes and their values of the new
|
13
|
-
# CMS attribute.
|
14
|
-
#
|
15
|
-
# @return nothing
|
16
|
-
# @deprecated Please use local attributes. Create attributes using {#create_obj_class} or
|
17
|
-
# {#update_obj_class}.
|
18
|
-
# @api public
|
19
|
-
def create_attribute(attributes = {})
|
20
|
-
warn_deprecated __callee__, 'create_obj_class', 'update_obj_class'
|
21
|
-
endpoint = "revisions/#{Workspace.current.revision_id}/attributes"
|
22
|
-
|
23
|
-
CmsRestApi.post(endpoint, attribute: attributes)
|
24
|
-
end
|
25
|
-
|
26
6
|
# Adds an attribute to an object class.
|
27
7
|
#
|
28
8
|
# @example Add "test" attribute to object class "Foo.
|
@@ -54,17 +34,13 @@ module RailsConnector
|
|
54
34
|
def delete_attribute_from(obj_class_name, attribute_name)
|
55
35
|
attributes = get_obj_class(obj_class_name)['attributes']
|
56
36
|
attributes = attributes.delete_if do |attribute|
|
57
|
-
|
58
|
-
name = attribute.is_a?(String) ? attribute : attribute['name']
|
59
|
-
|
60
|
-
name == attribute_name.to_s
|
37
|
+
attribute['name'] == attribute_name.to_s
|
61
38
|
end
|
62
39
|
|
63
40
|
update_obj_class(obj_class_name, attributes: attributes)
|
64
41
|
end
|
65
42
|
|
66
|
-
# Updates an attribute for an object class.
|
67
|
-
# attribute if found.
|
43
|
+
# Updates an attribute for an object class.
|
68
44
|
#
|
69
45
|
# @example Update "test" attribute for object class "Foo.
|
70
46
|
#
|
@@ -82,13 +58,7 @@ module RailsConnector
|
|
82
58
|
found = false
|
83
59
|
|
84
60
|
attributes.each_with_index do |attribute, index|
|
85
|
-
|
86
|
-
|
87
|
-
if name == attribute_name
|
88
|
-
if attribute.is_a?(String)
|
89
|
-
attribute = get_attribute(attribute)
|
90
|
-
end
|
91
|
-
|
61
|
+
if attribute['name'] == attribute_name
|
92
62
|
attributes[index] = attribute.merge(params.stringify_keys)
|
93
63
|
update_obj_class(obj_class_name, attributes: attributes)
|
94
64
|
|
@@ -115,7 +85,7 @@ module RailsConnector
|
|
115
85
|
# @return nothing
|
116
86
|
# @api public
|
117
87
|
def create_obj(attributes = {})
|
118
|
-
endpoint = "
|
88
|
+
endpoint = "workspaces/#{Workspace.current.id}/objs"
|
119
89
|
|
120
90
|
CmsRestApi.post(endpoint, obj: attributes)
|
121
91
|
end
|
@@ -132,29 +102,11 @@ module RailsConnector
|
|
132
102
|
# @return nothing
|
133
103
|
# @api public
|
134
104
|
def create_obj_class(attributes = {})
|
135
|
-
endpoint = "
|
105
|
+
endpoint = "workspaces/#{Workspace.current.id}/obj_classes"
|
136
106
|
|
137
107
|
CmsRestApi.post(endpoint, obj_class: attributes)
|
138
108
|
end
|
139
109
|
|
140
|
-
# Deletes a CMS attribute.
|
141
|
-
#
|
142
|
-
# @example Delete "test" Attribute
|
143
|
-
#
|
144
|
-
# delete_attribute('test')
|
145
|
-
#
|
146
|
-
# @param id [String] The ID of the CMS attribute.
|
147
|
-
#
|
148
|
-
# @return nothing
|
149
|
-
# @deprecated Please use local attributes. Delete attributes using {#update_obj_class}.
|
150
|
-
# @api public
|
151
|
-
def delete_attribute(id)
|
152
|
-
warn_deprecated __callee__, 'update_obj_class'
|
153
|
-
endpoint = "revisions/#{Workspace.current.revision_id}/attributes/#{id}"
|
154
|
-
|
155
|
-
CmsRestApi.delete(endpoint)
|
156
|
-
end
|
157
|
-
|
158
110
|
# Deletes a CMS object with the given id.
|
159
111
|
#
|
160
112
|
# @example Deletes "a1b2c3" Object
|
@@ -166,29 +118,11 @@ module RailsConnector
|
|
166
118
|
# @return nothing
|
167
119
|
# @api public
|
168
120
|
def delete_obj(id)
|
169
|
-
endpoint = "
|
121
|
+
endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}"
|
170
122
|
|
171
123
|
CmsRestApi.delete(endpoint)
|
172
124
|
end
|
173
125
|
|
174
|
-
# Fetches all attribute attributes and their values.
|
175
|
-
#
|
176
|
-
# @example Get all attributes for the attribute "test"
|
177
|
-
#
|
178
|
-
# get_attribute('test')
|
179
|
-
#
|
180
|
-
# @param id [String] The ID of the attribute.
|
181
|
-
#
|
182
|
-
# @return [Hash] a hash with attributes and their values.
|
183
|
-
# @deprecated Please use local attributes. Get attributes using {#get_obj_class}.
|
184
|
-
# @api public
|
185
|
-
def get_attribute(id)
|
186
|
-
warn_deprecated __callee__, 'get_obj_class'
|
187
|
-
endpoint = "revisions/#{Workspace.current.revision_id}/attributes/#{id}"
|
188
|
-
|
189
|
-
CmsRestApi.get(endpoint)
|
190
|
-
end
|
191
|
-
|
192
126
|
# Fetches all object attributes and their values.
|
193
127
|
#
|
194
128
|
# @example Get all attributes for the obj with id "abc123"
|
@@ -200,7 +134,7 @@ module RailsConnector
|
|
200
134
|
# @return [Hash] a hash with attributes and their values.
|
201
135
|
# @api public
|
202
136
|
def get_obj(id)
|
203
|
-
endpoint = "
|
137
|
+
endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}"
|
204
138
|
|
205
139
|
CmsRestApi.get(endpoint)
|
206
140
|
end
|
@@ -216,30 +150,11 @@ module RailsConnector
|
|
216
150
|
# @return [Hash] a hash with attributes and their values.
|
217
151
|
# @api public
|
218
152
|
def get_obj_class(id)
|
219
|
-
endpoint = "
|
153
|
+
endpoint = "workspaces/#{Workspace.current.id}/obj_classes/#{id}"
|
220
154
|
|
221
155
|
CmsRestApi.get(endpoint)
|
222
156
|
end
|
223
157
|
|
224
|
-
# Updates a CMS attribute.
|
225
|
-
#
|
226
|
-
# @example Update the title of the "test" Attribute
|
227
|
-
#
|
228
|
-
# update_attribute(title: 'Test Title')
|
229
|
-
#
|
230
|
-
# @param id [String] The ID of the attribute.
|
231
|
-
# @param attributes [Hash] The updated attributes and their values.
|
232
|
-
#
|
233
|
-
# @return nothing
|
234
|
-
# @deprecated Please use local attributes. Update attributes using {#update_obj_class}.
|
235
|
-
# @api public
|
236
|
-
def update_attribute(id, attributes = {})
|
237
|
-
warn_deprecated __callee__, 'update_obj_class'
|
238
|
-
endpoint = "revisions/#{Workspace.current.revision_id}/attributes/#{id}"
|
239
|
-
|
240
|
-
CmsRestApi.put(endpoint, attribute: attributes)
|
241
|
-
end
|
242
|
-
|
243
158
|
# Updates a CMS object.
|
244
159
|
#
|
245
160
|
# @example Update the title of the "a1b2c3" Object
|
@@ -252,7 +167,7 @@ module RailsConnector
|
|
252
167
|
# @return nothing
|
253
168
|
# @api public
|
254
169
|
def update_obj(id, attributes = {})
|
255
|
-
endpoint = "
|
170
|
+
endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}"
|
256
171
|
|
257
172
|
CmsRestApi.put(endpoint, obj: attributes)
|
258
173
|
end
|
@@ -269,7 +184,7 @@ module RailsConnector
|
|
269
184
|
# @return nothing
|
270
185
|
# @api public
|
271
186
|
def update_obj_class(id, attributes = {})
|
272
|
-
endpoint = "
|
187
|
+
endpoint = "workspaces/#{Workspace.current.id}/obj_classes/#{id}"
|
273
188
|
|
274
189
|
CmsRestApi.put(endpoint, obj_class: attributes)
|
275
190
|
end
|
@@ -297,12 +212,6 @@ module RailsConnector
|
|
297
212
|
|
298
213
|
upload_permission['blob']
|
299
214
|
end
|
300
|
-
|
301
|
-
private
|
302
|
-
|
303
|
-
def warn_deprecated(method, *substitutes)
|
304
|
-
warn "[DEPRECATION] '#{method}' is deprecated. Use '#{substitutes.join("' or '")}' instead."
|
305
|
-
end
|
306
215
|
end
|
307
216
|
end
|
308
217
|
end
|