BUG 0000 Feature Alfresco triggers
Added new trigger library for Alfresco DM methods
This commit is contained in:
319
gulliver/system/class.restClient.php
Normal file
319
gulliver/system/class.restClient.php
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RestClient
|
||||||
|
*/
|
||||||
|
class RestClient {
|
||||||
|
|
||||||
|
private $curl ;
|
||||||
|
private $url ;
|
||||||
|
private $response ="";
|
||||||
|
private $headers = array();
|
||||||
|
|
||||||
|
private $method="GET";
|
||||||
|
private $params=null;
|
||||||
|
private $contentType = null;
|
||||||
|
private $file =null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private Constructor, sets default options
|
||||||
|
*/
|
||||||
|
private function __construct() {
|
||||||
|
$this->curl = curl_init();
|
||||||
|
curl_setopt($this->curl,CURLOPT_RETURNTRANSFER,true);
|
||||||
|
curl_setopt($this->curl,CURLOPT_AUTOREFERER,true); // This make sure will follow redirects
|
||||||
|
curl_setopt($this->curl,CURLOPT_FOLLOWLOCATION,true); // This too
|
||||||
|
curl_setopt($this->curl,CURLOPT_HEADER,true); // THis verbose option for extracting the headers
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the call to the webservice
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function execute() {
|
||||||
|
if($this->method === "POST") {
|
||||||
|
curl_setopt($this->curl,CURLOPT_POST,true);
|
||||||
|
curl_setopt($this->curl,CURLOPT_POSTFIELDS,$this->params);
|
||||||
|
//var_dump($this->params);
|
||||||
|
//die;
|
||||||
|
} else if($this->method == "GET"){
|
||||||
|
curl_setopt($this->curl,CURLOPT_HTTPGET,true);
|
||||||
|
$this->treatURL();
|
||||||
|
} else if($this->method === "PUT") {
|
||||||
|
curl_setopt($this->curl,CURLOPT_PUT,true);
|
||||||
|
$this->treatURL();
|
||||||
|
$this->file = tmpFile();
|
||||||
|
fwrite($this->file,$this->params);
|
||||||
|
fseek($this->file,0);
|
||||||
|
curl_setopt($this->curl,CURLOPT_INFILE,$this->file);
|
||||||
|
curl_setopt($this->curl,CURLOPT_INFILESIZE,strlen($this->params));
|
||||||
|
} else {
|
||||||
|
curl_setopt($this->curl,CURLOPT_CUSTOMREQUEST,$this->method);
|
||||||
|
}
|
||||||
|
if($this->contentType != null) {
|
||||||
|
curl_setopt($this->curl,CURLOPT_HTTPHEADER,array("Content-Type: ".$this->contentType, "SKEY: 8QRtY5zXyViZ9fjYou"));
|
||||||
|
}
|
||||||
|
curl_setopt($this->curl,CURLOPT_URL,$this->url);
|
||||||
|
$r = curl_exec($this->curl);
|
||||||
|
if($this->method !== "DELETE")
|
||||||
|
{
|
||||||
|
$this->treatResponse($r); // Extract the headers and response
|
||||||
|
return $this ;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Treats URL
|
||||||
|
*/
|
||||||
|
private function treatURL(){
|
||||||
|
if(is_array($this->params) && count($this->params) >= 1) { // Transform parameters in key/value pars in URL
|
||||||
|
if(!strpos($this->url,'?'))
|
||||||
|
$this->url .= '?' ;
|
||||||
|
foreach($this->params as $k=>$v) {
|
||||||
|
$this->url .= "&".urlencode($k)."=".urlencode($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Treats the Response for extracting the Headers and Response
|
||||||
|
*/
|
||||||
|
private function treatResponse($r) {
|
||||||
|
if($r == null or strlen($r) < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$parts = explode("\n\r",$r); // HTTP packets define that Headers end in a blank line (\n\r) where starts the body
|
||||||
|
while(preg_match('@HTTP/1.[0-1] 100 Continue@',$parts[0]) or preg_match("@Moved@",$parts[0])) {
|
||||||
|
// Continue header must be bypass
|
||||||
|
for($i=1;$i<count($parts);$i++) {
|
||||||
|
$parts[$i - 1] = trim($parts[$i]);
|
||||||
|
}
|
||||||
|
unset($parts[count($parts) - 1]);
|
||||||
|
}
|
||||||
|
preg_match("@Content-Type: ([a-zA-Z0-9-]+/?[a-zA-Z0-9-]*)@",$parts[0],$reg);// This extract the content type
|
||||||
|
$this->headers['content-type'] = $reg[1];
|
||||||
|
preg_match("@HTTP/1.[0-1] ([0-9]{3}) ([a-zA-Z ]+)@",$parts[0],$reg); // This extracts the response header Code and Message
|
||||||
|
$this->headers['code'] = $reg[1];
|
||||||
|
$this->headers['message'] = $reg[2];
|
||||||
|
$this->response = "";
|
||||||
|
for($i=1;$i<count($parts);$i++) {//This make sure that exploded response get back togheter
|
||||||
|
if($i > 1) {
|
||||||
|
$this->response .= "\n\r";
|
||||||
|
}
|
||||||
|
$this->response .= $parts[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getHeaders() {
|
||||||
|
return $this->headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getResponse() {
|
||||||
|
return $this->response ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HTTP response code (404,401,200,etc)
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getResponseCode() {
|
||||||
|
return (int) $this->headers['code'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HTTP response message (Not Found, Continue, etc )
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getResponseMessage() {
|
||||||
|
return $this->headers['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Content-Type (text/plain, application/xml, etc)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getResponseContentType() {
|
||||||
|
return $this->headers['content-type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This sets that will not follow redirects
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function setNoFollow() {
|
||||||
|
curl_setopt($this->curl,CURLOPT_AUTOREFERER,false);
|
||||||
|
curl_setopt($this->curl,CURLOPT_FOLLOWLOCATION,false);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This closes the connection and release resources
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function close() {
|
||||||
|
curl_close($this->curl);
|
||||||
|
$this->curl = null ;
|
||||||
|
if($this->file !=null) {
|
||||||
|
fclose($this->file);
|
||||||
|
}
|
||||||
|
return $this ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the URL to be Called
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function setUrl($url) {
|
||||||
|
$this->url = $url;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Content-Type of the request to be send
|
||||||
|
* Format like "application/xml" or "text/plain" or other
|
||||||
|
* @param string $contentType
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function setContentType($contentType) {
|
||||||
|
$this->contentType = $contentType;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Credentials for BASIC Authentication
|
||||||
|
* @param string $user
|
||||||
|
* @param string $pass
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function setCredentials($user,$pass) {
|
||||||
|
if($user != null) {
|
||||||
|
curl_setopt($this->curl,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
|
||||||
|
curl_setopt($this->curl,CURLOPT_USERPWD,"{$user}:{$pass}");
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Request HTTP Method
|
||||||
|
* For now, only accepts GET and POST
|
||||||
|
* @param string $method
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function setMethod($method) {
|
||||||
|
$this->method=$method;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Parameters to be send on the request
|
||||||
|
* It can be both a key/value par array (as in array("key"=>"value"))
|
||||||
|
* or a string containing the body of the request, like a XML, JSON or other
|
||||||
|
* Proper content-type should be set for the body if not a array
|
||||||
|
* @param mixed $params
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public function setParameters($params) {
|
||||||
|
$this->params=$params;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the RESTClient
|
||||||
|
* @param string $url=null [optional]
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public static function createClient($url=null) {
|
||||||
|
$client = new RestClient ;
|
||||||
|
if($url != null) {
|
||||||
|
$client->setUrl($url);
|
||||||
|
}
|
||||||
|
return $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method wrapping a commom POST call
|
||||||
|
* @param string $url
|
||||||
|
* @param mixed params
|
||||||
|
* @param string $user=null [optional]
|
||||||
|
* @param string $password=null [optional]
|
||||||
|
* @param string $contentType="multpary/form-data" [optional] commom post (multipart/form-data) as default
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
//public static function post($url,$params=null,$user=null,$pwd=null,$contentType="multipart/form-data") {
|
||||||
|
public static function post($url,$params,$user,$pwd,$contentType="multipart/form-data") {
|
||||||
|
//return self::call("POST",$url,$params,$user,$pwd,$contentType);
|
||||||
|
return self::call("POST",$url,$params,$user,$pwd,$contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method wrapping a commom PUT call
|
||||||
|
* @param string $url
|
||||||
|
* @param string $body
|
||||||
|
* @param string $user=null [optional]
|
||||||
|
* @param string $password=null [optional]
|
||||||
|
* @param string $contentType=null [optional]
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public static function put($url,$body,$user=null,$pwd=null,$contentType=null) {
|
||||||
|
return self::call("PUT",$url,$body,$user,$pwd,$contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method wrapping a commom GET call
|
||||||
|
* @param string $url
|
||||||
|
* @param array params
|
||||||
|
* @param string $user=null [optional]
|
||||||
|
* @param string $password=null [optional]
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
//public static function get($url,array $params=null,$user=null,$pwd=null,$contentType=null) {
|
||||||
|
public static function get($url,$user,$pwd,$contentType=null) {
|
||||||
|
//return self::call("GET",$url,$params,$user,$pwd,$contentType);
|
||||||
|
return self::call("GET",$url,null,$user,$pwd,$contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method wrapping a commom delete call
|
||||||
|
* @param string $url
|
||||||
|
* @param array params
|
||||||
|
* @param string $user=null [optional]
|
||||||
|
* @param string $password=null [optional]
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public static function delete($url,$user=null,$pwd=null,$contentType=null) {
|
||||||
|
return self::call("DELETE",$url,null,$user,$pwd,$contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method wrapping a commom custom call
|
||||||
|
* @param string $method
|
||||||
|
* @param string $url
|
||||||
|
* @param string $body
|
||||||
|
* @param string $user=null [optional]
|
||||||
|
* @param string $password=null [optional]
|
||||||
|
* @param string $contentType=null [optional]
|
||||||
|
* @return RestClient
|
||||||
|
*/
|
||||||
|
public static function call($method,$url,$body,$user=null,$pwd=null,$contentType=null) {
|
||||||
|
return self::createClient($url)
|
||||||
|
->setParameters($body)
|
||||||
|
->setMethod($method)
|
||||||
|
->setCredentials($user,$pwd)
|
||||||
|
->setContentType($contentType)
|
||||||
|
->execute()
|
||||||
|
->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
296
workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php
Normal file
296
workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class.pmTrAlfresco.pmFunctions.php
|
||||||
|
*
|
||||||
|
* ProcessMaker Open Source Edition
|
||||||
|
* Copyright (C) 2004 - 2008 Colosa Inc.
|
||||||
|
* *
|
||||||
|
*/
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
// pmTrAlfresco PM Functions
|
||||||
|
//
|
||||||
|
// Copyright (C) 2007 COLOSA
|
||||||
|
//
|
||||||
|
// License: LGPL, see LICENSE
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alfresco Triggers that allow ProcessMaker to perform common DM actions
|
||||||
|
* @class pmTrAlfresco
|
||||||
|
* @name Alfresco DM Triggers v. 0.1
|
||||||
|
* @icon /images/triggers/alfrescoIcon.png
|
||||||
|
* @className class.pmTrAlfresco.pmFunctions.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Cancel Checkedout document/file
|
||||||
|
*
|
||||||
|
* @name cancelCheckout
|
||||||
|
* @label Cancel Checkedout document/file
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $docUid | Document Uid
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
G::LoadSystem('restClient');
|
||||||
|
// Validation left
|
||||||
|
function cancelCheckout($alfrescoServerUrl, $docUid, $user="", $pwd="") {
|
||||||
|
//require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrAlfresco.php');
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/s/workspace:SpacesStore/i/$docUid";
|
||||||
|
$domapi_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml;type=entry");
|
||||||
|
//$alfrescoMessage = $domapi_exec['header'];
|
||||||
|
$domapi_res = json_decode($domapi_exec->getResponse());
|
||||||
|
return $domapi_res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Checkin document/file
|
||||||
|
*
|
||||||
|
* @name Checkin
|
||||||
|
* @label Checkin document/file
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $docUid | Document Uid
|
||||||
|
* @param string | $comments | Comments
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// Validation done
|
||||||
|
function checkIn($alfrescoServerUrl, $docUid, $comments, $user="", $pwd="") {
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments";
|
||||||
|
$xmlData = array();
|
||||||
|
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"/>';
|
||||||
|
|
||||||
|
$alfresco_exec = RestClient::put($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml");
|
||||||
|
$alfrescoMessage = $alfresco_exec->getResponseMessage();
|
||||||
|
if($alfrescoMessage === 'OK' )
|
||||||
|
return "The Document has been Checkedin";
|
||||||
|
elseif ($alfrescoMessage === 'Internal Server Error')
|
||||||
|
return "Please enter a Valid Document Id";
|
||||||
|
else
|
||||||
|
return $alfrescoMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Checkout document/file
|
||||||
|
*
|
||||||
|
* @name Checkout
|
||||||
|
* @label Checkout document/file
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $docUid | Document Uid
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// Validation done
|
||||||
|
function checkOut($alfrescoServerUrl, $docUid, $user="", $pwd="") {
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout";
|
||||||
|
$xmlData = array();
|
||||||
|
$xmlData = '<?xml version="1.0" encoding="utf-8"?>'.'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">'.'<cmisra:object>'.'<cmis:properties>'.'<cmis:propertyId propertyDefinitionId="cmis:objectId">'.'<cmis:value>workspace://SpacesStore/'.$docUid.'</cmis:value>'.'</cmis:propertyId>'.'</cmis:properties>'.'</cmisra:object>'.'</entry>';
|
||||||
|
|
||||||
|
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml;type=entry");
|
||||||
|
$alfrescoMessage = $alfresco_exec->getResponseMessage();
|
||||||
|
if($alfrescoMessage === 'Created' )
|
||||||
|
return "The Document has been Checkedout";
|
||||||
|
elseif ($alfrescoMessage === 'Conflict')
|
||||||
|
return "The Document you are trying to checkout has already been Checkedout";
|
||||||
|
else
|
||||||
|
return $alfrescoMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Create a folder in Alfresco Repository
|
||||||
|
*
|
||||||
|
* @name createFolder
|
||||||
|
* @label Create a folder in Alfresco Repository
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $parentFolder | Parent Folder Name
|
||||||
|
* @param string | $folderName | Name of the Folder to be created
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd) {
|
||||||
|
//$domapi_url = "http://localhost:8086/alfresco/service/api/path/workspace/SpacesStore/9ee86211-cc3c-4348-beb0-5320635c2dcb/children";
|
||||||
|
$parentFolder = "$parentFolder/";
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/".$parentFolder."children";
|
||||||
|
$xmlData = array();
|
||||||
|
$xmlData = '<?xml version="1.0" encoding="utf-8"?>'.'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">'.'<title>'.$folderName.'</title>'.'<cmisra:object>'.'<cmis:properties>'.'<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId>'.'</cmis:properties>'.'</cmisra:object>'.'</entry>';
|
||||||
|
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml");
|
||||||
|
$alfrescoMessage = $alfresco_exec->getResponseMessage();
|
||||||
|
if($alfrescoMessage === 'Created')
|
||||||
|
return "The Folder has been Created";
|
||||||
|
else{
|
||||||
|
return $alfrescoMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Delete an object(Folder/File) from Alfresco Repository
|
||||||
|
*
|
||||||
|
* @name deleteObject
|
||||||
|
* @label Delete an object(Folder/File) from Alfresco Repository
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $objetcId | Id of the Object(Folder/File) to be deleted
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) {
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
|
||||||
|
$alfresco_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml");
|
||||||
|
|
||||||
|
$alfresco_res = json_decode($alfresco_exec->getResponse());
|
||||||
|
echo($alfresco_res);
|
||||||
|
return $alfresco_res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Download Document/File from Alfresco Repository
|
||||||
|
*
|
||||||
|
* @name downloadDoc
|
||||||
|
* @label Download Document/File from Alfresco Repository
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $objetcId | Id of the Object(Folder/File) to be deleted
|
||||||
|
* @param string | $parentFolder | Parent Folder Name
|
||||||
|
* @param string | $folderName | Name of the Folder to be created
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function downloadDoc($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd) {
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
|
||||||
|
$alfresco_exec = RestClient::delete($alfresco,$user,$pwd,"application/atom+xml");
|
||||||
|
$alfresco_res = json_decode($alfresco_exec->getResponse());
|
||||||
|
echo($alfresco_res);
|
||||||
|
return $alfresco_res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Get a list of Checkedout Document/File from Alfresco Repository
|
||||||
|
*
|
||||||
|
* @name getCheckedoutFiles
|
||||||
|
* @label Get a list of Checkedout Document/File from Alfresco Repository
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd) {
|
||||||
|
$getChildrenUrl = "$alfrescoServerUrl/s/cmis/checkedout";
|
||||||
|
|
||||||
|
$domapi_exec = RestClient::get($getChildrenUrl,$user,$pwd,'application/atom+xml');
|
||||||
|
$sXmlArray = json_decode($domapi_exec->getResponse());
|
||||||
|
$sXmlArray = trim($sXmlArray);
|
||||||
|
$xXmlArray = simplexml_load_string($sXmlArray);
|
||||||
|
$aXmlArray = @json_decode(@json_encode($xXmlArray),1);
|
||||||
|
var_dump($aXmlArray);
|
||||||
|
|
||||||
|
return $alfresco_res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Get Children of the given folder
|
||||||
|
*
|
||||||
|
* @name getFolderChildren
|
||||||
|
* @label Get Children of the given folder
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $folderId | FolderId of the Folder whose children is to be listed
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) {
|
||||||
|
$getChildrenUrl = "$alfrescoServerUrl/service/api/node/workspace/SpacesStore/$folderId/children";
|
||||||
|
$alfresco_exec = RestClient::get($getChildrenUrl,$user,$pwd);
|
||||||
|
$sXmlArray = $alfresco_exec->getResponse();
|
||||||
|
$sXmlArray = trim($sXmlArray);
|
||||||
|
$xXmlArray = simplexml_load_string($sXmlArray);
|
||||||
|
$aXmlArray = @json_decode(@json_encode($xXmlArray),1);
|
||||||
|
//var_dump($aXmlArray);
|
||||||
|
var_dump($aXmlArray);
|
||||||
|
|
||||||
|
return $aXmlArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* Uplaod file/document in Alfresco Repository
|
||||||
|
*
|
||||||
|
* @name uploadDoc
|
||||||
|
* @label Uplaod file/document in Alfresco Repository
|
||||||
|
*
|
||||||
|
* @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
|
||||||
|
* @param string | $fileSource | File Source
|
||||||
|
* @param string | $title | File Title
|
||||||
|
* @param string | $description | Description about File
|
||||||
|
* @param string | $docType | Type of document to be Uploaded
|
||||||
|
* @param string | $user | Valid Admin username to connect to Alfresco server
|
||||||
|
* @param string | $pwd | Valid Admin password to connect to Alfresco server
|
||||||
|
*
|
||||||
|
* @return string | $result | Response
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd) {
|
||||||
|
$filep = fopen($fileSource,"r");
|
||||||
|
$fileLength = filesize($fileSource);
|
||||||
|
$fileContent = fread($filep,$fileLength);
|
||||||
|
$fileContent = base64_encode($fileContent);
|
||||||
|
|
||||||
|
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/Sites/children";
|
||||||
|
$xmlData = array();
|
||||||
|
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>'.$title.'</title><summary>'.$description.'</summary><content type="application/'.$docType.'">'.$fileContent.'</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
|
||||||
|
|
||||||
|
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml");
|
||||||
|
$sXmlArray = $alfresco_exec->getResponse();
|
||||||
|
$sXmlArray = trim($sXmlArray);
|
||||||
|
$xXmlArray = simplexml_load_string($sXmlArray);
|
||||||
|
$aXmlArray = @json_decode(@json_encode($xXmlArray),1);
|
||||||
|
var_dump($aXmlArray);
|
||||||
|
return $aXmlArray;
|
||||||
|
}
|
||||||
BIN
workflow/public_html/images/triggers/alfrescoIcon.png
Normal file
BIN
workflow/public_html/images/triggers/alfrescoIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user