diff --git a/app/Http/Controllers/Oai/RequestController.php b/app/Http/Controllers/Oai/RequestController.php index 7f34cdd..f916f03 100644 --- a/app/Http/Controllers/Oai/RequestController.php +++ b/app/Http/Controllers/Oai/RequestController.php @@ -145,9 +145,10 @@ class RequestController extends Controller $this->handleIllegalVerb(); } } else { - $oaiRequest['verb'] = 'Identify'; - $this->proc->setParameter('', 'oai_verb', $oaiRequest['verb']); - $this->doc = $this->handleIdentify(); + // $oaiRequest['verb'] = 'Identify'; + // $this->proc->setParameter('', 'oai_verb', $oaiRequest['verb']); + // $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"; $this->proc->setParameter('', 'repIdentifier', $repIdentifier); + + + // Identifier references metadata Urn, not plain Id! // 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']); $dataset = null; @@ -203,6 +213,11 @@ class RequestController extends Controller $metadataPrefix = null; if (true === array_key_exists('metadataPrefix', $oaiRequest)) { $metadataPrefix = $oaiRequest['metadataPrefix']; + } else { + throw new OaiModelException( + 'The prefix of the metadata argument is unknown.', + OaiModelError::BADARGUMENT + ); } $this->proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix); diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 6c8c1c9..f727870 100755 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -11,6 +11,6 @@ class VerifyCsrfToken extends Middleware * @var array */ protected $except = [ - // + 'oai*', ]; } diff --git a/app/Models/Oai/OaiModelError.php b/app/Models/Oai/OaiModelError.php index 5dabd23..16b3f26 100644 --- a/app/Models/Oai/OaiModelError.php +++ b/app/Models/Oai/OaiModelError.php @@ -2,6 +2,8 @@ namespace App\Models\Oai; +use App\Exceptions\OaiModelException; + class OaiModelError { /** @@ -35,7 +37,7 @@ class OaiModelError public static function mapCode($code) { 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]; } diff --git a/routes/web.php b/routes/web.php index bdf533d..88fbc35 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Route; //Auth::routes(); //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(