Class: Wings::Works::AddFileToFileSet
- Inherits:
-
Object
- Object
- Wings::Works::AddFileToFileSet
- Defined in:
- lib/wings/hydra/works/services/add_file_to_file_set.rb
Class Method Summary collapse
-
.call(file_set:, file:, type:, update_existing: true, versioning: true) ⇒ Object
Adds a file to the file_set.
Class Method Details
.call(file_set:, file:, type:, update_existing: true, versioning: true) ⇒ Object
Adds a file to the file_set
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wings/hydra/works/services/add_file_to_file_set.rb', line 14 def call(file_set:, file:, type:, update_existing: true, versioning: true) raise ArgumentError, 'supplied object must be an instance of Valkyrie::Resource' unless file_set.is_a?(Valkyrie::Resource) && file_set.file_set? raise ArgumentError, 'supplied file must respond to read' unless file.respond_to? :read af_type = normalize_type(type) raise ArgumentError, "supplied type (#{type}) is not supported" if af_type.blank? af_file_set = Wings::ActiveFedoraConverter.new(resource: file_set).convert result = Hydra::Works::AddFileToFileSet.call(af_file_set, file, af_type, update_existing: update_existing, versioning: versioning) # TODO: model_transformer/file_converter_service should create FileMetadata and set ids and attributes result ? af_file_set.valkyrie_resource : false end |