Class: WorkEmbargoReleaseService
- Inherits:
-
Object
- Object
- WorkEmbargoReleaseService
- Defined in:
- app/services/work_embargo_release_service.rb
Overview
A service to move work data from the post-curation bucket to the embargo bucket for currently embargoed works
Instance Attribute Summary collapse
-
#pul_s3_client ⇒ Object
readonly
Returns the value of attribute pul_s3_client.
-
#source_bucket ⇒ Object
readonly
Returns the value of attribute source_bucket.
-
#target_bucket ⇒ Object
readonly
Returns the value of attribute target_bucket.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Instance Method Summary collapse
-
#initialize(work:) ⇒ WorkEmbargoReleaseService
constructor
A new instance of WorkEmbargoReleaseService.
-
#move ⇒ Object
move the files.
Constructor Details
#initialize(work:) ⇒ WorkEmbargoReleaseService
Returns a new instance of WorkEmbargoReleaseService.
9 10 11 12 13 14 |
# File 'app/services/work_embargo_release_service.rb', line 9 def initialize(work:) @work = work @target_bucket = PULS3Client.post_curation_config[:bucket] @source_bucket = PULS3Client.[:bucket] @pul_s3_client = S3QueryService.new(work, bucket_name: source_bucket) end |
Instance Attribute Details
#pul_s3_client ⇒ Object (readonly)
Returns the value of attribute pul_s3_client.
6 7 8 |
# File 'app/services/work_embargo_release_service.rb', line 6 def pul_s3_client @pul_s3_client end |
#source_bucket ⇒ Object (readonly)
Returns the value of attribute source_bucket.
6 7 8 |
# File 'app/services/work_embargo_release_service.rb', line 6 def source_bucket @source_bucket end |
#target_bucket ⇒ Object (readonly)
Returns the value of attribute target_bucket.
6 7 8 |
# File 'app/services/work_embargo_release_service.rb', line 6 def target_bucket @target_bucket end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
6 7 8 |
# File 'app/services/work_embargo_release_service.rb', line 6 def work @work end |
Instance Method Details
#move ⇒ Object
move the files
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/work_embargo_release_service.rb', line 17 def move files = pul_s3_client.client_s3_files(reload: true, bucket_name: source_bucket) snapshot = EmbargoReleaseSnapshot.new(work:) snapshot.store_files(files) snapshot.save files.each do |file| move_service = S3MoveService.new(work_id: work.id, source_bucket:, source_key: file.key, target_bucket:, target_key: file.key, size: file.size) etag = move_service.move # if there is an error and exception is raised snapshot.mark_complete(file.key, etag) end true end |