Skip to content

Commit

Permalink
ISLANDORA-1110
Browse files Browse the repository at this point in the history
Minor changes to main module to allow external handlers to manage/serve
deleted records
  • Loading branch information
DiegoPino committed Jul 14, 2016
1 parent 634c86e commit 600514c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
17 changes: 16 additions & 1 deletion includes/admin.form.inc
Expand Up @@ -51,6 +51,20 @@ function islandora_oai_admin_form($form, $form_state) {
'#default_value' => variable_get('islandora_oai_repository_identifier', 'drupal-site.org'),
'#description' => t('The identifier for this repository, e.g. oai:<strong>drupal-site.org</strong>:123.'),
);
// This variable should be re-set by other OAI-PMH handlers if
// the deleted records capability is implemented correctly.
$form['islandora_oai_configuration']['islandora_oai_repository_deletedrecords'] = array(
'#type' => 'select',
'#title' => t('Deleted records handling'),
'#required' => TRUE,
'#options' => array(
'no' => 'no',
'transient' => 'transient',
'persistent' => 'persistent',
),
'#default_value' => variable_get('islandora_oai_repository_deletedrecords', 'no'),
'#description' => t('OAI-PMH Service handling of deleted records. The default handler does not provide this capability, but contributed ones could provide a way of registering deleted objects and publicising which method was used to do so.'),
);
$form['islandora_oai_configuration']['islandora_oai_admin_email'] = array(
'#type' => 'textfield',
'#title' => t('Administrator Email'),
Expand Down Expand Up @@ -98,7 +112,7 @@ function islandora_oai_admin_form($form, $form_state) {
);
$form['islandora_oai_configuration']['handlers']['configuration'][$name] = array(
'#type' => 'item',
'#markup' => (isset($profile['configuration']) AND $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '',
'#markup' => (isset($profile['configuration']) and $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '',
);
}
$form['islandora_oai_configuration']['handlers']['default'] = array(
Expand Down Expand Up @@ -131,6 +145,7 @@ function islandora_oai_admin_form_submit($form, $form_state) {
variable_set('islandora_oai_repository_name', $form_state['values']['islandora_oai_configuration']['islandora_oai_repository_name']);
variable_set('islandora_oai_path', $form_state['values']['islandora_oai_configuration']['islandora_oai_path']);
variable_set('islandora_oai_repository_identifier', $form_state['values']['islandora_oai_configuration']['islandora_oai_repository_identifier']);
variable_set('islandora_oai_repository_deletedrecords', $form_state['values']['islandora_oai_configuration']['islandora_oai_repository_deletedrecords']);
variable_set('islandora_oai_admin_email', $form_state['values']['islandora_oai_configuration']['islandora_oai_admin_email']);
variable_set('islandora_oai_max_size', $form_state['values']['islandora_oai_configuration']['islandora_oai_max_size']);
variable_set('islandora_oai_expire_time', $form_state['values']['islandora_oai_configuration']['islandora_oai_expire_time']);
Expand Down
1 change: 1 addition & 0 deletions includes/handler.admin.inc
Expand Up @@ -381,6 +381,7 @@ function islandora_oai_file_management_form_validate($form, $form_state) {
}
}
}

/**
* Submit handler for the islandora_oai_file_management form.
*
Expand Down
18 changes: 13 additions & 5 deletions includes/request.inc
Expand Up @@ -176,7 +176,8 @@ function islandora_oai_add_error($code, $argument = '', $value = '') {
*
* Helper function for islandora_oai_add_error and islandora_oai_get_errors.
* Basically faking a singleton with getter and setter methods.
* OAI2 specification: http://www.openarchives.org/OAI/openarchivesprotocol.html
* OAI2 specification:
* http://www.openarchives.org/OAI/openarchivesprotocol.html .
*
* @param string $code
* Error code to be added, or 'get' if we want to get the errors array.
Expand Down Expand Up @@ -461,7 +462,7 @@ function islandora_oai_identify(&$writer, $args) {
$writer->writeElement('protocolVersion', '2.0');
$writer->writeElement('adminEmail', variable_get('islandora_oai_admin_email', 'N/A'));
$writer->writeElement('earliestDatestamp', $earliest_datestamp);
$writer->writeElement('deletedRecord', 'no');
$writer->writeElement('deletedRecord', variable_get('islandora_oai_repository_deletedrecords', 'no'));
$writer->writeElement('granularity', 'YYYY-MM-DDThh:mm:ssZ');
$writer->writeElement('compression', 'yes');

Expand Down Expand Up @@ -517,7 +518,7 @@ EOQ;
* @param object $writer
* The XMLWriter object being passed by reference for constructing our output.
* @param array $args
* Arguments of the POST or GET Request
* Arguments of the POST or GET Request.
* @param bool $list_rec
* List identifiers if FALSE, records if TRUE.
*
Expand Down Expand Up @@ -745,12 +746,19 @@ function islandora_oai_build_record_response(&$writer, $record, $full_record = F
$repo_id = variable_get('islandora_oai_repository_identifier', 'drupal-site.org');
$date = new DateTime((string) $record['date'], new DateTimeZone('UTC'));
$date_stamp = $date->format("Y-m-d\TH:i:s\Z");

$tombstone = isset($record['tombstone']) && $record['tombstone'] ? TRUE : FALSE;
if ($full_record) {
$writer->startElement('record');
}

$writer->startElement('header');

// If record contains a tombstone key with a value that evaluates to true
// mark status as deleted.
if ($tombstone) {
$writer->writeAttribute('status', 'deleted');
}

$writer->writeElement('identifier', 'oai:' . $repo_id . ':' . $identifier);
$writer->writeElement('datestamp', $date_stamp);

Expand All @@ -777,6 +785,7 @@ function islandora_oai_build_record_response(&$writer, $record, $full_record = F
$oai_output = call_user_func($record_xml['function'], array(
'metadata_prefix' => $metadata_prefix,
'pid' => $record['pid'],
'tombstone' => $tombstone,
));
if (!empty($oai_output)) {
$writer->startElement('metadata');
Expand Down Expand Up @@ -944,7 +953,6 @@ EOQ;
*
* @param object $writer
* The XMLWriter object being passed by reference for constructing our output.
*
* @param array $args
* Arguments of the $_POST or the $_GET request.
*
Expand Down

0 comments on commit 600514c

Please sign in to comment.