diff --git a/src/Chullo.php b/src/Chullo.php index f013275..ab6c179 100644 --- a/src/Chullo.php +++ b/src/Chullo.php @@ -58,19 +58,16 @@ public function getBaseUri() * * @param string $uri Resource URI * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return mixed Full response if found. Null otherwise. */ public function getResource( $uri = "", - $headers = [], - $transaction = "" + $headers = [] ) { $response = $this->api->getResource( $uri, - $headers, - $transaction + $headers ); if ($response->getStatusCode() != 200) { return null; @@ -83,17 +80,14 @@ public function getResource( * Gets a Fedora resource's headers. * * @param string $uri Resource URI - * @param string $transaction Transaction id * * @return array Headers of a resource, null on failure */ public function getResourceHeaders( - $uri = "", - $transaction = "" + $uri = "" ) { $response = $this->api->getResourceHeaders( - $uri, - $transaction + $uri ); if ($response->getStatusCode() != 200) { @@ -124,17 +118,15 @@ public function getResourceOptions($uri = "") * * @param string $uri Resource URI * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return EasyRdf_Graph EasyRdf_Graph if found, null otherwise */ public function getGraph( $uri = "", - $headers = [], - $transaction = "" + $headers = [] ) { $headers['Accept'] = 'application/ld+json'; - $rdf = $this->getResource($uri, $headers, $transaction); + $rdf = $this->getResource($uri, $headers); if (empty($rdf)) { return null; } @@ -150,21 +142,18 @@ public function getGraph( * @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 */ public function createResource( $uri = "", $content = null, - $headers = [], - $transaction = "" + $headers = [] ) { $response = $this->api->createResource( $uri, $content, - $headers, - $transaction + $headers ); if ($response->getStatusCode() != 201) { @@ -182,21 +171,18 @@ public function createResource( * @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 */ public function saveResource( $uri, $content = null, - $headers = [], - $transaction = "" + $headers = [] ) { $response = $this->api->saveResource( $uri, $content, - $headers, - $transaction + $headers ); return $response->getStatusCode() == 204; @@ -207,14 +193,12 @@ public function saveResource( * * @param string $uri Resource URI * @param EasyRdf_Resource $graph Graph to save - * @param string $transaction Transaction id * * @return boolean True if successful */ public function saveGraph( $uri, - \EasyRdf_Graph $graph, - $transaction = "" + \EasyRdf_Graph $graph ) { // Serialze the rdf. $turtle = $graph->serialise('turtle'); @@ -229,8 +213,7 @@ public function saveGraph( [ 'Content-Type' => 'text/turtle', 'digest' => 'sha1='.$checksum_value - ], - $transaction + ] ); } @@ -240,21 +223,18 @@ public function saveGraph( * @param string $uri Resource URI * @param string $sparql SPARQL Update query * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return boolean True if successful */ public function modifyResource( $uri, $sparql = "", - $headers = [], - $transaction = "" + $headers = [] ) { $response = $this->api->modifyResource( $uri, $sparql, - $headers, - $transaction + $headers ); return $response->getStatusCode() == 204; @@ -264,17 +244,14 @@ public function modifyResource( * Issues a DELETE request to Fedora. * * @param string $uri Resource URI - * @param string $transaction Transaction id * * @return boolean True if successful */ public function deleteResource( - $uri, - $transaction = "" + $uri ) { $response = $this->api->deleteResource( - $uri, - $transaction + $uri ); return $response->getStatusCode() == 204; diff --git a/src/FedoraApi.php b/src/FedoraApi.php index ca4020c..9e5b01a 100644 --- a/src/FedoraApi.php +++ b/src/FedoraApi.php @@ -64,21 +64,16 @@ public function getBaseUri() * * @param string $uri Resource URI * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return ResponseInterface */ public function getResource( $uri = "", - $headers = [], - $transaction = "" + $headers = [] ) { // Set headers $options = ['http_errors' => false, 'headers' => $headers]; - // Ensure uri takes transaction into account. - $uri = $this->prepareUri($uri, $transaction); - // Send the request. return $this->client->request( 'GET', @@ -91,18 +86,13 @@ public function getResource( * Gets a Fedora resoure's headers. * * @param string $uri Resource URI - * @param string $transaction Transaction id * * @return ResponseInterface */ public function getResourceHeaders( - $uri = "", - $transaction = "" + $uri = "" ) { - // Ensure uri takes transaction into account. - $uri = $this->prepareUri($uri, $transaction); - // Send the request. return $this->client->request( 'HEAD', @@ -133,15 +123,13 @@ public function getResourceOptions($uri = "") * @param string $uri Resource URI * @param string $content String or binary content * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return ResponseInterface */ public function createResource( $uri = "", $content = null, - $headers = [], - $transaction = "" + $headers = [] ) { $options = ['http_errors' => false]; @@ -150,10 +138,7 @@ public function createResource( // Set headers. $options['headers'] = $headers; - - // Ensure uri takes transaction into account. - $uri = $this->prepareUri($uri, $transaction); - + return $this->client->request( 'POST', $uri, @@ -167,15 +152,13 @@ public function createResource( * @param string $uri Resource URI * @param string $content String or binary content * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return ResponseInterface */ public function saveResource( $uri, $content = null, - $headers = [], - $transaction = "" + $headers = [] ) { $options = ['http_errors' => false]; @@ -185,9 +168,6 @@ public function saveResource( // Set headers. $options['headers'] = $headers; - // Ensure uri takes transaction into account. - $uri = $this->prepareUri($uri, $transaction); - return $this->client->request( 'PUT', $uri, @@ -201,15 +181,13 @@ public function saveResource( * @param string $uri Resource URI * @param string $sparql SPARQL Update query * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return ResponseInterface */ public function modifyResource( $uri, $sparql = "", - $headers = [], - $transaction = "" + $headers = [] ) { $options = ['http_errors' => false]; @@ -220,8 +198,6 @@ public function modifyResource( $options['headers'] = $headers; $options['headers']['content-type'] = 'application/sparql-update'; - // Ensure uri takes transaction into account. - $uri = $this->prepareUri($uri, $transaction); return $this->client->request( 'PATCH', $uri, @@ -233,56 +209,18 @@ public function modifyResource( * Issues a DELETE request to Fedora. * * @param string $uri Resource URI - * @param string $transaction Transaction id * * @return ResponseInterface */ public function deleteResource( - $uri, - $transaction = "" + $uri ) { $options = ['http_errors' => false]; - // Ensure uri takes transaction into account. - $uri = $this->prepareUri($uri, $transaction); - return $this->client->request( 'DELETE', $uri, $options ); } - - protected function prepareUri($uri, $transaction = "") - { - $base_uri = rtrim($this->getBaseUri(), '/'); - - if (empty($uri)) { - return "$base_uri/$transaction"; - } - - if (strpos($uri, $base_uri) !== 0) { - $uri = $base_uri . '/' . ltrim($uri, '/'); - } - - $uri = rtrim($uri, '/'); - - if (strcmp($uri, $base_uri) == 0) { - return "$base_uri/$transaction"; - } - - if (empty($transaction)) { - return $uri; - } - - $exploded = explode($base_uri, $uri); - $relative_path = ltrim($exploded[1], '/'); - $exploded = explode('/', $relative_path); - - if (in_array($transaction, $exploded)) { - return $uri; - } - - return implode([$base_uri, $transaction, $relative_path], '/'); - } } diff --git a/src/IFedoraApi.php b/src/IFedoraApi.php index 2d0ff12..ebb05c9 100644 --- a/src/IFedoraApi.php +++ b/src/IFedoraApi.php @@ -38,22 +38,18 @@ public function getBaseUri(); * * @param string $uri Resource URI * @param array $headers HTTP Headers - * @param string $transaction Transaction id */ public function getResource( $uri = "", - $headers = [], - $transaction = "" + $headers = [] ); /** * Gets a Fedora resoure's headers. * * @param string $uri Resource URI - * @param string $transaction Transaction id */ public function getResourceHeaders( - $uri = "", - $transaction = "" + $uri = "" ); /** * Gets information about the supported HTTP methods, etc., for a Fedora resource. @@ -68,13 +64,11 @@ public function getResourceOptions($uri = ""); * @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 = "" + $headers = [] ); /** @@ -83,13 +77,11 @@ public function createResource( * @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 = "" + $headers = [] ); /** @@ -98,23 +90,19 @@ public function saveResource( * @param string $uri Resource URI * @param string $sparql SPARQL Update query * @param array $headers HTTP Headers - * @param string $transaction Transaction id */ public function modifyResource( $uri, $sparql = "", - $headers = [], - $transaction = "" + $headers = [] ); /** * Issues a DELETE request to Fedora. * * @param string $uri Resource URI - * @param string $transaction Transaction id */ public function deleteResource( - $uri, - $transaction = "" + $uri ); } diff --git a/src/IFedoraClient.php b/src/IFedoraClient.php index 0d695c1..a1d7d1f 100644 --- a/src/IFedoraClient.php +++ b/src/IFedoraClient.php @@ -29,14 +29,12 @@ interface IFedoraClient extends IFedoraApi * * @param string $uri Resource URI * @param array $headers HTTP Headers - * @param string $transaction Transaction id * * @return EasyRdf_Graph */ public function getGraph( $uri = "", - $headers = [], - $transaction = "" + $headers = [] ); /** @@ -44,13 +42,11 @@ public function getGraph( * * @param string $uri Resource URI * @param EasyRdf_Resource $rdf RDF to save - * @param string $transaction Transaction id * * @return null */ public function saveGraph( $uri, - \EasyRdf_Graph $graph, - $transaction = "" + \EasyRdf_Graph $graph ); }