Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources/job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ sub job_action {
my $attr = $n->{attributes};
$attr->{status} = 'public';
$self->update_shock_node($n->{id}, $attr, $self->mgrast_token);
$self->edit_shock_acl($n->{id}, $self->mgrast_token, 'mgrast', 'delete', 'read');
$self->edit_shock_public_acl($n->{id}, $self->mgrast_token, 'put', 'read');
}
# update db
$job->public(1);
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources/notebook.pm
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ sub shock_post_acl {
map { $self->edit_shock_acl($id, $self->{nb_token}, $_, 'put', 'read') } @$access;
} elsif ($self->{nb_token} && $self->{nb_info} && (@$access == 0)) {
# public
$self->edit_shock_acl($id, $self->{nb_token}, $self->{nb_info}{username}, 'delete', 'read');
$self->edit_shock_public_acl($id, $self->{nb_token}, 'put', 'read');
} else {
# missing config
print STDERR "Missing notebook config options\n";
Expand Down
30 changes: 30 additions & 0 deletions src/MGRAST/lib/resources/resource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,36 @@ sub edit_shock_acl {
}
}

# add or delete public from a node ACL
sub edit_shock_public_acl {
my ($self, $id, $auth, $action, $acl, $authPrefix) = @_;

if (! $authPrefix) {
$authPrefix = "OAuth";
}

my $response = undef;
my $url = $Conf::shock_url.'/node/'.$id.'/acl/public_'.$acl;
eval {
my $tmp = undef;
if ($action eq 'delete') {
$tmp = $self->agent->delete($url, 'Authorization' => "$authPrefix $auth");
} elsif ($action eq 'put') {
$tmp = $self->agent->put($url, 'Authorization' => "$authPrefix $auth");
} else {
$self->return_data( {"ERROR" => "Invalid Shock ACL action: $action"}, 500 );
}
$response = $self->json->decode( $tmp->content );
};
if ($@ || (! ref($response))) {
return undef;
} elsif (exists($response->{error}) && $response->{error}) {
$self->return_data( {"ERROR" => "Unable to $action public ACL for '$acl' to node $id in Shock: ".$response->{error}[0]}, $response->{status} );
} else {
return $response->{data};
}
}

# create node with optional file and/or attributes
# file is json struct by default
sub set_shock_node {
Expand Down