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');
 
   66            $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Using deprecated call');
 
   79        $this->header_strings[] = ($a_name . 
': ' . $a_value);
 
   89        $this->header_strings = $a_header_strings;
 
  115    public function addAuth($a_post, $a_target_mid)
 
  119        $ilLog->write(__METHOD__ . 
': Add new Auth resource...');
 
  121        $this->path_postfix = 
'/sys/auths';
 
  126            $this->
addHeader(
'Content-Type', 
'application/json');
 
  127            $this->
addHeader(
'Accept', 
'application/json');
 
  129            #$this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, 1); 
  131            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  132            $this->curl->setOpt(CURLOPT_POST, 
true);
 
  133            $this->curl->setOpt(CURLOPT_POSTFIELDS, $a_post);
 
  136            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  138            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  139            if (
$info != self::HTTP_CODE_CREATED) {
 
  140                $ilLog->write(__METHOD__ . 
': Cannot create auth resource, did not receive HTTP 201. ');
 
  141                $ilLog->write(__METHOD__ . 
': POST was: ' . $a_post);
 
  142                $ilLog->write(__METHOD__ . 
': HTTP code: ' . 
$info);
 
  145            $ilLog->write(__METHOD__ . 
': ... got HTTP 201 (created)');
 
  146            $ilLog->write(__METHOD__ . 
': POST was: ' . $a_post);
 
  151            $ilLog->write(__METHOD__ . 
': ... got hash: ' . 
$auth->hash);
 
  166    public function getAuth($a_hash, $a_details_only = 
false)
 
  170        if (!strlen($a_hash)) {
 
  171            $ilLog->write(__METHOD__ . 
': No auth hash given. Aborting.');
 
  175        $this->path_postfix = 
'/sys/auths/' . $a_hash;
 
  177        if ($a_details_only) {
 
  178            $this->path_postfix .= (
'/details');
 
  185            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  187            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  188            if (
$info != self::HTTP_CODE_OK) {
 
  189                $ilLog->write(__METHOD__ . 
': Cannot get auth resource, did not receive HTTP 200. ');
 
  192            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  196            if ($a_details_only) {
 
  197                include_once 
'./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
 
  199                $details->loadFromJson($ecs_result->getResult());
 
  223        $this->path_postfix = 
'/eventqueues';
 
  229            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  231            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  232            if (
$info != self::HTTP_CODE_OK) {
 
  233                $ilLog->write(__METHOD__ . 
': Cannot get event queue, did not receive HTTP 200. ');
 
  236            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  243    ####################################################### 
  245    ##################################################### 
  256        $this->path_postfix = 
'/sys/events/fifo';
 
  260            $this->
addHeader(
'Content-Type', 
'application/json');
 
  261            $this->
addHeader(
'Accept', 
'application/json');
 
  264                $this->curl->setOpt(CURLOPT_POST, 
true);
 
  265                $this->curl->setOpt(CURLOPT_POSTFIELDS, 
'');
 
  270            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  271            #$ilLog->write(__METHOD__.': Checking HTTP status...'); 
  272            if (
$info != self::HTTP_CODE_OK) {
 
  273                $ilLog->write(__METHOD__ . 
': Cannot read event fifo, did not receive HTTP 200. ');
 
  276            #$ilLog->write(__METHOD__.': ... got HTTP 200 (ok)'); 
  280            #$GLOBALS['ilLog']->write(__METHOD__.':------------------------------------- FIFO content'. print_r($result,true)); 
  296        $this->path_postfix = $a_path;
 
  300            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  304            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  305            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  306            if (
$info != self::HTTP_CODE_OK) {
 
  307                $ilLog->write(__METHOD__ . 
': Cannot get ressource list, did not receive HTTP 200. ');
 
  310            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  330    public function getResource($a_path, $a_econtent_id, $a_details_only = 
false)
 
  334        if ($a_econtent_id) {
 
  335            $ilLog->write(__METHOD__ . 
': Get resource with ID: ' . $a_econtent_id);
 
  337            $ilLog->write(__METHOD__ . 
': Get all resources ...');
 
  340        $this->path_postfix = $a_path;
 
  341        if ($a_econtent_id) {
 
  342            $this->path_postfix .= (
'/' . (int) $a_econtent_id);
 
  344        if ($a_details_only) {
 
  345            $this->path_postfix .= (
'/details');
 
  353            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  354            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  355            if (
$info != self::HTTP_CODE_OK) {
 
  356                $ilLog->write(__METHOD__ . 
': Cannot get ressource, did not receive HTTP 200. ');
 
  359            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  362            $result->setHeaders($this->curl->getResponseHeaderArray());
 
  385        $ilLog->write(__METHOD__ . 
': Add new EContent...');
 
  387        $this->path_postfix = $a_path;
 
  392            $this->
addHeader(
'Content-Type', 
'application/json');
 
  394            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  395            $this->curl->setOpt(CURLOPT_HEADER, 
true);
 
  396            $this->curl->setOpt(CURLOPT_POST, 
true);
 
  397            $this->curl->setOpt(CURLOPT_POSTFIELDS, $a_post);
 
  400            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  402            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  403            if (
$info != self::HTTP_CODE_CREATED) {
 
  404                $ilLog->write(__METHOD__ . 
': Cannot create econtent, did not receive HTTP 201. ');
 
  407            $ilLog->write(__METHOD__ . 
': ... got HTTP 201 (created)');
 
  429        $ilLog->write(__METHOD__ . 
': Update resource with id ' . $a_econtent_id);
 
  431        $this->path_postfix = $a_path;
 
  433        if ($a_econtent_id) {
 
  434            $this->path_postfix .= (
'/' . (int) $a_econtent_id);
 
  440            $this->
addHeader(
'Content-Type', 
'application/json');
 
  441            $this->
addHeader(
'Accept', 
'application/json');
 
  442            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  443            $this->curl->setOpt(CURLOPT_HEADER, 
true);
 
  444            $this->curl->setOpt(CURLOPT_PUT, 
true);
 
  447            $ilLog->write(__METHOD__ . 
': Created new tempfile: ' . $tempfile);
 
  449            $fp = fopen($tempfile, 
'w');
 
  450            fwrite($fp, $a_post_string);
 
  453            $this->curl->setOpt(CURLOPT_UPLOAD, 
true);
 
  454            $this->curl->setOpt(CURLOPT_INFILESIZE, filesize($tempfile));
 
  455            $fp = fopen($tempfile, 
'r');
 
  456            $this->curl->setOpt(CURLOPT_INFILE, $fp);
 
  481        $ilLog->write(__METHOD__ . 
': Delete resource with id ' . $a_econtent_id);
 
  483        $this->path_postfix = $a_path;
 
  485        if ($a_econtent_id) {
 
  486            $this->path_postfix .= (
'/' . (int) $a_econtent_id);
 
  493            $this->curl->setOpt(CURLOPT_CUSTOMREQUEST, 
'DELETE');
 
  516        $ilLog->write(__METHOD__ . 
': Get existing memberships');
 
  518        $this->path_postfix = 
'/sys/memberships';
 
  520            $ilLog->write(__METHOD__ . 
': Read membership with id: ' . $a_mid);
 
  521            $this->path_postfix .= (
'/' . (int) $a_mid);
 
  527            $this->curl->setOpt(CURLOPT_HTTPHEADER, array(0 => 
'X-EcsQueryStrings: sender=true'));
 
  530            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  531            if (
$info != self::HTTP_CODE_OK) {
 
  532                $ilLog->write(__METHOD__ . 
': Cannot get memberships, did not receive HTTP 200. ');
 
  553            $this->curl->setOpt(CURLOPT_HTTPHEADER, array(0 => 
'Accept: application/json'));
 
  554            $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
 
  555            $this->curl->setOpt(CURLOPT_VERBOSE, 1);
 
  556            $this->curl->setOpt(CURLOPT_TIMEOUT_MS, 2000);
 
  558            switch ($this->
getServer()->getAuthType()) {
 
  560                    $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
 
  561                    #$this->curl->setOpt(CURLOPT_SSL_VERIFYHOST,0); 
  562                    $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
 
  570                    $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 1);
 
  572                    $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 2);
 
  573                    $this->curl->setOpt(CURLOPT_CAINFO, $this->
settings->getCACertPath());
 
  574                    $this->curl->setOpt(CURLOPT_SSLCERT, $this->
settings->getClientCertPath());
 
  575                    $this->curl->setOpt(CURLOPT_SSLKEY, $this->
settings->getKeyPath());
 
  576                    $this->curl->setOpt(CURLOPT_SSLKEYPASSWD, $this->
settings->getKeyPassword());
 
  594            $res = $this->curl->exec();
 
  614        if (!isset($a_header[
'Location'])) {
 
  617        $end_path = strrpos($a_header[
'Location'], 
"/");
 
  619        if ($end_path === 
false) {
 
  620            $ilLog->write(__METHOD__ . 
': Cannot find path seperator.');
 
  623        $econtent_id = substr($a_header[
'Location'], $end_path + 1);
 
  624        $ilLog->write(__METHOD__ . 
': Received EContentId ' . $econtent_id);
 
  625        return (
int) $econtent_id;
 
An exception for terminatinating execution or to throw for unit testing.
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
getServer()
Get current server setting.
getEventQueues()
get event queue
getAuth($a_hash, $a_details_only=false)
get auth resource
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($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res