Merged in cochalo/processmaker (pull request #369)

Correcion en error de body en MULTIPART
This commit is contained in:
erik ao
2014-04-03 12:36:03 -04:00
2 changed files with 33 additions and 3 deletions

View File

@@ -3,6 +3,9 @@ namespace Maveriks\Extension;
use Luracast\Restler\Defaults; use Luracast\Restler\Defaults;
use Luracast\Restler\Format\UrlEncodedFormat; use Luracast\Restler\Format\UrlEncodedFormat;
use ProcessMaker\Services\Api;
use Luracast\Restler\RestException;
/** /**
* Class Restler * Class Restler
* Extension Restler class to implement in ProcessMaker * Extension Restler class to implement in ProcessMaker
@@ -103,4 +106,20 @@ class Restler extends \Luracast\Restler\Restler
} }
return $includeQueryParameters ? $get : array(); //no body return $includeQueryParameters ? $get : array(); //no body
} }
/**
* This method call the function message
*
* @param RestException $e. Exception the error
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/
public function setMessage(RestException $e)
{
$this->message($e);
}
} }

View File

@@ -3,6 +3,8 @@ namespace Maveriks;
use Maveriks\Util; use Maveriks\Util;
use ProcessMaker\Services; use ProcessMaker\Services;
use ProcessMaker\Services\Api;
use Luracast\Restler\RestException;
class WebApplication class WebApplication
{ {
@@ -106,10 +108,19 @@ class WebApplication
public function multipart($uri, $version = "1.0") public function multipart($uri, $version = "1.0")
{ {
$stringInput = file_get_contents('php://input'); $stringInput = file_get_contents('php://input');
if (is_null($stringInput)) { if (empty($stringInput)) {
return array(); //no body $rest = new \Maveriks\Extension\Restler();
} $rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart without body."));
exit();
} else {
$input = json_decode($stringInput); $input = json_decode($stringInput);
if (empty($input->calls)) {
$rest = new \Maveriks\Extension\Restler();
$rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart body without calls."));
exit();
}
}
$baseUrl = (empty($input->base_url)) ? $uri : $input->base_url; $baseUrl = (empty($input->base_url)) ? $uri : $input->base_url;
foreach($input->calls as $value) { foreach($input->calls as $value) {