protected function EasyRdf_GraphStore::sendGraph

Send some graph data to the graph store

This method is used by insert() and replace()

@ignore

2 calls to EasyRdf_GraphStore::sendGraph()
EasyRdf_GraphStore::insert in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php
Add data to a graph in the graph store
EasyRdf_GraphStore::replace in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php
Replace the contents of a graph in the graph store with new data

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php, line 96

Class

EasyRdf_GraphStore
A class for fetching, saving and deleting graphs to a Graph Store. Implementation of the SPARQL 1.1 Graph Store HTTP Protocol.

Code

protected function sendGraph($method, $graph, $uriRef, $format) {
  if (is_object($graph) and $graph instanceof EasyRdf_Graph) {
    if ($uriRef == null) {
      $uriRef = $graph
        ->getUri();
    }
    $data = $graph
      ->serialise($format);
  }
  else {
    $data = $graph;
  }
  $formatObj = EasyRdf_Format::getFormat($format);
  $mimeType = $formatObj
    ->getDefaultMimeType();
  $graphUri = $this->parsedUri
    ->resolve($uriRef)
    ->toString();
  $dataUrl = $this
    ->urlForGraph($graphUri);
  $client = EasyRdf_Http::getDefaultHttpClient();
  $client
    ->resetParameters(true);
  $client
    ->setUri($dataUrl);
  $client
    ->setMethod($method);
  $client
    ->setRawData($data);
  $client
    ->setHeaders('Content-Type', $mimeType);
  $client
    ->setHeaders('Content-Length', strlen($data));
  $response = $client
    ->request();
  if (!$response
    ->isSuccessful()) {
    throw new EasyRdf_Exception("HTTP request for {$dataUrl} failed: " . $response
      ->getMessage());
  }
  return $response;
}