Browse Source

Fixed a conflict

pull/81/head
Ben Woodhead 13 years ago
parent
commit
91696027f7
  1. 20
      CollectionClass.inc
  2. 4
      ObjectHelper.inc
  3. 101
      api/fedora_item.inc
  4. 1
      fedora_repository.solutionpacks.inc
  5. 2
      xsl/sparql_to_html.xsl

20
CollectionClass.inc

@ -45,11 +45,12 @@ class CollectionClass {
* @return type * @return type
*/ */
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
if (!isset($itqlquery)) { if (!isset($itqlquery)) {
// $query_string = $objectHelper->getStream($pid, 'QUERY', 0); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$itqlquery = $objectHelper->getStream($pid, 'QUERY', 0); $item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$itqlquery = $item->get_datastream_dissemination('QUERY');
}
} }
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset); return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
} }
@ -78,7 +79,11 @@ class CollectionClass {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$query_string = $itqlquery; $query_string = $itqlquery;
if (!isset($query_string)) { if (!isset($query_string)) {
$query_string = $objectHelper->getStream($pid, 'QUERY', 0); $query_string = NULL;
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query_string = $item->get_datastream_dissemination('QUERY');
}
if ($query_string == NULL) { if ($query_string == NULL) {
$query_string = 'select $object $title $content from <#ri> $query_string = 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title where ($object <fedora-model:label> $title
@ -498,11 +503,10 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'CollectionManagement'); module_load_include('inc', 'fedora_repository', 'CollectionManagement');
module_load_include('inc', 'fedora_repository', 'BatchIngest'); module_load_include('inc', 'fedora_repository', 'BatchIngest');
global $base_url; global $base_url;
$tabset = array();
global $user; global $user;
$objectHelper = new ObjectHelper(); $tabset = array();
$item = new Fedora_Item($this->pid);
$query = NULL; $query = NULL;
$item = new Fedora_Item($this->pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) { if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query = $item->get_datastream_dissemination('QUERY'); $query = $item->get_datastream_dissemination('QUERY');
} }

4
ObjectHelper.inc

@ -383,8 +383,8 @@ class ObjectHelper {
$xsl->load($path . '/xsl/convertQDC.xsl'); $xsl->load($path . '/xsl/convertQDC.xsl');
$input = new DomDocument(); $input = new DomDocument();
$input->loadXML(trim($xmlstr)); $input->loadXML(trim($xmlstr));
} catch (exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "Problem loading XSL file: @e", array('@e' => $e), NULL, WATCHDOG_ERROR); watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
} }
$xsl = $proc->importStylesheet($xsl); $xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input); $newdom = $proc->transformToDoc($input);

101
api/fedora_item.inc

@ -18,6 +18,22 @@ class Fedora_Item {
public $datastreams = NULL; public $datastreams = NULL;
private static $connection_helper = NULL; private static $connection_helper = NULL;
private static $instantiated_pids = array(); private static $instantiated_pids = array();
private static $SoapManagedFunctions = array(
'ingest',
'addDataStream',
'addRelationship',
'export',
'getDatastream',
'getDatastreamHistory',
'getNextPID',
'getRelationships',
'modifyDatastreamByValue',
'modifyDatastreamByReference',
'purgeDatastream',
'purgeObject',
'modifyObject',
'setDatastreamState'
);
/** /**
* Create an object to represent an item in the Fedora repository. * Create an object to represent an item in the Fedora repository.
@ -164,7 +180,6 @@ class Fedora_Item {
return $returnvalue; return $returnvalue;
} }
/** /**
* Wrapper to add new or modify existing datastream * Wrapper to add new or modify existing datastream
* @global url $base_url * @global url $base_url
@ -662,11 +677,9 @@ class Fedora_Item {
/** /**
* Set the object to a deleted state * Set the object to a deleted state
*/ */
function move_to_trash($log_message = 'Flagged deleted using Islandora API.') function move_to_trash($log_message = 'Flagged deleted using Islandora API.') {
{
// Loop through the datastreams and mark them deleted // Loop through the datastreams and mark them deleted
foreach($this->get_datastreams_list_as_array() as $dsid) foreach ($this->get_datastreams_list_as_array() as $dsid) {
{
$this->set_datastream_state($dsid, 'D'); $this->set_datastream_state($dsid, 'D');
} }
@ -901,75 +914,47 @@ class Fedora_Item {
} }
/** /**
* Soap call * Make a soap call to the fedora API.
* @param type $function_name *
* @param type $params_array * @param string $function
* @param type $quiet * The name of the soap function to call.
* @return type * @param array $parameters
* Paramters to pass onto the soap call
* @param boolean $quiet
* If TRUE suppress drupal messages.
*
* @return mixed
* The return value from the soap function if successful, NULL otherwise.
*/ */
static function soap_call($function_name, $params_array, $quiet = FALSE) { static function soap_call($function, $parameters, $quiet = FALSE) {
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();
} }
switch ($function_name) { $url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ?
case 'ingest': variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl') :
case 'addDataStream': variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
case 'addRelationship':
case 'export':
case 'getDatastream':
case 'getDatastreamHistory':
case 'getNextPID':
case 'getRelationships':
case 'modifyDatastreamByValue':
case 'modifyDatastreamByReference':
case 'purgeDatastream':
case 'purgeObject':
case 'modifyObject':
case 'setDatastreamState':
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
try { try {
if (!empty($soap_client)) { $soap_client = self::$connection_helper->getSoapClient($url);
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array)); if (isset($soap_client)) {
$result = $soap_client->__soapCall($function, array('parameters' => $parameters));
} }
else { else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL;
}
} catch (exception $e) {
if (!$quiet) { if (!$quiet) {
drupal_set_message(t('Error trying to get SOAP client connection'));
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name)), 'error');
}
else {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
} }
watchdog('fedora_repository', 'Error trying to get SOAP client connection.');
watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR);
}
return NULL;
}
break;
default:
try {
$soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
}
else {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL; return NULL;
} }
} catch (exception $e) { } catch (Exception $e) {
if (!$quiet) { if (!$quiet) {
watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR); 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('Error trying to call SOAP function "%func". Check watchdog logs for more information.', array('%func' => $function)), 'error');
} }
watchdog('fedora_repository', 'Error Trying to call SOAP function "%func". Exception: @e in @f(@l)\n@t', array('%func' => $function, '@e' => $e->getMessage(), '@f' => $e->getFile(), '@l' => $e->getLine(), '@t' => $e->getTraceAsString()), NULL, WATCHDOG_ERROR);
return NULL; return NULL;
} }
}
return $result; return $result;
} }

1
fedora_repository.solutionpacks.inc

@ -210,4 +210,3 @@ function solution_pack_add_form_association($content_model, $form_name) {
drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$form_name))); drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$form_name)));
} }
} }

2
xsl/sparql_to_html.xsl

@ -173,7 +173,7 @@
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>--> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="s:content"/> <xsl:value-of select="s:content"/>

Loading…
Cancel
Save