cmis_server 1.0.3 → 1.2.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 +4 -4
- data/Rakefile +14 -0
- data/app/controllers/cmis_server/atom_pub/base_controller.rb +43 -0
- data/app/controllers/cmis_server/atom_pub/bulk_controller.rb +2 -0
- data/app/controllers/cmis_server/atom_pub/content_controller.rb +2 -0
- data/app/controllers/cmis_server/atom_pub/entries_controller.rb +2 -0
- data/app/controllers/cmis_server/atom_pub/folder_collection_controller.rb +8 -0
- data/app/controllers/cmis_server/atom_pub/query_controller.rb +8 -2
- data/app/controllers/cmis_server/atom_pub/repository_controller.rb +5 -1
- data/app/controllers/cmis_server/atom_pub/secondary_types_controller.rb +2 -0
- data/app/controllers/cmis_server/atom_pub/service_documents_controller.rb +4 -1
- data/app/controllers/cmis_server/atom_pub/types_controller.rb +2 -0
- data/app/controllers/cmis_server/atom_pub/uri_templates_controller.rb +32 -21
- data/app/services/cmis_server/object_service.rb +21 -11
- data/app/services/cmis_server/repository_service.rb +10 -8
- data/app/views/cmis_server/atom_pub/entries/_cmis_folder_links.atom_entry.builder +1 -1
- data/app/views/cmis_server/atom_pub/entries/_object_entry.atom_entry.builder +3 -3
- data/app/views/cmis_server/atom_pub/entries/type_entry.atom_entry.builder +1 -1
- data/app/views/cmis_server/atom_pub/feeds/feed.atom_feed.builder +1 -1
- data/app/views/cmis_server/atom_pub/service_documents/_workspace.atom_service.builder +6 -26
- data/config/initializers/cmis_base_types.rb +95 -0
- data/config/initializers/cmis_core_configuration.rb +60 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/routes.rb +37 -28
- data/config/routes_standard.rb +49 -0
- data/lib/cmis_server/base_objects/base_type.rb +14 -1
- data/lib/cmis_server/base_objects/folder.rb +1 -1
- data/lib/cmis_server/base_types.rb +11 -1
- data/lib/cmis_server/configuration.rb +12 -3
- data/lib/cmis_server/connectors/base_connector.rb +41 -0
- data/lib/cmis_server/connectors/connector_factory.rb +20 -0
- data/lib/cmis_server/connectors/core_connector.rb +300 -0
- data/lib/cmis_server/context.rb +10 -0
- data/lib/cmis_server/engine.rb +13 -54
- data/lib/cmis_server/engine_diagnostics.rb +56 -0
- data/lib/cmis_server/folder_object.rb +12 -1
- data/lib/cmis_server/inflections.rb +13 -0
- data/lib/cmis_server/repository.rb +116 -5
- data/lib/cmis_server/type.rb +1 -1
- data/lib/cmis_server/version.rb +1 -1
- data/lib/cmis_server/zeitwerk_configuration.rb +39 -0
- data/lib/cmis_server.rb +264 -1
- data/test/dummy/log/test.log +0 -0
- metadata +47 -4
data/lib/cmis_server/engine.rb
CHANGED
@@ -1,60 +1,19 @@
|
|
1
|
-
module CmisServer
|
1
|
+
module CmisServer
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
config.autoload_paths << File.expand_path("../../app/services", __FILE__)
|
4
3
|
isolate_namespace CmisServer
|
5
4
|
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
# Add paths
|
6
|
+
config.autoload_paths << File.join(root, "lib")
|
7
|
+
config.autoload_paths << File.join(root, "app", "controllers")
|
8
|
+
config.autoload_paths << File.join(root, "app", "helpers")
|
9
|
+
config.autoload_paths << File.join(root, "app", "models")
|
10
|
+
|
11
|
+
# Register MIME types according to Rails conventions
|
12
|
+
initializer "cmis_server.register_mime_types", before: :load_config_initializers do
|
13
|
+
Mime::Type.register "application/atom+xml", :atom_xml unless Mime::Type.lookup_by_extension(:atom_xml)
|
14
|
+
Mime::Type.register "application/atom+xml;type=feed", :atom_feed unless Mime::Type.lookup_by_extension(:atom_feed)
|
15
|
+
Mime::Type.register "application/atom+xml;type=entry", :atom_entry unless Mime::Type.lookup_by_extension(:atom_entry)
|
16
|
+
Mime::Type.register "application/atomsvc+xml", :atom_service unless Mime::Type.lookup_by_extension(:atom_service)
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
15
|
-
|
16
|
-
require 'cmis_server/version'
|
17
|
-
require 'cmis_server/constants'
|
18
|
-
require 'cmis_server/configuration'
|
19
|
-
|
20
|
-
require 'cmis_server/exceptions'
|
21
|
-
|
22
|
-
#CMIS special types
|
23
|
-
require 'cmis_server/id'
|
24
|
-
require 'cmis_server/content_stream'
|
25
|
-
|
26
|
-
require 'cmis_server/repository'
|
27
|
-
require 'cmis_server/property_definition'
|
28
|
-
require 'cmis_server/property'
|
29
|
-
|
30
|
-
# Charger BaseType en premier
|
31
|
-
require 'cmis_server/base_objects/base_type'
|
32
|
-
|
33
|
-
require 'cmis_server/type'
|
34
|
-
require 'cmis_server/base_types'
|
35
|
-
require 'cmis_server/type_registry'
|
36
|
-
require 'cmis_server/cmis_object'
|
37
|
-
require 'cmis_server/document_type'
|
38
|
-
require 'cmis_server/document_object'
|
39
|
-
require 'cmis_server/folder_type'
|
40
|
-
require 'cmis_server/folder_object'
|
41
|
-
require 'cmis_server/item_type'
|
42
|
-
require 'cmis_server/item_object'
|
43
|
-
require 'cmis_server/secondary_type'
|
44
|
-
# require 'cmis_server/type_registry'
|
45
|
-
|
46
|
-
|
47
|
-
require 'cmis_server/object_adapter'
|
48
|
-
require 'cmis_server/item_adapter'
|
49
|
-
require 'cmis_server/base_objects/base_type'
|
50
|
-
require 'cmis_server/base_objects/document'
|
51
|
-
require 'cmis_server/base_objects/folder'
|
52
|
-
require 'cmis_server/base_objects/item'
|
53
|
-
|
54
|
-
require 'cmis_server/atom_pub/entry_parser'
|
55
|
-
|
56
|
-
require 'cmis_server/context'
|
57
|
-
|
58
|
-
require 'cmis_server/query'
|
59
|
-
require 'cmis_server/renderable_object'
|
60
|
-
require 'cmis_server/renderable_collection'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module CmisServer
|
2
|
+
# Engine diagnostics utilities for testing and troubleshooting
|
3
|
+
class EngineDiagnostics
|
4
|
+
class << self
|
5
|
+
# Check if engine routes are properly loaded
|
6
|
+
def routes_loaded?
|
7
|
+
CmisServer::Engine.routes.routes.any?
|
8
|
+
end
|
9
|
+
|
10
|
+
# Force reload engine routes
|
11
|
+
def reload_engine_routes!
|
12
|
+
routes_file = File.expand_path('../../../config/routes.rb', __FILE__)
|
13
|
+
if File.exist?(routes_file)
|
14
|
+
CmisServer::Engine.routes.clear!
|
15
|
+
load routes_file
|
16
|
+
true
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get detailed diagnostics information
|
23
|
+
def diagnostic_info
|
24
|
+
{
|
25
|
+
engine_routes_count: CmisServer::Engine.routes.routes.size,
|
26
|
+
engine_routes_loaded: routes_loaded?,
|
27
|
+
engine_controllers: engine_controllers,
|
28
|
+
rails_version: Rails::VERSION::STRING,
|
29
|
+
zeitwerk_enabled: defined?(Zeitwerk) && Rails.autoloaders.main.is_a?(Zeitwerk::Loader),
|
30
|
+
frozen_arrays: check_frozen_arrays
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Get list of engine controllers
|
37
|
+
def engine_controllers
|
38
|
+
Dir.glob(File.expand_path('../../../app/controllers/cmis_server/**/*.rb', __FILE__)).map do |file|
|
39
|
+
file.split('/').last.gsub('.rb', '')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Check if Rails is using frozen arrays
|
44
|
+
def check_frozen_arrays
|
45
|
+
return false unless defined?(Rails)
|
46
|
+
|
47
|
+
begin
|
48
|
+
app = Rails::Application.new
|
49
|
+
app.config.autoload_paths.frozen?
|
50
|
+
rescue => e
|
51
|
+
e.message.include?('frozen')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -3,7 +3,7 @@ module CmisServer
|
|
3
3
|
|
4
4
|
def self.root_folder
|
5
5
|
unless @root
|
6
|
-
@root=new(CmisServer.configuration.arguments_for_root_folder)
|
6
|
+
@root=new(**CmisServer.configuration.arguments_for_root_folder)
|
7
7
|
@root.define_singleton_method :is_root?,(lambda { true })
|
8
8
|
end
|
9
9
|
@root
|
@@ -11,8 +11,19 @@ module CmisServer
|
|
11
11
|
|
12
12
|
def initialize(type:, properties: {})
|
13
13
|
raise InvalidType unless type.base_id == 'cmis:folder'
|
14
|
+
# Initialiser les attributs avant d'appeler super
|
15
|
+
@cmis_object_id = nil
|
16
|
+
@cmis_name = nil
|
17
|
+
@cmis_description = nil
|
18
|
+
@cmis_last_modification_date = nil
|
19
|
+
@cmis_creation_date = nil
|
20
|
+
@cmis_created_by = nil
|
14
21
|
super
|
15
22
|
end
|
16
23
|
|
24
|
+
# Ajouter les setters pour les propriétés CMIS
|
25
|
+
attr_accessor :cmis_object_id, :cmis_name, :cmis_description,
|
26
|
+
:cmis_last_modification_date, :cmis_creation_date, :cmis_created_by
|
27
|
+
|
17
28
|
end
|
18
29
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# CMIS Server inflections configuration
|
2
|
+
# This file configures Rails inflections to handle the CMIS acronym correctly
|
3
|
+
|
4
|
+
# Configure inflections to prevent CMIS -> CMIS transformation
|
5
|
+
if defined?(ActiveSupport)
|
6
|
+
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# We explicitly do NOT want to add 'CMIS' as an acronym
|
8
|
+
# because that would make Rails look for CMISServer instead of CmisServer
|
9
|
+
|
10
|
+
# Ensure proper handling of our module names
|
11
|
+
inflect.irregular 'cmis_server', 'cmis_servers'
|
12
|
+
end
|
13
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module CmisServer
|
2
2
|
class Repository
|
3
3
|
|
4
|
-
class
|
4
|
+
class Capabilities
|
5
5
|
|
6
6
|
attr_reader :acl, :all_versions_searchable, :changes, :content_stream_updatability, :get_descendants, :get_folder_tree, :multifiling, :pwc_searchable, :pwc_updatable, :query, :renditions, :unfiling, :version_specific_filing, :join, :secondary_types
|
7
7
|
|
8
8
|
# CMIS 1.1 capabilities
|
9
|
-
attr_reader :create_type, :bulk_update, :append_content_stream, :update_type, :delete_type
|
9
|
+
attr_reader :create_type, :bulk_update, :append_content_stream, :update_type, :delete_type, :bulk_delete_properties, :bulk_move, :extended_query, :extended_acl
|
10
10
|
|
11
11
|
def initialize(attrs={})
|
12
12
|
@acl = attrs.fetch(:acl, :none)
|
@@ -31,19 +31,81 @@ module CmisServer
|
|
31
31
|
@append_content_stream = attrs.fetch(:append_content_stream, false)
|
32
32
|
@update_type = attrs.fetch(:update_type, false)
|
33
33
|
@delete_type = attrs.fetch(:delete_type, false)
|
34
|
+
@bulk_delete_properties = attrs.fetch(:bulk_delete_properties, false)
|
35
|
+
@bulk_move = attrs.fetch(:bulk_move, false)
|
36
|
+
@extended_query = attrs.fetch(:extended_query, false)
|
37
|
+
@extended_acl = attrs.fetch(:extended_acl, false)
|
34
38
|
end
|
35
39
|
|
36
40
|
def [](attr)
|
37
41
|
self.send(attr)
|
38
42
|
end
|
43
|
+
|
44
|
+
def to_h
|
45
|
+
{
|
46
|
+
acl: @acl,
|
47
|
+
all_versions_searchable: @all_versions_searchable,
|
48
|
+
changes: @changes,
|
49
|
+
content_stream_updatability: @content_stream_updatability,
|
50
|
+
get_descendants: @get_descendants,
|
51
|
+
get_folder_tree: @get_folder_tree,
|
52
|
+
multifiling: @multifiling,
|
53
|
+
pwc_searchable: @pwc_searchable,
|
54
|
+
pwc_updatable: @pwc_updatable,
|
55
|
+
query: @query,
|
56
|
+
renditions: @renditions,
|
57
|
+
unfiling: @unfiling,
|
58
|
+
version_specific_filing: @version_specific_filing,
|
59
|
+
join: @join,
|
60
|
+
secondary_types: @secondary_types,
|
61
|
+
create_type: @create_type,
|
62
|
+
bulk_update: @bulk_update,
|
63
|
+
append_content_stream: @append_content_stream,
|
64
|
+
update_type: @update_type,
|
65
|
+
delete_type: @delete_type,
|
66
|
+
bulk_delete_properties: @bulk_delete_properties,
|
67
|
+
bulk_move: @bulk_move,
|
68
|
+
extended_query: @extended_query,
|
69
|
+
extended_acl: @extended_acl
|
70
|
+
}
|
71
|
+
end
|
39
72
|
end
|
40
73
|
|
41
74
|
|
42
|
-
attr_accessor :id, :name, :description, :vendor_name, :product_name, :product_version, :root_folder_id, :capabilities, :latest_change_log_token, :cmis_version_supported
|
75
|
+
attr_accessor :id, :name, :description, :vendor_name, :product_name, :product_version, :root_folder_id, :capabilities, :latest_change_log_token, :cmis_version_supported
|
43
76
|
|
44
77
|
alias_method :repository_id, :id
|
45
78
|
alias_method :repository_name, :name
|
46
79
|
alias_method :repository_description, :description
|
80
|
+
|
81
|
+
# Méthodes pour les informations supplémentaires du repository
|
82
|
+
def extensions
|
83
|
+
{
|
84
|
+
extended_features: ["bulk_operations", "secondary_types", "type_management"],
|
85
|
+
vendor_extensions: {},
|
86
|
+
namespace: "http://docs.oasis-open.org/ns/cmis/core/200908/"
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
def acl_capabilities
|
91
|
+
{
|
92
|
+
supported_permissions: ["cmis:read", "cmis:write", "cmis:all"],
|
93
|
+
propagation: "repositorydetermined",
|
94
|
+
permissions: [
|
95
|
+
{ permission: "cmis:read", description: "Read permission" },
|
96
|
+
{ permission: "cmis:write", description: "Write permission" },
|
97
|
+
{ permission: "cmis:all", description: "All permissions" }
|
98
|
+
]
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
def repository_specific_information
|
103
|
+
{
|
104
|
+
implementation: "CmisServer Ruby Gem",
|
105
|
+
version: CmisServer::VERSION,
|
106
|
+
core_integration: true
|
107
|
+
}
|
108
|
+
end
|
47
109
|
|
48
110
|
|
49
111
|
def initialize(attrs={})
|
@@ -64,13 +126,17 @@ module CmisServer
|
|
64
126
|
root_folder_id: CmisServer::FolderObject.root_folder.cmis_object_id,
|
65
127
|
latest_change_log_token: 0,
|
66
128
|
cmis_version_supported: CmisServer::CMIS_VERSION_SUPPORTED,
|
67
|
-
capabilities:
|
129
|
+
capabilities: Capabilities.new(
|
68
130
|
# Activer les capacités CMIS 1.1 par défaut
|
69
131
|
create_type: true,
|
70
132
|
bulk_update: true,
|
71
133
|
append_content_stream: true,
|
72
134
|
update_type: true,
|
73
|
-
delete_type: true
|
135
|
+
delete_type: true,
|
136
|
+
bulk_delete_properties: true,
|
137
|
+
bulk_move: true,
|
138
|
+
extended_query: true,
|
139
|
+
extended_acl: false
|
74
140
|
)
|
75
141
|
)
|
76
142
|
repo
|
@@ -86,6 +152,51 @@ module CmisServer
|
|
86
152
|
# Cette méthode devrait retourner l'objet CMIS correspondant à l'ID ou nil
|
87
153
|
nil
|
88
154
|
end
|
155
|
+
|
156
|
+
# Extensions du repository (CMIS 1.1)
|
157
|
+
def extensions
|
158
|
+
{
|
159
|
+
extended_features: ['bulk_operations', 'secondary_types', 'type_management'],
|
160
|
+
vendor_extensions: {},
|
161
|
+
namespace: 'http://docs.oasis-open.org/ns/cmis/core/200908/'
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
# Types disponibles dans le repository
|
166
|
+
def types
|
167
|
+
CmisServer::TypeRegistry.types || {}
|
168
|
+
end
|
169
|
+
|
170
|
+
# ACL Capabilities
|
171
|
+
def acl_capabilities
|
172
|
+
{
|
173
|
+
supported_permissions: ['cmis:read', 'cmis:write', 'cmis:all'],
|
174
|
+
acl_propagation: 'repositorydetermined',
|
175
|
+
permissions: [
|
176
|
+
{
|
177
|
+
permission: 'cmis:read',
|
178
|
+
description: 'Read permission for objects'
|
179
|
+
},
|
180
|
+
{
|
181
|
+
permission: 'cmis:write',
|
182
|
+
description: 'Write permission for objects'
|
183
|
+
},
|
184
|
+
{
|
185
|
+
permission: 'cmis:all',
|
186
|
+
description: 'All permissions for objects'
|
187
|
+
}
|
188
|
+
]
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
# Repository specific information
|
193
|
+
def repository_specific_information
|
194
|
+
{
|
195
|
+
implementation: 'CmisServer Ruby Gem',
|
196
|
+
version: CmisServer::VERSION,
|
197
|
+
features: ['atom_pub', 'browser_binding', 'rest_api']
|
198
|
+
}
|
199
|
+
end
|
89
200
|
|
90
201
|
end
|
91
202
|
end
|
data/lib/cmis_server/type.rb
CHANGED
@@ -35,7 +35,7 @@ module CmisServer
|
|
35
35
|
@fulltext_indexed = attrs.fetch(:fulltext_indexed, false)
|
36
36
|
@included_in_supertype_query = attrs.fetch(:included_in_supertype_query, false)
|
37
37
|
|
38
|
-
@self_property_definitions = attrs.fetch(:property_definitions, [])
|
38
|
+
@self_property_definitions = attrs.fetch(:property_definitions, []).dup
|
39
39
|
end
|
40
40
|
|
41
41
|
def parent_id
|
data/lib/cmis_server/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
module CmisServer
|
2
|
+
# Configuration for Zeitwerk autoloading
|
3
|
+
# This ensures proper class loading in Rails 7+
|
4
|
+
class ZeitwerkConfiguration
|
5
|
+
def self.setup
|
6
|
+
# Get main paths
|
7
|
+
lib_path = File.expand_path('../../', __FILE__)
|
8
|
+
app_path = File.expand_path('../../../app', __FILE__)
|
9
|
+
|
10
|
+
# Setup for Rails 6+ with Zeitwerk
|
11
|
+
if defined?(Rails) && Rails.respond_to?(:autoloaders) && Rails.autoloaders.respond_to?(:main)
|
12
|
+
Rails.autoloaders.main.push_dir(lib_path, namespace: CmisServer)
|
13
|
+
|
14
|
+
# Add controller directories with proper namespacing
|
15
|
+
controllers_path = File.join(app_path, 'controllers', 'cmis_server')
|
16
|
+
Rails.autoloaders.main.push_dir(controllers_path, namespace: CmisServer) if Dir.exist?(controllers_path)
|
17
|
+
|
18
|
+
# Explicitly handle nested controllers
|
19
|
+
atom_pub_path = File.join(controllers_path, 'atom_pub')
|
20
|
+
if Dir.exist?(atom_pub_path)
|
21
|
+
Rails.autoloaders.main.push_dir(atom_pub_path, namespace: CmisServer::AtomPub)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Add models, views and services
|
25
|
+
%w[models views services].each do |dir|
|
26
|
+
path = File.join(app_path, dir, 'cmis_server')
|
27
|
+
Rails.autoloaders.main.push_dir(path, namespace: CmisServer) if Dir.exist?(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
Rails.logger&.info "CMIS: Zeitwerk autoloading configured"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Setup Zeitwerk when this file is loaded
|
37
|
+
if defined?(Rails) && Rails.application && !Rails.application.config.eager_load
|
38
|
+
CmisServer::ZeitwerkConfiguration.setup
|
39
|
+
end
|
data/lib/cmis_server.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
+
# Load inflections first to prevent autoloading issues
|
2
|
+
require "cmis_server/inflections"
|
3
|
+
require "cmis_server/configuration"
|
4
|
+
require "cmis_server/exceptions"
|
5
|
+
require "cmis_server/zeitwerk_configuration" if File.exist?(File.expand_path("cmis_server/zeitwerk_configuration.rb", __dir__))
|
1
6
|
require "cmis_server/engine"
|
7
|
+
require "cmis_server/engine_diagnostics"
|
8
|
+
require "cmis_server/connectors/base_connector"
|
9
|
+
require "cmis_server/connectors/core_connector"
|
10
|
+
require "cmis_server/connectors/connector_factory"
|
2
11
|
|
3
12
|
module CmisServer
|
4
|
-
|
5
13
|
class << self
|
6
14
|
attr_writer :configuration
|
7
15
|
end
|
@@ -17,6 +25,261 @@ module CmisServer
|
|
17
25
|
def self.configure
|
18
26
|
yield(configuration)
|
19
27
|
end
|
28
|
+
|
29
|
+
# Method to properly mount CmisServer in a Rails application
|
30
|
+
# Usage in host app: CmisServer.mount_engine(Rails.application, "/path", mount_name: 'custom_name')
|
31
|
+
def self.mount_engine(application, mount_path, mount_name: nil, debug: false)
|
32
|
+
if application && application.routes && mount_path
|
33
|
+
# Save original Rails.application
|
34
|
+
original_rails_app = Rails.application
|
35
|
+
Rails.application = application
|
36
|
+
|
37
|
+
# Make sure engine routes are loaded first
|
38
|
+
if !EngineDiagnostics.routes_loaded?
|
39
|
+
EngineDiagnostics.reload_engine_routes!
|
40
|
+
|
41
|
+
# Log diagnostic if in debug mode
|
42
|
+
if debug
|
43
|
+
puts "CMIS Server Engine Diagnostics:"
|
44
|
+
puts EngineDiagnostics.diagnostic_info.inspect
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Check if application is already initialized
|
49
|
+
if !application.initialized?
|
50
|
+
puts "CMIS Server: Initializing application before mounting" if debug
|
51
|
+
# Handle Rails 7+ with frozen arrays in autoload paths
|
52
|
+
begin
|
53
|
+
application.initialize!
|
54
|
+
rescue FrozenError => e
|
55
|
+
puts "CMIS Server: Frozen array error during initialization (Rails 7+ issue)" if debug
|
56
|
+
puts "CMIS Server: Proceeding with mounting anyway" if debug
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Mount the engine with a custom name if provided
|
61
|
+
application.routes.draw do
|
62
|
+
if mount_name
|
63
|
+
mount CmisServer::Engine => mount_path, as: mount_name
|
64
|
+
else
|
65
|
+
mount CmisServer::Engine => mount_path
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Force route drawing
|
70
|
+
application.routes.finalize!
|
71
|
+
|
72
|
+
# Check if engine routes are loaded again
|
73
|
+
engine_routes_count = Engine.routes.routes.size
|
74
|
+
if engine_routes_count == 0
|
75
|
+
puts "CMIS Server: Engine routes not loaded, forcing reload again" if debug
|
76
|
+
|
77
|
+
# Try once more to reload engine routes
|
78
|
+
EngineDiagnostics.reload_engine_routes!
|
79
|
+
|
80
|
+
# And refresh application routes
|
81
|
+
application.routes.reload!
|
82
|
+
end
|
83
|
+
|
84
|
+
# Count mounted routes for verification
|
85
|
+
cmis_routes = application.routes.routes.select do |route|
|
86
|
+
route.path.spec.to_s.include?(mount_path) ||
|
87
|
+
(route.defaults[:controller]&.start_with?('cmis_server'))
|
88
|
+
end
|
89
|
+
|
90
|
+
puts "CMIS Server mounted at '#{mount_path}' with #{cmis_routes.size} routes" if debug
|
91
|
+
|
92
|
+
# Restore the original Rails.application
|
93
|
+
Rails.application = original_rails_app
|
94
|
+
|
95
|
+
return cmis_routes.size
|
96
|
+
else
|
97
|
+
puts "CMIS Server mount failed: Invalid parameters" if debug
|
98
|
+
return 0
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Méthode de diagnostic pour vérifier l'état du moteur CMIS
|
103
|
+
def self.diagnostic
|
104
|
+
result = {
|
105
|
+
gem_loaded: true,
|
106
|
+
version: defined?(VERSION) ? VERSION : "unknown",
|
107
|
+
engine_defined: defined?(Engine),
|
108
|
+
engine_routes_count: nil,
|
109
|
+
engine_mounted: false,
|
110
|
+
rails_routes_count: nil,
|
111
|
+
cmis_routes_found: 0,
|
112
|
+
configuration_valid: false,
|
113
|
+
errors: []
|
114
|
+
}
|
115
|
+
|
116
|
+
begin
|
117
|
+
# Vérifier la version
|
118
|
+
require 'cmis_server/version'
|
119
|
+
result[:version] = CmisServer::VERSION if defined?(CmisServer::VERSION)
|
120
|
+
rescue => e
|
121
|
+
result[:errors] << "Version error: #{e.message}"
|
122
|
+
end
|
123
|
+
|
124
|
+
begin
|
125
|
+
# Vérifier le moteur
|
126
|
+
if defined?(CmisServer::Engine)
|
127
|
+
result[:engine_defined] = true
|
128
|
+
result[:engine_routes_count] = CmisServer::Engine.routes.routes.size
|
129
|
+
else
|
130
|
+
result[:errors] << "CmisServer::Engine not defined"
|
131
|
+
end
|
132
|
+
rescue => e
|
133
|
+
result[:errors] << "Engine error: #{e.message}"
|
134
|
+
end
|
135
|
+
|
136
|
+
begin
|
137
|
+
# Vérifier la configuration
|
138
|
+
if configuration && configuration.respond_to?(:repository_info)
|
139
|
+
result[:configuration_valid] = !configuration.repository_info.nil?
|
140
|
+
end
|
141
|
+
rescue => e
|
142
|
+
result[:errors] << "Configuration error: #{e.message}"
|
143
|
+
end
|
144
|
+
|
145
|
+
# Vérifier Rails si disponible
|
146
|
+
if defined?(Rails) && Rails.application
|
147
|
+
begin
|
148
|
+
result[:rails_routes_count] = Rails.application.routes.routes.size
|
149
|
+
|
150
|
+
# Chercher les routes CMIS montées
|
151
|
+
cmis_routes = Rails.application.routes.routes.select { |r|
|
152
|
+
r.path.spec.to_s.include?('cmis') ||
|
153
|
+
(r.app.class.name.include?('Engine') && r.path.spec.to_s.include?('cmis'))
|
154
|
+
}
|
155
|
+
result[:cmis_routes_found] = cmis_routes.size
|
156
|
+
result[:engine_mounted] = cmis_routes.any? { |r| r.app.class.name.include?('CmisServer') }
|
157
|
+
|
158
|
+
rescue => e
|
159
|
+
result[:errors] << "Rails routes error: #{e.message}"
|
160
|
+
end
|
161
|
+
else
|
162
|
+
result[:errors] << "Rails not available or not initialized"
|
163
|
+
end
|
164
|
+
|
165
|
+
result
|
166
|
+
end
|
167
|
+
|
168
|
+
# Méthode pour forcer le chargement et diagnostic des routes du moteur
|
169
|
+
def self.debug_engine_routes
|
170
|
+
result = {
|
171
|
+
engine_class_loaded: false,
|
172
|
+
routes_file_exists: false,
|
173
|
+
routes_content_sample: nil,
|
174
|
+
routes_loaded: false,
|
175
|
+
route_count: 0,
|
176
|
+
routes_list: [],
|
177
|
+
load_errors: []
|
178
|
+
}
|
179
|
+
|
180
|
+
begin
|
181
|
+
# Vérifier si la classe Engine existe
|
182
|
+
if defined?(CmisServer::Engine)
|
183
|
+
result[:engine_class_loaded] = true
|
184
|
+
|
185
|
+
# Vérifier si le fichier routes existe
|
186
|
+
routes_file = File.expand_path('../../config/routes.rb', __FILE__)
|
187
|
+
if File.exist?(routes_file)
|
188
|
+
result[:routes_file_exists] = true
|
189
|
+
result[:routes_content_sample] = File.read(routes_file).lines.first(5).join
|
190
|
+
|
191
|
+
# Vérifier les routes chargées
|
192
|
+
begin
|
193
|
+
result[:route_count] = CmisServer::Engine.routes.routes.size
|
194
|
+
result[:routes_loaded] = result[:route_count] > 0
|
195
|
+
|
196
|
+
# Lister quelques routes
|
197
|
+
CmisServer::Engine.routes.routes.first(10).each do |route|
|
198
|
+
result[:routes_list] << "#{route.verb} #{route.path.spec}"
|
199
|
+
end
|
200
|
+
|
201
|
+
rescue => e
|
202
|
+
result[:load_errors] << "Error accessing routes: #{e.message}"
|
203
|
+
end
|
204
|
+
|
205
|
+
# Tenter de forcer le rechargement des routes
|
206
|
+
begin
|
207
|
+
CmisServer::Engine.routes.clear!
|
208
|
+
load routes_file
|
209
|
+
result[:route_count] = CmisServer::Engine.routes.routes.size
|
210
|
+
result[:routes_loaded] = result[:route_count] > 0
|
211
|
+
result[:load_errors] << "Routes reloaded successfully" if result[:routes_loaded]
|
212
|
+
rescue => e
|
213
|
+
result[:load_errors] << "Error reloading routes: #{e.message}"
|
214
|
+
end
|
215
|
+
|
216
|
+
else
|
217
|
+
result[:load_errors] << "Routes file not found: #{routes_file}"
|
218
|
+
end
|
219
|
+
else
|
220
|
+
result[:load_errors] << "CmisServer::Engine not defined"
|
221
|
+
end
|
222
|
+
|
223
|
+
rescue => e
|
224
|
+
result[:load_errors] << "General error: #{e.message}"
|
225
|
+
end
|
226
|
+
|
227
|
+
result
|
228
|
+
end
|
229
|
+
|
230
|
+
# Méthode pour afficher le diagnostic des routes du moteur
|
231
|
+
def self.print_engine_routes_debug
|
232
|
+
debug = debug_engine_routes
|
233
|
+
|
234
|
+
puts "\n=== ENGINE ROUTES DEBUG ==="
|
235
|
+
puts "Engine class loaded: #{debug[:engine_class_loaded] ? '✅' : '❌'}"
|
236
|
+
puts "Routes file exists: #{debug[:routes_file_exists] ? '✅' : '❌'}"
|
237
|
+
puts "Routes loaded: #{debug[:routes_loaded] ? '✅' : '❌'}"
|
238
|
+
puts "Route count: #{debug[:route_count]}"
|
239
|
+
|
240
|
+
if debug[:routes_content_sample]
|
241
|
+
puts "\nRoutes file sample:"
|
242
|
+
puts debug[:routes_content_sample]
|
243
|
+
end
|
244
|
+
|
245
|
+
if debug[:routes_list].any?
|
246
|
+
puts "\nLoaded routes:"
|
247
|
+
debug[:routes_list].each { |route| puts " #{route}" }
|
248
|
+
end
|
249
|
+
|
250
|
+
if debug[:load_errors].any?
|
251
|
+
puts "\nDebug messages:"
|
252
|
+
debug[:load_errors].each { |error| puts " 🔍 #{error}" }
|
253
|
+
end
|
254
|
+
|
255
|
+
puts "=== END ENGINE DEBUG ==="
|
256
|
+
|
257
|
+
debug
|
258
|
+
end
|
20
259
|
|
21
260
|
|
22
261
|
end
|
262
|
+
# Méthode pour initialiser les propriétés custom de façon sécurisée
|
263
|
+
def self.add_custom_properties
|
264
|
+
return unless defined?(DocumentType) && defined?(PropertyDefinition)
|
265
|
+
|
266
|
+
Rails.logger&.info "[CMIS] Ajout des propriétés de document"
|
267
|
+
|
268
|
+
# Propriété metadata pour les documents
|
269
|
+
DocumentType.base.self_property_definitions.push(
|
270
|
+
PropertyDefinition.register_property_definition({
|
271
|
+
id: 'plugandwork:metadata'.freeze,
|
272
|
+
type: String,
|
273
|
+
required: false,
|
274
|
+
cardinality: :single,
|
275
|
+
updatability: :readwrite,
|
276
|
+
description: 'Document metadata serialized as XML'
|
277
|
+
})
|
278
|
+
)
|
279
|
+
|
280
|
+
Rails.logger&.info "[CMIS] Propriétés ajoutées"
|
281
|
+
true
|
282
|
+
rescue => e
|
283
|
+
Rails.logger&.error "[CMIS] Erreur ajout propriétés: #{e.message}"
|
284
|
+
false
|
285
|
+
end
|
File without changes
|