class ActiveFedora::Datastream

This class represents a Fedora datastream

def self.delete(parent_pid, dsid)

def self.delete(parent_pid, dsid)
  Fedora::Repository.instance.delete("%s/datastreams/%s"%[parent_pid, dsid])
end

def self.from_xml(tmpl, el)

def self.from_xml(tmpl, el)
  el.elements.each("foxml:xmlContent/fields") do |f|
    tmpl.send("#{f.name}_append", f.text)
  end
  tmpl.instance_variable_set(:@dirty, false)
  tmpl.control_group= el.attributes['CONTROL_GROUP']
  tmpl
end

def after_save

def after_save
  self.dirty = false
end

def before_save # :nodoc:

:nodoc:
def before_save # :nodoc:
  #check_concurrency
end

def check_concurrency # :nodoc:

:nodoc:
def check_concurrency # :nodoc:
  return true
end

def content

Return the xml content representing this Datastream from Fedora
def content
  result = Fedora::Repository.instance.fetch_custom(self.attributes[:pid], "datastreams/#{self.dsid}/content")
  return result
end

def content=(content)

set this Datastream's content
def content=(content)
  self.blob = content
end

def delete

def delete
  self.class.delete(self.pid, self.dsid)
end

def dirty?

has this datastream been modified since it was last saved?
def dirty?
  @dirty
end

def dsid=(dsid)

set this datastreams identifier (note: sets both dsID and dsid)
def dsid=(dsid)
  self.attributes[:dsID] = dsid
  self.attributes[:dsid] = dsid
end

def initialize(attrs = {})

def initialize(attrs = {})
  @fields={}
  @dirty = false
  super
end

def last_modified_in_repository

ie 2008-10-17T00:17:18.194Z
returns a datetime in the standard W3C DateTime Format.
def last_modified_in_repository
  # A hack to get around the fact that you can't call getDatastreamHistory 
  # or API-M getDatasreams on Fedora 3.0 REST API  
  # grabs the CREATED attribute off of the last foxml:datastreamVersion 
  # within the appropriate datastream node in the objectXML
  if self.pid != nil
    object_xml = Fedora::FedoraObject.object_xml(self.pid).gsub("\n     ","")
    datastream_xml = REXML::Document.new(object_xml).root.elements["foxml:datastream[@ID='#{self.dsid}']"]
    
    puts datastream_xml.length
    if datastream_xml.length > 3
      datastream_xml.elements.each do |el|
        puts el.inspect
      end
    end
    
    datastream_xml.elements[datastream_xml.length - 2].attributes["CREATED"]
  else
    return nil
  end
end

def pid

get this datastreams identifier
def pid
  self.attributes[:pid]
end

def pid=(pid)

set this datastreams parent identifier
def pid=(pid)
  self.attributes[:pid] = pid
end

def save

saves this datastream into fedora.
def save
  before_save
  result = Fedora::Repository.instance.save(self)
  after_save
  result
end

def to_param

invalid characters in a dsid.
urlescape escape dots, which are apparently
compatibility method for rails' url generators. This method will
def to_param
  dsid.gsub(/\./, '%2e')
end