diff --git a/islandora/include/rdf_mapping.inc b/islandora/include/rdf_mapping.inc index 1def7777..34b193a9 100644 --- a/islandora/include/rdf_mapping.inc +++ b/islandora/include/rdf_mapping.inc @@ -42,11 +42,11 @@ function islandora_get_default_rdf_mapping($bundle, array $rdf_types) { ), ISLANDORA_FEDORA_HAS_PARENT_FIELD => array( 'predicates' => array('fedora:hasParent'), - 'datatype' => 'xsd:string', + 'type' => 'rel', ), ISLANDORA_PCDM_HAS_MEMBER_FIELD => array( 'predicates' => array('pcdm:hasMember'), - 'datatype' => 'xsd:string', + 'type' => 'rel', ), ), ), diff --git a/islandora_collection/islandora_collection.module b/islandora_collection/islandora_collection.module index 169b7460..4126a087 100644 --- a/islandora_collection/islandora_collection.module +++ b/islandora_collection/islandora_collection.module @@ -71,7 +71,8 @@ function islandora_collection_node_postinsert($node) { } $node = array_pop($nodes); - httprl_request("http://localhost:8080/islandora-services/rest/collection", + // Don't forget the trailing slash. + httprl_request("http://localhost:8181/islandora/rest/collection/", array( 'method' => 'POST', 'data' => json_encode($node), @@ -80,7 +81,7 @@ function islandora_collection_node_postinsert($node) { } /** - * Implements hook_update(). + * Implements hook_node_postupdate(). */ function islandora_collection_node_postupdate($node) { if (isset($_SERVER['HTTP_IGNORE_HOOKS']) && strcmp(strtolower($_SERVER['HTTP_IGNORE_HOOKS']), "true") == 0) { @@ -105,10 +106,31 @@ function islandora_collection_node_postupdate($node) { $node = array_pop($nodes); $uuid = $node->uuid; - httprl_request("http://localhost:8080/islandora-services/rest/collection/$uuid", + httprl_request("http://localhost:8181/islandora/rest/collection/$uuid", array( 'method' => 'PUT', 'data' => json_encode($node), )); $response = httprl_send_request(); } + +/** + * Implements hook_node_postdelete(). + */ +function islandora_collection_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_COLLECTION_CONTENT_TYPE) != 0) { + return; + } + + $uuid = $node->uuid; + httprl_request("http://localhost:8181/islandora/rest/collection/$uuid", + array( + 'method' => 'DELETE', + )); + $response = httprl_send_request(); +} diff --git a/islandora_delete_by_fedora_uri_service/include/islandora_delete_by_fedora_uri_service.inc b/islandora_delete_by_fedora_uri_service/include/islandora_delete_by_fedora_uri_service.inc new file mode 100644 index 00000000..0c2e9a88 --- /dev/null +++ b/islandora_delete_by_fedora_uri_service/include/islandora_delete_by_fedora_uri_service.inc @@ -0,0 +1,42 @@ +fieldCondition('field_fedora_path', 'value', $fedora_uri) + ->execute(); + + // Delete 'em all. + foreach ($results as $entity_type => $entities) { + $ids = array_keys($entities); + if (entity_delete_multiple($entity_type, $ids) === FALSE) { + $response[] = "Could not delete any $entity_type identified by $fedora_uri."; + } + else { + $response[] = "Deleted entities of type $entity_type with ids " . implode(', ', $ids) . "."; + } + } + + if (!isset($response)) { + $response[] = "Could not find any entities identified by $fedora_uri."; + } + + return $response; +} diff --git a/islandora_delete_by_fedora_uri_service/islandora_delete_by_fedora_uri_service.info b/islandora_delete_by_fedora_uri_service/islandora_delete_by_fedora_uri_service.info new file mode 100644 index 00000000..3c1d5a48 --- /dev/null +++ b/islandora_delete_by_fedora_uri_service/islandora_delete_by_fedora_uri_service.info @@ -0,0 +1,6 @@ +name = Islandora Delete By Fedora URI Service +description = "Deletes Drupal nodes by Fedora URI. Needed for Sync to handle delete events that don't originate from Drupal." +package = Islandora +version = 7.x-dev +core = 7.x +dependencies[] = rest_server diff --git a/islandora_delete_by_fedora_uri_service/islandora_delete_by_fedora_uri_service.module b/islandora_delete_by_fedora_uri_service/islandora_delete_by_fedora_uri_service.module new file mode 100644 index 00000000..6b234b35 --- /dev/null +++ b/islandora_delete_by_fedora_uri_service/islandora_delete_by_fedora_uri_service.module @@ -0,0 +1,48 @@ + array( + 'title' => t('Delete by Fedora URI.'), + 'description' => t('Allows external sources to delete Drupal nodes by Fedora URI.'), + ), + ); +} + +/** + * Implements hook_services_resources(). + */ +function islandora_delete_by_fedora_uri_service_services_resources() { + return array( + 'delete_by_fedora_uri' => array( + 'create' => array( + 'help' => t('Deletes a Drupal node by the Fedora URI supplied in the POST data.'), + 'file' => array( + 'type' => 'inc', + 'module' => 'islandora_delete_by_fedora_uri_service', + 'name' => 'include/islandora_delete_by_fedora_uri_service', + ), + 'callback' => 'islandora_delete_by_fedora_uri_service_delete', + 'access callback' => 'user_access', + 'access arguments' => array('islandora delete by fedora uri'), + 'args' => array( + array( + 'name' => 'args', + 'type' => 'array', + 'description' => t("JSON data containing arguments to the delete function (e.g. the Fedora URI)"), + 'source' => 'data', + 'optional' => FALSE, + ), + ), + ), + ), + ); +}