diff --git a/framework/src/Maveriks/Extension/Restler.php b/framework/src/Maveriks/Extension/Restler.php index e4f043839..c60c3d163 100644 --- a/framework/src/Maveriks/Extension/Restler.php +++ b/framework/src/Maveriks/Extension/Restler.php @@ -3,6 +3,9 @@ namespace Maveriks\Extension; use Luracast\Restler\Defaults; use Luracast\Restler\Format\UrlEncodedFormat; +use ProcessMaker\Services\Api; +use Luracast\Restler\RestException; + /** * Class Restler * Extension Restler class to implement in ProcessMaker @@ -103,4 +106,20 @@ class Restler extends \Luracast\Restler\Restler } return $includeQueryParameters ? $get : array(); //no body } + + /** + * This method call the function message + * + * @param RestException $e. Exception the error + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return void + */ + public function setMessage(RestException $e) + { + $this->message($e); + } } \ No newline at end of file diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 8d645659f..edc86752e 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -3,6 +3,8 @@ namespace Maveriks; use Maveriks\Util; use ProcessMaker\Services; +use ProcessMaker\Services\Api; +use Luracast\Restler\RestException; class WebApplication { @@ -106,10 +108,19 @@ class WebApplication public function multipart($uri, $version = "1.0") { $stringInput = file_get_contents('php://input'); - if (is_null($stringInput)) { - return array(); //no body + if (empty($stringInput)) { + $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; foreach($input->calls as $value) {