@Override
  public Document queryPartner(
      PartnerConfiguration partnerConfiguration,
      SecureUserProfile userProfile,
      PartnerdataLogger logger)
      throws IOException {
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);

    Client client = Client.create(clientConfig);
    AccessTokenResponse accessTokenResponse = getAccessToken(client, partnerConfiguration);

    MendeleyResponse mR;
    try {
      mR = fetchSearchResults(client, userProfile, accessTokenResponse, partnerConfiguration);
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e1) {
      log.log(
          Level.SEVERE,
          "Could not get results from partner for query: "
              + userProfile
              + "\n with accestoken:"
              + accessTokenResponse
              + "\n and configuration:"
              + partnerConfiguration,
          e1);
      throw new IOException(e1);
    }
    client.destroy();
    ObjectMapper mapper =
        PartnerConfigurationEnum.CONFIG.getObjectMapper(); // can reuse, share globally
    for (MendeleyDocs doc : mR.getDocuments()) {
      doc.authorsString = getAuthorsString(doc.authors);
    }

    Document newResponse;
    try {
      newResponse = transformJSON2XML(mapper.writeValueAsString(mR));
    } catch (EEXCESSDataTransformationException e) {
      log.log(
          Level.SEVERE,
          "Partners response could not be transformed to xml for query: "
              + userProfile
              + "\n with accestoken:"
              + accessTokenResponse
              + "\n configuration:"
              + partnerConfiguration
              + "\n and repsonse:"
              + mR,
          e);
      throw new IOException(e);
    }
    return newResponse;
  }
  protected MendeleyResponse fetchSearchResults(
      Client client,
      SecureUserProfile userProfile,
      AccessTokenResponse accessTokenResponse,
      PartnerConfiguration partnerConfiguration)
      throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    String query = PartnerConfigurationEnum.CONFIG.getQueryGenerator().toQuery(userProfile);
    Map<String, String> valuesMap = new HashMap<String, String>();
    valuesMap.put("query", URLParamEncoder.encode(query));
    String searchRequest = StrSubstitutor.replace(partnerConfiguration.searchEndpoint, valuesMap);
    MendeleyResponse jsonResponse = getJSONResponse(client, accessTokenResponse, searchRequest);

    if (jsonResponse == null || jsonResponse.getDocuments() == null)
      log.log(Level.WARNING, "Mendeley returned an empty result list");

    int numResults = 100;
    if (userProfile.numResults != null) numResults = userProfile.numResults;

    jsonResponse.limitNumDocuments(numResults);

    return jsonResponse;
  }