Browse Source

created helper function to connect to Fedora

pull/123/merge
Danny Joris 13 years ago
parent
commit
c7a0e1319b
  1. 15
      admin/islandora.admin.inc
  2. 23
      includes/utilities.inc

15
admin/islandora.admin.inc

@ -8,6 +8,7 @@
function islandora_repository_admin($form, &$form_state) { function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/tuque'); module_load_include('inc', 'islandora', 'includes/tuque');
module_load_include('inc', 'islandora', 'includes/utilities');
if (!IslandoraTuque::exists()) { if (!IslandoraTuque::exists()) {
$message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'))); $message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque')));
@ -24,16 +25,10 @@ function islandora_repository_admin($form, &$form_state) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
} }
$connection = new IslandoraTuque(NULL, $url); // Connect to Fedora
try { $info = islandora_describe_repository($url);
$info = $connection->api->a->describeRepository();
$connected = TRUE; if($info) {
}
catch (RepositoryException $e) {
$connected = FALSE;
}
if($connected) {
$confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>' $confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
. t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion'])); . t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
} }

23
includes/utilities.inc

@ -45,4 +45,27 @@ function islandora_control_group_to_human_readable($control_group) {
default: default:
return $control_group; return $control_group;
} }
}
/**
* Helper function to describe a Fedora repository.
*
* Can be used to check if Fedora is available.
*
* @param $url
* A url to a Fedora repository.
* @return
* Returns an array describing the repository. Returns FALSE if Fedora is down
* or if the url is incorrect.
*/
function islandora_describe_repository($url) {
$connection = new IslandoraTuque(NULL, $url);
try {
$info = $connection->api->a->describeRepository();
return $info;
}
catch (RepositoryException $e) {
return FALSE;
}
} }
Loading…
Cancel
Save