From 64e8745279daa180e893a46737397383c7bf1c87 Mon Sep 17 00:00:00 2001 From: Fritz Freiheit Date: Wed, 20 Dec 2023 10:56:14 -0500 Subject: [PATCH] DEEPBLUE-285 - Send works to APTrust - 10 --- app/jobs/aptrust_upload_job.rb | 3 ++- app/services/aptrust/aptrust_uploader.rb | 26 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/jobs/aptrust_upload_job.rb b/app/jobs/aptrust_upload_job.rb index 1dd82573..a5bfcdeb 100644 --- a/app/jobs/aptrust_upload_job.rb +++ b/app/jobs/aptrust_upload_job.rb @@ -33,7 +33,7 @@ class AptrustUploadJob < AbstractRakeTaskJob #filter_min_total_size: 1 #filter_max_total_size: 1000000 # 1 million bytes #filter_max_total_size: 1000000000 # 1 billion bytes - filter_ignore_status: false + #filter_ignore_status: true # i.e. reupload xfilter_skip_statuses: # see: ::Aptrust::FilterStatus::SKIP_STATUSES - uploaded - verified @@ -74,6 +74,7 @@ def perform( *args ) "" ] if aptrust_upload_job_debug_verbose ::Deepblue::SchedulerHelper.log( class_name: self.class.name ) return unless initialized + return job_finished unless by_request_only? && from_dashboard.present? debug_verbose = job_options_value( key: 'debug_verbose', default_value: debug_verbose ) filter_debug_verbose = job_options_value( key: 'filter_debug_verbose', default_value: false ) msg_handler.debug_verbose = debug_verbose diff --git a/app/services/aptrust/aptrust_uploader.rb b/app/services/aptrust/aptrust_uploader.rb index 7c8f38c5..f4afd4f1 100644 --- a/app/services/aptrust/aptrust_uploader.rb +++ b/app/services/aptrust/aptrust_uploader.rb @@ -25,9 +25,10 @@ class AptrustUploader IDENTIFIER_TEMPLATE = '%repository%.%context%%type%%id%' unless const_defined? :IDENTIFIER_TEMPLATE def self.bag_date_now() - rv = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ") - rv = Time.parse(rv).iso8601 - return rv + return Time.now + # rv = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ") + # rv = Time.parse(rv).iso8601 + # return rv end attr_accessor :additional_tag_files @@ -166,7 +167,9 @@ def initialize( object_id:, @bag = bag @bag_info = bag_info - @bi_date = Aptrust.arg_init_squish( bi_date, AptrustUploader.bag_date_now ) + # @bi_date = Aptrust.arg_init_squish( bi_date, AptrustUploader.bag_date_now ) + @bi_date = bi_date + @bi_date ||= AptrustUploader.bag_date_now @bi_description = Aptrust.arg_init_squish( bi_description, DEFAULT_BI_DESCRIPTION ) @bi_id = Aptrust.arg_init_squish( bi_id, @object_id ) @bi_source = Aptrust.arg_init_squish( bi_source, DEFAULT_BI_SOURCE ) @@ -228,6 +231,18 @@ def bag_data_dir @bag_data_dir ||= File.join( bag.bag_dir, "data" ) end + def bag_date_str( t ) + rv = t.utc.strftime("%Y-%m-%d") + rv = Time.parse(rv).iso8601 + return rv + end + + def bag_date_time_str( t ) + rv = t.utc.strftime("%Y-%m-%dT%H:%M:%SZ") + rv = Time.parse(rv).iso8601 + return rv + end + def bag_id_context @bag_id_context = bag_id_context_init if @bag_id_context.blank? @bag_id_context @@ -278,7 +293,8 @@ def bag_info_init rv = { 'Source-Organization' => bi_source, 'Bag-Count' => '1', - 'Bagging-Date' => bi_date, + 'Bagging-Date' => bag_date_str( bi_date ), + 'Bagging-Timestamp' => bag_date_time_str( bi_date ), 'Internal-Sender-Description' => bi_description, 'Internal-Sender-Identifier' => bi_id }