Class: FileAssetsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- FileAssetsController
- Includes:
- Blacklight::SolrHelper, Hydra::AssetsControllerHelper, Hydra::FileAssetsHelper, Hydra::RepositoryController, MediaShelf::ActiveFedoraHelper
- Defined in:
- vendor/plugins/hydra_repository/app/controllers/file_assets_controller.rb
Constant Summary
Constants included from Blacklight::SolrHelper
Instance Method Summary (collapse)
- - (Object) create
-
- (Object) destroy
Common destroy method for all AssetsControllers.
- - (Object) index
- - (Object) new
- - (Object) show
Methods included from Blacklight::SolrHelper
#facet_limit_for, #facet_limit_hash, #get_facet_pagination, #get_opensearch_response, #get_search_results, #get_single_doc_via_search, #get_solr_response_for_doc_id, #get_solr_response_for_field_values, included, #max_per_page, #solr_doc_params, #solr_facet_params, #solr_opensearch_params, #solr_param_quote, #solr_search_params
Methods included from MediaShelf::ActiveFedoraHelper
#load_af_instance_from_solr, #retrieve_af_model
Methods included from Hydra::RepositoryController
#downloadables, included, #solr_name
Methods included from Hydra::FileAssetsHelper
#add_posted_blob_to_asset, #asset_class_from_params, #choose_model_by_filename, #choose_model_by_filename_extension, #create_and_save_file_asset_from_params, #create_asset_from_params
Methods included from Hydra::AssetsControllerHelper
#apply_depositor_metadata, #prep_updater_method_args, #set_collection_type
Methods inherited from ApplicationController
#current_user, #default_html_head, #error, #extra_head_content, #javascript_includes, #stylesheet_links, #user_class
Methods included from HydraAccessControlsHelper
#editor?, #reader?, #test_permission
Instance Method Details
- (Object) create
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'vendor/plugins/hydra_repository/app/controllers/file_assets_controller.rb', line 34 def create @file_asset = create_and_save_file_asset_from_params (@file_asset) if !params[:container_id].nil? @container = ActiveFedora::Base.load_instance(params[:container_id]) @container.file_objects_append(@file_asset) @container.save end ## FOR CAPTURING ANY FILE METADATA // THERE'S PROBABY A BETTER PLACE FOR THIS. unless params[:asset].nil? updater_method_args = prep_updater_method_args(params) logger.debug("attributes submitted: #{updater_method_args.inspect}") result = @file_asset.update_indexed_attributes(updater_method_args[:params], updater_method_args[:opts]) @file_asset.save end ## logger.debug "Created #{@file_asset.pid}." render :nothing => true end |
- (Object) destroy
Common destroy method for all AssetsControllers
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'vendor/plugins/hydra_repository/app/controllers/file_assets_controller.rb', line 58 def destroy # The correct implementation, with garbage collection: # if params.has_key?(:container_id) # container = ActiveFedora::Base.load_instance(params[:container_id]) # container.file_objects_remove(params[:id]) # FileAsset.garbage_collect(params[:id]) # else # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers) ActiveFedora::Base.load_instance(params[:id]).delete render :text => "Deleted #{params[:id]} from #{params[:container_id]}." end |
- (Object) index
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'vendor/plugins/hydra_repository/app/controllers/file_assets_controller.rb', line 13 def index if params[:layout] == "false" # action = "index_embedded" layout = false end if !params[:container_id].nil? @response, @document = get_solr_response_for_doc_id(params[:container_id]) @container = ActiveFedora::Base.load_instance(params[:container_id]) @solr_result = @container.file_objects(:response_format=>:solr) else # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/afmodel\:FileAsset', @search_params) @solr_result = FileAsset.find_by_solr(:all) puts @solr_result.inspect end render :action=>params[:action], :layout=>layout end |
- (Object) new
30 31 32 |
# File 'vendor/plugins/hydra_repository/app/controllers/file_assets_controller.rb', line 30 def new render :partial=>"new", :layout=>false end |
- (Object) show
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'vendor/plugins/hydra_repository/app/controllers/file_assets_controller.rb', line 72 def show @file_asset = FileAsset.find(params[:id]) if (@file_asset.nil?) logger.warn("No such file asset: " + params[:id]) flash[:notice]= "No such file asset." redirect_to(:action => 'index', :q => nil , :f => nil) else # get array of parent (container) objects for this FileAsset @id_array = @file_asset.containers(:response_format => :id_array) @downloadable = false # A FileAsset is downloadable iff the user has read or higher access to a parent @id_array.each do |pid| @response, @document = get_solr_response_for_doc_id(pid) if reader? @downloadable = true break end end if @downloadable if @file_asset.datastreams_in_memory.include?("DS1") send_datastream @file_asset.datastreams_in_memory["DS1"] end else flash[:notice]= "You do not have sufficient access privileges to download this document, which has been marked private." redirect_to(:action => 'index', :q => nil , :f => nil) end end end |