cul_scv_hydra 0.22.6 → 0.22.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
  3. data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
  4. data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
  5. data/app/controllers/concerns/cul/scv/hydra/controller.rb +3 -19
  6. data/app/controllers/concerns/cul/scv/hydra/resolver.rb +2 -65
  7. data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +3 -59
  8. data/app/models/concept.rb +1 -1
  9. data/app/models/concerns/cul/hydra/models.rb +24 -0
  10. data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
  11. data/app/models/concerns/cul/hydra/models/common.rb +220 -0
  12. data/app/models/concerns/cul/hydra/models/image_resource.rb +78 -0
  13. data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
  14. data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
  15. data/app/models/concerns/cul/scv/hydra/models.rb +1 -13
  16. data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +1 -116
  17. data/app/models/concerns/cul/scv/hydra/models/common.rb +1 -213
  18. data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +3 -75
  19. data/app/models/concerns/cul/scv/hydra/models/linkable_resources.rb +3 -105
  20. data/app/models/concerns/cul/scv/hydra/models/resource.rb +2 -83
  21. data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
  22. data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
  23. data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
  24. data/app/models/cul/scv/hydra/datastreams/dc_metadata.rb +5 -104
  25. data/app/models/cul/scv/hydra/datastreams/mods_document.rb +5 -178
  26. data/app/models/cul/scv/hydra/datastreams/struct_metadata.rb +5 -174
  27. data/app/models/dc_document.rb +1 -1
  28. data/app/models/generic_aggregator.rb +5 -5
  29. data/app/models/generic_object.rb +2 -2
  30. data/app/models/generic_resource.rb +4 -4
  31. data/app/models/mets_structured_aggregator.rb +2 -2
  32. data/app/models/resource.rb +3 -3
  33. data/app/models/resource_aggregator.rb +3 -3
  34. data/fixtures/spec/CUL_MODS/mods-subjects.xml +24 -0
  35. data/lib/cul_hydra.rb +18 -0
  36. data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
  37. data/lib/cul_hydra/controllers.rb +13 -0
  38. data/lib/cul_hydra/controllers/aggregates.rb +93 -0
  39. data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
  40. data/lib/cul_hydra/controllers/catalog.rb +12 -0
  41. data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
  42. data/lib/cul_hydra/controllers/datastreams.rb +145 -0
  43. data/lib/cul_hydra/controllers/helpers.rb +10 -0
  44. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/active_fedora_helper_behavior.rb +1 -1
  45. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/application_helper_behavior.rb +1 -1
  46. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/dc_metadata_helper_behavior.rb +1 -1
  47. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_assets_helper_behavior.rb +1 -1
  48. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_autocomplete_helper_behavior.rb +1 -1
  49. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_uploader_helper_behavior.rb +1 -1
  50. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/resources_helper_behavior.rb +1 -1
  51. data/lib/cul_hydra/controllers/resources.rb +161 -0
  52. data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
  53. data/lib/cul_hydra/controllers/suggestions.rb +126 -0
  54. data/lib/cul_hydra/controllers/terms.rb +205 -0
  55. data/lib/cul_hydra/engine.rb +31 -0
  56. data/lib/cul_hydra/fedora.rb +41 -0
  57. data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
  58. data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
  59. data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
  60. data/lib/cul_hydra/indexer.rb +84 -0
  61. data/lib/cul_hydra/om.rb +7 -0
  62. data/lib/cul_hydra/om/standard_mods.rb +115 -0
  63. data/lib/cul_hydra/risearch_members.rb +92 -0
  64. data/lib/cul_hydra/solrizer.rb +10 -0
  65. data/lib/cul_hydra/solrizer/extractor.rb +27 -0
  66. data/lib/cul_hydra/solrizer/mods_fieldable.rb +435 -0
  67. data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
  68. data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
  69. data/lib/{cul_scv_hydra/solrizer/field_mapper.rb → cul_hydra/solrizer_patch.rb} +0 -0
  70. data/lib/cul_hydra/version.rb +8 -0
  71. data/lib/cul_hydra/version.rb~ +8 -0
  72. data/lib/cul_scv_fedora/dummy_object.rb +1 -30
  73. data/lib/cul_scv_fedora/rubydora_patch.rb +3 -7
  74. data/lib/cul_scv_fedora/url_helper_behavior.rb +3 -23
  75. data/lib/cul_scv_hydra.rb +5 -32
  76. data/lib/cul_scv_hydra/access_controls_enforcement.rb +3 -50
  77. data/lib/cul_scv_hydra/controllers.rb +10 -10
  78. data/lib/cul_scv_hydra/controllers/aggregates.rb +1 -86
  79. data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +4 -23
  80. data/lib/cul_scv_hydra/controllers/catalog.rb +5 -9
  81. data/lib/cul_scv_hydra/controllers/content_aggregators.rb +4 -77
  82. data/lib/cul_scv_hydra/controllers/datastreams.rb +3 -140
  83. data/lib/cul_scv_hydra/controllers/helpers.rb +44 -8
  84. data/lib/cul_scv_hydra/controllers/resources.rb +4 -157
  85. data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +4 -100
  86. data/lib/cul_scv_hydra/controllers/suggestions.rb +4 -122
  87. data/lib/cul_scv_hydra/controllers/terms.rb +4 -201
  88. data/lib/cul_scv_hydra/engine.rb +1 -1
  89. data/lib/cul_scv_hydra/indexer.rb +3 -82
  90. data/lib/cul_scv_hydra/om.rb +2 -2
  91. data/lib/cul_scv_hydra/om/standard_mods.rb +1 -108
  92. data/lib/cul_scv_hydra/risearch_members.rb +4 -89
  93. data/lib/cul_scv_hydra/solrizer.rb +5 -6
  94. data/lib/cul_scv_hydra/solrizer/extractor.rb +1 -25
  95. data/lib/cul_scv_hydra/solrizer/scv_mods_fieldable.rb +4 -429
  96. data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +4 -32
  97. data/lib/cul_scv_hydra/solrizer/value_mapper.rb +1 -44
  98. data/lib/cul_scv_hydra/version.rb +5 -5
  99. data/lib/tasks/index.rake +2 -2
  100. data/lib/tasks/transform.rake +23 -0
  101. metadata +55 -12
