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[
'DIC'][
'ilLog']->write(__METHOD__ . 
': Using deprecated call');
 
   67            $GLOBALS[
'DIC'][
'ilLog']->logStack();
 
   79        $this->header_strings[] = ($a_name . 
': ' . $a_value);
 
   89        $this->header_strings = $a_header_strings;
 
  115    public function addAuth($a_post, $a_target_mid)
 
  121        $ilLog->write(__METHOD__ . 
': Add new Auth resource...');
 
  123        $this->path_postfix = 
'/sys/auths';
 
  128            $this->
addHeader(
'Content-Type', 
'application/json');
 
  129            $this->
addHeader(
'Accept', 
'application/json');
 
  131            #$this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, 1); 
  133            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  134            $this->curl->setOpt(CURLOPT_POST, 
true);
 
  135            $this->curl->setOpt(CURLOPT_POSTFIELDS, $a_post);
 
  138            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  140            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  141            if (
$info != self::HTTP_CODE_CREATED) {
 
  142                $ilLog->write(__METHOD__ . 
': Cannot create auth resource, did not receive HTTP 201. ');
 
  143                $ilLog->write(__METHOD__ . 
': POST was: ' . $a_post);
 
  144                $ilLog->write(__METHOD__ . 
': HTTP code: ' . 
$info);
 
  147            $ilLog->write(__METHOD__ . 
': ... got HTTP 201 (created)');
 
  148            $ilLog->write(__METHOD__ . 
': POST was: ' . $a_post);
 
  153            $ilLog->write(__METHOD__ . 
': ... got hash: ' . 
$auth->hash);
 
  168    public function getAuth($a_hash, $a_details_only = 
false)
 
  174        if (!strlen($a_hash)) {
 
  175            $ilLog->write(__METHOD__ . 
': No auth hash given. Aborting.');
 
  179        $this->path_postfix = 
'/sys/auths/' . $a_hash;
 
  181        if ($a_details_only) {
 
  182            $this->path_postfix .= (
'/details');
 
  189            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  191            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  192            if (
$info != self::HTTP_CODE_OK) {
 
  193                $ilLog->write(__METHOD__ . 
': Cannot get auth resource, did not receive HTTP 200. ');
 
  196            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  200            if ($a_details_only) {
 
  201                include_once 
'./Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
 
  203                $details->loadFromJson($ecs_result->getResult());
 
  229        $this->path_postfix = 
'/eventqueues';
 
  235            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  237            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  238            if (
$info != self::HTTP_CODE_OK) {
 
  239                $ilLog->write(__METHOD__ . 
': Cannot get event queue, did not receive HTTP 200. ');
 
  242            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  249    ####################################################### 
  251    ##################################################### 
  264        $this->path_postfix = 
'/sys/events/fifo';
 
  268            $this->
addHeader(
'Content-Type', 
'application/json');
 
  269            $this->
addHeader(
'Accept', 
'application/json');
 
  272                $this->curl->setOpt(CURLOPT_POST, 
true);
 
  273                $this->curl->setOpt(CURLOPT_POSTFIELDS, 
'');
 
  278            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  279            #$ilLog->write(__METHOD__.': Checking HTTP status...'); 
  280            if (
$info != self::HTTP_CODE_OK) {
 
  281                $ilLog->write(__METHOD__ . 
': Cannot read event fifo, did not receive HTTP 200. ');
 
  284            #$ilLog->write(__METHOD__.': ... got HTTP 200 (ok)'); 
  288            #$GLOBALS['DIC']['ilLog']->write(__METHOD__.':------------------------------------- FIFO content'. print_r($result,true)); 
  294            $this->curl->close();
 
  308        $this->path_postfix = $a_path;
 
  312            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  316            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  317            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  318            if (
$info != self::HTTP_CODE_OK) {
 
  319                $ilLog->write(__METHOD__ . 
': Cannot get ressource list, did not receive HTTP 200. ');
 
  322            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  342    public function getResource($a_path, $a_econtent_id, $a_details_only = 
false)
 
  348        if ($a_econtent_id) {
 
  349            $ilLog->write(__METHOD__ . 
': Get resource with ID: ' . $a_econtent_id);
 
  351            $ilLog->write(__METHOD__ . 
': Get all resources ...');
 
  354        $this->path_postfix = $a_path;
 
  355        if ($a_econtent_id) {
 
  356            $this->path_postfix .= (
'/' . (int) $a_econtent_id);
 
  358        if ($a_details_only) {
 
  359            $this->path_postfix .= (
'/details');
 
  367            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  368            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  369            if (
$info != self::HTTP_CODE_OK) {
 
  370                $ilLog->write(__METHOD__ . 
': Cannot get ressource, did not receive HTTP 200. ');
 
  373            $ilLog->write(__METHOD__ . 
': ... got HTTP 200 (ok)');
 
  376            $result->setHeaders($this->curl->getResponseHeaderArray());
 
  401        $ilLog->write(__METHOD__ . 
': Add new EContent...');
 
  403        $this->path_postfix = $a_path;
 
  408            $this->
addHeader(
'Content-Type', 
'application/json');
 
  410            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  411            $this->curl->setOpt(CURLOPT_HEADER, 
true);
 
  412            $this->curl->setOpt(CURLOPT_POST, 
true);
 
  413            $this->curl->setOpt(CURLOPT_POSTFIELDS, $a_post);
 
  416            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  418            $ilLog->write(__METHOD__ . 
': Checking HTTP status...');
 
  419            if (
$info != self::HTTP_CODE_CREATED) {
 
  420                $ilLog->write(__METHOD__ . 
': Cannot create econtent, did not receive HTTP 201. ');
 
  423            $ilLog->write(__METHOD__ . 
': ... got HTTP 201 (created)');
 
  447        $ilLog->write(__METHOD__ . 
': Update resource with id ' . $a_econtent_id);
 
  449        $this->path_postfix = $a_path;
 
  451        if ($a_econtent_id) {
 
  452            $this->path_postfix .= (
'/' . (int) $a_econtent_id);
 
  458            $this->
addHeader(
'Content-Type', 
'application/json');
 
  459            $this->
addHeader(
'Accept', 
'application/json');
 
  460            $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->
getHeader());
 
  461            $this->curl->setOpt(CURLOPT_HEADER, 
true);
 
  462            $this->curl->setOpt(CURLOPT_PUT, 
true);
 
  465            $ilLog->write(__METHOD__ . 
': Created new tempfile: ' . $tempfile);
 
  467            $fp = fopen($tempfile, 
'w');
 
  468            fwrite($fp, $a_post_string);
 
  471            $this->curl->setOpt(CURLOPT_UPLOAD, 
true);
 
  472            $this->curl->setOpt(CURLOPT_INFILESIZE, filesize($tempfile));
 
  473            $fp = fopen($tempfile, 
'r');
 
  474            $this->curl->setOpt(CURLOPT_INFILE, $fp);
 
  501        $ilLog->write(__METHOD__ . 
': Delete resource with id ' . $a_econtent_id);
 
  503        $this->path_postfix = $a_path;
 
  505        if ($a_econtent_id) {
 
  506            $this->path_postfix .= (
'/' . (int) $a_econtent_id);
 
  513            $this->curl->setOpt(CURLOPT_CUSTOMREQUEST, 
'DELETE');
 
  538        $ilLog->write(__METHOD__ . 
': Get existing memberships');
 
  540        $this->path_postfix = 
'/sys/memberships';
 
  542            $ilLog->write(__METHOD__ . 
': Read membership with id: ' . $a_mid);
 
  543            $this->path_postfix .= (
'/' . (int) $a_mid);
 
  549            $this->curl->setOpt(CURLOPT_HTTPHEADER, array(0 => 
'X-EcsQueryStrings: sender=true'));
 
  552            $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
 
  553            if (
$info != self::HTTP_CODE_OK) {
 
  554                $ilLog->write(__METHOD__ . 
': Cannot get memberships, did not receive HTTP 200. ');
 
  575            $this->curl->setOpt(CURLOPT_HTTPHEADER, array(0 => 
'Accept: application/json'));
 
  576            $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
 
  577            $this->curl->setOpt(CURLOPT_VERBOSE, 1);
 
  578            $this->curl->setOpt(CURLOPT_TIMEOUT_MS, 2000);
 
  580            switch ($this->
getServer()->getAuthType()) {
 
  582                    $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
 
  583                    #$this->curl->setOpt(CURLOPT_SSL_VERIFYHOST,0); 
  584                    $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
 
  592                    $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 1);
 
  594                    $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 2);
 
  595                    $this->curl->setOpt(CURLOPT_CAINFO, $this->
settings->getCACertPath());
 
  596                    $this->curl->setOpt(CURLOPT_SSLCERT, $this->
settings->getClientCertPath());
 
  597                    $this->curl->setOpt(CURLOPT_SSLKEY, $this->
settings->getKeyPath());
 
  598                    $this->curl->setOpt(CURLOPT_SSLKEYPASSWD, $this->
settings->getKeyPassword());
 
  616            $res = $this->curl->exec();
 
  638        if (!isset($a_header[
'Location'])) {
 
  641        $end_path = strrpos($a_header[
'Location'], 
"/");
 
  643        if ($end_path === 
false) {
 
  644            $ilLog->write(__METHOD__ . 
': Cannot find path seperator.');
 
  647        $econtent_id = substr($a_header[
'Location'], $end_path + 1);
 
  648        $ilLog->write(__METHOD__ . 
': Received EContentId ' . $econtent_id);
 
  649        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)
Returns a unique and non existing Path for e temporary file or directory.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
foreach($_POST as $key=> $value) $res