executeAdapterRequest () не работает при вызове другого java адаптера - PullRequest
0 голосов
/ 18 марта 2020

Кто-нибудь знает, почему executeAdapterRequest() не работает здесь, когда я вызываю другой адаптер ( NotificationAdapter ) в mfp? При тестировании HKSampleAdapter / getAdvisorCount в Postman, я получаю сообщение об ошибке

"Unexpected error in server, see logs" Status: 500 Internal Server Error. 

При проверке mfp Analytics код не выполняется в строке

logger.info("get response [getAdvisorCount] " + response.toString());

Так что я думаю executeAdapterRequest() не работает.

HKSampleAdapter

  @OAuthSecurity(scope = "UserAuthentication")
  @GET
  @Path("/getAdvisorCount")
  @Produces(MediaType.APPLICATION_JSON)
  public JSONObject getAdvisorCount(@HeaderParam("Correlation-Id") String correlationId,
      @HeaderParam("Set-Language") String lang)
      throws ClientProtocolException, IOException, IllegalStateException, SAXException {
    try {
      String adapterUrl = "/NotificationAdapter/getNotificationCount";

      HttpUriRequest request = new HttpGet(adapterUrl);
      request.addHeader(CONTENT_TYPE, APP_JSON);
      request.addHeader(ACCEPT, APP_JSON);
      request.addHeader(CORRELATION_ID, correlationId);
      request.addHeader("Set-Language", lang);
      logger.info("get request [getAdvisorCount] " + request.toString());

      HttpResponse response = adaptersAPI.executeAdapterRequest(request);
      logger.info("get response [getAdvisorCount] " + response.toString());

      JSONObject jsonGetNotificationCount = adaptersAPI.getResponseAsJSON(response);

      String notificationType = (String) jsonGetNotificationCount.get("notificationType");
      JSONObject jsonObj = new JSONObject();
      jsonObj.put("notificationType", notificationType);
      return jsonObj;
    } catch (Exception e) {
      logger.severe("Error getAdvisorCount" + e.getMessage());
      return null;
    }
  }

NotificationAdapter

  @OAuthSecurity(scope = "UserAuthentication")
  @GET
  @Path("/getNotificationCount")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getNotificationCount(@HeaderParam("Correlation-Id") String correlationId,
      @HeaderParam("Set-Language") String lang)
      throws ClientProtocolException, IOException, IllegalStateException, SAXException {
    try {
      lang = this.getLanguage(lang);
      String userId = this.getUserId(correlationId);
      logger.info("getNotificationCount currentUser>>" + correlationId + " - " + userId);

      String url = API_CONTEXT + "/advisors/" + userId + "?version=" + VERSION + "&language="
          + lang.toLowerCase();

      HttpGet request = new HttpGet(url);
      request.addHeader(CONTENT_TYPE, APP_JSON);
      request.addHeader(ACCEPT, APP_JSON);
      request.addHeader(CORRELATION_ID, correlationId);

      HttpResponse response = httpClient.execute(host, request);

      Integer statusCode = response.getStatusLine().getStatusCode();

      String json = EntityUtils.toString(response.getEntity(), ENCODING);

      if (statusCode == HttpStatus.SC_OK) {
        return Response.ok().entity(json).build();
      } else {
        return Response.status(statusCode).entity(response.getStatusLine().getReasonPhrase())
            .build();
      }
    } catch (Exception e) {
      logger.info("Error getNotificationCount" + e.getMessage());
      return null;
    }
  }
...