-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from mgcam/consolidate_acl_rules
Consolidate acl rules
- Loading branch information
Showing
3 changed files
with
161 additions
and
30 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 |
---|---|---|
|
@@ -9,8 +9,6 @@ use Set::Scalar; | |
use Try::Tiny; | ||
|
||
use WTSI::NPG::iRODS; | ||
use WTSI::NPG::iRODS::Metadata qw($SAMPLE_CONSENT | ||
$SAMPLE_CONSENT_WITHDRAWN); | ||
use WTSI::NPG::iRODS::Replicate; | ||
use WTSI::NPG::iRODS::Types qw(ArrayRefOfReplicate); | ||
|
||
|
@@ -452,19 +450,14 @@ sub get_groups { | |
logged only. | ||
Example : $obj->update_group_permissions | ||
Description: Modify a data objects ACL with respect to its study_id and | ||
sample_consent / consent_withdrawn metadata and return the | ||
data object. | ||
Description: Modify a data objects ACL. | ||
The target group membership is determined by the result of | ||
calling $self->expected_groups. The current group membership | ||
is determined and any difference calculated. Unwanted | ||
group memberships are pruned, then missing group memberships | ||
are added. | ||
If there are sample_consent or consent_withdrawn metadata, | ||
access for all groups is removed. | ||
This method does not add or remove access for the 'public' | ||
group. | ||
Returntype : WTSI::NPG::iRODS::DataObject | ||
|
@@ -488,16 +481,6 @@ sub update_group_permissions { | |
$self->debug('Updated annotations: [', join(', ', @groups_annotated), ']'); | ||
|
||
my $path = $self->str; | ||
|
||
my $true = 1; | ||
my $false = 0; | ||
if ($self->get_avu($SAMPLE_CONSENT, $false) or | ||
$self->get_avu($SAMPLE_CONSENT_WITHDRAWN, $true)) { | ||
$self->info('Data is marked as CONSENT WITHDRAWN; ', | ||
'all permissions will be withdrawn'); | ||
@groups_annotated = (); # Emptying this means all will be removed | ||
} | ||
|
||
my $perms = Set::Scalar->new(@groups_permissions); | ||
my $annot = Set::Scalar->new(@groups_annotated); | ||
my @to_remove = $perms->difference($annot)->members; | ||
|
@@ -638,7 +621,7 @@ Keith James <[email protected]> | |
=head1 COPYRIGHT AND DISCLAIMER | ||
Copyright (C) 2013, 2014, 2015, 2016, 2021 Genome Research Limited. All | ||
Copyright (C) 2013, 2014, 2015, 2016, 2021, 2023 Genome Research Limited. All | ||
Rights Reserved. | ||
This program is free software: you can redistribute it and/or modify | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,10 @@ use List::MoreUtils qw(any notall uniq); | |
use Moose::Role; | ||
|
||
use WTSI::NPG::iRODS; | ||
use WTSI::NPG::iRODS::Metadata qw($STUDY_ID); | ||
use WTSI::NPG::iRODS::Metadata qw($STUDY_ID | ||
$ALIGNMENT_FILTER | ||
$SAMPLE_CONSENT | ||
$SAMPLE_CONSENT_WITHDRAWN); | ||
|
||
our $VERSION = ''; | ||
|
||
|
@@ -276,22 +279,61 @@ sub supersede_multivalue_avus { | |
Arg [1] : None | ||
Example : @groups = $path->expected_groups | ||
Description: Return an array of iRODS group names given metadata containing | ||
>=1 study_id. | ||
Returntype : Array | ||
Description: Return a list of iRODS group names. The list might be empty or | ||
contain either one or multiple iRODS group names. | ||
An empty list is returned if the concent has been withdrawn or | ||
for split-out xa-human data, for which the consent does not | ||
exist by definition, or for split-out human data that is | ||
associated with multiple studies. | ||
Special study-related 'human' group ss_<STUDY_ID>_human is | ||
returned for split-out human data associated with a single study. | ||
In all other cases if data is associated with a list of studies, | ||
a list of groups is returned, a group per study, the group name | ||
pattern being ss_<STUDY_ID>. | ||
The logic is based on examining such iRODS metadata as | ||
'study_id', 'alignment_filter', 'sample_consent', | ||
'sample_consent_withdrawn'. Neither object's path nor file name | ||
is considered. | ||
Returntype : List | ||
=cut | ||
|
||
sub expected_groups { | ||
my ($self) = @_; | ||
|
||
my @af_avus = $self->find_in_metadata($ALIGNMENT_FILTER); | ||
my @ss_study_avus = $self->find_in_metadata($STUDY_ID); | ||
my $human_subset = any { $_->{value} eq 'human' } @af_avus; | ||
my $xahuman_subset = any { $_->{value} eq 'xahuman' } @af_avus; | ||
|
||
my $info; | ||
my $true = 1; | ||
my $false = 0; | ||
my @groups; | ||
foreach my $avu (@ss_study_avus) { | ||
my $study_id = $avu->{value}; | ||
my $group = $self->irods->make_group_name($study_id); | ||
push @groups, $group; | ||
if ($self->get_avu($SAMPLE_CONSENT, $false) || | ||
$self->get_avu($SAMPLE_CONSENT_WITHDRAWN, $true)) { | ||
$info = 'Data is marked as CONSENT WITHDRAWN'; | ||
} elsif ($xahuman_subset) { | ||
$info = 'Data belongs to xahuman subset'; | ||
} elsif ($human_subset && (@ss_study_avus > 1)) { | ||
$info = 'Data belongs to human subset and multiple studies'; | ||
} else { | ||
@groups = map { $self->irods->make_group_name($_) } | ||
map { $_->{value} } | ||
@ss_study_avus; | ||
if (@groups == 1 and $human_subset) { | ||
$self->info('Data belongs to human subset'); | ||
@groups = ($groups[0] . '_human'); # Reset the list | ||
} | ||
} | ||
|
||
if ($info) { | ||
$self->info("${info}:\n no study-associated iRODS groups are applicable"); | ||
} | ||
|
||
return @groups; | ||
|
@@ -448,7 +490,7 @@ Keith James <[email protected]> | |
=head1 COPYRIGHT AND DISCLAIMER | ||
Copyright (C) 2013, 2014, 2015, 2016 Genome Research Limited. All | ||
Copyright (C) 2013, 2014, 2015, 2016, 2023, 2024 Genome Research Limited. All | ||
Rights Reserved. | ||
This program is free software: you can redistribute it and/or modify | ||
|
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