Browse Source

created helper function to connect to Fedora

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

13
admin/islandora.admin.inc

@ -8,6 +8,7 @@
function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/tuque');
module_load_include('inc', 'islandora', 'includes/utilities');
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')));
@ -24,16 +25,10 @@ function islandora_repository_admin($form, &$form_state) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
}
$connection = new IslandoraTuque(NULL, $url);
try {
$info = $connection->api->a->describeRepository();
$connected = TRUE;
}
catch (RepositoryException $e) {
$connected = FALSE;
}
// Connect to Fedora
$info = islandora_describe_repository($url);
if($connected) {
if($info) {
$confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
. t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
}

23
includes/utilities.inc

@ -46,3 +46,26 @@ function islandora_control_group_to_human_readable($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