ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilECSCourseUrlConnector Class Reference

Connector for writing ecs course urls. More...

+ Inheritance diagram for ilECSCourseUrlConnector:
+ Collaboration diagram for ilECSCourseUrlConnector:

Public Member Functions

 __construct (ilECSSetting $settings=null)
 Constructor. More...
 
 addUrl (ilECSCourseUrl $url, $a_target_mid)
 Send url of newly created courses to ecs. More...
 
- Public Member Functions inherited from ilECSConnector
 __construct (ilECSSetting $settings=null)
 Constructor. More...
 
 addHeader ($a_name, $a_value)
 Add Header. More...
 
 getHeader ()
 
 setHeader ($a_header_strings)
 
 getServer ()
 Get current server setting. More...
 
 addAuth ($a_post, $a_target_mid)
 Add auth resource. More...
 
 getAuth ($a_hash, $a_details_only=false)
 get auth resource More...
 
 getEventQueues ()
 get event queue More...
 
 readEventFifo ($a_delete=false)
 Read event fifo. More...
 
 getResourceList ($a_path)
 
 getResource ($a_path, $a_econtent_id, $a_details_only=false)
 Get resources from ECS server. More...
 
 addResource ($a_path, $a_post)
 Add resource. More...
 
 updateResource ($a_path, $a_econtent_id, $a_post_string)
 update resource More...
 
 deleteResource ($a_path, $a_econtent_id)
 Delete resource. More...
 
 getMemberships ($a_mid=0)
 public More...
 

Additional Inherited Members

- Data Fields inherited from ilECSConnector
const HTTP_CODE_CREATED = 201
 
const HTTP_CODE_OK = 200
 
const HTTP_CODE_NOT_FOUND = 404
 
const HEADER_MEMBERSHIPS = 'X-EcsReceiverMemberships'
 
const HEADER_COMMUNITIES = 'X-EcsReceiverCommunities'
 
- Protected Member Functions inherited from ilECSConnector
 prepareConnection ()
 prepare connection More...
 
 call ()
 call peer More...
 
- Static Protected Member Functions inherited from ilECSConnector
static _fetchEContentIdFromHeader ($a_header)
 fetch new econtent id from location header More...
 
- Protected Attributes inherited from ilECSConnector
 $path_postfix = ''
 
 $settings
 
 $header_strings = array()
 

Detailed Description

Connector for writing ecs course urls.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e $Id$

Definition at line 13 of file class.ilECSCourseUrlConnector.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCourseUrlConnector::__construct ( ilECSSetting  $settings = null)

Constructor.

Parameters
ilECSSetting$settings

Definition at line 19 of file class.ilECSCourseUrlConnector.php.

References ilECSConnector\$settings.

20  {
21  parent::__construct($settings);
22  }

Member Function Documentation

◆ addUrl()

ilECSCourseUrlConnector::addUrl ( ilECSCourseUrl  $url,
  $a_target_mid 
)

Send url of newly created courses to ecs.

Returns
type
Exceptions
ilECSConnectorException

Definition at line 29 of file class.ilECSCourseUrlConnector.php.

References $GLOBALS, $ilLog, $info, $ret, ilECSConnector\addHeader(), ilECSConnector\call(), ilECSConnector\getHeader(), ilECSConnector\HEADER_MEMBERSHIPS, and ilECSConnector\prepareConnection().

30  {
31  global $ilLog;
32 
33  $ilLog->write(__METHOD__ . ': Add new course url ...');
34 
35  $this->path_postfix = '/campusconnect/course_urls';
36 
37  try {
38  $this->prepareConnection();
39 
40  $this->addHeader('Content-Type', 'application/json');
41  $this->addHeader('Accept', 'application/json');
42  $this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, $a_target_mid);
43 
44  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
45  $this->curl->setOpt(CURLOPT_POST, true);
46  $this->curl->setOpt(CURLOPT_POSTFIELDS, json_encode($url));
47 
48  $GLOBALS['ilLog']->write(__METHOD__ . ': Sending url ' . print_r(json_encode($url), true));
49 
50  $ret = $this->call();
51 
52  $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
53 
54  $ilLog->write(__METHOD__ . ': Checking HTTP status...');
55  if ($info != self::HTTP_CODE_CREATED) {
56  $ilLog->write(__METHOD__ . ': Cannot create course url ressource, did not receive HTTP 201. ');
57  $ilLog->write(__METHOD__ . ': POST was: ' . json_encode($url));
58  $ilLog->write(__METHOD__ . ': HTTP code: ' . $info);
59  throw new ilECSConnectorException('Received HTTP status code: ' . $info);
60  }
61  $ilLog->write(__METHOD__ . ': ... got HTTP 201 (created)');
62  } catch (ilCurlConnectionException $exc) {
63  throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
64  }
65  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$ret
Definition: parser.php:6
addHeader($a_name, $a_value)
Add Header.
prepareConnection()
prepare connection
$info
Definition: index.php:5
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: