Class: CmisServer::ObjectService
- Inherits:
-
Object
- Object
- CmisServer::ObjectService
- Defined in:
- app/services/cmis_server/object_service.rb
Defined Under Namespace
Classes: DuplicateFile
Instance Method Summary collapse
- #append_content_stream ⇒ Object
- #bulk_update_properties ⇒ Object
- #create_document(properties, folder_id: nil, content_stream: nil, versionning_state: :none, policies: [], add_aces: [], remove_aces: []) ⇒ Object
- #create_document_from_source ⇒ Object
- #create_folder(properties, add_aces: [], remove_aces: []) ⇒ Object
- #create_item(properties, folder_id: nil, policies: [], add_aces: [], remove_aces: []) ⇒ Object
- #create_policy ⇒ Object
- #create_relationship ⇒ Object
- #delete_content_stream ⇒ Object
- #delete_object ⇒ Object
- #delete_tree ⇒ Object
- #get_allowable_actions ⇒ Object
- #get_content_stream ⇒ Object
- #get_object(id, filter: [], include_relationships: :none, include_policy_ids: false, rendition_filter: "cmis:none", include_acl: false, include_allowable_actions: false, with_object: false) ⇒ Object
- #get_object_by_path(path, filter: [], include_relationships: :none, include_policy_ids: false, rendition_filter: "cmis:none", include_acl: false, include_allowable_actions: false, with_object: false) ⇒ Object
- #get_properties(id, filter: []) ⇒ Object
- #get_renditions ⇒ Object
-
#initialize(repository, context) ⇒ ObjectService
constructor
A new instance of ObjectService.
- #move_object ⇒ Object
- #set_content_stream ⇒ Object
- #update_properties(id, properties, with_object: false) ⇒ Object
Constructor Details
#initialize(repository, context) ⇒ ObjectService
Returns a new instance of ObjectService.
13 14 15 16 |
# File 'app/services/cmis_server/object_service.rb', line 13 def initialize(repository, context) @repository= repository.is_a?(Repository) ? repository : CmisServer::Repository.find(repository) @context =context end |
Instance Method Details
#append_content_stream ⇒ Object
171 172 173 |
# File 'app/services/cmis_server/object_service.rb', line 171 def append_content_stream raise NotImplemented end |
#bulk_update_properties ⇒ Object
151 152 153 |
# File 'app/services/cmis_server/object_service.rb', line 151 def bulk_update_properties raise NotImplemented end |
#create_document(properties, folder_id: nil, content_stream: nil, versionning_state: :none, policies: [], add_aces: [], remove_aces: []) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/cmis_server/object_service.rb', line 18 def create_document(properties, folder_id: nil, content_stream: nil, versionning_state: :none, policies: [], add_aces: [], remove_aces: []) doc =CmisServer::DocumentObject.new(type: DocumentType.base, properties: properties) adapter=CmisServer::DocumentAdapter.new(doc, context: @context) if folder_id&&folder=CmisServer::FolderAdapter.class_adapter(context: @context).find(folder_id) adapter.add_to_folder(folder) end if content_stream adapter.add_content_stream(content_stream) end adapter.save! adapter.object.cmis_object_id end |
#create_document_from_source ⇒ Object
34 35 36 |
# File 'app/services/cmis_server/object_service.rb', line 34 def create_document_from_source raise NotImplemented end |
#create_folder(properties, add_aces: [], remove_aces: []) ⇒ Object
38 39 40 |
# File 'app/services/cmis_server/object_service.rb', line 38 def create_folder(properties, add_aces: [], remove_aces: []) raise NotImplemented end |
#create_item(properties, folder_id: nil, policies: [], add_aces: [], remove_aces: []) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/services/cmis_server/object_service.rb', line 50 def create_item(properties, folder_id: nil, policies: [], add_aces: [], remove_aces: []) item = CmisServer::ItemObject.new(type: ItemType.base, properties: properties) adapter = CmisServer::ItemAdapter.new(item, context: @context) if folder_id && folder = CmisServer::FolderAdapter.class_adapter(context: @context).find(folder_id) adapter.add_to_folder(folder) end adapter.save! adapter.object.cmis_object_id end |
#create_policy ⇒ Object
46 47 48 |
# File 'app/services/cmis_server/object_service.rb', line 46 def create_policy raise NotImplemented end |
#create_relationship ⇒ Object
42 43 44 |
# File 'app/services/cmis_server/object_service.rb', line 42 def create_relationship raise NotImplemented end |
#delete_content_stream ⇒ Object
175 176 177 |
# File 'app/services/cmis_server/object_service.rb', line 175 def delete_content_stream raise NotImplemented end |
#delete_object ⇒ Object
159 160 161 |
# File 'app/services/cmis_server/object_service.rb', line 159 def delete_object raise NotImplemented end |
#delete_tree ⇒ Object
163 164 165 |
# File 'app/services/cmis_server/object_service.rb', line 163 def delete_tree raise NotImplemented end |
#get_allowable_actions ⇒ Object
62 63 64 |
# File 'app/services/cmis_server/object_service.rb', line 62 def get_allowable_actions raise NotImplemented end |
#get_content_stream ⇒ Object
98 99 100 |
# File 'app/services/cmis_server/object_service.rb', line 98 def get_content_stream raise NotImplemented end |
#get_object(id, filter: [], include_relationships: :none, include_policy_ids: false, rendition_filter: "cmis:none", include_acl: false, include_allowable_actions: false, with_object: false) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/services/cmis_server/object_service.rb', line 66 def get_object(id, filter: [], include_relationships: :none, include_policy_ids: false, rendition_filter: "cmis:none", include_acl: false, include_allowable_actions: false, with_object: false) # Utiliser le nouveau connecteur pour récupérer l'objet connector = CmisServer::Connectors::ConnectorFactory.create_connector( user: @context[:current_user] || @context.current_user ) record = connector.find_object_by_id(id) raise CmisServer::ObjectNotFound unless record # Pour l'instant, retourner l'objet tel quel # TODO: implémenter la conversion en renderable_object record end |
#get_object_by_path(path, filter: [], include_relationships: :none, include_policy_ids: false, rendition_filter: "cmis:none", include_acl: false, include_allowable_actions: false, with_object: false) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/services/cmis_server/object_service.rb', line 84 def get_object_by_path(path, filter: [], include_relationships: :none, include_policy_ids: false, rendition_filter: "cmis:none", include_acl: false, include_allowable_actions: false, with_object: false) # Utiliser le nouveau connecteur pour récupérer l'objet par path connector = CmisServer::Connectors::ConnectorFactory.create_connector( user: @context[:current_user] || @context.current_user ) record = connector.find_object_by_path(path) raise CmisServer::ObjectNotFound unless record # Pour l'instant, retourner l'objet tel quel # TODO: implémenter la conversion en renderable_object record end |
#get_properties(id, filter: []) ⇒ Object
80 81 82 |
# File 'app/services/cmis_server/object_service.rb', line 80 def get_properties(id, filter: []) raise NotImplemented end |
#get_renditions ⇒ Object
102 103 104 |
# File 'app/services/cmis_server/object_service.rb', line 102 def get_renditions raise NotImplemented end |
#move_object ⇒ Object
155 156 157 |
# File 'app/services/cmis_server/object_service.rb', line 155 def move_object raise NotImplemented end |
#set_content_stream ⇒ Object
167 168 169 |
# File 'app/services/cmis_server/object_service.rb', line 167 def set_content_stream raise NotImplemented end |
#update_properties(id, properties, with_object: false) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/services/cmis_server/object_service.rb', line 106 def update_properties(id, properties, with_object: false) if id==CmisServer::FolderObject.root_folder.cmis_object_id record=CmisServer::Folder.Objectroot_folder else #Todo Mockup record=CmisServer::DocumentAdapter::ClassAdapter.new(context: @context).find(id)||CmisServer::Folder.find(id)||CmisServer::ItemAdapter::ClassAdapter.new(context: @context).find(id) end raise CmisServer::ObjectNotFound unless record # Gérer les types secondaires if properties['cmis:secondaryObjectTypeIds'] current_secondary_types = record.properties['cmis:secondaryObjectTypeIds']&.value || [] new_secondary_types = properties['cmis:secondaryObjectTypeIds'] # Supprimer les types qui ne sont plus présents types_to_remove = current_secondary_types - new_secondary_types # Ajouter les nouveaux types types_to_add = new_secondary_types - current_secondary_types # Mettre à jour les propriétés secondaryObjectTypeIds record.properties['cmis:secondaryObjectTypeIds'].value = new_secondary_types # Supprimer les propriétés des types secondaires qui ont été retirés # et ajouter celles des nouveaux types (implementation future) end # Mettre à jour les autres propriétés properties.each do |prop_id, value| next if prop_id == 'cmis:secondaryObjectTypeIds' # Déjà traité au-dessus record.properties[prop_id.to_s].value = value if record.properties[prop_id.to_s] end adapter = if record.is_a?(CmisServer::DocumentObject) CmisServer::DocumentAdapter.new(record, context: @context) elsif record.is_a?(CmisServer::FolderObject) CmisServer::FolderAdapter.new(record, context: @context) elsif record.is_a?(CmisServer::ItemObject) CmisServer::ItemAdapter.new(record, context: @context) end adapter.save! return adapter.object.to_renderable_object end |