-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Access-granting workflow services should work on member file sets
Fixes #1477
- Loading branch information
Showing
8 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Hyrax | ||
# Grants the user's edit access on the provided FileSet | ||
class GrantEditJob < ApplicationJob | ||
queue_as Hyrax.config.ingest_queue_name | ||
|
||
# @param [String] file_set_id - the identifier of the object to grant access to | ||
# @param [String] user_key - the user to add | ||
def perform(file_set_id, user_key) | ||
file_set = ::FileSet.find(file_set_id) | ||
file_set.edit_users += [user_key] | ||
file_set.save! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Hyrax | ||
# Grants edit access for the supplied user for the members attached to a work | ||
class GrantEditToMembersJob < ApplicationJob | ||
queue_as Hyrax.config.ingest_queue_name | ||
|
||
# @param [ActiveFedora::Base] work - the work object | ||
# @param [String] user_key - the user to add | ||
def perform(work, user_key) | ||
# Iterate over ids because reifying objects is slow. | ||
file_set_ids(work).each do |file_set_id| | ||
# Call this synchronously, since we're already in a job | ||
GrantEditJob.perform_now(file_set_id, user_key) | ||
end | ||
end | ||
|
||
private | ||
|
||
# Filter the member ids and return only the FileSet ids (filter out child works) | ||
# @return [Array<String>] the file set ids | ||
def file_set_ids(work) | ||
::FileSet.search_with_conditions(id: work.member_ids).map(&:id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Hyrax | ||
# Grants the user's read access on the provided FileSet | ||
class GrantReadJob < ApplicationJob | ||
queue_as Hyrax.config.ingest_queue_name | ||
|
||
# @param [String] file_set_id - the identifier of the object to grant access to | ||
# @param [String] user_key - the user to add | ||
def perform(file_set_id, user_key) | ||
file_set = ::FileSet.find(file_set_id) | ||
file_set.read_users += [user_key] | ||
file_set.save! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Hyrax | ||
# Grants read access for the supplied user for the members attached to a work | ||
class GrantReadToMembersJob < ApplicationJob | ||
queue_as Hyrax.config.ingest_queue_name | ||
|
||
# @param [ActiveFedora::Base] work - the work object | ||
# @param [String] user_key - the user to add | ||
def perform(work, user_key) | ||
# Iterate over ids because reifying objects is slow. | ||
file_set_ids(work).each do |file_set_id| | ||
# Call this synchronously, since we're already in a job | ||
GrantReadJob.perform_now(file_set_id, user_key) | ||
end | ||
end | ||
|
||
private | ||
|
||
# Filter the member ids and return only the FileSet ids (filter out child works) | ||
# @return [Array<String>] the file set ids | ||
def file_set_ids(work) | ||
::FileSet.search_with_conditions(id: work.member_ids).map(&:id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters