infopark_fiona7 0.30.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/Rakefile +21 -0
- data/app/assets/images/fiona7-logo.png +0 -0
- data/app/assets/images/fiona7-marker.png +0 -0
- data/app/assets/javascripts/fiona7.js +284 -0
- data/app/assets/stylesheets/fiona7-login.css.scss +15 -0
- data/app/assets/stylesheets/fiona7.css.scss +83 -0
- data/app/controllers/fiona7/blobs_controller.rb +35 -0
- data/app/controllers/fiona7/default_scrivito_cms_controller.rb +16 -0
- data/app/controllers/fiona7/release_controller.rb +24 -0
- data/app/controllers/fiona7/sessions_controller.rb +49 -0
- data/app/controllers/fiona7_login_page_controller.rb +27 -0
- data/app/helpers/fiona7_login_helper.rb +18 -0
- data/app/helpers/fiona7_override_helper.rb +47 -0
- data/app/models/fiona7/edited_obj.rb +15 -0
- data/app/models/fiona7/internal_released_obj.rb +18 -0
- data/app/models/fiona7/released_obj.rb +18 -0
- data/app/models/fiona7/write_obj.rb +63 -0
- data/app/models/fiona7_login_page.rb +5 -0
- data/app/models/x_container.rb +5 -0
- data/app/models/x_generic.rb +5 -0
- data/app/models/x_image.rb +5 -0
- data/app/views/fiona7_login_page/index.html.erb +14 -0
- data/app/views/layouts/fiona7_login_page_layout.html.erb +23 -0
- data/config/locales/login.yml +19 -0
- data/config/locales/permissions.yml +7 -0
- data/config/routes.rb +9 -0
- data/lib/fiona7/assert.rb +17 -0
- data/lib/fiona7/builder/batch_widget_writer.rb +107 -0
- data/lib/fiona7/builder/obj_builder.rb +297 -0
- data/lib/fiona7/builder/obj_class_builder.rb +111 -0
- data/lib/fiona7/builder/obj_class_updater.rb +69 -0
- data/lib/fiona7/builder/obj_updater.rb +25 -0
- data/lib/fiona7/builder/widget_builder.rb +13 -0
- data/lib/fiona7/builder/widget_building.rb +35 -0
- data/lib/fiona7/builder/widget_updater.rb +13 -0
- data/lib/fiona7/controllers/content_service/obj_controller.rb +125 -0
- data/lib/fiona7/controllers/content_service/workspace_controller.rb +19 -0
- data/lib/fiona7/controllers/rest_api/blob_controller.rb +11 -0
- data/lib/fiona7/controllers/rest_api/obj_class_controller.rb +39 -0
- data/lib/fiona7/controllers/rest_api/obj_controller.rb +175 -0
- data/lib/fiona7/controllers/rest_api/workspace_controller.rb +58 -0
- data/lib/fiona7/engine.rb +138 -0
- data/lib/fiona7/fiona_connector_patches/basic_obj.rb +9 -0
- data/lib/fiona7/initializer.rb +78 -0
- data/lib/fiona7/json/obj_class_decorator.rb +45 -0
- data/lib/fiona7/json/obj_decorator.rb +153 -0
- data/lib/fiona7/json/typeless_obj_decorator.rb +30 -0
- data/lib/fiona7/json/widget_decorator.rb +18 -0
- data/lib/fiona7/link_converter/fiona_to_scrivito.rb +37 -0
- data/lib/fiona7/link_converter/scrivito_to_fiona.rb +42 -0
- data/lib/fiona7/mode_switch.rb +7 -0
- data/lib/fiona7/mode_switch/abstract_mode_switch.rb +19 -0
- data/lib/fiona7/mode_switch/cms_routes.rb +33 -0
- data/lib/fiona7/mode_switch/cms_routes/fiona_connector.rb +17 -0
- data/lib/fiona7/mode_switch/cms_routes/scrivito_sdk.rb +20 -0
- data/lib/fiona7/mode_switch/cms_routes/scrivito_sdk_slave.rb +20 -0
- data/lib/fiona7/mode_switch/composite.rb +33 -0
- data/lib/fiona7/mode_switch/constants.rb +86 -0
- data/lib/fiona7/mode_switch/views.rb +37 -0
- data/lib/fiona7/naive_search_engine.rb +111 -0
- data/lib/fiona7/recursive_link_resolver.rb +93 -0
- data/lib/fiona7/routers/content_service.rb +19 -0
- data/lib/fiona7/routers/rest_api.rb +135 -0
- data/lib/fiona7/routing_monkey_patch.rb +33 -0
- data/lib/fiona7/scrivito_patches/attribute_content.rb +19 -0
- data/lib/fiona7/scrivito_patches/basic_obj.rb +92 -0
- data/lib/fiona7/scrivito_patches/basic_widget.rb +14 -0
- data/lib/fiona7/scrivito_patches/binary.rb +55 -0
- data/lib/fiona7/scrivito_patches/client_config.rb +19 -0
- data/lib/fiona7/scrivito_patches/cms_dispatch_controller.rb +31 -0
- data/lib/fiona7/scrivito_patches/cms_rest_api.rb +11 -0
- data/lib/fiona7/scrivito_patches/cms_routing.rb +66 -0
- data/lib/fiona7/scrivito_patches/controller_actions.rb +14 -0
- data/lib/fiona7/scrivito_patches/link_parser.rb +22 -0
- data/lib/fiona7/scrivito_patches/migrator.rb +13 -0
- data/lib/fiona7/scrivito_patches/obj_class.rb +16 -0
- data/lib/fiona7/scrivito_patches/type_computer.rb +25 -0
- data/lib/fiona7/scrivito_patches/workspace.rb +12 -0
- data/lib/fiona7/scrivito_user.rb +44 -0
- data/lib/fiona7/search_engine.rb +20 -0
- data/lib/fiona7/type_register.rb +140 -0
- data/lib/fiona7/type_register_mixin.rb +9 -0
- data/lib/fiona7/version.rb +3 -0
- data/lib/fiona7/version_helper.rb +84 -0
- data/lib/fiona7/widget_resolver.rb +37 -0
- data/lib/fiona7/workspace.rb +76 -0
- data/lib/infopark_fiona7.rb +4 -0
- data/lib/tasks/fiona7_tasks.rake +13 -0
- metadata +216 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fiona7/builder/obj_builder'
|
2
|
+
#require 'fiona7/write_obj'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module Builder
|
6
|
+
class ObjUpdater < ObjBuilder
|
7
|
+
protected
|
8
|
+
def validate
|
9
|
+
# revert command sends this info. which is silly.
|
10
|
+
@values.delete(:_last_changed)
|
11
|
+
|
12
|
+
return true
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_object
|
16
|
+
@obj_id = @values.delete(:_id)
|
17
|
+
@obj = WriteObj.find(@obj_id)
|
18
|
+
@obj.name = @name unless @name.blank?
|
19
|
+
@name = @obj.name
|
20
|
+
@obj_class ||= @obj.obj_class
|
21
|
+
# TODO: move (parent change)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fiona7/builder/obj_builder'
|
2
|
+
require 'fiona7/builder/widget_building'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module Builder
|
6
|
+
class WidgetBuilder < ObjBuilder
|
7
|
+
include WidgetBuilding
|
8
|
+
def initialize(owner_obj, widget_id, values, path_map)
|
9
|
+
@owner_obj, @widget_id, @values, @widget_path_map = owner_obj, widget_id, values.symbolize_keys, path_map
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fiona7
|
2
|
+
module Builder
|
3
|
+
module WidgetBuilding
|
4
|
+
def path
|
5
|
+
@obj.path
|
6
|
+
end
|
7
|
+
|
8
|
+
def build
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def prepare_object
|
15
|
+
raise Scrivito::ScrivitoError, "Inconsistent internal state: unable to create widgets for nonexiting parent." if @owner_obj.path.nil?
|
16
|
+
# only publication type can contain children (code = "5")
|
17
|
+
# also handle / this way
|
18
|
+
if @owner_obj.obj_type_code != "5" || @owner_obj.id == 2001
|
19
|
+
parent_path = "/_widgets/#{@owner_obj.id}"
|
20
|
+
else
|
21
|
+
parent_path = "#{@owner_obj.path}/_widgets"
|
22
|
+
end
|
23
|
+
@path = "#{parent_path}/#{@widget_id}"
|
24
|
+
@name = @widget_id.to_s
|
25
|
+
@parent = ensure_parent_exists(parent_path)
|
26
|
+
raise Scrivito::ScrivitoError, "Error storing widget, container #{parent_path.inspect} not found." if @parent.nil?
|
27
|
+
@obj_class = @values.delete(:_obj_class)
|
28
|
+
end
|
29
|
+
|
30
|
+
def write_widget_pool
|
31
|
+
# NOP
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fiona7/builder/obj_updater'
|
2
|
+
require 'fiona7/builder/widget_building'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module Builder
|
6
|
+
class WidgetUpdater < ObjUpdater
|
7
|
+
include WidgetBuilding
|
8
|
+
def initialize(owner_obj, widget_id, values, path_map)
|
9
|
+
@owner_obj, @widget_id, @values, @widget_path_map = owner_obj, widget_id, values.symbolize_keys, path_map
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'set'
|
2
|
+
#require 'fiona7/released_obj'
|
3
|
+
#require 'fiona7/edited_obj'
|
4
|
+
require 'fiona7/assert'
|
5
|
+
require 'fiona7/workspace'
|
6
|
+
require 'fiona7/json/obj_decorator'
|
7
|
+
|
8
|
+
module Fiona7
|
9
|
+
module Controllers
|
10
|
+
module ContentService
|
11
|
+
class ObjController
|
12
|
+
SCRIVITO_DIFF_MODE_BROKEN = true
|
13
|
+
|
14
|
+
def fetch_multiple(params)
|
15
|
+
@queries = params[:queries]
|
16
|
+
workspace_id = params[:workspace_id]
|
17
|
+
revision_id = params[:revision_id]
|
18
|
+
@klass = self.get_matching_class(workspace_id, revision_id)
|
19
|
+
|
20
|
+
all_refs = Set.new
|
21
|
+
all_objs = Set.new
|
22
|
+
|
23
|
+
@queries.each do |query|
|
24
|
+
objs, refs = process_query(query)
|
25
|
+
|
26
|
+
all_objs.merge(objs)
|
27
|
+
all_refs << refs
|
28
|
+
end
|
29
|
+
|
30
|
+
r = {results: all_refs, objs: all_objs}
|
31
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(r))
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
def get_matching_class(workspace_id, revision_id)
|
36
|
+
Assert.input(
|
37
|
+
workspace_id.nil? || (
|
38
|
+
workspace_id == 'published' || workspace_id == 'rtc'
|
39
|
+
),
|
40
|
+
"Invalid workspace_id: #{workspace_id}"
|
41
|
+
)
|
42
|
+
|
43
|
+
if workspace_id && !SCRIVITO_DIFF_MODE_BROKEN
|
44
|
+
workspace_id == 'published' ? ReleasedObj : EditedObj
|
45
|
+
elsif revision_id
|
46
|
+
# no workspace_id given, we need to go by revision_id
|
47
|
+
rtc_workspace = Workspace.rtc
|
48
|
+
published_workspace = Workspace.published
|
49
|
+
|
50
|
+
# in most cases a query without workspace_id is caused
|
51
|
+
# by modification calculation, which compares the object
|
52
|
+
# with it's base revision (i.e. revision of published)
|
53
|
+
if revision_id[0] == 'f' && published_workspace.revision_id == revision_id
|
54
|
+
ReleasedObj
|
55
|
+
elsif revision_id[0] == 'b' && rtc_workspace.revision_id == revision_id
|
56
|
+
EditedObj
|
57
|
+
else
|
58
|
+
# we don't know this revision (anymore), it may be that
|
59
|
+
# the content has been changed between requests (concurrent
|
60
|
+
# modification may cause race conditions),
|
61
|
+
# but we know that published revisions start with a 'f'
|
62
|
+
# and rtc revisions start with a 'b'
|
63
|
+
if revision_id[0] == 'f'
|
64
|
+
ReleasedObj
|
65
|
+
elsif revision_id[0] == 'b'
|
66
|
+
EditedObj
|
67
|
+
else
|
68
|
+
Assert.input(
|
69
|
+
false,
|
70
|
+
"Invalid revision_id received: #{revision_id}"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
else
|
75
|
+
Assert.input(
|
76
|
+
false,
|
77
|
+
"Neither workspace_id nor revision_id given, unable to identify content"
|
78
|
+
)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def process_query(query)
|
83
|
+
objs = case query[:type]
|
84
|
+
when "id"
|
85
|
+
find_by_id(query[:param])
|
86
|
+
when "path"
|
87
|
+
find_by_path(query[:param])
|
88
|
+
when "ppath"
|
89
|
+
find_by_parent_path(query[:param])
|
90
|
+
when "permalink"
|
91
|
+
find_by_permalink(query[:param])
|
92
|
+
else
|
93
|
+
Assert.input(
|
94
|
+
false,
|
95
|
+
"Invalid query type #{query[:type]}"
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
refs = {"refs" => objs.map {|o| {"id" => o.id} } }
|
100
|
+
objs = objs.map {|o| JSON::ObjDecorator.new(@klass, o) }
|
101
|
+
|
102
|
+
return objs, refs
|
103
|
+
end
|
104
|
+
|
105
|
+
def find_by_id(id)
|
106
|
+
@klass.where(obj_id: id).limit(1).to_a
|
107
|
+
end
|
108
|
+
|
109
|
+
def find_by_path(path)
|
110
|
+
path = path.gsub('.', '_')
|
111
|
+
@klass.where(path: path).limit(1).to_a
|
112
|
+
end
|
113
|
+
|
114
|
+
def find_by_parent_path(path)
|
115
|
+
parent = @klass.find_by_path(path)
|
116
|
+
parent ? parent.children : []
|
117
|
+
end
|
118
|
+
|
119
|
+
def find_by_permalink(permalink)
|
120
|
+
@klass.where(permalink: permalink).limit(1).to_a
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fiona7/workspace'
|
2
|
+
require 'fiona7/assert'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module Controllers
|
6
|
+
module ContentService
|
7
|
+
class WorkspaceController
|
8
|
+
def fetch(playload)
|
9
|
+
id = playload[:workspace_id]
|
10
|
+
id = id.to_sym
|
11
|
+
return {} if id != :published && id != :rtc
|
12
|
+
|
13
|
+
w = {'workspace' => Workspace.new(id)}
|
14
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(w))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Fiona7
|
2
|
+
module Controllers
|
3
|
+
module RestAPI
|
4
|
+
class BlobController
|
5
|
+
def fetch(blob_id)
|
6
|
+
raise ::Scrivito::ClientError.new("This API is not supported by Fiona7 and should not be called, try using Scrivito::Binary#content or scrivito_url(obj) when appropriate", 412)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'fiona7/builder/obj_class_builder'
|
2
|
+
require 'fiona7/builder/obj_class_updater'
|
3
|
+
require 'fiona7/json/obj_class_decorator'
|
4
|
+
require 'fiona7/type_register'
|
5
|
+
|
6
|
+
module Fiona7
|
7
|
+
module Controllers
|
8
|
+
module RestAPI
|
9
|
+
class ObjClassController
|
10
|
+
def all
|
11
|
+
# ObjClasses with X_ prefix are hidden, so is Root (temporarily)
|
12
|
+
cms_classes = RailsConnector::ObjClass.all.select {|o| o.name != 'Root' && o.name !~ /\AX_/ }.map {|cms_class| JSON::ObjClassDecorator.new(cms_class) }
|
13
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode({results: cms_classes}))
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(workspace_id, values)
|
17
|
+
raise "Unexpected workspace_id: #{workspace_id}" unless workspace_id.to_s == "rtc"
|
18
|
+
cms_class = JSON::ObjClassDecorator.new(Builder::ObjClassBuilder.new(values[:obj_class].dup).build)
|
19
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(cms_class))
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(workspace_id, values)
|
23
|
+
raise "Unexpected workspace_id: #{workspace_id}" unless workspace_id.to_s == "rtc"
|
24
|
+
cms_class = JSON::ObjClassDecorator.new(Builder::ObjClassUpdater.new(values[:obj_class].dup).build)
|
25
|
+
# invalidate caches:
|
26
|
+
TypeRegister.instance.invalidate_cached_type(cms_class.name)
|
27
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(cms_class))
|
28
|
+
end
|
29
|
+
|
30
|
+
def fetch(workspace_id, name)
|
31
|
+
# TODO: assert workspace_id
|
32
|
+
cms_class = JSON::ObjClassDecorator.new(RailsConnector::ObjClass.find_by_obj_class_name(name))
|
33
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(cms_class))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#require 'fiona7/write_obj'
|
2
|
+
#require 'fiona7/released_obj'
|
3
|
+
#require 'fiona7/edited_obj'
|
4
|
+
|
5
|
+
require 'fiona7/builder/obj_builder'
|
6
|
+
require 'fiona7/builder/obj_updater'
|
7
|
+
|
8
|
+
require 'fiona7/naive_search_engine'
|
9
|
+
|
10
|
+
require 'fiona7/assert'
|
11
|
+
|
12
|
+
require 'fiona7/json/typeless_obj_decorator'
|
13
|
+
|
14
|
+
module Fiona7
|
15
|
+
module Controllers
|
16
|
+
module RestAPI
|
17
|
+
class ObjController
|
18
|
+
def create(workspace_id, values)
|
19
|
+
assert_writable(workspace_id)
|
20
|
+
|
21
|
+
# This is a hack to make it seem as if the root obj does not exist
|
22
|
+
if values[:obj][:_path] != '/' && values[:obj]["_path"] != '/'
|
23
|
+
obj = Builder::ObjBuilder.new(values[:obj].dup).build
|
24
|
+
else
|
25
|
+
obj = Builder::ObjUpdater.new(values[:obj].merge(_id: 2001)).build
|
26
|
+
end
|
27
|
+
|
28
|
+
klass = EditedObj
|
29
|
+
decorated = Fiona7::JSON::TypelessObjDecorator.new(klass, obj)
|
30
|
+
|
31
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
32
|
+
end
|
33
|
+
|
34
|
+
def fetch_by_path(workspace_id, path)
|
35
|
+
klass = matching_class(workspace_id)
|
36
|
+
|
37
|
+
path = path.gsub('.', '_')
|
38
|
+
obj = klass.find_by_path(path)
|
39
|
+
|
40
|
+
Assert.input(
|
41
|
+
!obj.nil?,
|
42
|
+
"Obj with path #{path} not found in workspace #{workspace_id}",
|
43
|
+
404
|
44
|
+
)
|
45
|
+
|
46
|
+
decorated = Fiona7::JSON::TypelessObjDecorator.new(klass, obj)
|
47
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
48
|
+
end
|
49
|
+
|
50
|
+
def fetch_by_id(workspace_id, obj_id)
|
51
|
+
klass = matching_class(workspace_id)
|
52
|
+
obj = klass.where(obj_id: obj_id).first
|
53
|
+
|
54
|
+
Assert.input(
|
55
|
+
!obj.nil?,
|
56
|
+
"Obj with id #{obj_id} not found in workspace #{workspace_id}",
|
57
|
+
404
|
58
|
+
)
|
59
|
+
|
60
|
+
decorated = Fiona7::JSON::TypelessObjDecorator.new(klass, obj)
|
61
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
62
|
+
end
|
63
|
+
|
64
|
+
def fetch_by_id_from_revision(revision_id, obj_id)
|
65
|
+
# TODO: use implementation from ContentService controller
|
66
|
+
# FIXME: code duplication with fetch_by_id
|
67
|
+
klass = revision_id.start_with?('f') ? ReleasedObj : EditedObj
|
68
|
+
obj = klass.where(obj_id: obj_id).first
|
69
|
+
|
70
|
+
Assert.input(
|
71
|
+
!obj.nil?,
|
72
|
+
"Obj with id #{obj_id} not found in revision #{revision_id}",
|
73
|
+
404
|
74
|
+
)
|
75
|
+
|
76
|
+
decorated = Fiona7::JSON::TypelessObjDecorator.new(klass, obj)
|
77
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
78
|
+
end
|
79
|
+
|
80
|
+
def search(workspace_id, params)
|
81
|
+
klass = matching_class(workspace_id)
|
82
|
+
|
83
|
+
offset = params[:offset] || 0
|
84
|
+
size = params[:size] || 100
|
85
|
+
query = params[:query] || []
|
86
|
+
order = (params[:sort_order] || :asc).to_sym
|
87
|
+
sort = (params[:sort_by] || :id).to_sym
|
88
|
+
|
89
|
+
search = NaiveSearchEngine.new(klass, query, offset, size, sort, order)
|
90
|
+
result = search.results.map {|o| {id: o.id} }
|
91
|
+
total = search.total
|
92
|
+
|
93
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode({
|
94
|
+
total: total,
|
95
|
+
results: result
|
96
|
+
}))
|
97
|
+
end
|
98
|
+
|
99
|
+
def update(workspace_id, values)
|
100
|
+
assert_writable(workspace_id)
|
101
|
+
|
102
|
+
obj = Builder::ObjUpdater.new(values[:obj].dup.with_indifferent_access).build
|
103
|
+
klass = EditedObj
|
104
|
+
decorated = Fiona7::JSON::TypelessObjDecorator.new(klass, obj)
|
105
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
106
|
+
end
|
107
|
+
|
108
|
+
def destroy(workspace_id, obj_id)
|
109
|
+
# TODO: cleanup /_widgets and /_uploads
|
110
|
+
obj = WriteObj.find(obj_id)
|
111
|
+
if !obj.children.empty?
|
112
|
+
if obj.children.all? {|c| c.name == '_widgets' || c.name == '_uploads' }
|
113
|
+
remove_obj_tree(obj)
|
114
|
+
else
|
115
|
+
Assert.input(
|
116
|
+
false,
|
117
|
+
"Cannot remove object #{obj_id} because it has children objects"
|
118
|
+
)
|
119
|
+
end
|
120
|
+
else
|
121
|
+
obj.destroy
|
122
|
+
end
|
123
|
+
return {}
|
124
|
+
end
|
125
|
+
|
126
|
+
protected
|
127
|
+
def remove_obj_tree(rc_obj)
|
128
|
+
subtree_objects = WriteObj.where(["path like ?", "#{rc_obj.path}/%"])
|
129
|
+
tree = ([rc_obj] + subtree_objects).sort_by{|obj| obj.path}.reverse
|
130
|
+
outside_objects = []
|
131
|
+
tree.each do |obj|
|
132
|
+
obj.super_objects.each do |super_object|
|
133
|
+
if !super_object.path.start_with?(rc_obj.path)
|
134
|
+
outside_objects << super_object
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
if outside_objects.length != 0
|
139
|
+
outsize_paths = outsize_objects.map(&:path).join(" ")
|
140
|
+
Assert.input(
|
141
|
+
false,
|
142
|
+
"Cannot remove object because #{outside_paths} have links pointing to it"
|
143
|
+
)
|
144
|
+
end
|
145
|
+
tree.each do |obj|
|
146
|
+
obj.send(:crul_obj).remove_archived_contents!
|
147
|
+
obj.send(:crul_obj).remove_active_contents!
|
148
|
+
end
|
149
|
+
tree.each do |obj|
|
150
|
+
obj.send(:crul_obj).delete!
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def matching_class(workspace_id)
|
155
|
+
workspace_id = workspace_id.to_sym
|
156
|
+
|
157
|
+
Assert.input(
|
158
|
+
workspace_id == :rtc || workspace_id == :published,
|
159
|
+
"Workspace #{workspace_id} not found"
|
160
|
+
)
|
161
|
+
|
162
|
+
klass = workspace_id == :published ? ReleasedObj : EditedObj
|
163
|
+
end
|
164
|
+
|
165
|
+
def assert_writable(workspace_id)
|
166
|
+
workspace_id = workspace_id.to_sym
|
167
|
+
Assert.input(
|
168
|
+
workspace_id == :rtc,
|
169
|
+
"Workspace #{workspace_id} is not writable, only workspace rtc is writable"
|
170
|
+
)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|