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
9 changes: 8 additions & 1 deletion src/MGRAST/lib/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ sub authenticate {
$ustruct = globus_token($key);
if ($ustruct) {
if ($ustruct->{access_token}) {
my $info = { token => $ustruct->{access_token} };
if ($cgi->param('verbosity') && $cgi->param('verbosity') eq 'verbose') {
my $verb = globus_info($ustruct->{access_token});
foreach my $key (keys(%$verb)) {
$info->{$key} = $verb->{$key};
}
}
print $cgi->header(-type => 'application/json',
-status => 200,
-charset => 'UTF-8',
-Access_Control_Allow_Origin => '*' );
print '{ "token": "'.$ustruct->{access_token}.'" }';
print $json->encode($info);
exit;
} else {
return (undef, "invalid globus online credentials");
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/JobDB/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ sub fetch_browsepage_in_progress {
my $stats = {};
eval {
my @args = ('Authorization', "OAuth ".$mgrast_token);
my $get = $agent->get($Conf::awe_url.'/job?query&info.user=mgu'.$user->{_id}, @args);
my $get = $agent->get($Conf::awe_url.'/job?query&limit=0&info.user=mgu'.$user->{_id}, @args);
$stats = $json->decode( $get->content );
};
if ($@ || (! $stats) || (exists($stats->{error}) && $stats->{error})) {
Expand Down
16 changes: 8 additions & 8 deletions src/MGRAST/lib/WebPage/PublishGenome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use MGRAST::Metadata;

use JSON;
use LWP::UserAgent;
use HTTP::Request;
use Data::Dumper;

use WebConfig;
Expand Down Expand Up @@ -247,22 +248,21 @@ sub publish {
$json->allow_nonref;

my $url = $self->data('api')."/job/public";
my @args = (
($user && (! $job->public)) ? ('auth', $Conf::api_key) : (),
'Content_Type', 'multipart/form-data',
'Content', {metagenome_id => 'mgm'.$job->{metagenome_id}}
);
my $data = {metagenome_id => 'mgm'.$job->{metagenome_id}};
my $req = HTTP::Request->new(POST => $url);
$req->header('Content-Type' => 'application/json', 'auth' => $Conf::api_key);
$req->content($json->encode($data));

eval {
my $post = $agent->post($url, @args);
my $post = $agent->request($req);
$response = $json->decode($post->content);
};
if ($@ || (! ref($response))) {
$self->application->add_message('warning', "Could not make metagenome public: ".$@);
return 1;
return "<pre>Could not make metagenome public: ".$@."</pre>";
} elsif (exists($response->{ERROR}) && $response->{ERROR}) {
$self->application->add_message('warning', "Could not make metagenome public: ". $response->{ERROR});
return 1;
return "<pre>Could not make metagenome public: ".$response->{ERROR}."</pre>";
}

# send email
Expand Down
26 changes: 26 additions & 0 deletions src/MGRAST/lib/WebPage/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Digest::MD5 qw(md5 md5_hex md5_base64);
use JSON;
use Encode;
use Number::Format qw(format_bytes);
use LWP::UserAgent;

use Conf;
use WebConfig;
Expand Down Expand Up @@ -572,6 +573,31 @@ sub submit_to_mgrast {
my $project_obj = undef;
my $mddb = MGRAST::Metadata->new();
my ($is_valid, $data, $log);

# test if Shock-AWE are running
my $info = undef;
my $agent = LWP::UserAgent->new;
my $json = JSON->new;
$json = $json->utf8();
$json->max_size(0);
$json->allow_nonref;
$agent->timeout(10);
eval {
my $get = $agent->get($Conf::shock_url);
$info = $json->decode($get->content);
};
if ($@ || ($info->{id} ne 'Shock')) {
$self->application->add_message('warning', "Unable to access MG-RAST data store. Please try again later.");
return undef;
}
eval {
my $get = $agent->get($Conf::awe_url);
$info = $json->decode($get->content);
};
if ($@ || ($info->{id} ne 'AWE')) {
$self->application->add_message('warning', "Unable to access MG-RAST pipeline. Please try again later.");
return undef;
}

# get project name from metadata
if ($mdata) {
Expand Down