Class: CMIS::Object

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/cmis/object.rb

Direct Known Subclasses

Document, Folder, Item, Policy, Relationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#cmis_properties, #initialize_properties, #method_missing, respond_to?, #with_change_token

Constructor Details

#initialize(raw, repository) ⇒ Object

Returns a new instance of Object.



10
11
12
13
14
15
16
17
18
# File 'lib/cmis/object.rb', line 10

def initialize(raw, repository)
  initialize_properties(raw)
  cmis_properties %w( cmis:objectId cmis:baseTypeId cmis:objectTypeId
                      cmis:secondaryObjectTypeIds cmis:name cmis:description
                      cmis:createdBy cmis:creationDate cmis:lastModifiedBy
                      cmis:lastModificationDate cmis:changeToken )

  @repository = repository
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CMIS::Helpers

Instance Attribute Details

#propertiesObject (readonly)

Returns the value of attribute properties.



8
9
10
# File 'lib/cmis/object.rb', line 8

def properties
  @properties
end

#repositoryObject (readonly)

Returns the value of attribute repository.



7
8
9
# File 'lib/cmis/object.rb', line 7

def repository
  @repository
end

Instance Method Details

#acls(opts = {}) ⇒ Object



91
92
93
94
95
# File 'lib/cmis/object.rb', line 91

def acls(opts = {})
  server.execute!({ cmisselector: 'acl',
                    repositoryId: repository.id,
                    objectId: cmis_object_id }, opts)
end

#add_aces(aces, opts = {}) ⇒ Object



97
98
99
100
101
102
# File 'lib/cmis/object.rb', line 97

def add_aces(aces, opts = {})
  server.execute!({ cmisaction: 'applyACL',
                    repositoryId: repository.id,
                    objectId: cmis_object_id,
                    addACEs: aces }, opts)
end

#allowable_actions(opts = {}) ⇒ Object



49
50
51
52
53
# File 'lib/cmis/object.rb', line 49

def allowable_actions(opts = {})
  server.execute!({ cmisselector: 'allowableActions',
                    repositoryId: repository.id,
                    objectId: cmis_object_id }, opts)
end

#delete(opts = {}) ⇒ Object



24
25
26
27
28
29
# File 'lib/cmis/object.rb', line 24

def delete(opts = {})
  server.execute!({ cmisaction: 'delete',
                    repositoryId: repository.id,
                    objectId: cmis_object_id,
                    allVersions: true }, opts)
end

#detached?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/cmis/object.rb', line 111

def detached?
  cmis_object_id.nil?
end

#move(target_folder, opts = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cmis/object.rb', line 77

def move(target_folder, opts = {})
  object_parents = parents

  unless object_parents.size == 1
    raise 'Cannot move object because it is not in exactly one folder'
  end

  server.execute!({ cmisaction: 'move',
                    repositoryId: repository.id,
                    objectId: cmis_object_id,
                    targetFolderId: target_folder.cmis_object_id,
                    sourceFolderId: object_parents.first.cmis_object_id }, opts)
end

#object_type(opts = {}) ⇒ Object



20
21
22
# File 'lib/cmis/object.rb', line 20

def object_type(opts = {})
  repository.type(object_type_id, opts)
end

#parents(opts = {}) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/cmis/object.rb', line 41

def parents(opts = {})
  result = server.execute!({ cmisselector: 'parents',
                             repositoryId: repository.id,
                             objectId: cmis_object_id }, opts)

  result.map { |o| ObjectFactory.create(o['object'], repository) }
end

#policies(opts = {}) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/cmis/object.rb', line 59

def policies(opts = {})
  result = server.execute!({ cmisselector: 'policies',
                             repositoryId: repository.id,
                             objectId: cmis_object_id }, opts)

  result.map { |r| Policy.new(r, repository) }
end

#relationships(opts = {}) ⇒ Object



55
56
57
# File 'lib/cmis/object.rb', line 55

def relationships(opts = {})
  Relationships.new(self, opts)
end

#remove_aces(aces, opts = {}) ⇒ Object



104
105
106
107
108
109
# File 'lib/cmis/object.rb', line 104

def remove_aces(aces, opts = {})
  server.execute!({ cmisaction: 'applyACL',
                    repositoryId: repository.id,
                    objectId: cmis_object_id,
                    removeACEs: aces }, opts)
end

#unfile(folder = nil, opts = {}) ⇒ Object

By default removes from all folders



68
69
70
71
72
73
74
75
# File 'lib/cmis/object.rb', line 68

def unfile(folder = nil, opts = {})
  params = { repositoryId: repository.id,
             cmisaction: 'removeObjectFromFolder',
             objectId: cmis_object_id }
  params.update!(folderId: folder.cmis_object_id) if folder

  server.execute!(params, opts)
end

#update_properties(properties, opts = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/cmis/object.rb', line 31

def update_properties(properties, opts = {})
  with_change_token do
    server.execute!({ cmisaction: 'update',
                      repositoryId: repository.id,
                      objectId: cmis_object_id,
                      properties: properties,
                      changeToken: change_token }, opts)
  end
end