diff --git a/gulliver/system/class.restClient.php b/gulliver/system/class.restClient.php index 83442f496..5cc5d29cd 100755 --- a/gulliver/system/class.restClient.php +++ b/gulliver/system/class.restClient.php @@ -33,7 +33,7 @@ class RestClient * * @return RestClient */ - public function execute () + public function execute ($getResponseIfDelete = false) { if ($this->method === "POST") { curl_setopt( $this->curl, CURLOPT_POST, true ); @@ -59,7 +59,7 @@ class RestClient } curl_setopt( $this->curl, CURLOPT_URL, $this->url ); $r = curl_exec( $this->curl ); - if ($this->method !== "DELETE") { + if ($this->method !== "DELETE" || $getResponseIfDelete) { $this->treatResponse( $r ); // Extract the headers and response return $this; } else { @@ -325,9 +325,9 @@ class RestClient * @param string $password=null [optional] * @return RestClient */ - public static function delete ($url, $user = null, $pwd = null, $contentType = null) + public static function delete ($url, $user = null, $pwd = null, $contentType = null, $getResponse = false) { - return self::call( "DELETE", $url, null, $user, $pwd, $contentType ); + return self::call( "DELETE", $url, null, $user, $pwd, $contentType, $getResponse ); } /** @@ -341,9 +341,9 @@ class RestClient * @param string $contentType=null [optional] * @return RestClient */ - public static function call ($method, $url, $body, $user = null, $pwd = null, $contentType = null) + public static function call ($method, $url, $body, $user = null, $pwd = null, $contentType = null, $getResponseIfDelete) { - return self::createClient( $url )->setParameters( $body )->setMethod( $method )->setCredentials( $user, $pwd )->setContentType( $contentType )->execute()->close(); + return self::createClient( $url )->setParameters( $body )->setMethod( $method )->setCredentials( $user, $pwd )->setContentType( $contentType )->execute($getResponseIfDelete)->close(); } } diff --git a/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php b/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php index f6d3a3065..28c328452 100755 --- a/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php +++ b/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php @@ -179,12 +179,15 @@ function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pw */ function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) { + $getResponse = true; $alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId"; - $alfresco_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml"); - - $alfresco_res = G::json_decode($alfresco_exec->getResponse()); - - return $alfresco_res; + $alfresco_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml", $getResponse); + if($alfresco_exec->getResponseCode() === 204 && trim($alfresco_exec->getResponse()) === '') { + $alfresco_res = true; + } else { + $alfresco_res = false; + } + return $getResponse ? $alfresco_res : ''; } /**