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(); }