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

Sprint 002 issue 150 #206

Closed
wants to merge 4 commits into from
Closed
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
37 changes: 29 additions & 8 deletions services/ResourceService/src/Controller/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,38 @@ public function patch(Application $app, Request $request, $id, $child) {
public function delete(Application $app, Request $request, $id, $child) {
$tx = $request->query->get('tx', "");
$force = $request->query->get('force', FALSE);

error_log('---START OF DELETE RESOURCE REQUEST: ');
error_log($id);

$delete_queue = array($app->escape($id).'/'.$child, );
$sparql_query = $app['twig']->render('findAllOreProxy.sparql', array(
'resource' => $id,
));
try {
$response = $app['api']->deleteResource($app->escape($id).'/'.$child, $tx);
//remove tombstone also if 'force' == true and previous response is 204
if ((204 == $response->getStatusCode() || 410 == $response->getStatusCode()) && $force) {
$response= $app['api']->deleteResource($app->escape($id).'/'.$child.'/fcr:tombstone', $tx);
}
$sparql_result = $app['triplestore']->query($sparql_query);
}
catch (\Exception $e) {
$app->abort(503, '"Chullo says Fedora4 Repository is Not available"');
$app->abort(503, 'Chullo says "Triple Store Not available"');
}
if (count($sparql_result) > 0) {
foreach ($sparql_result as $ore_proxy) {
$delete_queue[] = $ore_proxy->obj->getUri();
}
}
error_log(implode(',', $delete_queue));
foreach($delete_queue as $object_uri) {
try {
$response = $app['api']->deleteResource($object_uri, $tx);
//remove tombstone also if 'force' == true and previous response is 204
if ((204 == $response->getStatusCode() || 410 == $response->getStatusCode()) && $force) {
$response = $app['api']->deleteResource($object_uri.'/fcr:tombstone', $tx);
}
}
catch (\Exception $e) {
$app->abort(503, '"Chullo says Fedora4 Repository is Not available"');
}
error_log($response->getStatusCode());
}
return $response;
}

}
5 changes: 5 additions & 0 deletions services/ResourceService/templates/findAllOreProxy.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX ldp: <http://www.w3.org/ns/ldp#>
SELECT ?obj WHERE {
?obj ore:proxyFor <{{ resource }}> .
}