class CMIS::Object

Attributes

properties[R]
repository[R]

Public Class Methods

new(raw, repository) click to toggle source
# 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

Public Instance Methods

acls(opts = {}) click to toggle source
# File lib/cmis/object.rb, line 102
def acls(opts = {})
  server.execute!({ cmisselector: 'acl',
                    repositoryId: repository.id,
                    objectId: cmis_object_id }, opts)
end
add_aces(aces, opts = {}) click to toggle source
# File lib/cmis/object.rb, line 108
def add_aces(aces, opts = {})
  server.execute!({ cmisaction: 'applyACL',
                    repositoryId: repository.id,
                    objectId: cmis_object_id,
                    addACEs: aces }, opts)
end
allowable_actions(opts = {}) click to toggle source
# File lib/cmis/object.rb, line 60
def allowable_actions(opts = {})
  server.execute!({ cmisselector: 'allowableActions',
                    repositoryId: repository.id,
                    objectId: cmis_object_id }, opts)
end
delete(opts = {}) click to toggle source
# 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
delete_with_relationships(opts = {}) click to toggle source
# File lib/cmis/object.rb, line 31
def delete_with_relationships(opts = {})
  relationships.each_relationship(limit: :all) do |rel|
    rel.delete(opts)
  end
  delete(opts)
end
detached?() click to toggle source
# File lib/cmis/object.rb, line 122
def detached?
  cmis_object_id.nil?
end
inspect() click to toggle source
# File lib/cmis/object.rb, line 130
def inspect
  "#{self.class}[#{cmis_object_id}] @ #{repository.inspect}"
end
move(target_folder, opts = {}) click to toggle source
# File lib/cmis/object.rb, line 88
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 = {}) click to toggle source
# File lib/cmis/object.rb, line 20
def object_type(opts = {})
  repository.type(object_type_id, opts)
end
parents(opts = {}) click to toggle source
# File lib/cmis/object.rb, line 52
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 = {}) click to toggle source
# File lib/cmis/object.rb, line 70
def policies(opts = {})
  result = server.execute!({ cmisselector: 'policies',
                             repositoryId: repository.id,
                             objectId: cmis_object_id }, opts)

  result.map { |r| Policy.new(r, repository) }
end
refresh(opts = {}) click to toggle source
# File lib/cmis/object.rb, line 126
def refresh(opts = {})
  detached? ? self : repository.object(cmis_object_id, opts)
end
relationships(opts = {}) click to toggle source
# File lib/cmis/object.rb, line 66
def relationships(opts = {})
  Relationships.new(self, opts)
end
remove_aces(aces, opts = {}) click to toggle source
# File lib/cmis/object.rb, line 115
def remove_aces(aces, opts = {})
  server.execute!({ cmisaction: 'applyACL',
                    repositoryId: repository.id,
                    objectId: cmis_object_id,
                    removeACEs: aces }, opts)
end
unfile(folder = nil, opts = {}) click to toggle source

By default removes from all folders

# File lib/cmis/object.rb, line 79
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(props, opts = {}) click to toggle source
# File lib/cmis/object.rb, line 38
def update_properties(props, opts = {})
  if detached?
    properties.merge!(props)
  else
    with_change_token do
      server.execute!({ cmisaction: 'update',
                        repositoryId: repository.id,
                        objectId: cmis_object_id,
                        properties: props,
                        changeToken: change_token }, opts)
    end
  end
end

Private Instance Methods

server() click to toggle source
# File lib/cmis/object.rb, line 136
def server
  repository.server if repository
end