[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4976] trunk



Revision: 4976
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4976&view=rev
Author:   einhverfr
Date:     2012-07-13 07:54:45 +0000 (Fri, 13 Jul 2012)
Log Message:
-----------
More web services errors fixed, authentication with web services now works

Modified Paths:
--------------
    trunk/LedgerSMB/REST_Class/Contact.pm
    trunk/ledgersmb-httpd.conf.template
    trunk/rest-handler.pl

Modified: trunk/LedgerSMB/REST_Class/Contact.pm
===================================================================
--- trunk/LedgerSMB/REST_Class/Contact.pm	2012-07-13 07:33:12 UTC (rev 4975)
+++ trunk/LedgerSMB/REST_Class/Contact.pm	2012-07-13 07:54:45 UTC (rev 4976)
@@ -38,9 +38,10 @@
 
 sub get {
     my ($request) = @_;
+    die "418 I'm a Teapot";
     my $id = $request->{$cname};
     my $data;
-    if ($id){
+    if (defined $id){
        my $company = LedgerSMB::DBObject::Entity::Company->get($id);
        if ($company){
           $data= $company;

Modified: trunk/ledgersmb-httpd.conf.template
===================================================================
--- trunk/ledgersmb-httpd.conf.template	2012-07-13 07:33:12 UTC (rev 4975)
+++ trunk/ledgersmb-httpd.conf.template	2012-07-13 07:54:45 UTC (rev 4976)
@@ -40,7 +40,7 @@
 <Directory WORKING_DIR/rest>
    RewriteEngine On
    RewriteBase /ledgersmb/rest/
-   RewriteRule . ../rest-handler.pl
+   RewriteRule .* ../rest-handler.pl
 </Directory>
 
 <Directory WORKING_DIR/users>

Modified: trunk/rest-handler.pl
===================================================================
--- trunk/rest-handler.pl	2012-07-13 07:33:12 UTC (rev 4975)
+++ trunk/rest-handler.pl	2012-07-13 07:54:45 UTC (rev 4976)
@@ -145,7 +145,6 @@
 use Try::Tiny;
 use strict;
 use warnings;
-warn 'starting';
 process_request();
 
 # Note:  Indenting try/catch only two characters here because it wraps all
@@ -167,7 +166,7 @@
         if ($fmtpackage->can('from_input')){
             $request->{payload} = $fmtpackage->can('from_input')->($request);
         } else {
-            die '404 Unsupported Format';
+            die '415 Unsupported Media Type';
         }
     }
 
@@ -228,11 +227,11 @@
     my $content = $error;
     $content =~ s/^\d\d\d\s//;
     $error =~ s/(.*)\n.*/$1/m;
-    if ($error =~ /^\d\d\d/){
+    $error =~ s/ at .*//;
+    if ($error !~ /^\d\d\d/){
         $error = "500 $error";
     }
-    warn $error;
-    output({state => $error, content => $content, content_type => 'text/text'});
+    output({state => $error, content => $content, });
 }
 
 # Isolating request-> hashref logic so that it is easier to port to other
@@ -250,8 +249,7 @@
     $request->{args} = $cgi->Vars();
     $request->{method} = $ENV{REQUEST_METHOD};
     $request->{payload} = $cgi->param( "$request->{method}DATA" );
-
-    $url =~ s|/rest/(.*)|$1|;
+    $url =~ s|.*/rest-handler.pl/(.*)|$1|;
     $url =~ s|(\.[^/]$)||;
     $request->{format} = $1;
 
@@ -266,7 +264,7 @@
     );
 
     if (!$request->{dbh}) {
-           die '403 Authentication Failed';
+           die '401 Unauthorized';
     }
 
     if (!$request->{format}){
@@ -280,7 +278,7 @@
     while (@components) {
         my $class = shift @components;
         my $id = shift @components;
-        $id = undef if $id == 'all';
+        $id = undef if $id eq 'all';
         $request->{class_name} .= "::$class";
         $request->{classes}->{$request->{class_name}} = $id;
     }
@@ -299,7 +297,7 @@
     } else {
         $ctype = 'text/text';
     }
-    $cgi->header($ctype, $args->{state});
+    print $cgi->header($ctype, $args->{state});
     $cgi->put($args->{content});
 }
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.