Class: CMIS::Document
Instance Attribute Summary
Attributes inherited from Object
#properties, #repository
Instance Method Summary
collapse
Methods inherited from Object
#acls, #add_aces, #allowable_actions, #delete, #delete_with_relationships, #detached?, #inspect, #move, #object_type, #parents, #policies, #refresh, #relationships, #remove_aces, #unfile, #update_properties
Methods included from Helpers
#cmis_properties, #initialize_properties, #method_missing, #respond_to?, #with_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/cmis/document.rb', line 47
def content(opts = {})
if detached?
@local_content
else
server.execute!({ cmisselector: 'content',
repositoryId: repository.id,
objectId: cmis_object_id }, opts)
end
rescue Exceptions::Constraint => e
if e.message =~ /no content stream/
nil
else
raise e
end
end
|
#content=(opts = {}) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/cmis/document.rb', line 71
def content=(opts = {})
opts = opts.symbolize_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
with_change_token do
server.execute!({ cmisaction: 'setContent',
repositoryId: repository.id,
objectId: cmis_object_id,
content: content,
changeToken: change_token }, opts)
end
end
end
|
#content? ⇒ Boolean
43
44
45
|
# File 'lib/cmis/document.rb', line 43
def content?
!content_stream_length.nil?
end
|
#content_url(query_params = {}) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/cmis/document.rb', line 63
def content_url(query_params = {})
root_folder_url = server.connection.send(:infer_url, repository.id, true)
content_url = "#{root_folder_url}?cmisselector=content&objectId=#{cmis_object_id}"
query = query_params.map { |k, v| "#{k}=#{v}" }.join('&')
content_url << "&#{query}" unless query.empty?
content_url
end
|
#copy_in_folder(folder, opts = {}) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/cmis/document.rb', line 34
def copy_in_folder(folder, opts = {})
id = server.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 = server.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
|
#create_unfiled(opts = {}) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/cmis/document.rb', line 26
def create_unfiled(opts = {})
r = server.execute!({ cmisaction: 'createDocument',
repositoryId: repository.id,
properties: properties,
content: @local_content }, opts)
ObjectFactory.create(r, repository)
end
|