@@ -1,12 +1,8 @@
1
- require 'cul_scv_hydra/controllers/aggregator_controller_helper'
2
- require 'cul_scv_hydra/controllers/helpers/active_fedora_helper_behavior'
3
1
  module Cul::Scv::Hydra::Controllers
4
- module Catalog
5
- extend ActiveSupport::Concern
6
- included do
7
- include Cul::Scv::Hydra::Controllers::AggregatorControllerHelper
8
- include Cul::Scv::Hydra::Controllers::Helpers::ActiveFedoraHelperBehavior
9
- before_filter :load_resources, :only=>[:show, :edit]
2
+ module Catalog
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Cul::Hydra::Controllers::Catalog
6
+ end
10
7
  end
11
8
  end
12
- end
@@ -1,81 +1,8 @@
1
- require 'cul_scv_hydra/controllers/helpers/resources_helper_behavior'
2
1
  module Cul::Scv::Hydra::Controllers
3
- module ContentAggregators
4
- extend ActiveSupport::Concern
5
- included do
6
- include Hydra::AssetsControllerHelper
7
- include Cul::Scv::Hydra::Controllers::Helpers::ResourcesHelperBehavior
8
- include Hydra::RepositoryController
9
- include MediaShelf::ActiveFedoraHelper
10
- include Blacklight::SolrHelper
11
- prepend_before_filter :sanitize_update_params
12
- end
13
-
14
- def index
15
- if params[:layout] == "false"
16
- # action = "index_embedded"
17
- layout = false
18
- end
19
- if !params[:container_id].nil?
20
- container_uri = "info:fedora/#{params[:container_id]}"
21
- escaped_uri = container_uri.gsub(/(:)/, '\\:')
22
- extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"}
23
- @response, @document_list = get_search_results( extra_controller_params )
24
-
25
- # Including this line so permissions tests can be run against the container
26
- @container_response, @document = get_solr_response_for_doc_id(params[:container_id])
27
-
28
- # Including these lines for backwards compatibility (until we can use Rails3 callbacks)
29
- @container = ActiveFedora::Base.load_instance(params[:container_id])
30
- @solr_result = @container.file_objects(:response_format=>:solr)
31
- else
32
- # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/ldpd\:Resource', @search_params)
33
- @solr_result = Resource.find_by_solr(:all)
34
- end
35
- render :action=>params[:action], :layout=>layout
36
- end
37
-
38
- def new
39
- @asset = ContentAggregator.new
40
- apply_depositor_metadata(@asset)
41
- set_collection_type(@asset, params[:content_type])
42
- if !params[:container_id].nil?
43
- associate_resource_with_container(@asset, params[:container_id])
2
+ module ContentAggregators
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Cul::Hydra::Controllers::ContentAggregators
44
6
  end
