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.
- checksums.yaml +4 -4
- data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
- data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
- data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
- data/app/controllers/concerns/cul/scv/hydra/controller.rb +3 -19
- data/app/controllers/concerns/cul/scv/hydra/resolver.rb +2 -65
- data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +3 -59
- data/app/models/concept.rb +1 -1
- data/app/models/concerns/cul/hydra/models.rb +24 -0
- data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
- data/app/models/concerns/cul/hydra/models/common.rb +220 -0
- data/app/models/concerns/cul/hydra/models/image_resource.rb +78 -0
- data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
- data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
- data/app/models/concerns/cul/scv/hydra/models.rb +1 -13
- data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +1 -116
- data/app/models/concerns/cul/scv/hydra/models/common.rb +1 -213
- data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +3 -75
- data/app/models/concerns/cul/scv/hydra/models/linkable_resources.rb +3 -105
- data/app/models/concerns/cul/scv/hydra/models/resource.rb +2 -83
- data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
- data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
- data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
- data/app/models/cul/scv/hydra/datastreams/dc_metadata.rb +5 -104
- data/app/models/cul/scv/hydra/datastreams/mods_document.rb +5 -178
- data/app/models/cul/scv/hydra/datastreams/struct_metadata.rb +5 -174
- data/app/models/dc_document.rb +1 -1
- data/app/models/generic_aggregator.rb +5 -5
- data/app/models/generic_object.rb +2 -2
- data/app/models/generic_resource.rb +4 -4
- data/app/models/mets_structured_aggregator.rb +2 -2
- data/app/models/resource.rb +3 -3
- data/app/models/resource_aggregator.rb +3 -3
- data/fixtures/spec/CUL_MODS/mods-subjects.xml +24 -0
- data/lib/cul_hydra.rb +18 -0
- data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
- data/lib/cul_hydra/controllers.rb +13 -0
- data/lib/cul_hydra/controllers/aggregates.rb +93 -0
- data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
- data/lib/cul_hydra/controllers/catalog.rb +12 -0
- data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
- data/lib/cul_hydra/controllers/datastreams.rb +145 -0
- data/lib/cul_hydra/controllers/helpers.rb +10 -0
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/active_fedora_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/application_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/dc_metadata_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_assets_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_autocomplete_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_uploader_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/resources_helper_behavior.rb +1 -1
- data/lib/cul_hydra/controllers/resources.rb +161 -0
- data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
- data/lib/cul_hydra/controllers/suggestions.rb +126 -0
- data/lib/cul_hydra/controllers/terms.rb +205 -0
- data/lib/cul_hydra/engine.rb +31 -0
- data/lib/cul_hydra/fedora.rb +41 -0
- data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
- data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
- data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
- data/lib/cul_hydra/indexer.rb +84 -0
- data/lib/cul_hydra/om.rb +7 -0
- data/lib/cul_hydra/om/standard_mods.rb +115 -0
- data/lib/cul_hydra/risearch_members.rb +92 -0
- data/lib/cul_hydra/solrizer.rb +10 -0
- data/lib/cul_hydra/solrizer/extractor.rb +27 -0
- data/lib/cul_hydra/solrizer/mods_fieldable.rb +435 -0
- data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
- data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
- data/lib/{cul_scv_hydra/solrizer/field_mapper.rb → cul_hydra/solrizer_patch.rb} +0 -0
- data/lib/cul_hydra/version.rb +8 -0
- data/lib/cul_hydra/version.rb~ +8 -0
- data/lib/cul_scv_fedora/dummy_object.rb +1 -30
- data/lib/cul_scv_fedora/rubydora_patch.rb +3 -7
- data/lib/cul_scv_fedora/url_helper_behavior.rb +3 -23
- data/lib/cul_scv_hydra.rb +5 -32
- data/lib/cul_scv_hydra/access_controls_enforcement.rb +3 -50
- data/lib/cul_scv_hydra/controllers.rb +10 -10
- data/lib/cul_scv_hydra/controllers/aggregates.rb +1 -86
- data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +4 -23
- data/lib/cul_scv_hydra/controllers/catalog.rb +5 -9
- data/lib/cul_scv_hydra/controllers/content_aggregators.rb +4 -77
- data/lib/cul_scv_hydra/controllers/datastreams.rb +3 -140
- data/lib/cul_scv_hydra/controllers/helpers.rb +44 -8
- data/lib/cul_scv_hydra/controllers/resources.rb +4 -157
- data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +4 -100
- data/lib/cul_scv_hydra/controllers/suggestions.rb +4 -122
- data/lib/cul_scv_hydra/controllers/terms.rb +4 -201
- data/lib/cul_scv_hydra/engine.rb +1 -1
- data/lib/cul_scv_hydra/indexer.rb +3 -82
- data/lib/cul_scv_hydra/om.rb +2 -2
- data/lib/cul_scv_hydra/om/standard_mods.rb +1 -108
- data/lib/cul_scv_hydra/risearch_members.rb +4 -89
- data/lib/cul_scv_hydra/solrizer.rb +5 -6
- data/lib/cul_scv_hydra/solrizer/extractor.rb +1 -25
- data/lib/cul_scv_hydra/solrizer/scv_mods_fieldable.rb +4 -429
- data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +4 -32
- data/lib/cul_scv_hydra/solrizer/value_mapper.rb +1 -44
- data/lib/cul_scv_hydra/version.rb +5 -5
- data/lib/tasks/index.rake +2 -2
- data/lib/tasks/transform.rake +23 -0
- metadata +55 -12
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'cul_hydra/controllers/helpers/application_helper_behavior'
|
2
|
+
module Cul::Hydra::Controllers
|
3
|
+
module Datastreams
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
include Cul::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"
|
33
|
+
end
|
34
|
+
render :action=>params[:action], :layout=>layout
|
35
|
+
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
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Cul::Hydra::Controllers::Helpers
|
2
|
+
autoload :Aggregates, 'cul_hydra/controllers/helpers/aggregates'
|
3
|
+
autoload :ActiveFedoraHelperBehavior, 'cul_hydra/controllers/helpers/active_fedora_helper_behavior'
|
4
|
+
autoload :ApplicationHelperBehavior, 'cul_hydra/controllers/helpers/application_helper_behavior'
|
5
|
+
autoload :DcMetadataHelperBehavior, 'cul_hydra/controllers/helpers/dc_metadata_helper_behavior'
|
6
|
+
autoload :HydraAssetsHelperBehavior, 'cul_hydra/controllers/helpers/hydra_assets_helper_behavior'
|
7
|
+
autoload :HydraAutocompleteHelperBehavior, 'cul_hydra/controllers/helpers/hydra_autocomplete_helper_behavior'
|
8
|
+
autoload :HydraUploaderHelperBehavior, 'cul_hydra/controllers/helpers/hydra_uploader_helper_behavior'
|
9
|
+
autoload :ResourcesHelperBehavior, 'cul_hydra/controllers/helpers/resources_helper_behavior'
|
10
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Methods added to this helper will be available to all templates in the application.
|
2
|
-
module Cul::
|
2
|
+
module Cul::Hydra::Controllers::Helpers
|
3
3
|
module ApplicationHelperBehavior
|
4
4
|
def load_dc_document_from_solr(doc)
|
5
5
|
pid = doc[:id] ? doc[:id] : doc[:id.to_s]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#require 'mediashelf/active_fedora_helper'
|
2
2
|
|
3
|
-
module Cul::
|
3
|
+
module Cul::Hydra::Controllers::Helpers::HydraAssetsHelperBehavior
|
4
4
|
# include MediaShelf::ActiveFedoraHelper
|
5
5
|
|
6
6
|
def link_to_create_asset(link_label, content_type, container_id=nil)
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module Cul::Hydra::Controllers
|
2
|
+
module Resources
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
include Hydra::AssetsControllerHelper
|
7
|
+
include Cul::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}
|
72
|
+
end
|
73
|
+
|
74
|
+
redirect_params ||= {:action=>:index}
|
75
|
+
|
76
|
+
redirect_to redirect_params
|
77
|
+
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
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'cul_hydra/controllers/helpers/resources_helper_behavior'
|
2
|
+
module Cul::Hydra::Controllers
|
3
|
+
module StaticImageAggregators
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
include Hydra::AssetsControllerHelper
|
8
|
+
include Cul::Hydra::Controllers::Helpers::ResourcesHelperBehavior
|
9
|
+
include Hydra::RepositoryController
|
10
|
+
include MediaShelf::ActiveFedoraHelper
|
11
|
+
include Blacklight::SolrHelper
|
12
|
+
before_filter :require_fedora
|
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
|
+
@asset = StaticImageAggregator.new
|
42
|
+
apply_depositor_metadata(@asset)
|
43
|
+
set_collection_type(@asset, params[:content_type])
|
44
|
+
if !params[:container_id].nil?
|
45
|
+
associate_resource_with_container(@asset, params[:container_id])
|
46
|
+
end
|
47
|
+
@asset.save
|
48
|
+
@asset.refresh
|
49
|
+
msg = "Created a Static Image Aggregator with pid #{@asset.pid}. Now it's ready to be edited."
|
50
|
+
flash[:notice]= msg
|
51
|
+
|
52
|
+
if params.has_key?(:Filedata)
|
53
|
+
@file_asset = create_and_save_resource_from_params
|
54
|
+
apply_depositor_metadata(@file_asset)
|
55
|
+
|
56
|
+
flash[:notice] += " The file #{params[:Filename]} has been saved in <a href=\"#{asset_url(@file_asset.pid)}\">#{@file_asset.pid}</a>."
|
57
|
+
|
58
|
+
if !params[:container_id].nil?
|
59
|
+
associate_resource_with_container(@file_asset, @asset.pid)
|
60
|
+
end
|
61
|
+
|
62
|
+
## Apply any posted file metadata
|
63
|
+
unless params[:asset].nil?
|
64
|
+
logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}")
|
65
|
+
@metadata_update_response = update_document(@file_asset, @sanitized_params)
|
66
|
+
end
|
67
|
+
@file_asset.save
|
68
|
+
# If redirect_params has not been set, use {:action=>:index}
|
69
|
+
logger.debug "Created #{@file_asset.pid}."
|
70
|
+
end
|
71
|
+
@asset.save
|
72
|
+
|
73
|
+
session[:scripts] = params[:combined] == "true"
|
74
|
+
redirect_to url_for(:action=>"edit", :id=>@asset.pid, :new_asset=>true, :controller=>'catalog')
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# Common destroy method for all AssetsControllers
|
79
|
+
def destroy
|
80
|
+
# The correct implementation, with garbage collection:
|
81
|
+
# if params.has_key?(:container_id)
|
82
|
+
# container = ActiveFedora::Base.load_instance(params[:container_id])
|
83
|
+
# container.file_objects_remove(params[:id])
|
84
|
+
# FileAsset.garbage_collect(params[:id])
|
85
|
+
# else
|
86
|
+
|
87
|
+
# The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)
|
88
|
+
ActiveFedora::Base.load_instance(params[:id]).delete
|
89
|
+
render :text => "Deleted #{params[:id]} from #{params[:container_id]}."
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def show
|
94
|
+
@image_agg = StaticImageAggregator.find(params[:id])
|
95
|
+
if (@image_agg.nil?)
|
96
|
+
logger.warn("No such object: " + params[:id])
|
97
|
+
flash[:notice]= "No such object."
|
98
|
+
redirect_to(:action => 'index', :q => nil , :f => nil)
|
99
|
+
else
|
100
|
+
@id_array = @image_agg.containers(:response_format => :id_array)
|
101
|
+
end
|
102
|
+
render :action=>params[:action], :layout=>(params[:layout]=="false")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|