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
7 changes: 6 additions & 1 deletion src/MGRAST/lib/resources/inbox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,12 @@ sub update_node_actions {
if ($act->{status} eq 'completed') {
push @$new_actions, $act;
} else {
my $job = $self->get_awe_job($act->{id}, $self->token, $self->user_auth);
my $job = $self->get_awe_job($act->{id}, $self->token, $self->user_auth, 1);
# if the job no longer exists, drop
if ($job->{ERROR}) {
next;
}

# drop if deleted
if ($job->{state} eq 'deleted') {
next;
Expand Down
31 changes: 28 additions & 3 deletions src/MGRAST/lib/resources/resource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ sub awe_job_action {

# get job document
sub get_awe_job {
my ($self, $id, $auth, $authPrefix) = @_;
my ($self, $id, $auth, $authPrefix, $pass_back_errors) = @_;

if (! $authPrefix) {
$authPrefix = "mgrast";
Expand All @@ -1402,8 +1402,13 @@ sub get_awe_job {
};
if ($@ || (! ref($response))) {
return undef;
} elsif (exists($response->{error}) && $response->{error}) {
$self->return_data( {"ERROR" => "Unable to GET job $id from AWE: ".$response->{error}[0]}, $response->{status} );
} elsif (exists($response->{error}) && $response->{error}) {
my $err = {"ERROR" => "Unable to GET job $id from AWE: ".$response->{error}[0]};
if ($pass_back_errors) {
return $err;
} else {
$self->return_data( $err, $response->{status} );
}
} else {
return $response->{data};
}
Expand Down Expand Up @@ -2579,3 +2584,23 @@ sub prepare_data {

# enable hash-resolving in the JSON->encode function
sub TO_JSON { return { %{ shift() } }; }

# turn a hidden id into a normal one and vice versa
sub idmap {
my ($id) = @_;

# this is a decoded id, encode it
if (($id =~ /mgm/) or ($id =~ /mgp/)) {
my @set = ('0' ..'9', 'a' .. 'f');
my $str = join '' => map $set[rand @set], 1 .. 10;
$id = unpack ("H*",$id);
$id = $str.$id;
}

# this is an encoded id, decode it
else {
$id = substr $id, 10;
$id = pack (qq{H*},qq{$id});
}
return $id;
}