Class: CmisServer::FolderAdapter
- Inherits:
-
Object
- Object
- CmisServer::FolderAdapter
- Defined in:
- lib/cmis_server/folder_adapter.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
- #cmis_object_id ⇒ Object
- #find(id) ⇒ Object
-
#initialize(object, context:) ⇒ FolderAdapter
constructor
A new instance of FolderAdapter.
- #save! ⇒ Object
- #to_renderable_object ⇒ Object
Constructor Details
#initialize(object, context:) ⇒ FolderAdapter
Returns a new instance of FolderAdapter.
5 6 7 8 |
# File 'lib/cmis_server/folder_adapter.rb', line 5 def initialize(object, context:) @object = object @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/cmis_server/folder_adapter.rb', line 3 def context @context end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/cmis_server/folder_adapter.rb', line 3 def object @object end |
Class Method Details
.class_adapter(context:) ⇒ Object
10 11 12 |
# File 'lib/cmis_server/folder_adapter.rb', line 10 def self.class_adapter(context:) new(nil, context: context) end |
Instance Method Details
#cmis_object_id ⇒ Object
77 78 79 |
# File 'lib/cmis_server/folder_adapter.rb', line 77 def cmis_object_id @object.respond_to?(:cmis_object_id) ? @object.cmis_object_id : @object.id end |
#find(id) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cmis_server/folder_adapter.rb', line 14 def find(id) if id == 'root_folder' || id == 'root_folder_id' || id == 'core_root' || id == 'root' # Utiliser le connector pour récupérer l'objet root virtuel connector = CmisServer::Connectors::ConnectorFactory.create_connector( user: @context.is_a?(Hash) ? @context[:current_user] : @context.current_user ) root_object = connector.find_object_by_id(id) if root_object && root_object.respond_to?(:is_virtual) && root_object.is_virtual # Convertir l'objet virtuel en FolderObject CMIS folder_obj = virtual_folder_to_folder_object(root_object) else # Fallback : utiliser le root folder par défaut folder_obj = CmisServer::FolderObject.root_folder end self.class.new(folder_obj, context: @context) else # Chercher un Tagset dans Core = ::Tagset.find(id) # Convertir le Tagset en FolderObject CMIS folder_obj = () self.class.new(folder_obj, context: @context) end end |
#save! ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cmis_server/folder_adapter.rb', line 39 def save! # Créer un espace Core (Tagset) = ::Tagset.new # Mapper les propriétés CMIS vers Core if @object && @object.properties # Extraire la valeur si c'est un objet Property name_value = @object.properties['cmis:name'] name_value = name_value.value if name_value.respond_to?(:value) .title = name_value || 'Untitled Folder' end .is_space = true # Définir le responsable (obligatoire) current_user = @context.is_a?(Hash) ? @context[:current_user] : @context.current_user if current_user .responsible = current_user.id.to_s end # Gérer la hiérarchie si un parent est spécifié if @object && @object.properties && @object.properties['cmis:parentId'] parent_value = @object.properties['cmis:parentId'] parent_value = parent_value.value if parent_value.respond_to?(:value) if parent_value && parent_value != 'root_folder' .parent_ids = [parent_value.to_s] end end # Sauvegarder l'espace if .save # Mettre à jour l'objet CMIS avec l'ID du tagset créé @object.cmis_object_id = .id.to_s if @object true else raise "Failed to save folder: #{.errors..join(', ')}" end end |
#to_renderable_object ⇒ Object
81 82 83 |
# File 'lib/cmis_server/folder_adapter.rb', line 81 def to_renderable_object CmisServer::RenderableObject.new(base_object: @object) end |