1 /*
2 * Copyright (c) 2023 Kaiserpfalz EDV-Service, Roland T. Lichti
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 package de.kaiserpfalzedv.services.dnb.client;
19
20 import org.springframework.cloud.openfeign.support.ResponseEntityDecoder;
21 import org.springframework.context.annotation.Bean;
22
23 import com.fasterxml.jackson.databind.ObjectMapper;
24
25 import de.kaiserpfalzedv.services.dnb.marcxml.MarcConverter;
26 import feign.Logger;
27 import feign.RequestInterceptor;
28
29 /**
30 *
31 * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
32 * @version 1.0.0
33 * @since 2023-12-11
34 */
35 // No @Configuration - otherwise it would be the default for all feign clients
36 public class DnbLookupClientConfig {
37 private static final String VERSION = "1.1";
38 private static final String OPERATION = "searchRetrieve";
39 private static final String RECORD_SCHEMA = "MARC21-xml";
40
41
42 @Bean
43 public RequestInterceptor dnbDefaultParameters() {
44 return requestTemplate -> requestTemplate
45 .query("operation", OPERATION)
46 .query("version", VERSION)
47 .query("recordSchema", RECORD_SCHEMA)
48 ;
49 }
50
51 @Bean
52 public ResponseEntityDecoder dnbDecoder() {
53 return new ResponseEntityDecoder(new Marc21Decoder(new MarcConverter(new ObjectMapper())));
54 }
55
56 @Bean
57 public Logger.Level logLevel() {
58 return Logger.Level.FULL;
59 }
60 }