Class: CMIS::Document
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
- #content(opts = {}) ⇒ Object
- #copy_in_folder(folder, opts = {}) ⇒ Object
- #create_in_folder(folder, opts = {}) ⇒ Object
-
#initialize(raw, repository) ⇒ Document
constructor
A new instance of Document.
- #set_content(opts = {}) ⇒ Object
Methods inherited from Object
#acls, #add_aces, #allowable_actions, #delete, #detached?, #move, #object_type, #parents, #policies, #relationships, #remove_aces, #unfile, #update_properties
Methods included from Helpers
#cmis_properties, #initialize_properties, #method_missing, respond_to?, #update_change_token
Constructor Details
#initialize(raw, repository) ⇒ Document
Returns a new instance of Document.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/cmis/document.rb', line 3 def initialize(raw, repository) super cmis_properties %w( cmis:isImmutable cmis:isLatestVersion cmis:isMajorVersion cmis:isLatestMajorVersion cmis:isPrivateWorkingCopy cmis:versionLabel cmis:versionSeriesId cmis:isVersionSeriesCheckedOut cmis:versionSeriesCheckedOutBy cmis:versionSeriesCheckedOutId cmis:checkinComment cmis:contentStreamLength cmis:contentStreamMimeType cmis:contentStreamFileName cmis:contentStreamId ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CMIS::Helpers
Instance Method Details
#content(opts = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/cmis/document.rb', line 35 def content(opts = {}) connection.execute!({ cmisselector: 'content', repositoryId: repository.id, objectId: cmis_object_id }, opts) rescue Exceptions::Constraint # Check for specific constraint? nil end |
#copy_in_folder(folder, opts = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/cmis/document.rb', line 26 def copy_in_folder(folder, opts = {}) id = connection.execute!({ cmisaction: 'createDocument', repositoryId: repository.id, sourceId: cmis_object_id, objectId: folder.cmis_object_id }, opts) repository.object(id) end |
#create_in_folder(folder, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cmis/document.rb', line 15 def create_in_folder(folder, opts = {}) r = connection.execute!({ cmisaction: 'createDocument', repositoryId: repository.id, properties: properties, objectId: folder.cmis_object_id, folderId: folder.cmis_object_id, content: @local_content }, opts) ObjectFactory.create(r, repository) end |
#set_content(opts = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cmis/document.rb', line 45 def set_content(opts = {}) opts.stringify_keys! content = { stream: opts.delete('stream'), mime_type: opts.delete('mime_type'), filename: opts.delete('filename') } if content[:stream].is_a? String content[:stream] = StringIO.new(content[:stream]) end if detached? @local_content = content else update_change_token connection.execute!({ cmisaction: 'setContent', repositoryId: repository.id, objectId: cmis_object_id, content: content, changeToken: change_token }, opts) end end |