34include_once(
'Services/WebServices/ECS/classes/class.ilECSSetting.php');
 
   35include_once(
'Services/WebServices/ECS/classes/class.ilECSResult.php');
 
   36include_once(
'Services/WebServices/Curl/classes/class.ilCurlConnection.php');
 
   69                        $GLOBALS[
'ilLog']->write(__METHOD__.
': Using deprecated call');
 
   82                $this->header_strings[] = ($a_name.
': '.$a_value);
 
   92                $this->header_strings = $a_header_strings;
 
  118        public function addAuth($a_post,$a_target_mid)
 
  122                $ilLog->write(__METHOD__.
': Add new Auth resource...');
 
  124                $this->path_postfix = 
'/sys/auths';
 
  130                        $this->
addHeader(
'Content-Type', 
'application/json');
 
  131                        $this->
addHeader(
'Accept', 
'application/json');
 
  133                        #$this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, 1); 
  135                        $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  136                        $this->curl->setOpt(CURLOPT_POST,
true);
 
  137                        $this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post);
 
  140                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  142                        $ilLog->write(__METHOD__.
': Checking HTTP status...');
 
  143                        if($info != self::HTTP_CODE_CREATED)
 
  145                                $ilLog->write(__METHOD__.
': Cannot create auth resource, did not receive HTTP 201. ');
 
  146                                $ilLog->write(__METHOD__.
': POST was: '.$a_post);
 
  147                                $ilLog->write(__METHOD__.
': HTTP code: '.$info);
 
  150                        $ilLog->write(__METHOD__.
': ... got HTTP 201 (created)');
 
  151                        $ilLog->write(__METHOD__.
': POST was: '.$a_post);
 
  156                        $ilLog->write(__METHOD__.
': ... got hash: '.
$auth->hash);
 
  173        public function getAuth($a_hash, $a_details_only = FALSE)
 
  179                        $ilLog->write(__METHOD__.
': No auth hash given. Aborting.');
 
  183                $this->path_postfix = 
'/sys/auths/'.$a_hash;
 
  187                        $this->path_postfix .= (
'/details');
 
  195                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  197                        $ilLog->write(__METHOD__.
': Checking HTTP status...');
 
  198                        if($info != self::HTTP_CODE_OK)
 
  200                                $ilLog->write(__METHOD__.
': Cannot get auth resource, did not receive HTTP 200. ');
 
  203                        $ilLog->write(__METHOD__.
': ... got HTTP 200 (ok)');
 
  209                                include_once 
'./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
 
  211                                $details->loadFromJson($ecs_result->getResult());
 
  237                $this->path_postfix = 
'/eventqueues';
 
  244                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  246                        $ilLog->write(__METHOD__.
': Checking HTTP status...');
 
  247                        if($info != self::HTTP_CODE_OK)
 
  249                                $ilLog->write(__METHOD__.
': Cannot get event queue, did not receive HTTP 200. ');
 
  252                        $ilLog->write(__METHOD__.
': ... got HTTP 200 (ok)');                    
 
  261        ####################################################### 
  263        ##################################################### 
  274                $this->path_postfix = 
'/sys/events/fifo';
 
  278                        $this->
addHeader(
'Content-Type', 
'application/json');
 
  279                        $this->
addHeader(
'Accept', 
'application/json');
 
  283                                $this->curl->setOpt(CURLOPT_POST,
true);
 
  284                                $this->curl->setOpt(CURLOPT_POSTFIELDS, 
'');
 
  289                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  290                        #$ilLog->write(__METHOD__.': Checking HTTP status...'); 
  291                        if($info != self::HTTP_CODE_OK)
 
  293                                $ilLog->write(__METHOD__.
': Cannot read event fifo, did not receive HTTP 200. ');
 
  296                        #$ilLog->write(__METHOD__.': ... got HTTP 200 (ok)'); 
  300                        #$GLOBALS['ilLog']->write(__METHOD__.':------------------------------------- FIFO content'. print_r($result,true)); 
  318                $this->path_postfix = $a_path;
 
  322                        $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  326                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  327                        $ilLog->write(__METHOD__.
': Checking HTTP status...');
 
  328                        if($info != self::HTTP_CODE_OK)
 
  330                                $ilLog->write(__METHOD__.
': Cannot get ressource list, did not receive HTTP 200. ');
 
  333                        $ilLog->write(__METHOD__.
': ... got HTTP 200 (ok)');
 
  355        public function getResource($a_path, $a_econtent_id, $a_details_only = 
false)
 
  361                        $ilLog->write(__METHOD__.
': Get resource with ID: '.$a_econtent_id);
 
  365                        $ilLog->write(__METHOD__.
': Get all resources ...');
 
  368                $this->path_postfix = $a_path;
 
  371                        $this->path_postfix .= (
'/'.(int) $a_econtent_id);
 
  375                        $this->path_postfix .= (
'/details');
 
  384                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  385                        $ilLog->write(__METHOD__.
': Checking HTTP status...');
 
  386                        if($info != self::HTTP_CODE_OK)
 
  388                                $ilLog->write(__METHOD__.
': Cannot get ressource, did not receive HTTP 200. ');
 
  391                        $ilLog->write(__METHOD__.
': ... got HTTP 200 (ok)');
 
  394                        $result->setHeaders($this->curl->getResponseHeaderArray());
 
  419                $ilLog->write(__METHOD__.
': Add new EContent...');
 
  421                $this->path_postfix = $a_path;
 
  427                        $this->