45
- @asset.save
46
- msg = "Created a Content Aggregator with pid #{@asset.pid}. Now it's ready to be edited."
47
- flash[:notice]= msg
48
-
49
- session[:scripts] = params[:combined] == "true"
50
- redirect_to url_for(:action=>"edit", :id=>@asset.pid, :new_asset=>true, :controller=>'catalog')
51
-
52
7
  end
53
-
54
- # Common destroy method for all AssetsControllers
55
- def destroy
56
- # The correct implementation, with garbage collection:
57
- # if params.has_key?(:container_id)
58
- # container = ActiveFedora::Base.load_instance(params[:container_id])
59
- # container.file_objects_remove(params[:id])
60
- # FileAsset.garbage_collect(params[:id])
61
- # else
62
-
63
- # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)
64
- ActiveFedora::Base.load_instance(params[:id]).delete
65
- render :text => "Deleted #{params[:id]} from #{params[:container_id]}."
66
- end
67
-
68
-
69
- def show
70
- @image_agg = ContentAggregator.find(params[:id])
71
- if (@image_agg.nil?)
72
- logger.warn("No such object: " + params[:id])
73
- flash[:notice]= "No such object."
74
- redirect_to(:action => 'index', :q => nil , :f => nil)
75
- else
76
- @id_array = @image_agg.containers(:response_format => :id_array)
77
- end
78
- render :action=>params[:action], :layout=>(params[:layout]=="false")
79
- end
80
- end
81
8
  end
@@ -1,145 +1,8 @@
1
- require 'cul_scv_hydra/controllers/helpers/application_helper_behavior'
2
1
  module Cul::Scv::Hydra::Controllers
3
2
  module Datastreams
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- include Cul::Scv::Hydra::Controllers::Helpers::ApplicationHelperBehavior
8
- include Hydra::AssetsControllerHelper
9
- include Hydra::AssetsControllerHelper
10
- include Hydra::FileAssetsHelper
11
- include Hydra::RepositoryController
12
- include MediaShelf::ActiveFedoraHelper
13
- include Blacklight::SolrHelper
14
- prepend_before_filter :sanitize_update_params
15
- end
16
-
17
- def index
18
- if params[:layout] == "false"
19
- # action = "index_embedded"
20
- layout = false
21
- end
22
- unless params[:asset_id].nil?
23
-
24
- # Including this line so permissions tests can be run against the container
25
- @container_response, @document = get_solr_response_for_doc_id(params[:asset_id])
26
-
27
- # Including these lines for backwards compatibility (until we can use Rails3 callbacks)
28
- @container = ActiveFedora::Base.load_instance(params[:asset_id])
29
- @ds = @container.datastreams(params[:id])
30
- else
31
- # What are we doing here without a containing object?
32
- raise "called DatastreamsController#index without containing object"
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Cul::Hydra::Controllers::Datastreams
33
6
  end
34
- render :action=>params[:action], :layout=>layout
35
7
  end
