-
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
Closed
Closed
Example service #126
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
015dd6c
Example transaction service.
daniel-dgi 9638bca
Merge remote-tracking branch 'labs/sprint-002' into example-service
daniel-dgi 00c2cf3
Updating PR to use static factory function for Chullo.
daniel-dgi d3d34c8
Using view handler to convert PSR-7 to Symfony responses. Using the …
daniel-dgi b7a5146
Work in progress for Resource Services
DiegoPino 92d04ca
uuid check + child resource for ResourceService
DiegoPino f6baff1
Adds metadata options to ResourceService get route
DiegoPino 86bd39b
POST resource creation working
DiegoPino 89a09cc
PUT resource route working
DiegoPino 2a0efc3
PATCH route added
DiegoPino 4b84572
Using app->share in TransactionService.
daniel-dgi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
composer.lock | ||
composer.phar | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "islandora/transaction-service", | ||
"description": "RESTful service providing transactions in Fedora 4", | ||
"require": { | ||
"islandora/chullo": "^0.0.1", | ||
"silex/silex": "^1.3" | ||
}, | ||
"autoload": { | ||
"psr-4": {"Islandora\\TransactionService\\": "src/"} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Daniel Lamb", | ||
"email": "daniel@discoverygarden.ca" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Islandora\TransactionService; | ||
|
||
require_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Exception\ClientException; | ||
use Islandora\Chullo\Chullo; | ||
use Silex\Application; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
date_default_timezone_set('UTC'); | ||
|
||
$app = new Application(); | ||
|
||
$app['debug'] = true; | ||
|
||
$app['fedora'] = function () use ($app) { | ||
$client = new Client(['base_uri' => 'http://127.0.0.1:8080/fcrepo/rest']); | ||
return new Chullo($client); | ||
}; | ||
|
||
$app->post( | ||
"/islandora/transaction", | ||
function (Application $app) { | ||
try { | ||
return new Response($app['fedora']->createTransaction(), 201); | ||
} | ||
catch (ClientException $e) { | ||
$response = $e->getResponse(); | ||
$app->abort($response->getStatusCode(), $response->getReasonPhrase()); | ||
} | ||
} | ||
); | ||
|
||
$app->post( | ||
"/islandora/transaction/{id}/extend", | ||
function (Application $app, $id) { | ||
try { | ||
$app['fedora']->extendTransaction($id); | ||
return new Response("", 204); | ||
} | ||
catch (ClientException $e) { | ||
$response = $e->getResponse(); | ||
$app->abort($response->getStatusCode(), $response->getReasonPhrase()); | ||
} | ||
} | ||
); | ||
|
||
$app->post( | ||
"/islandora/transaction/{id}/commit", | ||
function (Application $app, $id) { | ||
try { | ||
$app['fedora']->commitTransaction($id); | ||
return new Response("", 204); | ||
} | ||
catch (ClientException $e) { | ||
$response = $e->getResponse(); | ||
$app->abort($response->getStatusCode(), $response->getReasonPhrase()); | ||
} | ||
} | ||
); | ||
|
||
$app->post( | ||
"/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 commentThe reason will be displayed to describe this comment to others. Learn more. Probably should remove this 'return' |
||
return new Response("", 204); | ||
} | ||
catch (ClientException $e) { | ||
$response = $e->getResponse(); | ||
$app->abort($response->getStatusCode(), $response->getReasonPhrase()); | ||
} | ||
} | ||
); | ||
|
||
$app->run(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.