-
Notifications
You must be signed in to change notification settings - Fork 71
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
Example service #126
Example service #126
Conversation
To run: $ cd /path/to/islandora/services/TransactionService
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
$ cd src
$ php -S localhost:9999 index.php |
$app['debug'] = true; | ||
|
||
$app['fedora'] = function () use ($app) { | ||
$client = new Client(['base_uri' => 'http://127.0.0.1:8080/fcrepo/rest']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still new to this stuff, is there a reason you didn't use the static constructor with the base_uri and get back the Chullo?
ie.
return Chullo::create('http://127.0.0.1:8080/fcrepo/rest');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason in particular. Doing it manually gives you a bit more control over the client, which in this case, is unneccessary.
"/islandora/transaction/{id}/rollback", | ||
function (Application $app, $id) { | ||
try { | ||
return $app['fedora']->rollbackTransaction($id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should remove this 'return'
…edoraApi class from Chullo.
Depends on Chullo fixes at https://github.com/DiegoPino/chullo/tree/api
for get route: assuming it's running in 8181 (example php -S localhost:8181 -t src src/index.php ) then http://localhost:8181/islandora/resource/7ef68f6f-72ab-4708-b0f4-8ec1f07 cd580 will get the resource for a resource that has nfo:uuid -> 7ef68f6f-72ab-4708-b0f4-8ec1f07cd580 in the triple store and http://localhost:8181/islandora/resource/7ef68f6f-72ab-4708-b0f4-8ec1f07 cd580/OBJ will get the child resource for that one (in this case binary) Accepts also a ?tx=transactionid * if the transactionid does not exist if fails with 404 * if uuid is not uuid then it fails with 404 * if resource path is not in triple store if fails with 404
Main route for getting a resource accepts also a metadata argument localhost:8181/islandora/resource/7ef68f6f-72ab-4708-b0f4-8ec1f07cd580/O BJ/?metadata=true In case of binary it will return triples instead of the binary resource In case of an container i will get you the RDF (basically ignoring this option)
Also moved some route parameters to query arguments (checksum) in all routes: tx ,checksum and metadata (depending on what is used in each route)
Did also a lot of coding cleanup. Not sure if the Symphony coding standard as base is good enough? Moved the ->abort for non existing resource path in triple store into the middleware.
Superseded #131 |
So here's the smallest thing I could think of that showcases what I've been trying to describe. It's pretty small, and shows that really all we're trying to do is hack info out of the request and return responses. This is what is meant by 'Thin Controllers'. All the heavy lifting is done elsewhere. In this case, it's Chullo.
As things grow, we can either have a lot of these little guys, or try and manage all of them in a single deployable project.