Class: WorkPublishService
- Inherits:
-
Object
- Object
- WorkPublishService
- Defined in:
- app/services/work_publish_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
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#pul_s3_client ⇒ Object
readonly
Returns the value of attribute pul_s3_client.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Instance Method Summary collapse
-
#initialize(work:, current_user:) ⇒ WorkPublishService
constructor
A new instance of WorkPublishService.
-
#publish ⇒ Object
Copies the existing files from the pre-curation bucket to the target bucket (postcuration or embargo).
Constructor Details
#initialize(work:, current_user:) ⇒ WorkPublishService
Returns a new instance of WorkPublishService.
9 10 11 12 13 |
# File 'app/services/work_publish_service.rb', line 9 def initialize(work:, current_user:) @work = work @current_user = current_user @pul_s3_client = S3QueryService.new(work, PULS3Client::PRECURATION) end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/services/work_publish_service.rb', line 6 def current_user @current_user end |
#pul_s3_client ⇒ Object (readonly)
Returns the value of attribute pul_s3_client.
6 7 8 |
# File 'app/services/work_publish_service.rb', line 6 def pul_s3_client @pul_s3_client end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
6 7 8 |
# File 'app/services/work_publish_service.rb', line 6 def work @work end |
Instance Method Details
#publish ⇒ Object
Copies the existing files from the pre-curation bucket to the target bucket (postcuration or embargo).
Notice that the copy process happens at AWS (i.e. the files are not downloaded and re-uploaded).
17 18 19 20 21 22 23 24 25 |
# File 'app/services/work_publish_service.rb', line 17 def publish s3_target_query_service = S3QueryService.new(work, target_mode) s3_dir = work.find_bucket_s3_dir(bucket_name: s3_target_query_service.bucket_name) raise(StandardError, "Attempting to publish a Work with an existing S3 Bucket directory for: #{target_bucket}/#{work.s3_object_key}") unless s3_dir.nil? # Copy the pre-curation S3 Objects to the target S3 Bucket. publish_files(current_user) end |