Sha256: 5aa65317cce6ca7ac5bde5570654304afcb45a21334a215e3b3a841a35f4ad2f

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

module FcrepoAdmin
  class DatastreamsController < ApplicationController

    layout 'fcrepo_admin/datastreams', :except => :index
    layout 'fcrepo_admin/objects', :only => :index

    include FcrepoAdmin::Controller::ControllerBehavior

    before_filter :load_and_authorize_object
    before_filter :load_datastream, :except => :index

    def index
    end

    def show
    end

    def content
      unless @datastream.content_is_text?
        render :text => "Datastream content is not text.", :status => 403
      end
    end

    def history
    end

    def edit
      unless @datastream.content_is_editable?
        render :text => "Datastream content is not editable", :status => 403
      end
    end

    def upload
      unless @datastream.content_is_uploadable?
        render :text => "This datstream does not support file content", :status => 403
      end
    end

    def update
      if params[:file] # file uploaded
        @datastream.content = params[:file].read
      else # content submitted
        @datastream.content = params[:content]
      end
      @object.save
      flash[:notice] = "Datastream content updated." # i18n
      redirect_to fcrepo_admin.object_datastream_url(@object, @datastream)
    end

    private
    
    def load_datastream
      @datastream = @object.datastreams[params[:id]]
      @datastream = @datastream.asOfDateTime(params[:asOfDateTime]) if params[:asOfDateTime]
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fcrepo_admin-0.6.1 app/controllers/fcrepo_admin/datastreams_controller.rb
fcrepo_admin-0.6.0 app/controllers/fcrepo_admin/datastreams_controller.rb
fcrepo_admin-0.5.5 app/controllers/fcrepo_admin/datastreams_controller.rb
fcrepo_admin-0.5.5.pre app/controllers/fcrepo_admin/datastreams_controller.rb