- throw 'bad verb' if no verb is given in oai -request
- handleGetRecord: break if no identifier is given - handleGetRecord: break if no metadataPrefix is given - allow post and get for oai requests
This commit is contained in:
parent
64faf73564
commit
4a6c69100a
|
@ -145,9 +145,10 @@ class RequestController extends Controller
|
||||||
$this->handleIllegalVerb();
|
$this->handleIllegalVerb();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$oaiRequest['verb'] = 'Identify';
|
// $oaiRequest['verb'] = 'Identify';
|
||||||
$this->proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
// $this->proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||||
$this->doc = $this->handleIdentify();
|
// $this->doc = $this->handleIdentify();
|
||||||
|
throw new OaiModelException('The verb provided in the request is illegal.', OaiModelError::BADVERB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,8 +185,17 @@ class RequestController extends Controller
|
||||||
{
|
{
|
||||||
$repIdentifier = "tethys.at";
|
$repIdentifier = "tethys.at";
|
||||||
$this->proc->setParameter('', 'repIdentifier', $repIdentifier);
|
$this->proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Identifier references metadata Urn, not plain Id!
|
// Identifier references metadata Urn, not plain Id!
|
||||||
// Currently implemented as 'oai:foo.bar.de:{docId}' or 'urn:nbn...-123'
|
// Currently implemented as 'oai:foo.bar.de:{docId}' or 'urn:nbn...-123'
|
||||||
|
if (!array_key_exists('identifier', $oaiRequest)) {
|
||||||
|
throw new OaiModelException(
|
||||||
|
'The prefix of the identifier argument is unknown.',
|
||||||
|
OaiModelError::BADARGUMENT
|
||||||
|
);
|
||||||
|
}
|
||||||
$dataId = $this->getDocumentIdByIdentifier($oaiRequest['identifier']);
|
$dataId = $this->getDocumentIdByIdentifier($oaiRequest['identifier']);
|
||||||
|
|
||||||
$dataset = null;
|
$dataset = null;
|
||||||
|
@ -203,6 +213,11 @@ class RequestController extends Controller
|
||||||
$metadataPrefix = null;
|
$metadataPrefix = null;
|
||||||
if (true === array_key_exists('metadataPrefix', $oaiRequest)) {
|
if (true === array_key_exists('metadataPrefix', $oaiRequest)) {
|
||||||
$metadataPrefix = $oaiRequest['metadataPrefix'];
|
$metadataPrefix = $oaiRequest['metadataPrefix'];
|
||||||
|
} else {
|
||||||
|
throw new OaiModelException(
|
||||||
|
'The prefix of the metadata argument is unknown.',
|
||||||
|
OaiModelError::BADARGUMENT
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
$this->proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,6 @@ class VerifyCsrfToken extends Middleware
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
//
|
'oai*',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Models\Oai;
|
namespace App\Models\Oai;
|
||||||
|
|
||||||
|
use App\Exceptions\OaiModelException;
|
||||||
|
|
||||||
class OaiModelError
|
class OaiModelError
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +37,7 @@ class OaiModelError
|
||||||
public static function mapCode($code)
|
public static function mapCode($code)
|
||||||
{
|
{
|
||||||
if (false === array_key_exists($code, self::$oaiErrorCodes)) {
|
if (false === array_key_exists($code, self::$oaiErrorCodes)) {
|
||||||
throw new Oai_Model_Exception("Unknown oai error code $code");
|
throw new OaiModelException("Unknown oai error code $code");
|
||||||
}
|
}
|
||||||
return self::$oaiErrorCodes[$code];
|
return self::$oaiErrorCodes[$code];
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Route;
|
||||||
//Auth::routes();
|
//Auth::routes();
|
||||||
//Route::get('/home', 'HomeController@index')->name('home');
|
//Route::get('/home', 'HomeController@index')->name('home');
|
||||||
|
|
||||||
Route::get('/oai', ['as' => 'oai', 'uses' => 'Oai\RequestController@index']);
|
Route::match(array('GET','POST'), '/oai', ['as' => 'oai', 'uses' => 'Oai\RequestController@index']);
|
||||||
|
|
||||||
//Route::get('/', 'LocalizationController@index');
|
//Route::get('/', 'LocalizationController@index');
|
||||||
Route::get(
|
Route::get(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user