HOR-429: (Trigger Alfresco) Delete an object(Folder/File) from Alfresco Repository no devuelve ningún mensaje de satisfactorio
.
This commit is contained in:
@@ -33,7 +33,7 @@ class RestClient
|
|||||||
*
|
*
|
||||||
* @return RestClient
|
* @return RestClient
|
||||||
*/
|
*/
|
||||||
public function execute ()
|
public function execute ($getResponseIfDelete = false)
|
||||||
{
|
{
|
||||||
if ($this->method === "POST") {
|
if ($this->method === "POST") {
|
||||||
curl_setopt( $this->curl, CURLOPT_POST, true );
|
curl_setopt( $this->curl, CURLOPT_POST, true );
|
||||||
@@ -59,7 +59,7 @@ class RestClient
|
|||||||
}
|
}
|
||||||
curl_setopt( $this->curl, CURLOPT_URL, $this->url );
|
curl_setopt( $this->curl, CURLOPT_URL, $this->url );
|
||||||
$r = curl_exec( $this->curl );
|
$r = curl_exec( $this->curl );
|
||||||
if ($this->method !== "DELETE") {
|
if ($this->method !== "DELETE" || $getResponseIfDelete) {
|
||||||
$this->treatResponse( $r ); // Extract the headers and response
|
$this->treatResponse( $r ); // Extract the headers and response
|
||||||
return $this;
|
return $this;
|
||||||
} else {
|
} else {
|
||||||
@@ -325,9 +325,9 @@ class RestClient
|
|||||||
* @param string $password=null [optional]
|
* @param string $password=null [optional]
|
||||||
* @return RestClient
|
* @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]
|
* @param string $contentType=null [optional]
|
||||||
* @return RestClient
|
* @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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,12 +179,15 @@ function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pw
|
|||||||
*/
|
*/
|
||||||
function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd)
|
function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd)
|
||||||
{
|
{
|
||||||
|
$getResponse = true;
|
||||||
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
|
||||||
$alfresco_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml");
|
$alfresco_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml", $getResponse);
|
||||||
|
if($alfresco_exec->getResponseCode() === 204 && trim($alfresco_exec->getResponse()) === '') {
|
||||||
$alfresco_res = G::json_decode($alfresco_exec->getResponse());
|
$alfresco_res = true;
|
||||||
|
} else {
|
||||||
return $alfresco_res;
|
$alfresco_res = false;
|
||||||
|
}
|
||||||
|
return $getResponse ? $alfresco_res : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user