"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "usr/sbin/benno-client" between
benno-web-2.8.9.tgz and benno-web-2.8.10.tgz

About: Open Benno (webapp) mail archiving solution (GUI and user-frontend; PHP5).

benno-client  (benno-web-2.8.9.tgz):benno-client  (benno-web-2.8.10.tgz)
skipping to change at line 17 skipping to change at line 17
use MIME::Base64; use MIME::Base64;
use LWP::UserAgent; use LWP::UserAgent;
use JSON; use JSON;
no warnings 'utf8'; no warnings 'utf8';
my $container = 'BennoContainer'; my $container = 'BennoContainer';
my $filter = '*'; my $filter = '*';
my $first = 0; my $first = 0;
my $help = ''; my $help = '';
my $resthost = 'localhost'; my $resthost = 'localhost';
my $instanceid = '';
my $json = ''; my $json = '';
my $limit = 20; my $limit = 20;
my $mailid = ''; my $mailid = '';
my $port = 21080; my $port = 21080;
my $query = ''; my $query = '';
my $scid = ''; my $scid = '';
my $secret = fetchSecret('/etc/benno/rest.secret','/etc/benno/benno.xml'); my $secret = fetchSecret('/etc/benno/rest.secret','/etc/benno/benno.xml');
my $verbose = 0; my $verbose = 0;
GetOptions ( GetOptions (
'container=s' => \$container, 'container=s' => \$container,
'filter=s' => \$filter, 'filter=s' => \$filter,
'first=i' => \$first, 'first=i' => \$first,
'help' => \$help, 'help' => \$help,
'json' => \$json, 'json' => \$json,
'limit=i' => \$limit, 'limit=i' => \$limit,
'instance-id' => \$instanceid,
'id=s' => \$mailid, 'id=s' => \$mailid,
'port=s' => \$port, 'port=s' => \$port,
'query=s' => \$query, 'query=s' => \$query,
'resthost=s' => \$resthost, 'resthost=s' => \$resthost,
'secret=s' => \$secret, 'secret=s' => \$secret,
'u_scid|scid=s' => \$scid, 'u_scid|scid=s' => \$scid,
'verbose+' => \$verbose, 'verbose+' => \$verbose,
) or help_exit(); ) or help_exit();
help_exit() if $help; help_exit() if $help;
help_exit() unless $secret; help_exit() unless $secret;
help_exit("No query or mailid given.") unless ($query || $mailid); help_exit("No query or mailid given.") unless ($query || $mailid || $instanceid) ;
my $proto = 'http'; my $proto = 'http';
my $params; my $params;
my $path; my $path;
if ($mailid) { if ($mailid) {
$params = { 'archive' => $container, $params = { 'archive' => $container,
'id' => $mailid, 'id' => $mailid,
}; };
$params->{'format'} = 'raw' if not $json; $params->{'format'} = 'raw' if not $json;
$path = '/mail/'; $path = '/mail/';
} }
elsif ($instanceid) {
$params = {};
$params->{'format'} = 'raw' if not $json;
$path = '/license/';
}
else { else {
$query =~ s/SortableDate:\[/Date:[/g; $query =~ s/SortableDate:\[/Date:[/g;
if (-f $query) { $query = read_first_line($query); } if (-f $query) { $query = read_first_line($query); }
if (-f $filter) { $filter = read_first_line($filter); } if (-f $filter) { $filter = read_first_line($filter); }
$params = { 'archive' => $container, $params = { 'archive' => $container,
'query' => '('.$query.')', 'query' => '('.$query.')',
'query' => $query, 'query' => $query,
'start' => $first, 'start' => $first,
'limit' => $limit, 'limit' => $limit,
'sort' => 'Date', 'sort' => 'Date',
skipping to change at line 82 skipping to change at line 89
} }
$scid and $params->{'scid'} = $scid; $scid and $params->{'scid'} = $scid;
my $uri = $proto.'://'.$resthost.':'.$port.$path; my $uri = $proto.'://'.$resthost.':'.$port.$path;
my $UA = LWP::UserAgent->new; my $UA = LWP::UserAgent->new;
my $b64creds = encode_base64('benno2'.':'.$secret); my $b64creds = encode_base64('benno2'.':'.$secret);
$UA->default_header('Authorization' => 'Basic '.$b64creds); $UA->default_header('Authorization' => 'Basic '.$b64creds);
my $Response = $UA->post($uri,$params); my $Response = $UA->post($uri,$params);
my $return; my $return;
if ($Response->is_success) { if ($Response->is_success) {
$return = $Response->decoded_content; $return = $Response->decoded_content;
} }
else { else {
print STDERR "Response status: ",$Response->status_line,"\n"; print STDERR "Response status: ",$Response->status_line,"\n";
print STDERR $Response->content,"\n"; print STDERR $Response->content,"\n";
exit 1; exit 1;
} }
if ($mailid || $json) { if ($mailid || $json) {
# Response returned raw email # Response returned raw email
print $return,"\n"; print $return,"\n";
exit 0; exit 0;
} }
# Response returned JSON data # Response returned JSON data
my $JSON = JSON->new->allow_nonref; my $JSON = JSON->new->allow_nonref;
my $data = $JSON->decode($return); my $data = $JSON->decode($return);
if ($data->{error}) { if ($data->{error}) {
print STDERR "Error: ",$data->{error},"\n"; print STDERR "Error: ",$data->{error},"\n";
exit 1; exit 1;
} }
if ($instanceid) {
print 'Instance-ID: ',$data->{licenseInstanceId},"\n";
exit 0;
}
my $first = $data->{first}; my $first = $data->{first};
my $last = $data->{last}; my $last = $data->{last};
my $limit = $data->{limit}; my $limit = $data->{limit};
my $found = $data->{found}; my $found = $data->{found};
my $results = $data->{results}; my $results = $data->{results};
verbose(3,"\n****** REQUEST ******"); verbose(3,"\n****** REQUEST ******");
verbose(3,"URI: $uri"); verbose(3,"URI: $uri");
verbose(3,"Parameter:"); verbose(3,"Parameter:");
foreach my $param (keys %{$params}) { foreach my $param (keys %{$params}) {
 End of changes. 7 change blocks. 
2 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)