cul_hydra 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/cul/hydra/application_id_behavior.rb +5 -6
- data/app/models/administrative_set.rb +0 -1
- data/app/models/concept.rb +0 -1
- data/app/models/concerns/cul/hydra/models.rb +1 -0
- data/app/models/concerns/cul/hydra/models/common.rb +8 -9
- data/app/models/concerns/cul/hydra/models/rels_int.rb +18 -0
- data/app/models/concerns/ore/proxy.rb +2 -3
- data/app/models/cul/hydra/datastreams/rels_int.rb +179 -0
- data/app/models/dc_document.rb +0 -1
- data/app/models/generic_aggregator.rb +0 -1
- data/app/models/generic_object.rb +0 -1
- data/app/models/generic_resource.rb +1 -3
- data/fixtures/spec/CUL_RELS_INT/rels_int_blank.xml +2 -0
- data/fixtures/spec/CUL_RELS_INT/rels_int_profile.xml +19 -0
- data/fixtures/spec/CUL_RELS_INT/rels_int_test.xml +12 -0
- data/fixtures/spec/FOXML/resource-thumb.xml +2 -1
- data/lib/cul_hydra.rb +1 -4
- data/lib/cul_hydra/rels_int.rb +9 -0
- data/lib/cul_hydra/rels_int/rdf_xml_writer.rb +33 -0
- data/lib/cul_hydra/version.rb +1 -1
- data/lib/tasks/cul_hydra_dev.rake +0 -28
- metadata +32 -58
- data/app/models/jp2_image_aggregator.rb +0 -34
- data/app/models/mets_structured_aggregator.rb +0 -18
- data/app/models/resource.rb +0 -78
- data/app/models/resource_aggregator.rb +0 -22
- data/app/models/static_audio_aggregator.rb +0 -12
- data/app/models/static_image_aggregator.rb +0 -32
- data/lib/cul_hydra/controllers.rb +0 -14
- data/lib/cul_hydra/controllers/aggregates.rb +0 -93
- data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +0 -27
- data/lib/cul_hydra/controllers/catalog.rb +0 -12
- data/lib/cul_hydra/controllers/collections.rb +0 -81
- data/lib/cul_hydra/controllers/content_aggregators.rb +0 -81
- data/lib/cul_hydra/controllers/datastreams.rb +0 -145
- data/lib/cul_hydra/controllers/helpers.rb +0 -10
- data/lib/cul_hydra/controllers/helpers/active_fedora_helper_behavior.rb +0 -9
- data/lib/cul_hydra/controllers/helpers/application_helper_behavior.rb +0 -16
- data/lib/cul_hydra/controllers/helpers/dc_metadata_helper_behavior.rb +0 -9
- data/lib/cul_hydra/controllers/helpers/hydra_assets_helper_behavior.rb +0 -46
- data/lib/cul_hydra/controllers/helpers/hydra_autocomplete_helper_behavior.rb +0 -35
- data/lib/cul_hydra/controllers/helpers/hydra_uploader_helper_behavior.rb +0 -34
- data/lib/cul_hydra/controllers/helpers/resources_helper_behavior.rb +0 -159
- data/lib/cul_hydra/controllers/resources.rb +0 -161
- data/lib/cul_hydra/controllers/static_image_aggregators.rb +0 -105
- data/lib/cul_hydra/controllers/suggestions.rb +0 -126
- data/lib/cul_hydra/controllers/terms.rb +0 -205
@@ -1,22 +0,0 @@
|
|
1
|
-
class ResourceAggregator < ::ActiveFedora::Base
|
2
|
-
include ::ActiveFedora::FinderMethods::RepositoryMethods
|
3
|
-
include ::ActiveFedora::DatastreamCollections
|
4
|
-
include ::Hydra::ModelMethods
|
5
|
-
include Cul::Hydra::Models::Common
|
6
|
-
include Cul::Hydra::Models::Aggregator
|
7
|
-
include Cul::Hydra::Models::LinkableResources
|
8
|
-
|
9
|
-
has_many :parts, :property => :cul_member_of, :class_name=>'Resource'
|
10
|
-
|
11
|
-
def route_as
|
12
|
-
"resource"
|
13
|
-
end
|
14
|
-
|
15
|
-
def index_type_label
|
16
|
-
"PART"
|
17
|
-
end
|
18
|
-
|
19
|
-
def thumbnail_info
|
20
|
-
return {:url=>image_url("cul_hydra/crystal/file.png"),:mime=>'image/png'}
|
21
|
-
end
|
22
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "active-fedora"
|
2
|
-
require "active_fedora_finders"
|
3
|
-
class StaticImageAggregator < ResourceAggregator
|
4
|
-
|
5
|
-
CUL_WIDTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageWidth"
|
6
|
-
CUL_LENGTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageLength"
|
7
|
-
|
8
|
-
def route_as
|
9
|
-
"image"
|
10
|
-
end
|
11
|
-
|
12
|
-
def index_type_label
|
13
|
-
'PART'
|
14
|
-
end
|
15
|
-
|
16
|
-
def thumbnail_info
|
17
|
-
candidate = nil
|
18
|
-
max_dim = 251
|
19
|
-
resources.each do |pid|
|
20
|
-
resource = Resource.find(pid)
|
21
|
-
if max_dim > resouce.long
|
22
|
-
candidate = resource
|
23
|
-
max_dim = resource.long
|
24
|
-
end
|
25
|
-
end
|
26
|
-
if candidate.nil?
|
27
|
-
return {:url=>image_url("cul_hydra/crystal/file_broken.png"),:mime=>'image/png'}
|
28
|
-
else
|
29
|
-
return {:url=>"#{ActiveFedora.fedora_config[:url]}/objects/#{candidate.pid}/datastreams/CONTENT/content",:mime=>candidate.datastreams['CONENT'].mimeType}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Cul::Hydra
|
2
|
-
module Controllers
|
3
|
-
autoload :Aggregates, 'cul_hydra/controllers/aggregates'
|
4
|
-
autoload :Catalog, 'cul_hydra/controllers/catalog'
|
5
|
-
autoload :Collections, 'cul_hydra/controllers/collections'
|
6
|
-
autoload :ContentAggregators, 'cul_hydra/controllers/content_aggregators'
|
7
|
-
autoload :Datastreams, 'cul_hydra/controllers/datastreams'
|
8
|
-
autoload :Helpers, 'cul_hydra/controllers/helpers'
|
9
|
-
autoload :Resources, 'cul_hydra/controllers/resources'
|
10
|
-
autoload :StaticImageAggregators, 'cul_hydra/controllers/static_image_aggregators'
|
11
|
-
autoload :Suggestions, 'cul_hydra/controllers/suggestions'
|
12
|
-
autoload :Terms, 'cul_hydra/controllers/terms'
|
13
|
-
end
|
14
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'cul_hydra/controllers/aggregator_controller_helper'
|
2
|
-
require 'cul_hydra/controllers/helpers/resources_helper_behavior'
|
3
|
-
module Cul::Hydra::Controllers
|
4
|
-
module Aggregates
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
include Hydra::AssetsControllerHelper
|
8
|
-
include Cul::Hydra::Controllers::AggregatorControllerHelper
|
9
|
-
include Cul::Hydra::Controllers::Helpers::ResourcesHelperBehavior
|
10
|
-
include Hydra::RepositoryController
|
11
|
-
include MediaShelf::ActiveFedoraHelper
|
12
|
-
include Blacklight::SolrHelper
|
13
|
-
before_filter :load_resources, :only=>[:index]
|
14
|
-
prepend_before_filter :sanitize_update_params
|
15
|
-
end
|
16
|
-
|
17
|
-
def index
|
18
|
-
|
19
|
-
if params[:layout] == "false"
|
20
|
-
layout = false
|
21
|
-
end
|
22
|
-
container_uri = "info:fedora/#{params[:asset_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[:asset_id])
|
29
|
-
|
30
|
-
render :action=>params[:action], :layout=>layout
|
31
|
-
end
|
32
|
-
|
33
|
-
def load_aggregate
|
34
|
-
if params.has_key? :aggregate_id
|
35
|
-
af_base = ActiveFedora::Base.load_instance(params[:aggregate_id])
|
36
|
-
else
|
37
|
-
af_base = ActiveFedora::Base.load_instance(params[:id])
|
38
|
-
end
|
39
|
-
the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
|
40
|
-
if the_model.nil? or the_model == ActiveFedora::Base
|
41
|
-
the_model = DcDocument
|
42
|
-
end
|
43
|
-
|
44
|
-
@resource = the_model.load_instance(af_base.pid)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Creates and Saves a Parent - Child relationship in the Child's RELS-EXT
|
48
|
-
# If container_id is provided:
|
49
|
-
# * the File Asset will use RELS-EXT to assert that it's a part of the specified container
|
50
|
-
# * the method will redirect to the container object's edit view after saving
|
51
|
-
def create
|
52
|
-
if params.has_key?(:aggregate_id)
|
53
|
-
@resource = load_aggregate
|
54
|
-
logger.debug @resource.class
|
55
|
-
logger.debug @resource.datastreams["RELS-EXT"].content
|
56
|
-
logger.debug @resource.to_rels_ext(@resource.pid)
|
57
|
-
if !params[:asset_id].nil?
|
58
|
-
associate_resource_with_container(@resource, params[:asset_id])
|
59
|
-
@resource.save
|
60
|
-
flash[:notice] = "Aggregated #{@resource.pid} under #{params[:asset_id]}."
|
61
|
-
else
|
62
|
-
flash[:notice] = "You must specify a container for the aggregate."
|
63
|
-
end
|
64
|
-
else
|
65
|
-
flash[:notice] = "You must specify a resource to aggregate."
|
66
|
-
end
|
67
|
-
|
68
|
-
if !params[:asset_id].nil?
|
69
|
-
redirect_params = {:controller=>"aggregates", :id=>params[:asset_id], :action=>:index}
|
70
|
-
end
|
71
|
-
|
72
|
-
redirect_params ||= {:action=>:index}
|
73
|
-
|
74
|
-
redirect_to redirect_params
|
75
|
-
end
|
76
|
-
|
77
|
-
# Common destroy method for all AssetsControllers
|
78
|
-
def destroy
|
79
|
-
@resource = load_aggregate
|
80
|
-
remove_resource_from_container(@resource, params[:asset_id])
|
81
|
-
@resource.save
|
82
|
-
|
83
|
-
flash[:notice] = "Deleted #{params[:id]} from #{params[:asset_id]}."
|
84
|
-
if !params[:asset_id].nil?
|
85
|
-
redirect_params = {:controller=>"aggregates", :id=>params[:asset_id], :action=>:index}
|
86
|
-
end
|
87
|
-
|
88
|
-
redirect_params ||= {:action=>:index}
|
89
|
-
|
90
|
-
redirect_to redirect_params
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'active-fedora'
|
2
|
-
module Cul::Hydra::Controllers
|
3
|
-
module AggregatorControllerHelper
|
4
|
-
def load_fedora_document
|
5
|
-
if params.has_key? :asset_id
|
6
|
-
af_base = ActiveFedora::Base.load_instance(params[:asset_id])
|
7
|
-
else
|
8
|
-
af_base = ActiveFedora::Base.load_instance(params[:id])
|
9
|
-
end
|
10
|
-
the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
|
11
|
-
if the_model.nil? or the_model == ActiveFedora::Base
|
12
|
-
the_model = DcDocument
|
13
|
-
end
|
14
|
-
|
15
|
-
@document_fedora = af_base.adapt_to the_model
|
16
|
-
end
|
17
|
-
def load_resources
|
18
|
-
@document_fedora ||= load_fedora_document
|
19
|
-
if @document_fedora.is_a? Cul::Hydra::ActiveFedora::Model::Aggregator
|
20
|
-
@resources = @document_fedora.resources
|
21
|
-
else
|
22
|
-
logger.debug "Only aggregators have parts!"
|
23
|
-
end
|
24
|
-
@resources
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'cul_hydra/controllers/aggregator_controller_helper'
|
2
|
-
require 'cul_hydra/controllers/helpers/active_fedora_helper_behavior'
|
3
|
-
module Cul::Hydra::Controllers
|
4
|
-
module Catalog
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
include Cul::Hydra::Controllers::AggregatorControllerHelper
|
8
|
-
include Cul::Hydra::Controllers::Helpers::ActiveFedoraHelperBehavior
|
9
|
-
before_filter :load_resources, :only=>[:show, :edit]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'cul_hydra/controllers/helpers/resources_helper_behavior'
|
2
|
-
module Cul::Hydra::Controllers
|
3
|
-
module Collections
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
included do
|
6
|
-
include Hydra::AssetsControllerHelper
|
7
|
-
include Cul::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 = Collection.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])
|
44
|
-
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
|
-
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 = Collection.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
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'cul_hydra/controllers/helpers/resources_helper_behavior'
|
2
|
-
module Cul::Hydra::Controllers
|
3
|
-
module ContentAggregators
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
included do
|
6
|
-
include Hydra::AssetsControllerHelper
|
7
|
-
include Cul::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])
|
44
|
-
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
|
-
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
|
-
end
|
@@ -1,145 +0,0 @@
|
|
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
|