36
-
37
- def new
38
- render :partial=>"new", :layout=>false
39
- end
40
-
41
- # Creates and Saves a Datastream to contain the the Uploaded file
42
- def create
43
- if params[:asset_id].nil?
44
- raise "Cannot created a datastream without a containing object"
45
- else
46
- @container = ActiveFedora::Base.load_instance(params[:asset_id])
47
- end
48
-
49
- if params[:id].nil?
50
- raise "Cannot created a datastream without a datastream id"
51
- end
52
-
53
- if params.has_key?(:Filedata)
54
- file_name = filename_from_params
55
- mime_type = params[:mime_type] || mime_type(file_name)
56
- @container.add_file_datastream(posted_file, :dsid=>params[:id], :label=>file_name, :mimeType=>mime_type, :size=>posted_file.size)
57
- @container.save
58
- # apply_depositor_metadata(@file_asset)
59
-
60
- flash[:notice] = "The file #{params[:Filename]} has been saved as #{params[:datastream_id]} in <a href=\"#{asset_url(@container.pid)}\">#{@container.pid}</a>."
61
-
62
- ## Apply any posted file metadata
63
- unless params[:asset].nil?
64
- # logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}")
65
- # apply_file_metadata
66
- end
67
- # If redirect_params has not been set, use {:action=>:index}
68
- logger.debug "Created #{@container.pid}##{params[:datastream_id]}."
69
- elsif params.has_key?(:Source)
70
- file_name = filename_from_url(params[:Source])
71
- mime_type = params[:mime_type] || mime_type(file_name)
72
- ds_props = {:dsid=>params[:id], :label=>file_name, :mimeType=>mime_type, :dsLocation=>params[:Source]}
73
- @container.add_datastream(ActiveFedora::Datastream.new(ds_props))
74
- @container.save
75
-
76
- flash[:notice] = "#{params[:Source]} has been saved as #{params[:datastream_id]} in <a href=\"#{asset_url(@container.pid)}\">#{@container.pid}</a>."
77
- else
78
- flash[:notice] = "You must specify a file to upload or a source URL."
79
- end
80
-
81
- unless params[:container_id].nil?
82
- redirect_params = {:controller=>"catalog", :id=>params[:asset_id], :action=>:edit}
83
- end
84
-
85
- redirect_params ||= {:action=>:index}
86
-
87
- redirect_to redirect_params
88
- end
89
-
90
- # Datastream destroy method
91
- def destroy
92
- @container = ActiveFedora::Base.load_instance(params[:asset_id])
93
- @container.datastreams[params[:datastream_id]].delete
94
- render :text => "Deleted #{params[:datastream_id]} from #{params[:asset_id]}."
95
- # Does the index need to be updated on delete here?
96
- @container.save
97
- end
98
-
99
- def update
100
- self.create
101
- end
102
-
103
- def show
104
- @container = ActiveFedora::Base.find(params[:asset_id])
105
- if (@container.nil?)
106
- logger.warn("No such fedora object: " + params[:asset_id])
107
- flash[:notice]= "No such fedora object."
108
- redirect_to(:action => 'index', :q => nil , :f => nil)
109
- return
110
- else
111
- # get array of parent (container) objects for this FileAsset
112
- @downloadable = false
113
- # A FileAsset is downloadable iff the user has read or higher access to a parent
114
- @response, @document = get_solr_response_for_doc_id(params[:asset_id])
115
- if reader?
116
- @downloadable = true
117
- end
118
-
119
- if @downloadable
120
- if @container.datastreams_in_memory.include?(params[:id])
121
- ds = @container.datastreams_in_memory[params[:id]]
122
- opts = {:filename => ds.label}
123
- if params[:mime_type].nil?
124
- opts[:type] = ds.attributes["mimeType"]
125
- else
126
- opts[:type] = params[:mime_type]
127
- end
128
- if params[:disposition].nil?
129
- opts[:disposition] = "attachment"
130
- else
131
- opts[:disposition] = params[:disposition]
132
- end
133
- logger.debug opts.inspect
134
- send_data ds.content, opts
135
- return
136
- end
137
- else
138
- flash[:notice]= "You do not have sufficient access privileges to download this document, which has been marked private."
139
- redirect_to(:action => 'index', :q => nil , :f => nil)
140
- return
141
- end
142
- end
143
- end
144
- end
145
8
  end
@@ -1,11 +1,47 @@
1
1
  module Cul::Scv::Hydra::Controllers
2
2
  module Helpers
