Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api Changes for PHP Services #30

Merged
merged 18 commits into from
Jan 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
402 changes: 163 additions & 239 deletions src/Chullo.php

Large diffs are not rendered by default.

439 changes: 439 additions & 0 deletions src/FedoraApi.php

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions src/IFedoraApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?php

/**
* This file is part of Islandora.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* PHP Version 5.5.9
*
* @category Islandora
* @package Islandora
* @author Daniel Lamb <daniel@discoverygarden.ca>
* @author Nick Ruest <ruestn@gmail.com>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/

namespace Islandora\Chullo;

use Psr\Http\Message\ResponseInterface;

/**
* Interface for Fedora interaction. All functions return a PSR-7 response.
*
* @category Islandora
* @package Islandora
* @author Daniel Lamb <daniel@discoverygarden.ca>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
interface IFedoraApi
{
/**
* Gets the Fedora base uri (e.g. http://localhost:8080/fcrepo/rest)
*
* @return string
*/
public function getBaseUri();

/**
* Gets a Fedora resource.
*
* @param string $uri Resource URI
* @param array $headers HTTP Headers
* @param string $transaction Transaction id
*/
public function getResource(
$uri = "",
$headers = [],
$transaction = ""
);
/**
* Gets a Fedora resoure's headers.
*
* @param string $uri Resource URI
* @param string $transaction Transaction id
*/
public function getResourceHeaders(
$uri = "",
$transaction = ""
);
/**
* Gets information about the supported HTTP methods, etc., for a Fedora resource.
*
* @param string $uri Resource URI
*/
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
*/
public function createResource(
$uri = "",
$content = null,
$headers = [],
$transaction = "",
$checksum = ""
);

/**
* 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
*/
public function saveResource(
$uri,
$content = null,
$headers = [],
$transaction = "",
$checksum = ""
);

/**
* Modifies a resource using a SPARQL Update query.
*
* @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 = ""
);

/**
* Issues a DELETE request to Fedora.
*
* @param string $uri Resource URI
* @param string $transaction Transaction id
*/
public function deleteResource(
$uri,
$transaction = ""
);
/**
* Issues a COPY request to Fedora.
*
* @param string $uri Resource URI
* @param array $destination Destination URI
* @param string $transaction Transaction id
*/
public function copyResource(
$uri,
$destination,
$transaction = ""
);
/**
* Issues a MOVE request to Fedora.
*
* @param string $uri Resource URI
* @param array $destination Destination URI
* @param string $transaction Transaction id
*/
public function moveResource(
$uri,
$destination,
$transaction = ""
);

/**
* Creates a new transaction.
*/
public function createTransaction();

/**
* Extends a transaction.
*
* @param string $id Transaction id
*/
public function extendTransaction($id);

/**
* Commits a transaction.
*
* @param string $id Transaction id
*/
public function commitTransaction($id);

/**
* Rolls back a transaction.
*
* @param string $id Transaction id
*/
public function rollbackTransaction($id);
}
174 changes: 11 additions & 163 deletions src/IFedoraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GPL
* @link http://www.islandora.ca
*/
interface IFedoraClient
interface IFedoraClient extends IFedoraApi
{
/**
* Gets the Fedora base uri (e.g. http://localhost:8080/fcrepo/rest)
*
* @return string
*/
public function getBaseUri();

/**
* Gets a Fedora resource.
*
* @param string $uri Resource URI
* @param array $headers HTTP Headers
* @param string $transaction Transaction id
*
* @return mixed String or binary content if 200. Null if 304.
*/
public function getResource($uri = "",
$headers = [],
$transaction = "");
/**
* Gets a Fedora resoure's headers.
*
* @param string $uri Resource URI
* @param string $transaction Transaction id
*
* @return array Headers of a resource.
*/
public function getResourceHeaders($uri = "",
$transaction = "");
/**
* Gets information about the supported HTTP methods, etc., for a Fedora resource.
*
* @param string $uri Resource URI
*
* @return string Options of a resource.
*/
public function getResourceOptions($uri = "");

/**
* Gets RDF metadata from Fedora.
*
Expand All @@ -76,43 +38,11 @@ public function getResourceOptions($uri = "");
*
* @return EasyRdf_Graph
*/
public function getGraph($uri = "",
$headers = [],
$transaction = "");

/**
* 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
*
* @return string Uri of newly created resource
*/
public function createResource($uri = "",
$content = null,
$headers = [],
$transaction = "",
$checksum = "");

/**
* 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
*
* @return null
*/
public function saveResource($uri,
$content = null,
$headers = [],
$transaction = "",
$checksum = "");
public function getGraph(
$uri = "",
$headers = [],
$transaction = ""
);

/**
* Saves RDF in Fedora.
Expand All @@ -123,91 +53,9 @@ public function saveResource($uri,
*
* @return null
*/
public function saveGraph($uri,
\EasyRdf_Graph $graph,
$transaction = "");

/**
* Modifies a resource using a SPARQL Update query.
*
* @param string $uri Resource URI
* @param string $sparql SPARQL Update query
* @param array $headers HTTP Headers
* @param string $transaction Transaction id
*
* @return null
*/
public function modifyResource($uri,
$sparql = "",
$headers = [],
$transaction = "");

/**
* Issues a DELETE request to Fedora.
*
* @param string $uri Resource URI
* @param string $transaction Transaction id
*
* @return null
*/
public function deleteResource($uri,
$transaction = "");
/**
* Issues a COPY request to Fedora.
*
* @param string $uri Resource URI
* @param array $destination Destination URI
* @param string $transaction Transaction id
*
* @return string
*/
public function copyResource($uri,
$destination,
$transaction = "");
/**
* Issues a MOVE request to Fedora.
*
* @param string $uri Resource URI
* @param array $destination Destination URI
* @param string $transaction Transaction id
*
* @return string
*/
public function moveResource($uri,
$destination,
$transaction = "");

/**
* Creates a new transaction.
*
* @return string Transaction id
*/
public function createTransaction();

/**
* Extends a transaction.
*
* @param string $id Transaction id
*
* @return string Fedora response
*/
public function extendTransaction($id);

/**
* Commits a transaction.
*
* @param string $id Transaction id
*
* @return boolean
*/
public function commitTransaction($id);

/**
* Rolls back a transaction.
*
* @param string $id Transaction id
*
* @return boolean
*/
public function rollbackTransaction($id);
public function saveGraph(
$uri,
\EasyRdf_Graph $graph,
$transaction = ""
);
}
1 change: 0 additions & 1 deletion src/ITriplestoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ interface ITriplestoreClient
*/
public function query($sparql);
}

Loading