diff --git a/src/Chullo.php b/src/Chullo.php index 49f9541..f15221c 100644 --- a/src/Chullo.php +++ b/src/Chullo.php @@ -153,11 +153,10 @@ public function getGraph( /** * Creates a new resource in Fedora. * - * @param string $uri Resource URI - * @param string $content String or binary content - * @param array $headers HTTP Headers - * @param string $transaction Transaction id - * @param string $checksum SHA-1 checksum + * @param string $uri Resource URI + * @param string $content String or binary content + * @param array $headers HTTP Headers + * @param string $transaction Transaction id * * @return string Uri of newly created resource or null if failed */ @@ -165,15 +164,13 @@ public function createResource( $uri = "", $content = null, $headers = [], - $transaction = "", - $checksum = "" + $transaction = "" ) { $response = $this->api->createResource( $uri, $content, $headers, - $transaction, - $checksum + $transaction ); if ($response->getStatusCode() != 201) { @@ -188,11 +185,10 @@ public function createResource( /** * Saves a resource in Fedora. * - * @param string $uri Resource URI - * @param string $content String or binary content - * @param array $headers HTTP Headers - * @param string $transaction Transaction id - * @param string $checksum SHA-1 checksum + * @param string $uri Resource URI + * @param string $content String or binary content + * @param array $headers HTTP Headers + * @param string $transaction Transaction id * * @return boolean True if successful */ @@ -200,15 +196,13 @@ public function saveResource( $uri, $content = null, $headers = [], - $transaction = "", - $checksum = "" + $transaction = "" ) { $response = $this->api->saveResource( $uri, $content, $headers, - $transaction, - $checksum + $transaction ); return $response->getStatusCode() == 204; @@ -232,15 +226,17 @@ public function saveGraph( $turtle = $graph->serialise('turtle'); // Checksum it. - $checksum = sha1($turtle); + $checksum_value = sha1($turtle); // Save it. return $this->saveResource( $uri, $turtle, - ['Content-Type' => 'text/turtle'], - $transaction, - $checksum + [ + 'Content-Type' => 'text/turtle', + 'digest' => 'sha1='.$checksum_value + ], + $transaction ); } diff --git a/src/FedoraApi.php b/src/FedoraApi.php index ca6a459..b90e22e 100644 --- a/src/FedoraApi.php +++ b/src/FedoraApi.php @@ -139,11 +139,10 @@ public function getResourceOptions($uri = "") /** * Creates a new resource in Fedora. * - * @param string $uri Resource URI - * @param string $content String or binary content - * @param array $headers HTTP Headers - * @param string $transaction Transaction id - * @param string $checksum SHA-1 checksum + * @param string $uri Resource URI + * @param string $content String or binary content + * @param array $headers HTTP Headers + * @param string $transaction Transaction id * * @return ResponseInterface */ @@ -151,8 +150,7 @@ public function createResource( $uri = "", $content = null, $headers = [], - $transaction = "", - $checksum = "" + $transaction = "" ) { $options = ['http_errors' => false]; @@ -162,11 +160,6 @@ public function createResource( // Set headers. $options['headers'] = $headers; - // Set query string. - if (!empty($checksum)) { - $options['query'] = ['checksum' => $checksum]; - } - // Ensure uri takes transaction into account. $uri = $this->prepareUri($uri, $transaction); @@ -180,11 +173,10 @@ public function createResource( /** * Saves a resource in Fedora. * - * @param string $uri Resource URI - * @param string $content String or binary content - * @param array $headers HTTP Headers - * @param string $transaction Transaction id - * @param string $checksum SHA-1 checksum + * @param string $uri Resource URI + * @param string $content String or binary content + * @param array $headers HTTP Headers + * @param string $transaction Transaction id * * @return ResponseInterface */ @@ -192,8 +184,7 @@ public function saveResource( $uri, $content = null, $headers = [], - $transaction = "", - $checksum = "" + $transaction = "" ) { $options = ['http_errors' => false]; @@ -203,11 +194,6 @@ public function saveResource( // Set headers. $options['headers'] = $headers; - // Set query string. - if (!empty($checksum)) { - $options['query'] = ['checksum' => $checksum]; - } - // Ensure uri takes transaction into account. $uri = $this->prepareUri($uri, $transaction); diff --git a/src/IFedoraApi.php b/src/IFedoraApi.php index 52e841b..65103c5 100644 --- a/src/IFedoraApi.php +++ b/src/IFedoraApi.php @@ -71,35 +71,31 @@ public function getResourceOptions($uri = ""); /** * Creates a new resource in Fedora. * - * @param string $uri Resource URI - * @param string $content String or binary content - * @param array $headers HTTP Headers - * @param string $transaction Transaction id - * @param string $checksum SHA-1 checksum + * @param string $uri Resource URI + * @param string $content String or binary content + * @param array $headers HTTP Headers + * @param string $transaction Transaction id */ public function createResource( $uri = "", $content = null, $headers = [], - $transaction = "", - $checksum = "" + $transaction = "" ); /** * Saves a resource in Fedora. * - * @param string $uri Resource URI - * @param string $content String or binary content - * @param array $headers HTTP Headers - * @param string $transaction Transaction id - * @param string $checksum SHA-1 checksum + * @param string $uri Resource URI + * @param string $content String or binary content + * @param array $headers HTTP Headers + * @param string $transaction Transaction id */ public function saveResource( $uri, $content = null, $headers = [], - $transaction = "", - $checksum = "" + $transaction = "" ); /** diff --git a/test/CreateTransactionTest.php b/test/CreateTransactionTest.php index 669c461..aaeee97 100644 --- a/test/CreateTransactionTest.php +++ b/test/CreateTransactionTest.php @@ -43,12 +43,12 @@ public function testReturnsNullOtherwise() ]); $handler = HandlerStack::create($mock); - $guzzle = new Client(['handler' => $handler]); + $guzzle = new Client(['handler' => $handler, 'base_uri' => 'http://localhost:8080/fcrepo/rest']); $api = new FedoraApi($guzzle); $client = new Chullo($api); //404 - $result = $client->createResource(); + $result = $client->createTransaction(); $this->assertNull($result); } }