3
+ module ActiveFedoraHelperBehavior
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ include Cul::Hydra::Controllers::ActiveFedoraHelperBehavior
7
+ end
8
+ end
9
+ end
10
+ module ApplicationHelperBehavior
11
+ extend ActiveSupport::Concern
12
+ included do
13
+ include Cul::Hydra::Controllers::ApplicationHelperBehavior
14
+ end
15
+ end
16
+ module DcMetadataHelperBehavior
17
+ extend ActiveSupport::Concern
18
+ included do
19
+ include Cul::Hydra::Controllers::DcMetadataHelperBehavior
20
+ end
21
+ end
22
+ module HydraAssetsHelperBehavior
23
+ extend ActiveSupport::Concern
24
+ included do
25
+ include Cul::Hydra::Controllers::HydraAssetsHelperBehavior
26
+ end
27
+ end
28
+ module HydraAutocompleteHelperBehavior
29
+ extend ActiveSupport::Concern
30
+ included do
31
+ include Cul::Hydra::Controllers::HydraAutocompleteHelperBehavior
32
+ end
33
+ end
34
+ module HydraUploaderHelperBehavior
35
+ extend ActiveSupport::Concern
36
+ included do
37
+ include Cul::Hydra::Controllers::HydraUploaderHelperBehavior
38
+ end
39
+ end
40
+ module ResourcesHelperBehavior
41
+ extend ActiveSupport::Concern
42
+ included do
43
+ include Cul::Hydra::Controllers::ResourcesHelperBehavior
44
+ end
45
+ end
3
46
  end
4
- end
5
- require 'cul_scv_hydra/controllers/helpers/active_fedora_helper_behavior.rb'
6
- require 'cul_scv_hydra/controllers/helpers/application_helper_behavior.rb'
7
- require 'cul_scv_hydra/controllers/helpers/dc_metadata_helper_behavior.rb'
8
- require 'cul_scv_hydra/controllers/helpers/hydra_assets_helper_behavior.rb'
9
- require 'cul_scv_hydra/controllers/helpers/hydra_autocomplete_helper_behavior.rb'
10
- require 'cul_scv_hydra/controllers/helpers/hydra_uploader_helper_behavior.rb'
11
- require 'cul_scv_hydra/controllers/helpers/resources_helper_behavior.rb'
47
+ end
@@ -1,161 +1,8 @@
1
1
  module Cul::Scv::Hydra::Controllers
2
- module Resources
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- include Hydra::AssetsControllerHelper
7
- include Cul::Scv::Hydra::Controllers::Helpers::ResourcesHelperBehavior
8
- include Hydra::Controller
9
- include Hydra::RepositoryController
10
- include MediaShelf::ActiveFedoraHelper
11
- include Blacklight::SolrHelper
12
- before_filter :load_fedora_document, :only=>[:update]
13
- prepend_before_filter :sanitize_update_params
14
- end
15
-
16
- def index
17
- if params[:layout] == "false"
18
- # action = "index_embedded"
19
- layout = false
20
- end
21
- if !params[:container_id].nil?
22
- container_uri = "info:fedora/#{params[:container_id]}"
23
- escaped_uri = container_uri.gsub(/(:)/, '\\:')
24
- extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"}
25
- @response, @document_list = get_search_results( extra_controller_params )
26
-
27
- # Including this line so permissions tests can be run against the container
28
- @container_response, @document = get_solr_response_for_doc_id(params[:container_id])
29
-
30
- # Including these lines for backwards compatibility (until we can use Rails3 callbacks)
31
- @container = ActiveFedora::Base.load_instance(params[:container_id])
32
- @solr_result = @container.file_objects(:response_format=>:solr)
33
- else
34
- # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/ldpd\:Resource', @search_params)
35
- @solr_result = Resource.find_by_solr(:all)
36
- end
37
- render :action=>params[:action], :layout=>layout
38
- end
39
-
40
- def new
41
- render :partial=>"new", :layout=>false
42
- end
43
-
44
- # Creates and Saves a File Asset to contain the the Uploaded file
45
- # If container_id is provided:
46
- # * the File Asset will use RELS-EXT to assert that it's a part of the specified container
47
- # * the method will redirect to the container object's edit view after saving
48
- def create
49
- if params.has_key?(:Filedata) or params.has_key?(:Fileurl)
50
- flash[:notice] = process_files # "The file #{params[:Filename]} has been saved in <a href=\"#{asset_url(@resource.pid)}\">#{@resource.pid}</a>."
51
- else
52
- flash[:notice] = "You must specify a file to upload."
53
- end
54
-
55
- if !params[:container_id].nil?
56
- redirect_params = {:controller=>"catalog", :id=>params[:container_id], :action=>:edit}
57
- end
58
-
59
- redirect_params ||= {:action=>:index}
60
-
61
- redirect_to redirect_params
62
- end
63
-
64
- def update
65
- if params.has_key?(:Filedata) or params.has_key?(:Fileurl)
66
- flash[:notice] = update_file # "The file #{params[:Filename]} has been saved in <a href=\"#{asset_url(@resource.pid)}\">#{@resource.pid}</a>."
67
- else
68
- flash[:notice] = "You must specify a file to upload."
69
- end
70
- if !params[:id].nil?
71
- redirect_params = {:controller=>"catalog", :id=>params[:id], :action=>:edit}
2
+ module Resources
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Cul::Hydra::Controllers::Resources
72
6
  end
