Skip to content
Merged
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
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