addHeader(
'Content-Type', 
'application/json');
 
  429                        $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  430                        $this->curl->setOpt(CURLOPT_HEADER,
true);
 
  431                        $this->curl->setOpt(CURLOPT_POST,
true);
 
  432                        $this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post);
 
  435                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  437                        $ilLog->write(__METHOD__.
': Checking HTTP status...');
 
  438                        if($info != self::HTTP_CODE_CREATED)
 
  440                                $ilLog->write(__METHOD__.
': Cannot create econtent, did not receive HTTP 201. ');
 
  443                        $ilLog->write(__METHOD__.
': ... got HTTP 201 (created)');                       
 
  467                $ilLog->write(__METHOD__.
': Update resource with id '.$a_econtent_id);
 
  469                $this->path_postfix = $a_path;
 
  473                        $this->path_postfix .= (
'/'.(int) $a_econtent_id);
 
  482                        $this->
addHeader(
'Content-Type', 
'application/json');
 
  483                        $this->
addHeader(
'Accept', 
'application/json');
 
  484                        $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  485                        $this->curl->setOpt(CURLOPT_HEADER,
true);
 
  486                        $this->curl->setOpt(CURLOPT_PUT,
true);
 
  489                        $ilLog->write(__METHOD__.
': Created new tempfile: '.$tempfile);
 
  491                        $fp = fopen($tempfile,
'w');
 
  492                        fwrite($fp,$a_post_string);
 
  495                        $this->curl->setOpt(CURLOPT_UPLOAD,
true);
 
  496                        $this->curl->setOpt(CURLOPT_INFILESIZE,filesize($tempfile));
 
  497                        $fp = fopen($tempfile,
'r');
 
  498                        $this->curl->setOpt(CURLOPT_INFILE,$fp);
 
  525                $ilLog->write(__METHOD__.
': Delete resource with id '.$a_econtent_id);
 
  527                $this->path_postfix = $a_path;
 
  531                        $this->path_postfix .= (
'/'.(int) $a_econtent_id);
 
  541                        $this->curl->setOpt(CURLOPT_CUSTOMREQUEST,
'DELETE');
 
  567                $ilLog->write(__METHOD__.
': Get existing memberships');
 
  569                $this->path_postfix = 
'/sys/memberships';
 
  572                        $ilLog->write(__METHOD__.
': Read membership with id: '.$a_mid);
 
  573                        $this->path_postfix .= (
'/'.(int) $a_mid);
 
  580                        $this->curl->setOpt(CURLOPT_HTTPHEADER,array(0 => 
'X-EcsQueryStrings: sender=true'));
 
  583                        $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  584                        if($info != self::HTTP_CODE_OK)
 
  586                                $ilLog->write(__METHOD__.
': Cannot get memberships, did not receive HTTP 200. ');
 
  609                        $this->curl = 
new ilCurlConnection($this->settings->getServerURI().$this->path_postfix);
 
  611                        $this->curl->setOpt(CURLOPT_HTTPHEADER,array(0 => 
'Accept: application/json'));
 
  612                        $this->curl->setOpt(CURLOPT_RETURNTRANSFER,1);
 
  613                        $this->curl->setOpt(CURLOPT_VERBOSE,1);
 
  614                        $this->curl->setOpt(CURLOPT_TIMEOUT_MS,2000);
 
  616                        switch($this->
getServer()->getAuthType())
 
  619                                        $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER,0);
 
  620                                        #$this->curl->setOpt(CURLOPT_SSL_VERIFYHOST,0); 
  621                                        $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
 
  622                                        $this->curl->setOpt(CURLOPT_USERPWD,
 
  628                                        $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER,1);
 
  630                                        $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
 
  631                                        $this->curl->setOpt(CURLOPT_CAINFO,$this->settings->getCACertPath());
 
  632                                        $this->curl->setOpt(CURLOPT_SSLCERT,$this->settings->getClientCertPath());
 
  633                                        $this->curl->setOpt(CURLOPT_SSLKEY,$this->settings->getKeyPath());
 
  634                                        $this->curl->setOpt(CURLOPT_SSLKEYPASSWD,$this->settings->getKeyPassword());
 
  655                        $res = $this->curl->exec();
 
  677                if(!isset($a_header[
'Location']))
 
  681                $end_path = strrpos($a_header[
'Location'],
"/");
 
  683                if($end_path === 
false)
 
  685                        $ilLog->write(__METHOD__.
': Cannot find path seperator.');
 
  688                $econtent_id = substr($a_header[
'Location'],$end_path + 1);
 
  689                $ilLog->write(__METHOD__.
': Received EContentId '.$econtent_id);
 
  690                return (
int) $econtent_id;
 
deleteResource($a_path, $a_econtent_id)
Delete resource.
getMemberships($a_mid=0)
@access public
static _fetchEContentIdFromHeader($a_header)
fetch new econtent id from location header
const HTTP_CODE_NOT_FOUND
addHeader($a_name, $a_value)
Add Header.
readEventFifo($a_delete=false)
Read event fifo.
getResource($a_path, $a_econtent_id, $a_details_only=false)
Get resources from ECS server.
addResource($a_path, $a_post)
Add resource.
__construct(ilECSSetting $settings=null)
Constructor.
prepareConnection()
prepare connection
updateResource($a_path, $a_econtent_id, $a_post_string)
update resource
getAuth($a_hash, $a_details_only=FALSE)
get auth resource
getServer()
Get current server setting.
getEventQueues()
get event queue
addAuth($a_post, $a_target_mid)
Add auth resource.
setHeader($a_header_strings)
Presentation of ecs content details (http://...campusconnect/courselinks/id/details)
const RESULT_TYPE_URL_LIST
static ilTempnam()
Create a temporary file in an ILIAS writable directory.