public function testPublicAccess() { $instance = new RepositoryClient('Foo', 'Bar', 'Nu', 'Vim'); $this->assertSame('Foo', $instance->getDefaultGraph()); $this->assertSame('Bar', $instance->getQueryEndpoint()); $this->assertSame('Nu', $instance->getUpdateEndpoint()); $this->assertSame('Vim', $instance->getDataEndpoint()); }
/** * Execute a SPARQL update and return a boolean to indicate if the * operations was successful. The method throws exceptions based on * GenericHttpDatabaseConnector::mapHttpRequestError(). If errors occur and this * method does not throw anything, then false is returned. * * @note When this is written, it is not clear if the update protocol * supports a default-graph-uri parameter. Hence the target graph for * all updates is generally encoded in the query string and not fixed * when sending the query. Direct callers to this function must include * the graph information in the queries that they build. * * @param $sparql string with the complete SPARQL update query (INSERT or DELETE) * * @return boolean */ public function doUpdate($sparql) { if ($this->repositoryClient->getUpdateEndpoint() === '') { throw new BadHttpDatabaseResponseException(BadHttpDatabaseResponseException::ERROR_NOSERVICE, $sparql, 'not specified'); } $this->httpRequest->setOption(CURLOPT_URL, $this->repositoryClient->getUpdateEndpoint()); $this->httpRequest->setOption(CURLOPT_POST, true); $parameterString = "update=" . urlencode($sparql); $this->httpRequest->setOption(CURLOPT_POSTFIELDS, $parameterString); $this->httpRequest->setOption(CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded;charset=UTF-8')); $this->httpRequest->execute(); if ($this->httpRequest->getLastErrorCode() == 0) { return true; } $this->mapHttpRequestError($this->repositoryClient->getUpdateEndpoint(), $sparql); return false; }