73
-
74
- redirect_params ||= {:action=>:index}
75
-
76
- redirect_to redirect_params
77
7
  end
78
-
79
- def process_files
80
- @resources = create_and_save_resources_from_params
81
- notice = []
82
- @resources.each do |resource|
83
- apply_depositor_metadata(resource)
84
- notice << "The file #{resource.label} has been saved in <a href=\"#{asset_url(resource.pid)}\">#{resource.pid}</a>."
85
- if !params[:container_id].nil?
86
- associate_resource_with_container(resource,params[:container_id])
87
- end
88
- ## Apply any posted file metadata
89
- unless params[:asset].nil?
90
- logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}")
91
- apply_posted_file_metadata(resource)
92
- end
93
- resource.save
94
- logger.debug("Created #{resource.pid}.")
95
- end
96
- end
97
-
98
- def update_file
99
- update_resource_from_params
100
- apply_depositor_metadata(@document_fedora)
101
- notice << "The file #{@document_fedora.label} has been saved in <a href=\"#{asset_url(@document_fedora.pid)}\">#{@document_fedora.pid}</a>."
102
- unless params[:asset].nil?
103
- logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}")
104
- apply_posted_file_metadata(@document_fedora)
105
- end
106
- @document_fedora.save
107
- logger.debug("Created #{@document_fedora.pid}.")
108
- end
109
- # Common destroy method for all AssetsControllers
110
- def destroy
111
- # The correct implementation, with garbage collection:
112
- # if params.has_key?(:container_id)
113
- # container = ActiveFedora::Base.load_instance(params[:container_id])
114
- # container.file_objects_remove(params[:id])
115
- # FileAsset.garbage_collect(params[:id])
116
- # else
117
-
118
- # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)
119
- ActiveFedora::Base.load_instance(params[:id]).delete
120
- flash[:notice] = "Deleted #{params[:id]}."
121
- if !params[:container_id].nil?
122
- redirect_params = {:controller=>"catalog", :id=>params[:container_id], :action=>:edit}
123
- end
124
-
125
- redirect_params ||= {:action=>:index}
126
-
127
- redirect_to redirect_params
128
- end
129
-
130
-
131
- def show
132
- @file_asset = Resource.find(params[:id])
133
- if (@file_asset.nil?)
134
- logger.warn("No such resource: " + params[:id])
135
- flash[:notice]= "No such resource."
136
- redirect_to(:action => 'index', :q => nil , :f => nil)
137
- else
138
- # get array of parent (container) objects for this FileAsset
139
- @id_array = @file_asset.containers(:response_format => :id_array)
140
- @downloadable = false
141
- # A FileAsset is downloadable iff the user has read or higher access to a parent
142
- @id_array.each do |pid|
143
- @response, @document = get_solr_response_for_doc_id(pid)
144
- if reader?
145
- @downloadable = true
146
- break
147
- end
148
- end
149
-
150
- if @downloadable
151
- if @file_asset.datastreams_in_memory.include?("CONTENT")
152
- send_datastream @file_asset.datastreams_in_memory["CONTENT"]
153
- end
154
- else
155
- flash[:notice]= "You do not have sufficient access privileges to download this document, which has been marked private."
156
- redirect_to(:action => 'index', :q => nil , :f => nil)
157
- end
158
- end
159
- end
160
- end
161
8
  end