1 | <?php |
||
14 | class OclcFilteredHttpResponseParser extends FilteredHttpResponseParser { |
||
15 | |||
16 | /** |
||
17 | * @see http://dataliberate.com/2013/06/content-negotiation-for-worldcat/ |
||
18 | */ |
||
19 | const OCLC_REST = "http://www.worldcat.org/oclc/"; |
||
20 | |||
21 | /** |
||
22 | * @since 0.1 |
||
23 | * |
||
24 | * {@inheritDoc} |
||
25 | */ |
||
26 | 5 | public function getRawResponseById( $oclcID ) { |
|
27 | 5 | return $this->requestResponseFor( $oclcID ); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @since 0.1 |
||
32 | * |
||
33 | * {@inheritDoc} |
||
34 | */ |
||
35 | 7 | public function doFilterResponseById( $oclcID ) { |
|
36 | |||
37 | 7 | $text = $this->requestResponseFor( $oclcID ); |
|
38 | |||
39 | 7 | if ( $this->httpRequest->getLastError() !== '' ) { |
|
40 | 1 | return $this->addMessage( array( 'onoi-remi-request-error', $this->httpRequest->getLastError(), $oclcID ) ); |
|
41 | } |
||
42 | |||
43 | 6 | $jsonld = json_decode( $text, true ); |
|
44 | |||
45 | 6 | if ( $jsonld === null || $jsonld === '' ) { |
|
46 | 1 | return $this->addMessage( array( 'onoi-remi-response-empty', $oclcID ) ); |
|
47 | } |
||
48 | |||
49 | 5 | $this->doProcessJsonLd( $oclcID, $jsonld ); |
|
50 | |||
51 | 5 | $this->filteredRecord->set( 'retrieved-from', 'http://www.worldcat.org/' ); |
|
52 | 5 | } |
|
53 | |||
54 | 5 | private function doProcessJsonLd( $oclcID, $jsonld ) { |
|
62 | |||
63 | /** |
||
64 | * @param string $id |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 7 | public function requestResponseFor( $id ) { |
|
83 | |||
84 | } |
||
85 |