diff --git a/.gitattributes b/.gitattributes index c1296f7a8c220c11c92dd6f1bfa74d02b5c1d1cd..8b90c09eb31943cdaf9fded240889255dfa00491 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1775,6 +1775,8 @@ library/Class/WebService/OAI/Response/ListIdentifiers.php -text library/Class/WebService/OAI/Response/ListMetadataFormats.php -text library/Class/WebService/OAI/Response/ListSets.php -text library/Class/WebService/OAI/Response/Null.php -text +library/Class/WebService/OAI/Response/RecordBuilder.php -text +library/Class/WebService/OAI/Response/RecordHeadersBuilder.php -text library/Class/WebService/OAI/ResponseFactory.php -text library/Class/WebService/Premiere.php -text library/Class/WebService/ReseauxSociaux.php -text diff --git a/library/Class/WebService/OAI/Response/GetRecord.php b/library/Class/WebService/OAI/Response/GetRecord.php index 79bf0b7b44a26276e305109267039b90271a6df2..d3f1926595328ca71afe3c19f1078547a8335308 100644 --- a/library/Class/WebService/OAI/Response/GetRecord.php +++ b/library/Class/WebService/OAI/Response/GetRecord.php @@ -20,33 +20,20 @@ */ class Class_WebService_OAI_Response_GetRecord extends Class_WebService_OAI_Response_Null { protected $_notice; - protected $_dublin_core_visitor; public function buildXmlOn($builder) { if (null === $this->_notice) return ''; - $this->_dublin_core_visitor = new Class_Notice_DublinCoreVisitor(); - $this->_dublin_core_visitor->visit($this->_notice); + $visitor = new Class_Notice_DublinCoreVisitor(); + $visitor->visit($this->_notice); + $recordBuilder = new Class_WebService_OAI_Response_RecordBuilder(); return $builder->request(array('verb' => 'GetRecord', 'metadataPrefix' => 'oai_dc'), $this->_baseUrl) - . $builder->GetRecord($builder->record($this->_buildHeaders($builder) - . $this->_buildMetadata($builder))); - } - - - protected function _buildHeaders($builder) { - return - $builder->header($builder->identifier($this->_dublin_core_visitor->getIdentifier()) - . $builder->datestamp($this->_dublin_core_visitor->getDate())); - } - - - protected function _buildMetadata($builder) { - return $builder->metadata($this->_dublin_core_visitor->xml()); + . $builder->GetRecord($builder->record($recordBuilder->xml($builder, $visitor))); } diff --git a/library/Class/WebService/OAI/Response/ListIdentifiers.php b/library/Class/WebService/OAI/Response/ListIdentifiers.php index ae64d04286052b690b2845d99ab610c11e46e060..fc09344a3c4cd2518097a0d3a9b9df8ef215ff75 100644 --- a/library/Class/WebService/OAI/Response/ListIdentifiers.php +++ b/library/Class/WebService/OAI/Response/ListIdentifiers.php @@ -36,11 +36,11 @@ class Class_WebService_OAI_Response_ListIdentifiers extends Class_WebService_OAI public function headers($builder) { $visitor = new Class_Notice_DublinCoreVisitor(); + $recordBuilder = new Class_WebService_OAI_Response_RecordHeadersBuilder(); $headers = ''; foreach ($this->_notices as $notice) { $visitor->visit($notice); - $headers .= $builder->header($builder->identifier($visitor->getIdentifier()) - . $builder->datestamp($visitor->getDate())); + $headers .= $recordBuilder->xml($builder, $visitor); } return $headers; diff --git a/library/Class/WebService/OAI/Response/RecordBuilder.php b/library/Class/WebService/OAI/Response/RecordBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..a85c41cc00816b10d5832e041ed39b0346f6fa79 --- /dev/null +++ b/library/Class/WebService/OAI/Response/RecordBuilder.php @@ -0,0 +1,39 @@ +<?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_RecordBuilder { + public function xml($builder, $visitor) { + return + $this->buildHeaders($builder, $visitor) + . $this->buildMetadata($builder, $visitor); + } + + + public function buildHeaders($builder, $visitor) { + return $builder->header($builder->identifier($visitor->getIdentifier()) + . $builder->datestamp($visitor->getDate())); + } + + + public function buildMetadata($builder, $visitor) { + return $builder->metadata($visitor->xml()); + } +} +?> \ No newline at end of file diff --git a/library/Class/WebService/OAI/Response/RecordHeadersBuilder.php b/library/Class/WebService/OAI/Response/RecordHeadersBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..b07516ac6b4979b82f77a4779b861c1453e82081 --- /dev/null +++ b/library/Class/WebService/OAI/Response/RecordHeadersBuilder.php @@ -0,0 +1,26 @@ +<?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_RecordHeadersBuilder extends Class_WebService_OAI_Response_RecordBuilder { + public function buildMetadata($builder, $visitor) { + return ''; + } +} +?> \ No newline at end of file diff --git a/tests/library/Class/WebService/OAI/Response/ListIdentifiersTest.php b/tests/library/Class/WebService/OAI/Response/ListIdentifiersTest.php index 2fea1bc9f9e80b040ccc216210dbd9f72df4a787..1b7889e26682daeef5b99fe22d4978809569a679 100644 --- a/tests/library/Class/WebService/OAI/Response/ListIdentifiersTest.php +++ b/tests/library/Class/WebService/OAI/Response/ListIdentifiersTest.php @@ -56,6 +56,13 @@ class ListIdentifiersTest extends Storm_Test_ModelTestCase { 3); } + + /** @test */ + public function shouldNotHaveMetadata() { + $this->_xpath->assertNotXpath($this->_response->xml(), + '//oai:ListIdentifiers/oai:metadata'); + } + /** @test */ public function firstIdentifierShouldContainSorciers() {