/[Search-Estraier]/trunk/lib/Search/Estraier.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Search/Estraier.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 134 by dpavlin, Tue May 9 12:21:26 2006 UTC revision 135 by dpavlin, Tue May 9 12:42:39 2006 UTC
# Line 1725  my $estmaster_rest = { Line 1725  my $estmaster_rest = {
1725          },          },
1726          userlist => {          userlist => {
1727                  status => 200,                  status => 200,
1728                  returns => qw/name passwd flags fname misc/,                  returns => [ qw/name passwd flags fname misc/ ],
1729          },          },
1730          useradd => {          useradd => {
1731                  required => qw/name passwd flags/,                  required => [ qw/name passwd flags/ ],
1732                  optional => qw/fname misc/,                  optional => [ qw/fname misc/ ],
1733                  status => 200,                  status => 200,
1734          },          },
1735          userdel => {          userdel => {
1736                  required => qw/name/,                  required => [ qw/name/ ],
1737                  status => 200,                  status => 200,
1738          },          },
1739          nodelist => {          nodelist => {
1740                  status => 200,                  status => 200,
1741                  returns => qw/name label doc_num word_num size/,                  returns => [ qw/name label doc_num word_num size/ ],
1742          },          },
1743          nodeadd => {          nodeadd => {
1744                  required => qw/name/,                  required => [ qw/name/ ],
1745                  optional => qw/label/,                  optional => [ qw/label/ ],
1746                  status => 200,                  status => 200,
1747          },          },
1748          nodedel => {          nodedel => {
1749                  required => qw/name/,                  required => [ qw/name/ ],
1750                  status => 200,                  status => 200,
1751          },          },
1752          nodeclr => {          nodeclr => {
1753                  required => qw/name/,                  required => [ qw/name/ ],
1754                  status => 200,                  status => 200,
1755          },          },
1756          nodertt => {          nodertt => {
# Line 1793  sub master { Line 1793  sub master {
1793    
1794          my $resbody;          my $resbody;
1795    
1796          if ($self->shuttle_url(          my $status = $self->shuttle_url(
1797                  'http://' . $uri->host_port . '/master?action=' . $action ,                  'http://' . $uri->host_port . '/master?action=' . $action ,
1798                  'application/x-www-form-urlencoded',                  'application/x-www-form-urlencoded',
1799                  join('&', @args),                  join('&', @args),
1800                  \$resbody,                  \$resbody,
1801                  1,                  1,
1802          ) == $rest->{status}) {          ) or confess "shuttle_url failed";
                 return 0E0 unless ($rest->{returns});  
1803    
1804                  if (wantarray) {          if ($status == $rest->{status}) {
1805                    if ($rest->{returns} && wantarray) {
1806    
1807                          my @results;                          my @results;
1808                            my $fields = $#{$rest->{returns}};
1809    
1810                          foreach my $line ( split(/[\r\n]/,$resbody) ) {                          foreach my $line ( split(/[\r\n]/,$resbody) ) {
1811                                  my @e = split(/\t/, $line);                                  my @e = split(/\t/, $line, $fields + 1);
1812                                  my $row;                                  my $row;
1813                                  map { $row->{$_} = shift @e; } @{ $rest->{returns} };                                  foreach my $i ( 0 .. $fields) {
1814                                            $row->{ $rest->{returns}->[$i] } = $e[ $i ];
1815                                    }
1816                                  push @results, $row;                                  push @results, $row;
1817                          }                          }
1818    
1819                          return @results;                          return @results;
                 } else {  
1820    
1821                          carp "calling master action '$action', but not expecting array back, returning whole body";                  } elsif ($resbody) {
1822                          return $resbody;                          return $resbody;
1823                    } else {
1824                            return 0E0;
1825                  }                  }
1826          }          }
1827    
1828            carp "expected status $rest->{status}, but got $status";
1829            return undef;
1830  }  }
1831    
1832  =head1 PRIVATE METHODS  =head1 PRIVATE METHODS

Legend:
Removed from v.134  
changed lines
  Added in v.135

  ViewVC Help
Powered by ViewVC 1.1.26