Skip to content
Snippets Groups Projects
Commit c8a38d94 authored by llaffont's avatar llaffont
Browse files

Dispatch des requêtes OAI

parent 23cbbc51
No related merge requests found
......@@ -1763,6 +1763,9 @@ library/Class/WebService/LibraryThing.php -text
library/Class/WebService/MappedSoapClient.php -text
library/Class/WebService/OAI.php -text
library/Class/WebService/OAI/Response/Identify.php -text
library/Class/WebService/OAI/Response/ListSets.php -text
library/Class/WebService/OAI/Response/Null.php -text
library/Class/WebService/OAI/ResponseFactory.php -text
library/Class/WebService/Premiere.php -text
library/Class/WebService/ReseauxSociaux.php -text
library/Class/WebService/ResumptionToken.php -text
......
......@@ -23,10 +23,15 @@ class OaiController extends Zend_Controller_Action {
$this->getResponse()->setHeader('Content-Type', 'text/xml;charset=utf-8');
$this->getHelper('ViewRenderer')->setNoRender();
$baseUrl = $this->_request->getScheme() . ':' . $_SERVER['SERVER_NAME']
$request = Class_WebService_OAI_ResponseFactory::verbAndBaseUrl($this->_getParam('verb'),
$this->buildBaseUrl());
$this->_response->setBody($request->xml($this->_request->getParams()));
}
protected function buildBaseUrl() {
return $this->_request->getScheme() . ':' . $_SERVER['SERVER_NAME']
. BASE_URL . '/opac/oai/request';
$response = new Class_WebService_OAI_Response_Identify($baseUrl);
$this->_response->setBody($response->xml());
}
}
......
......@@ -20,24 +20,11 @@
*/
class Class_WebService_OAI_Response_Identify {
protected $_baseUrl;
public function __construct($baseUrl) {
$this->_baseUrl = $baseUrl;
}
public function xml() {
$builder = new Class_Xml_Builder();
class Class_WebService_OAI_Response_Identify extends Class_WebService_OAI_Response_Null {
public function buildXmlOn($builder) {
return
$builder->_tag(array('OAI-PMH' => array('xmlns' => 'http://www.openarchives.org/OAI/2.0/',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd')),
$builder->responseDate(date('c')).
$builder->request(array('verb' => 'Identify'),
$this->_baseUrl));
$builder->request(array('verb' => 'Identify'),
$this->_baseUrl);
}
}
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_OAI_Response_ListSets extends Class_WebService_OAI_Response_Null {
public function buildXmlOn($builder) {
return
$builder->request(array('verb' => 'ListSets'),
$this->_baseUrl);
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_OAI_Response_Null {
protected $_baseUrl;
public function __construct($baseUrl) {
$this->_baseUrl = $baseUrl;
}
public function xml() {
$builder = new Class_Xml_Builder();
return $builder->_tag(array('OAI-PMH' => array('xmlns' => 'http://www.openarchives.org/OAI/2.0/',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd')),
$builder->responseDate(date('c')).
$this->buildXmlOn($builder));
}
public function buildXmlOn($builder) {
return '';
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_OAI_ResponseFactory {
public static function verbAndBaseUrl($verb, $baseUrl) {
$instance = new self();
return $instance->responseForVerbAndBaseUrl($verb, $baseUrl);
}
public function responseForVerbAndBaseUrl($verb, $baseUrl) {
$classname = $this->getResponseClassByVerb($verb);
return new $classname($baseUrl);
}
public function getResponseClassByVerb($verb) {
return 'Class_WebService_OAI_Response_'.$verb;
}
}
?>
\ No newline at end of file
......@@ -20,15 +20,26 @@ rf<?php
*/
require_once 'AbstractControllerTestCase.php';
class OaiControllerRequestTest extends AbstractControllerTestCase {
abstract class OaiControllerListSetsRequestTestCase extends AbstractControllerTestCase {
protected $_xpath;
public function setUp() {
parent::setUp();
$this->dispatch('/opac/oai/request?verb=Identify');
$this->_xpath = new Storm_Test_XPathXML();
$this->_xpath->registerNameSpace('oai', 'http://www.openarchives.org/OAI/2.0/');
}
}
class OaiControllerIndentifyRequestTest extends OaiControllerListSetsRequestTestCase {
protected $_xpath;
public function setUp() {
parent::setUp();
$this->dispatch('/opac/oai/request?verb=Identify');
}
/** @test */
......@@ -50,4 +61,23 @@ class OaiControllerRequestTest extends AbstractControllerTestCase {
'//oai:request[@verb="Identify"]');
}
}
class OaiControllerListSetsRequestTest extends OaiControllerListSetsRequestTestCase {
protected $_xpath;
public function setUp() {
parent::setUp();
$this->dispatch('/opac/oai/request?verb=ListSets');
}
/** @test */
public function identifyShouldReturnIdentifyResponse() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//oai:request[@verb="ListSets"]');
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment