class SakaiInfo::Content

Attributes

parent_id[R]

Public Class Methods

all_serializations() click to toggle source
# File lib/sakai-info/content.rb, line 144
def self.all_serializations
  [
   :default,
   :children,
   :realm,
   :properties,
   :mod
  ]
end
find(id) click to toggle source
# File lib/sakai-info/content.rb, line 22
def self.find(id)
  begin
    ContentResource.find(id)
  rescue ObjectNotFoundException
    begin
      ContentCollection.find(id)
    rescue ObjectNotFoundException
      if not id.match(/\/$/)
        ContentCollection.find(id + "/")
      else
        raise ObjectNotFoundException.new(Content, id)
      end
    end
  end
end

Public Instance Methods

binary_entity() click to toggle source
# File lib/sakai-info/content.rb, line 50
def binary_entity
  if @binary_entity.nil?
    @binary_entity = ContentBinaryEntity.new(@dbrow[:binary_entity])

    @dbrow[:_binary_entity_created_by] = @binary_entity["CHEF:creator"]
    @dbrow[:_binary_entity_modified_by] = @binary_entity["CHEF:modifiedby"]
    @dbrow[:_binary_entity_created_at] =
      Util.format_entity_date(@binary_entity["DAV:creationdate"])
    @dbrow[:_binary_entity_modified_at] =
      Util.format_entity_date(@binary_entity["DAV:getlastmodified"])
  end

  @binary_entity
end
child_summary_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 108
def child_summary_serialization
  {
    "id" => self.id.gsub(/^#{self.parent_id}/,""),
    "size" => self.size_on_disk,
  }
end
default_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 65
def default_serialization
  {
    "id" => self.id,
    "parent" => self.parent_id,
    "size_on_disk" => self.size_on_disk
  }
end
effective_realm() click to toggle source
# File lib/sakai-info/content.rb, line 94
def effective_realm
  self.realm || (parent.nil? ? nil : parent.effective_realm)
end
mod_details_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 139
def mod_details_serialization
  self.binary_entity
  self.original_mod_details_serialization
end
mod_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 134
def mod_serialization
  self.binary_entity
  self.original_mod_serialization
end
Also aliased as: original_mod_serialization
original_mod_details_serialization()
original_mod_serialization()

ensure @binary_entity has been parsed before returning mod info

Alias for: mod_serialization
parent() click to toggle source
# File lib/sakai-info/content.rb, line 38
def parent
  if @parent_id.nil?
    nil
  else
    @parent ||= ContentCollection.find(@parent_id)
  end
end
properties_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 115
def properties_serialization
  result = self.binary_entity.to_hash
  if result["groups"] == []
    result.delete("groups")
  end
  result.keys.each do |key|
    if result[key].nil? or result[key] == ""
      result.delete(key)
    end
  end
  {
    "properties" => result
  }
end
realm() click to toggle source
# File lib/sakai-info/content.rb, line 81
def realm
  if @realm_is_nil
    nil
  else
    begin
      @realm ||= AuthzRealm.find_by_name("/content#{@id}")
    rescue ObjectNotFoundException
      @realm_is_nil = true
      nil
    end
  end
end
realm_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 98
def realm_serialization
  if self.effective_realm.nil?
    {}
  else
    {
      "effective_realm" => self.effective_realm.name,
    }
  end
end
size_on_disk() click to toggle source
# File lib/sakai-info/content.rb, line 46
def size_on_disk
  0
end
summary_serialization() click to toggle source
# File lib/sakai-info/content.rb, line 73
def summary_serialization
  {
    "id" => self.id,
    "parent" => self.parent_id,
    "size_on_disk" => self.size_on_disk
  }
end