- 'from' and 'until' paramter in ReuqestController.php for OAI requests

- composer updates
- configure solr host with protocol
This commit is contained in:
Arno Kaimbacher 2020-07-27 13:58:47 +02:00
parent f62f812a0d
commit 3125df767b
4 changed files with 376 additions and 166 deletions

View File

@ -350,6 +350,12 @@ class RequestController extends Controller
$this->proc->setParameter('', 'oai_error_message', 'The verb provided in the request is illegal.');
}
private function checkmydate($date)
{
$tempDate = explode('-', $date);
return checkdate($tempDate[1], $tempDate[2], $tempDate[0]);
}
/**
* Helper method for handling lists.
*
@ -425,6 +431,43 @@ class RequestController extends Controller
}
}
// if (array_key_exists('from', $oaiRequest) && array_key_exists('until', $oaiRequest)) {
// $from = $oaiRequest['from'];
// $fromDate = \Illuminate\Support\Carbon::parse($from);
// $until = $oaiRequest['until'];
// }
if (array_key_exists('until', $oaiRequest)) {
$until = $oaiRequest['until'];
if ($this->checkmydate($until) == true) {
$earliestPublicationDate = Dataset::earliestPublicationDate()->server_date_published;//->format('Y-m-d\TH:i:s\Z');
$untilDate = \Illuminate\Support\Carbon::parse($until);
if ($earliestPublicationDate->gt($untilDate)) {
throw new OaiModelException(
"Given until date is greater than 'earliestDatestamp'. The given values results in an empty list.",
OaiModelError::NORECORDSMATCH
);
} else {
$finder->whereDate('server_date_published', '<=', date($until));
}
}
}
if (array_key_exists('from', $oaiRequest)) {
$from = $oaiRequest['from'];
if ($this->checkmydate($from) == true) {
$now = new Carbon();
$fromDate = \Illuminate\Support\Carbon::parse($from);
if ($fromDate->gt($now)) {
throw new OaiModelException(
"Given from date is grater than now. The given values results in an empty list.",
OaiModelError::NORECORDSMATCH
);
} else {
$finder->whereDate('server_date_published', '>=', date($from));
}
}
}
$totalIds = $finder->count();
$reldocIds = $finder->orderBy('publish_id')->pluck('publish_id')->toArray();
}

494
composer.lock generated

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,8 @@ export default {
// solr endpoint
// const host = 'http://voyagerdemo.com/';
//const host = 'https://www.tethys.at/';
const host = 'https://' + solrHost;
//const host = 'https://' + solrHost;
const host = solrHost;
const path = '/solr/' + solrCore + '/select?';
var base = host + path;