From 3e4111402539e710c61220fe7835156a6a95f79e Mon Sep 17 00:00:00 2001 From: Daniel Lamb Date: Tue, 10 Nov 2015 17:37:22 +0000 Subject: [PATCH 1/2] Using cxf for webservices --- .../islandora_basic_image.module | 27 +++++++++++++++++-- .../islandora_collection.module | 12 ++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index 71013339..47c3c639 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -141,7 +141,9 @@ function islandora_basic_image_node_postinsert($node) { ); } - httprl_request("http://127.0.0.1:8888/islandora/rest/basic-image/?uuid=$parent_collection", + $url = "http://127.0.0.1:8181/cxf/islandora/image/$parent_collection"; + dd($options); + httprl_request($url, $options); $response = httprl_send_request(); } @@ -184,7 +186,28 @@ function islandora_basic_image_node_postupdate($node) { ); } - httprl_request("http://127.0.0.1:8888/islandora/rest/basic-image/?uuid={$node->uuid}", + httprl_request("http://127.0.0.1:8181/cxf/islandora/image/{$node->uuid}", $options); $response = httprl_send_request(); } + +/** + * Implements hook_node_postdelete(). + */ +function islandora_basic_image_node_postdelete($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_BASIC_IMAGE_CONTENT_TYPE) != 0) { + return; + } + + $uuid = $node->uuid; + httprl_request("http://127.0.0.1:8181/cxf/islandora/image/$uuid", + array( + 'method' => 'DELETE', + )); + $response = httprl_send_request(); +} diff --git a/islandora_collection/islandora_collection.module b/islandora_collection/islandora_collection.module index 3ef27bf7..67003b81 100644 --- a/islandora_collection/islandora_collection.module +++ b/islandora_collection/islandora_collection.module @@ -124,12 +124,15 @@ function islandora_collection_node_postinsert($node) { } $node = array_pop($nodes); - $url = "http://127.0.0.1:8181/islandora/rest/collection/$parent_collection"; + $url = "http://127.0.0.1:8181/cxf/islandora/collection/$parent_collection"; // Don't forget the trailing slash. httprl_request($url, array( 'method' => 'POST', + 'headers' => array( + 'Content-Type' => 'application/json', + ), 'data' => json_encode($node), )); $response = httprl_send_request(); @@ -161,9 +164,12 @@ function islandora_collection_node_postupdate($node) { $node = array_pop($nodes); $uuid = $node->uuid; - httprl_request("http://127.0.0.1:8181/islandora/rest/collection/$uuid", + httprl_request("http://127.0.0.1:8181/cxf/islandora/collection/$uuid", array( 'method' => 'PUT', + 'headers' => array( + 'Content-Type' => 'application/json', + ), 'data' => json_encode($node), )); $response = httprl_send_request(); @@ -183,7 +189,7 @@ function islandora_collection_node_postdelete($node) { } $uuid = $node->uuid; - httprl_request("http://127.0.0.1:8181/islandora/rest/collection/$uuid", + httprl_request("http://127.0.0.1:8181/cxf/islandora/collection/$uuid", array( 'method' => 'DELETE', )); From d0b6733dda62094d5c4a3644ee2770e1563d24a1 Mon Sep 17 00:00:00 2001 From: Daniel Lamb Date: Tue, 10 Nov 2015 21:09:23 +0000 Subject: [PATCH 2/2] Getting rid of log statements. --- islandora_basic_image/islandora_basic_image.module | 1 - 1 file changed, 1 deletion(-) diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index 47c3c639..e17fddb6 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -142,7 +142,6 @@ function islandora_basic_image_node_postinsert($node) { } $url = "http://127.0.0.1:8181/cxf/islandora/image/$parent_collection"; - dd($options); httprl_request($url, $options); $response = httprl_send_request();