Correcion en error de body en MULTIPART

This commit is contained in:
Brayan Osmar Pereyra Suxo
2014-04-03 12:17:47 -04:00
parent 1659d68aeb
commit ef70d65ffc
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

@@ -1,7 +1,9 @@
<?php <?php
namespace Maveriks; namespace Maveriks;
use ProcessMaker\Services\Api;
use Maveriks\Util; use Maveriks\Util;
use Luracast\Restler\RestException;
class WebApplication class WebApplication
{ {
@@ -103,10 +105,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);
if (empty($input->calls)) {
$rest = new \Maveriks\Extension\Restler();
$rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart body without calls."));
exit();
}
} }
$input = json_decode($stringInput);
$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) {