@@ -89,6 +89,7 @@ public class QueryURLImport implements ExternalDataImportInterface {
8989 private static final String HTTPS_PROTOCOL = "https" ;
9090 private static final String FTP_PROTOCOL = "ftp" ;
9191 private static final String EQUALS_OPERAND = "=" ;
92+ private static final String EQUALS_OPERAND_ENCODED = "%3D" ;
9293 private static final String AND = "&" ;
9394 private static final String OAI_IDENTIFIER = "identifier" ;
9495 private final Charset encoding = StandardCharsets .UTF_8 ;
@@ -269,10 +270,11 @@ private DataRecord performQueryToRecord(DataImport dataImport, String queryURL,
269270 String prefix = Objects .nonNull (idPrefix ) && !identifier .startsWith (idPrefix ) ? idPrefix : "" ;
270271 String idParameter = SearchInterfaceType .OAI .equals (dataImport .getSearchInterfaceType ()) ? OAI_IDENTIFIER
271272 : dataImport .getIdParameter ();
273+ String encodedValue = URLEncoder .encode (prefix + identifier , encoding );
272274 if (SearchInterfaceType .SRU .equals (interfaceType )) {
273- fullUrl += URLEncoder . encode ( idParameter + EQUALS_OPERAND + prefix + identifier , encoding ) ;
275+ fullUrl += idParameter + EQUALS_OPERAND_ENCODED + encodedValue ;
274276 } else {
275- fullUrl += URLEncoder . encode ( idParameter , encoding ) + EQUALS_OPERAND + URLEncoder . encode ( prefix + identifier , encoding ) ;
277+ fullUrl += idParameter + EQUALS_OPERAND + encodedValue ;
276278 }
277279 try {
278280 this .reinitializeHttpClient (dataImport .getUsername (), dataImport .getPassword ());
@@ -414,17 +416,17 @@ private String createQueryParameterString(LinkedHashMap<String, String> searchFi
414416 }
415417
416418 private String createSearchFieldString (SearchInterfaceType interfaceType , LinkedHashMap <String , String > searchFields ) {
417- String searchString = "" ;
418419 List <String > searchOperands = searchFields .entrySet ().stream ()
419- .map (entry -> entry .getKey () + EQUALS_OPERAND + entry .getValue ())
420+ .map (entry -> {
421+ String key = entry .getKey ();
422+ String value = entry .getValue ();
423+ String encodedValue = URLEncoder .encode (value , encoding );
424+ return SearchInterfaceType .SRU .equals (interfaceType )
425+ ? key + EQUALS_OPERAND_ENCODED + encodedValue
426+ : key + EQUALS_OPERAND + encodedValue ;
427+ })
420428 .collect (Collectors .toList ());
421- if (SearchInterfaceType .SRU .equals (interfaceType )) {
422- searchString = URLEncoder .encode (String .join (" AND " , searchOperands ), encoding );
423- } else {
424- searchOperands .replaceAll (s -> !s .equals (EQUALS_OPERAND ) ? URLEncoder .encode (s , encoding ) : s );
425- searchString = String .join (" AND " , searchOperands );
426- }
427- return searchString ;
429+ return String .join (" AND " , searchOperands );
428430 }
429431
430432 private Document stringToDocument (String xmlContent ) throws ParserConfigurationException , IOException ,
0 commit comments