From 35b2f68af8dc4345d01d3b6e5541d0da0ef545f7 Mon Sep 17 00:00:00 2001 From: Daniel Lamb Date: Thu, 28 May 2015 17:01:17 -0300 Subject: [PATCH] RDF sync works on edit from either Drupal or Fedora. --- .../islandora_collection.module | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/islandora_collection/islandora_collection.module b/islandora_collection/islandora_collection.module index 38542f21..7a023c37 100644 --- a/islandora_collection/islandora_collection.module +++ b/islandora_collection/islandora_collection.module @@ -86,4 +86,29 @@ function islandora_collection_node_postupdate($node) { if (isset($_SERVER['HTTP_IGNORE_HOOKS']) && strcmp(strtolower($_SERVER['HTTP_IGNORE_HOOKS']), "true") == 0) { return; } + + // Exit early if it's not a collection. + if (strcmp($node->type, ISLANDORA_COLLECTION_CONTENT_TYPE) != 0) { + return; + } + + // Unfortunately, there's no way to tell if the db transaction got rolled back in this hook, + // so we'll default to doing it anyway so as not to miss any updates. + // Open to suggestions on this one. But we gotta do post_action hooks otherwise + // things can get crazy if the db transaction hasn't closed. + $nodes = entity_uuid_load('node', array($node->uuid)); + + // Exit early if something has gone wrong and there's no node info. + if (empty($nodes)) { + return; + } + + $node = array_pop($nodes); + $uuid = $node->uuid; + httprl_request("http://localhost:8080/islandora-services/rest/collection/$uuid", + array( + 'method' => 'PUT', + 'data' => json_encode($node), + )); + $response = httprl_send_request(); }