Skip to content

Commit

Permalink
WIP: Publish error handling improvement; DC Type detection improvemen…
Browse files Browse the repository at this point in the history
…t; Asset location display updates
  • Loading branch information
elohanlon committed Dec 5, 2024
1 parent 77781bf commit 43f01f8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
</div>
<div class="form-group">
<label class="col-sm-3">
Filesystem Location:
Location:
</label>
<div class="col-sm-9">
<%= digitalObject.getFilesystemLocation() %>
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/digital_object/assets/file_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def do_file_import
puts "final_save_location_uri is: #{final_save_location_uri}"
content_ds = @fedora_object.create_datastream(ActiveFedora::Datastream, 'content', controlGroup: 'E', mimeType: BestType.mime_type.for_file_name(original_filename), dsLabel: original_filename, versionable: true)
content_ds.dsLocation = Hyacinth::Utils::PathUtils.location_uri_to_encoded_ds_location(final_save_location_uri)
@fedora_object.datastreams["DC"].dc_source = path_to_final_save_location
@fedora_object.datastreams["DC"].dc_source = final_save_location_uri
@fedora_object.add_datastream(content_ds)

# Add checksum property to content datastream using :has_message_digest predicate
Expand Down
6 changes: 5 additions & 1 deletion app/models/concerns/digital_object/publishing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def execute_publish_action_for_target(publish_action, publish_target, do_ezid_up
rescue Errno::ECONNREFUSED
@errors.add(:publish_target, "Connection to server refused for Publish Target URL: #{publish_target.publish_target_field('publish_url')}")
rescue RestClient::ExceptionWithResponse => e
@errors.add(:publish_target, "#{response&.code || 'Undefined'} response received for Publish Target URL: #{publish_target.publish_target_field('publish_url')}")
@errors.add(
:publish_target,
"#{response&.code || 'Undefined'} response received for Publish Target URL: #{publish_target.publish_target_field('publish_url')}\n"\
"Error message: #{e.message}"
)
end
success
end
Expand Down
18 changes: 16 additions & 2 deletions app/models/digital_object/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,21 @@ def run_post_validation_pre_save_logic
do_poster_import if @poster_import_path.present?
do_service_copy_import if @service_copy_import_path.present? && self.service_copy_location.blank?

self.dc_type = BestType.dc_type.for_file_name(original_filename) if self.dc_type == 'Unknown' # Attempt to correct dc_type for 'Unknown' dc_type DigitalObjects
# Attempt to correct dc_type for 'Unknown' dc_type DigitalObjects, based on original filename
self.dc_type = BestType.dc_type.for_file_name(original_filename) if self.dc_type == 'Unknown'

# For ISO files, even the original filename can't tell us if they're possibly audio or video content,
# so if a service copy has been uploaded with the video then we'll determine dc type based on
# the extension of the service copy.
if self.dc_type == 'Unknown' && self.service_copy_location.present?
self.dc_type = BestType.dc_type.for_file_name(self.service_copy_location)
end

# If we still haven't been able to determine a dc type, see if we can get the
# information from an access copy file extension (if present)
if self.dc_type == 'Unknown' && self.access_copy_location.present?
self.dc_type = BestType.dc_type.for_file_name(self.access_copy_location)
end
end

def run_after_create_logic
Expand Down Expand Up @@ -96,7 +110,7 @@ def convert_upload_import_to_internal!
def filesystem_location
content_ds = @fedora_object.datastreams['content']
return nil unless content_ds.present?
Addressable::URI.unencode(content_ds.dsLocation).gsub(/^file:/, '')
Hyacinth::Utils::PathUtils.ds_location_to_decoded_location_uri(content_ds.dsLocation)
end

def access_copy_location
Expand Down
2 changes: 1 addition & 1 deletion lib/hyacinth/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def self.generate_location_uri_for(pid, project, local_file_path)
"#{scheme}://" +
Hyacinth::Utils::PathUtils.path_to_asset_file(pid, project, File.basename(local_file_path))
when S3_SCHEME
"#{scheme}://#{HYACINTH['default_asset_home_bucket_name']}/" +
"#{scheme}://#{HYACINTH['default_asset_home_bucket_name']}/"\
"#{HYACINTH['default_asset_home_bucket_path_prefix']}/" +
Hyacinth::Utils::PathUtils.path_to_asset_file(pid, project, File.basename(local_file_path))
else
Expand Down
1 change: 0 additions & 1 deletion lib/hyacinth/storage/file_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def filename
end

def size
raise "Path is: #{path}"
File.size(self.path)
end

Expand Down

0 comments on commit 43f01f8

Please sign in to comment.