Browse Source

added permission to view soap errors

pull/245/head
Alan Stanley 12 years ago
parent
commit
90a1de79a7
  1. 1
      ObjectHelper.inc
  2. 31
      api/fedora_item.inc
  3. 1
      fedora_repository.module

1
ObjectHelper.inc

@ -19,6 +19,7 @@ class ObjectHelper {
public static $INGEST_FEDORA_OBJECTS = 'ingest new fedora objects'; public static $INGEST_FEDORA_OBJECTS = 'ingest new fedora objects';
public static $EDIT_TAGS_DATASTREAM = 'edit tags datastream'; public static $EDIT_TAGS_DATASTREAM = 'edit tags datastream';
public static $VIEW_DETAILED_CONTENT_LIST = 'view detailed list of content'; public static $VIEW_DETAILED_CONTENT_LIST = 'view detailed list of content';
public static $VIEW_FEDORA_SOAP_ERROR_MESSAGES = 'view fedora soap error messages';
// TODO: Make this into a static member constant // TODO: Make this into a static member constant
public $availableDataStreamsText = 'Detailed list of content'; public $availableDataStreamsText = 'Detailed list of content';

31
api/fedora_item.inc

@ -1,9 +1,9 @@
<?php <?php
/** /**
* @file * @file
* Fedora Item * Fedora Item
*/ */
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#'); define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#'); define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#'); define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#');
@ -25,7 +25,6 @@ class Fedora_Item {
public $pid = NULL; public $pid = NULL;
public $objectProfile = NULL; public $objectProfile = NULL;
public $ownerId = NULL; public $ownerId = NULL;
// A SimpleXML object to store a list of this item's datastreams. // A SimpleXML object to store a list of this item's datastreams.
private $datastreams_list = NULL; private $datastreams_list = NULL;
public $datastreams = NULL; public $datastreams = NULL;
@ -200,7 +199,7 @@ class Fedora_Item {
'label' => $datastream_label, 'label' => $datastream_label,
'MIMEType' => $datastream_mimetype, 'MIMEType' => $datastream_mimetype,
'URL' => ($this->url() . '/' . $datastream_id . '/' . 'URL' => ($this->url() . '/' . $datastream_id . '/' .
drupal_urlencode($datastream_label)),); drupal_urlencode($datastream_label)),);
return $soap_result; return $soap_result;
} }
@ -338,7 +337,7 @@ RDF;
// Casting a string to an array gives an array containing the string, and // Casting a string to an array gives an array containing the string, and
// casting an array to an array does nothing. // casting an array to an array does nothing.
foreach ((array)$object as $obj) { foreach ((array) $object as $obj) {
if ($literal_value == RELS_TYPE_URI && strpos($obj, $f_prefix) !== 0) { if ($literal_value == RELS_TYPE_URI && strpos($obj, $f_prefix) !== 0) {
$obj = $f_prefix . $obj; $obj = $f_prefix . $obj;
} }
@ -399,7 +398,7 @@ RDF;
$relsxml->documentElement->appendChild($description); $relsxml->documentElement->appendChild($description);
} }
foreach ((array)$object as $obj) { foreach ((array) $object as $obj) {
if ($literal_value == RELS_TYPE_URI && strpos($obj, $f_prefix) !== 0) { if ($literal_value == RELS_TYPE_URI && strpos($obj, $f_prefix) !== 0) {
$obj = $f_prefix . $object; $obj = $f_prefix . $object;
} }
@ -447,7 +446,7 @@ RDF;
$rel = $rels->item($i - 1); $rel = $rels->item($i - 1);
// Foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted. // Foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted.
if ( if (
// If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. // If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed.
empty($object) || empty($object) ||
(($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) || (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||
(($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) || (($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) ||
@ -494,16 +493,16 @@ RDF;
$rels = $desc->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $desc->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { if (!empty($rels)) {
// Iterate backwards so if we delete something our pointer doesn't get out of sync. // Iterate backwards so if we delete something our pointer doesn't get out of sync.
for ($i = $rels->length; $i>0; $i--) { for ($i = $rels->length; $i > 0; $i--) {
$rel = $rels->item($i-1); $rel = $rels->item($i - 1);
// foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted // foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted
// If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. // If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed.
if ( if (
empty($object) || empty($object) ||
(($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) || (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||
(($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) || (($literal_value == RELS_TYPE_PLAIN_LITERAL) && $rel->textContent == $object) ||
(($literal_value == RELS_TYPE_STRING) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#string' && $rel->textContent == $object) || (($literal_value == RELS_TYPE_STRING) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#string' && $rel->textContent == $object) ||
(($literal_value == RELS_TYPE_INT) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#int' && intval($rel->textContent) == $object)) { (($literal_value == RELS_TYPE_INT) && $rel->getAttribute('rdf:datatype') == 'http://www.w3.org/2001/XMLSchema#int' && intval($rel->textContent) == $object)) {
$rel->parentNode->removeChild($rel); $rel->parentNode->removeChild($rel);
$modified = TRUE; $modified = TRUE;
} }
@ -1187,7 +1186,7 @@ RDF;
function modify_object($label = '', $state = NULL, $ownerId = NULL, $logMessage = 'Modified by Islandora API', $quiet=TRUE) { function modify_object($label = '', $state = NULL, $ownerId = NULL, $logMessage = 'Modified by Islandora API', $quiet=TRUE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
// Default to the current owner if none is provided.. // Default to the current owner if none is provided..
'ownerId' => (($ownerId !== NULL) ? 'ownerId' => (($ownerId !== NULL) ?
$ownerId : $ownerId :
$this->ownerId), $this->ownerId),
@ -1445,6 +1444,7 @@ RDF;
* The return value from the soap function if successful, NULL otherwise. * The return value from the soap function if successful, NULL otherwise.
*/ */
static function soap_call($function, $parameters, $quiet = FALSE) { static function soap_call($function, $parameters, $quiet = FALSE) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
if (!self::$connection_helper) { if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
@ -1467,7 +1467,7 @@ RDF;
return NULL; return NULL;
} }
} catch (Exception $e) { } catch (Exception $e) {
if (!$quiet) { if (!$quiet && user_access($VIEW_FEDORA_SOAP_ERROR_MESSAGES)) {
preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage()) ? preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage()) ?
drupal_set_message(t('Insufficient permissions to call SOAP function "%func".', array('%func' => $function)), 'error') : drupal_set_message(t('Insufficient permissions to call SOAP function "%func".', array('%func' => $function)), 'error') :
drupal_set_message(t('Error trying to call SOAP function "%func". Check watchdog logs for more information.', array('%func' => $function)), 'error'); drupal_set_message(t('Error trying to call SOAP function "%func". Check watchdog logs for more information.', array('%func' => $function)), 'error');
@ -1595,4 +1595,5 @@ RDF;
return $ownerId; return $ownerId;
} }
} }

1
fedora_repository.module

@ -935,6 +935,7 @@ function fedora_repository_perm() {
OBJECTHELPER::$INGEST_FEDORA_OBJECTS, OBJECTHELPER::$INGEST_FEDORA_OBJECTS,
OBJECTHELPER::$EDIT_TAGS_DATASTREAM, OBJECTHELPER::$EDIT_TAGS_DATASTREAM,
OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST,
OBJECTHELPER::$VIEW_FEDORA_SOAP_ERROR_MESSAGES,
); );
} }

Loading…
Cancel
Save