/** * fetch * * get the required data from the cmdb by getting the query from * the query object * * @access public * @return void */ public function fetch(QueryObj $queryObj) { /* check return value from query */ if (!($query = $queryObj->getQueryString())) { throw new CMDBException(self::BAD_QUERY_MSG); } if (!($queryUrl = $queryObj->getQueryUrl())) { throw new CMDBException(self::BAD_QUERY_URL); } /* Initialize Curl and Issue Request */ $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->m_curl_opt["http_header"]); curl_setopt($ch, CURLOPT_URL, $queryUrl); curl_setopt($ch, CURLOPT_USERPWD, $this->m_curl_opt["user_pwd"]); curl_setopt($ch, CURLOPT_USERAGENT, $this->m_curl_opt["user_agent"]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, $this->m_curl_opt["return_transfer"]); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->m_curl_opt["ssl_verify_peer"]); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->m_curl_opt["ssl_verify_host"]); curl_setopt($ch, CURLOPT_TIMEOUT, $this->m_curl_opt["timeout"]); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); /* Response or No Response ? */ $response = curl_exec($ch); $errno = curl_errno($ch); $errstr = curl_error($ch); curl_close($ch); if ($errno) { throw new CMDBException(self::BAD_CURL_MSG . $errno . " " . $errstr); } $result = NULL; if ($executor = $queryObj->getExecutorName()) { $result = $this->getObserver($executor)->execute($response); } else { throw new CMDBException(self::BAD_EXECUTOR_MSG); } return $result; }