Exemple #1
0
function oai_error($code, $argument = '', $value = '')
{
    global $request;
    global $request_err;
    switch ($code) {
        case 'badArgument':
            $text = "The argument '{$argument}' (value='{$value}') included in the request is not valid.";
            break;
        case 'badGranularity':
            $text = "The value '{$value}' of the argument '{$argument}' is not valid.";
            $code = 'badArgument';
            break;
        case 'badResumptionToken':
            $text = "The resumptionToken '{$value}' does not exist or has already expired.";
            break;
        case 'badRequestMethod':
            $text = "The request method '{$argument}' is unknown.";
            $code = 'badVerb';
            break;
        case 'badVerb':
            $text = "The verb '{$argument}' provided in the request is illegal.";
            break;
        case 'cannotDisseminateFormat':
            $text = "The metadata format '{$value}' given by {$argument} is not supported by this repository.";
            break;
        case 'exclusiveArgument':
            $text = 'The usage of resumptionToken as an argument allows no other arguments.';
            $code = 'badArgument';
            break;
        case 'idDoesNotExist':
            $text = "The value '{$value}' of the identifier is illegal for this repository.";
            if (!is_valid_uri($value)) {
                $code = 'badArgument';
            }
            break;
        case 'missingArgument':
            $text = "The required argument '{$argument}' is missing in the request.";
            $code = 'badArgument';
            break;
        case 'noRecordsMatch':
            $text = 'The combination of the given values results in an empty list.';
            break;
        case 'noMetadataFormats':
            $text = 'There are no metadata formats available for the specified item.';
            break;
        case 'noVerb':
            $text = 'The request does not provide any verb.';
            $code = 'badVerb';
            break;
        case 'noSetHierarchy':
            $text = 'This repository does not support sets.';
            break;
        case 'sameArgument':
            $text = 'Do not use them same argument more than once.';
            $code = 'badArgument';
            break;
        case 'sameVerb':
            $text = 'Do not use verb more than once.';
            $code = 'badVerb';
            break;
        default:
            $text = "Unknown error: code: '{$code}', argument: '{$argument}', value: '{$value}'";
            $code = 'badArgument';
    }
    if ($code == 'badVerb' || $code == 'badArgument') {
        $request = $request_err;
    }
    $error = ' <error code="' . xmlstr($code, 'iso8859-1', false) . '">' . xmlstr($text, 'iso8859-1', false) . "</error>\n";
    return $error;
}
Exemple #2
0
/** utility funciton to mapping error codes to readable messages */
function oai_error($code, $argument = '', $value = '')
{
    switch ($code) {
        case 'badArgument':
            $text = "The argument '{$argument}' (value='{$value}') included in the request is not valid.";
            break;
        case 'badGranularity':
            $text = "The value '{$value}' of the argument '{$argument}' is not valid.";
            $code = 'badArgument';
            break;
        case 'badResumptionToken':
            $text = "The resumptionToken '{$value}' does not exist or has already expired.";
            break;
        case 'badRequestMethod':
            $text = "The request method '{$argument}' is unknown.";
            $code = 'badVerb';
            break;
        case 'badVerb':
            $text = "The verb '{$argument}' provided in the request is illegal.";
            break;
        case 'cannotDisseminateFormat':
            $text = "The metadata format '{$value}' given by {$argument} is not supported by this repository.";
            break;
        case 'exclusiveArgument':
            $text = 'The usage of resumptionToken as an argument allows no other arguments.';
            $code = 'badArgument';
            break;
        case 'idDoesNotExist':
            $text = "The value '{$value}' of the identifier does not exist in this repository.";
            if (!is_valid_uri($value)) {
                $code = 'badArgument';
                $text .= ' Invalidated URI has been detected.';
            }
            break;
        case 'missingArgument':
            $text = "The required argument '{$argument}' is missing in the request.";
            $code = 'badArgument';
            break;
        case 'noRecordsMatch':
            $text = 'The combination of the given values results in an empty list.';
            break;
        case 'noMetadataFormats':
            $text = 'There are no metadata formats available for the specified item.';
            break;
        case 'noVerb':
            $text = 'The request does not provide any verb.';
            $code = 'badVerb';
            break;
        case 'noSetHierarchy':
            $text = 'This repository does not support sets.';
            break;
        case 'sameArgument':
            $text = 'Do not use the same argument more than once.';
            $code = 'badArgument';
            break;
        case 'sameVerb':
            $text = 'Do not use verb more than once.';
            $code = 'badVerb';
            break;
        case 'notImp':
            $text = 'Not yet implemented.';
            $code = 'debug';
            break;
        default:
            $text = "Unknown error: code: '{$code}', argument: '{$argument}', value: '{$value}'";
            $code = 'badArgument';
    }
    return $code . "|" . $text;
}
Exemple #3
0
* +----------------------------------------------------------------------+
* | Derived from work by U. Müller, HUB Berlin, 2002                     |
* |                                                                      |
* | Written by Heinrich Stamerjohanns, May 2002                          |
* |            stamer@uni-oldenburg.de                                   |
* +----------------------------------------------------------------------+
*/
//
// $Id$
//
// parse and check arguments
foreach ($args as $key => $val) {
    switch ($key) {
        case 'identifier':
            $identifier = $val;
            if (!is_valid_uri($identifier)) {
                $errors .= oai_error('badArgument', $key, $val);
            }
            break;
        case 'metadataPrefix':
            if (isset($METADATAFORMATS[$val]) && is_array($METADATAFORMATS[$val]) && isset($METADATAFORMATS[$val]['myhandler'])) {
                $metadataPrefix = $val;
                $inc_record = $METADATAFORMATS[$val]['myhandler'];
            } else {
                $errors .= oai_error('cannotDisseminateFormat', $key, $val);
            }
            break;
        default:
            $errors .= oai_error('badArgument', $key, $val);
    }
}