You are here

error.inc in Views OAI-PMH 7.3

Base class for an OAI-PMH error.

File

includes/error.inc
View source
<?php

/**
 * @file
 * Base class for an OAI-PMH error.
 */

/**
 * Views OAI-PMH error.
 */
class views_oai_pmh_error {
  public $code = '';
  protected $argument = '';
  protected $value = '';

  /**
   * Constructor.
   */
  public function __construct($code, $argument = '', $value = '') {
    $this->code = $code;
    $this->argument = $argument;
    $this->value = $value;
  }

  /**
   * Returns a generic message, normally overridden by subclasses.
   */
  public function get_message() {
    $message = array();
    $message[] = t('Error: @code.', array(
      '@code' => $this->code,
    ));
    if ($this->argument) {
      $message[] = t('Argument: @arg.', array(
        '@arg' => $this->argument,
      ));
    }
    if ($this->value) {
      $message[] = t('Value: @value.', array(
        '@value' => $this->value,
      ));
    }
    return implode(' ', $message);
  }

}

/**
 * Views OAI-PMH error missing verb.
 */
class views_oai_pmh_error_missing_verb extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct() {
    parent::__construct('badVerb');
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t('The OAI-PMH verb is missing.');
  }

}

/**
 * Views OAI-PMH error bad verb.
 */
class views_oai_pmh_error_bad_verb extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct() {
    parent::__construct('badVerb');
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t('Illegal OAI-PMH verb.');
  }

}

/**
 * Views OAI-PMH error exclusive argument.
 */
class views_oai_pmh_error_exclusive_argument extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($argument) {
    parent::__construct('badArgument', $argument);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The usage of '@arg' as an argument allows no other arguments.", array(
      '@arg' => $this->argument,
    ));
  }

}

/**
 * Views OAI-PMH error missing argument.
 */
class views_oai_pmh_error_missing_argument extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($argument) {
    parent::__construct('badArgument', $argument);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The required argument '@arg' is missing.", array(
      '@arg' => $this->argument,
    ));
  }

}

/**
 * Views OAI-PMH error bad argument.
 */
class views_oai_pmh_error_bad_argument extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($argument) {
    parent::__construct('badArgument', $argument);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The argument '@arg' is invalid with this verb.", array(
      '@arg' => $this->argument,
    ));
  }

}

/**
 * Views OAI-PMH error no set hierarchy.
 */
class views_oai_pmh_error_no_set_hierarchy extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct() {
    parent::__construct('noSetHierarchy');
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t('This repository does not support sets.');
  }

}

/**
 * Views OAI-PMH error bad value.
 */
class views_oai_pmh_error_bad_value extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($argument, $value) {
    parent::__construct('badArgument', $argument, $value);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("Illegal value '@value' for the argument '@arg'.", array(
      '@arg' => $this->argument,
      '@value' => $this->value,
    ));
  }

}

/**
 * Views OAI-PMH error invalid id.
 */
class views_oai_pmh_error_invalid_id extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($value) {
    parent::__construct('idDoesNotExist', '', $value);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The value of identifier '@value' is invalid in this repository.", array(
      '@value' => $this->value,
    ));
  }

}

/**
 * Views OAI-PMH error unknown id.
 */
class views_oai_pmh_error_unknown_id extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($value) {
    parent::__construct('idDoesNotExist', '', $value);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The value of identifier '@value' is unknown in this repository.", array(
      '@value' => $this->value,
    ));
  }

}

/**
 * Views OAI-PMH error can not disseminate format.
 */
class views_oai_pmh_error_cannot_disseminate_format extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($value) {
    parent::__construct('cannotDisseminateFormat', '', $value);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The metadata prefix '@value' is not supported by this repository.", array(
      '@value' => $this->value,
    ));
  }

}

/**
 * Views OAI-PMH error bad resumption token.
 */
class views_oai_pmh_error_bad_resumption_token extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct($value) {
    parent::__construct('badResumptionToken', '', $value);
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t("The resumptionToken '@value' is invalid or has already expired.", array(
      '@value' => $this->value,
    ));
  }

}

/**
 * Views OAI-PMH error no records match.
 */
class views_oai_pmh_error_no_records_match extends views_oai_pmh_error {

  /**
   * Constructor.
   */
  public function __construct() {
    parent::__construct('noRecordsMatch');
  }

  /**
   * Return the message.
   */
  public function get_message() {
    return t('No records match the request criteria.');
  }

}

Classes

Namesort descending Description
views_oai_pmh_error Views OAI-PMH error.
views_oai_pmh_error_bad_argument Views OAI-PMH error bad argument.
views_oai_pmh_error_bad_resumption_token Views OAI-PMH error bad resumption token.
views_oai_pmh_error_bad_value Views OAI-PMH error bad value.
views_oai_pmh_error_bad_verb Views OAI-PMH error bad verb.
views_oai_pmh_error_cannot_disseminate_format Views OAI-PMH error can not disseminate format.
views_oai_pmh_error_exclusive_argument Views OAI-PMH error exclusive argument.
views_oai_pmh_error_invalid_id Views OAI-PMH error invalid id.
views_oai_pmh_error_missing_argument Views OAI-PMH error missing argument.
views_oai_pmh_error_missing_verb Views OAI-PMH error missing verb.
views_oai_pmh_error_no_records_match Views OAI-PMH error no records match.
views_oai_pmh_error_no_set_hierarchy Views OAI-PMH error no set hierarchy.
views_oai_pmh_error_unknown_id Views OAI-PMH error unknown id.