add GetRecord to OAI request
This commit is contained in:
parent
f0e84a2991
commit
559dd4ee10
6 changed files with 200 additions and 10 deletions
|
@ -11,6 +11,7 @@ use App\Models\Person;
|
|||
use App\Models\XmlCache;
|
||||
use App\Models\File;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Dataset extends Model
|
||||
{
|
||||
|
@ -40,6 +41,7 @@ class Dataset extends Model
|
|||
'server_date_created',
|
||||
'server_date_modified',
|
||||
'server_date_published',
|
||||
'embargo_date',
|
||||
];
|
||||
//protected $dateFormat = 'Y-m-d';
|
||||
|
||||
|
@ -209,4 +211,31 @@ class Dataset extends Model
|
|||
{
|
||||
return $this->project()->exists();
|
||||
}
|
||||
|
||||
|
||||
public function hasEmbargoPassed($now = null)
|
||||
{
|
||||
$embargoDate = $this->embargo_date;
|
||||
if (is_null($embargoDate)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_null($now)) {
|
||||
$now = $dt = Carbon::now();
|
||||
}
|
||||
// Embargo has passed on the day after the specified date
|
||||
// $embargoDate->setHour(23);
|
||||
// $embargoDate->setMinute(59);
|
||||
// $embargoDate->setSecond(59);
|
||||
// $embargoDate->setTimezone('Z');
|
||||
|
||||
// $dt->year = 2015;
|
||||
// $dt->month = 04;
|
||||
// $dt->day = 21;
|
||||
$embargoDate->hour = 23;
|
||||
$embargoDate->minute = 59;
|
||||
$embargoDate->second = 59;
|
||||
|
||||
return ($embargoDate->gt($now) == true);
|
||||
}
|
||||
}
|
||||
|
|
42
app/Models/OaiModelError.php
Normal file
42
app/Models/OaiModelError.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class OaiModelError
|
||||
{
|
||||
/**
|
||||
* Define all valid error codes.
|
||||
*/
|
||||
const BADVERB = 1010;
|
||||
const BADARGUMENT = 1011;
|
||||
const CANNOTDISSEMINATEFORMAT = 1012;
|
||||
const BADRESUMPTIONTOKEN = 1013;
|
||||
const NORECORDSMATCH = 1014;
|
||||
const IDDOESNOTEXIST = 1015;
|
||||
/**
|
||||
* Holds OAI error codes for internal error numbers.
|
||||
*
|
||||
* @var array Valid OAI parameters.
|
||||
*/
|
||||
protected static $oaiErrorCodes = array(
|
||||
self::BADVERB => 'badVerb',
|
||||
self::BADARGUMENT => 'badArgument',
|
||||
self::NORECORDSMATCH => 'noRecordsMatch',
|
||||
self::CANNOTDISSEMINATEFORMAT => 'cannotDisseminateFormat',
|
||||
self::BADRESUMPTIONTOKEN => 'badResumptionToken',
|
||||
self::IDDOESNOTEXIST => 'idDoesNotExist',
|
||||
);
|
||||
/**
|
||||
* Map internal error codes to OAI error codes.
|
||||
*
|
||||
* @param int $code Internal error code.
|
||||
* @return string OAI error code.
|
||||
*/
|
||||
public static function mapCode($code)
|
||||
{
|
||||
if (false === array_key_exists($code, self::$oaiErrorCodes)) {
|
||||
throw new Oai_Model_Exception("Unknown oai error code $code");
|
||||
}
|
||||
return self::$oaiErrorCodes[$code];
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue