log =& JLog :: getInstance(); $this -> db =& JFactory :: getDBO(); $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'thriftConnectorHost\';'); $host = $this -> db -> loadResult(); if ($host === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ('Error loading Thrift host: ' . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'thriftConnectorPort\';'); $port = $this -> db -> loadResult(); if ($port === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ('Error loading Thrift port: ' . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'thriftConnectorTimeout\';'); $timeout = $this -> db -> loadResult(); if ($timeout === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ('Error loading Thrift timeout: ' . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); // Create a thrift connection (Boiler plate) $socket = new TSocket($host, $port); $socket -> setRecvTimeout($timeout); $this -> transport = new TBufferedTransport($socket); $this -> client = new OpenAireConnectorClient(new TBinaryProtocol($this -> transport)); } public function addConversionJob($fileUrl, $format) { $this->transport->open(); try { $status = $this->client->addJob($fileUrl, $format); } catch (Exception $e) { $this -> log -> addEntry(array('level' => 'error', 'comment' => "Error converting file:\n$e")); return NULL; } $this->transport->close(); return $status; } public function getStatus($id) { $this->transport->open(); try { $status = $this->client->getStatus($id); } catch (Exception $e) { $this -> log -> addEntry(array('level' => 'error', 'comment' => "Error converting file:\n$e")); return NULL; } $this->transport->close(); return $status; } } ?>