@Monitor(
      server = POIDETAIL_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_POI_DETAIL")
  private DetectResult monitorPoiDetailServer() {
    DetectResult result = new DetectResult();

    ContentInfoServiceStub stub = null;
    try {
      TnContext tc = BackendServerMonitorUtil.createTnContext();

      GetPoiDetailsRequest getPoiDetailRequest = new GetPoiDetailsRequest();
      getPoiDetailRequest.setClientName(HtmlConstants.clientName);
      getPoiDetailRequest.setClientVersion(HtmlConstants.clientVersion);
      getPoiDetailRequest.setContextString(tc.toContextString());
      getPoiDetailRequest.setTransactionId(System.currentTimeMillis() + "");
      getPoiDetailRequest.setPoiId(getSamplePoiId());

      stub = new ContentInfoServiceStub(WebServiceConfigurator.getUrlOfPoiDetail());
      GetPoiDetailsResponse getPoiDetailResponse = stub.getPoiDetails(getPoiDetailRequest);
      com.telenav.datatypes.services.v20.ResponseStatus status =
          getPoiDetailResponse.getResponseStatus();

      // poi detail can't be found is ok. only 20%-30% has detail information from zhangpan.
      if ("OK".equals(status.getStatusCode())
          || "DB_DATA_NOT_FOUND".equals(status.getStatusCode())) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.msg =
            "responseCode = "
                + status.getStatusCode()
                + ", responseMessage = "
                + status.getStatusMessage();
        logger.debug(result.msg);
      }

    } catch (Exception ex) {
      logger.fatal("#monitorLogoImageServer", ex);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when get logo image"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(ex);
    } finally {
      if (stub != null) {
        try {
          WebServiceUtils.cleanupStub(stub);
        } catch (Exception ex) {
        }
      }
    }
    return result;
  }
  @Monitor(
      server = LOGOIMAGE_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_GETLOGOIMAGE")
  private DetectResult monitorLogoImageServer() {
    DetectResult result = new DetectResult();

    HttpClient httpClient = null;
    HttpMethod method = null;
    try {
      String getLogImageUrl = WebServiceConfigurator.getUrlOfLogoImage();
      String url =
          MessageFormat.format(getLogImageUrl, "/tnimages/logo/cat-accomodation.png", "90", "90");
      method = new GetMethod(url);
      httpClient = new HttpClient();
      httpClient.executeMethod(method);
      String image = "";
      byte[] imageBytes = method.getResponseBody();
      if (method.getStatusCode() == 200) {
        if (imageBytes != null && imageBytes.length != 0) {
          image = Utility.byteArrayToBase64(imageBytes);
        }

        if (image != null && image.length() > 0) {
          result.isSuccess = true;
        } else {
          result.isSuccess = false;
          result.msg =
              image == null
                  ? "Image is null. Image url is " + url
                  : "result is empty. Image url is " + url;
        }
      } else {
        result.isSuccess = false;
        result.msg = "http status code is " + method.getStatusCode();
      }

    } catch (Exception ex) {
      logger.fatal("#monitorLogoImageServer", ex);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when get logo image"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(ex);
    } finally {
      if (method != null) {
        try {
          method.releaseConnection();
        } catch (Exception ex) {
        }
      }
    }
    return result;
  }
  @Monitor(
      server = ORGANICADVERTISE_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_ORGANIC_ADS_SEARCH")
  private DetectResult monitorOrganicAdvertiseServer() {
    DetectResult result = new DetectResult();

    com.telenav.services.content.ads.v10.AdServiceStub stub = null;
    try {
      TnContext tc = BackendServerMonitorUtil.createTnContext();

      AdServiceOrganicAdsRequestDTO requestDTO = new AdServiceOrganicAdsRequestDTO();
      requestDTO.setClientName(HtmlConstants.clientName);
      requestDTO.setClientVersion(HtmlConstants.clientVersion);
      requestDTO.setContextString(tc.toContextString());
      requestDTO.setTransactionId(HtmlPoiUtil.getTrxId());
      long[] poiIds = new long[1];
      poiIds[0] = getSamplePoiId();
      requestDTO.setPoiIds(poiIds);

      stub =
          new com.telenav.services.content.ads.v10.AdServiceStub(
              WebServiceConfigurator.getUrlOfOrganicAdsSearch());
      AdServiceResponseDTO response = stub.getOrganicAds(requestDTO);

      if (response != null) {
        result.isSuccess = true;

      } else {
        result.isSuccess = false;
        result.msg = "response is null";
      }
    } catch (Exception ex) {
      logger.fatal("#monitorOrganicAdvertiseServer", ex);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when get logo get organic advertise"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(ex);
    } finally {
      if (stub != null) {
        try {
          WebServiceUtils.cleanupStub(stub);
        } catch (Exception ex) {
        }
      }
    }
    return result;
  }
  @Monitor(
      server = USER_MANAGEMENT_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_POI_REVIEW_WRITE")
  private DetectResult monitorUserManagementServer() {

    DetectResult result = new DetectResult();

    UserManagementServiceStub stub = null;
    try {
      UserProfile userProfile = BackendServerMonitorUtil.createUserProfile();
      TnContext tc = BackendServerMonitorUtil.createTnContext();

      GetUserRequestDTO getUserRequest = new GetUserRequestDTO();
      getUserRequest.setParam(userProfile.getUserId() + "");
      getUserRequest.setParamType(UserQueryBy.USER_ID);

      getUserRequest.setClientName(HtmlConstants.clientName);
      getUserRequest.setClientVersion(HtmlConstants.clientVersion);
      getUserRequest.setContextString(tc.toContextString());
      getUserRequest.setTransactionId(HtmlPoiUtil.getTrxId());
      // get userInfo
      stub = new UserManagementServiceStub(WebServiceConfigurator.getUrlOfPoiReviewWrite());
      GetUserResponseDTO response = stub.getUser(getUserRequest);
      if (response != null) {
        if (response.getUser() != null) {
          result.isSuccess = true;
        } else {
          result.isSuccess = false;
          result.msg = "GetUserResponseDTO.getUser() is null";
        }
      } else {
        result.isSuccess = false;
        result.msg = "GetUserResponseDTO is Null";
      }
    } catch (Exception ex) {
      logger.fatal("#monitorUserManagementServer", ex);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when getUserName"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(ex);
    } finally {
      if (stub != null) {
        WebServiceUtils.cleanupStub(stub);
      }
    }
    return result;
  }
  @Monitor(
      server = WHETHER_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_WEATHER")
  private DetectResult monitorWhetherServer() {
    DetectResult result = new DetectResult();

    WeatherServiceStub stub = null;
    try {
      I18NWeatherServiceRequestDTO request = new I18NWeatherServiceRequestDTO();
      request.setClientName("6x-cserver");
      request.setClientVersion("1.0");
      request.setTransactionId("unknown");

      Location location = new Location();
      com.telenav.ws.datatypes.address.GeoCode latLon =
          new com.telenav.ws.datatypes.address.GeoCode();
      latLon.setLatitude(37.37515);
      latLon.setLongitude(-121.99769);
      location.setGeoCode(latLon);
      request.setLocation(location);

      request.setNumberOfDays(2);

      stub = new WeatherServiceStub(WebServiceConfigurator.getUrlOfWeather());
      I18NWeatherServiceResponseDTO response = stub.getI18NCurrentNForecast(request);
      String statusCode = response.getResponseStatus().getStatusCode();
      String statusMessage = response.getResponseStatus().getStatusMessage();
      if ("OK".equals(statusCode)) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.msg = "StatusCode = " + statusCode + ", StatusMessage = " + statusMessage;
      }

    } catch (Exception e) {
      logger.fatal("#monitorWhetherServer", e);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when getI18NCurrentNForecast"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(e);
    } finally {
      if (stub != null) {
        WebServiceUtils.cleanupStub(stub);
      }
    }
    return result;
  }
  @Monitor(
      server = FEEDBACK_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_FEEDBACK_SERVER")
  private DetectResult monitorFeedbackServer() {
    DetectResult result = new DetectResult();

    FeedbackServiceStub stub = null;
    try {
      stub = new FeedbackServiceStub(WebServiceConfigurator.getUrlOfFeedbackServer());
      GetFeedbackQuestionsRequestDTO requestDTO = new GetFeedbackQuestionsRequestDTO();

      // requestDTO.setTopic(topic);
      requestDTO.setLocale("en_US");
      requestDTO.setTopicString("fakeTopic");
      requestDTO.setCarrier(null); // (userProfile.getCarrier());
      requestDTO.setPlatform(null); // userProfile.getPlatform());
      requestDTO.setClientName("default"); // ("c-server");
      requestDTO.setClientVersion("default"); // (userProfile.getVersion());
      // requestDTO.setDevice(null);//(userProfile.getDevice());
      requestDTO.setTransactionId("default"); // ("unknown");

      GetFeedbackQuestionsResponseDTO response = stub.getAllFeedbackQuestions(requestDTO);

      if ("OK".equals(response.getResponseStatus().getStatusCode())) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.msg =
            "responseCode = "
                + response.getResponseStatus().getStatusCode()
                + ", responseMessage = "
                + response.getResponseStatus().getStatusMessage();
      }
    } catch (Exception e) {
      result.isSuccess = false;
      result.msg = "Error when getAllFeedbackQuestions. Exception occurs->" + e.getMessage();
    } finally {
      if (stub != null) {
        WebServiceUtils.cleanupStub(stub);
      }
    }

    return result;
  }
  @Monitor(
      server = ONEBOXSEARCH_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_PROPERTIES,
      filePath = "config/web_services.properties",
      serviceUrlKeys = "URL_ONE_BOX_SEARCH")
  private DetectResult monitorOneBoxSearchServer() {
    DetectResult result = new DetectResult();

    OneboxSearchServiceStub stub = null;
    try {
      UserProfile userProfile = BackendServerMonitorUtil.createUserProfile();
      TnContext tc = BackendServerMonitorUtil.createTnContext();

      OneboxSearchRequest obReq = new OneboxSearchRequest();

      // set user
      UserInformation user = new UserInformation();
      UserProfile usrProfile = userProfile;
      user.setUserId(usrProfile.getUserId());
      user.setPtn(usrProfile.getMin());
      obReq.setUserInfo(user);

      // set client info
      Date today = new Date();
      // using date only
      String trxnId = String.valueOf(today.getTime());
      obReq.setClientName(ClientNameEnum._MOBILE);
      obReq.setClientVersion("1");
      obReq.setTransactionId(trxnId);

      // set POI data set() and MAP data set
      obReq.setContextString(tc.toContextString());

      // set anchor
      com.telenav.ws.datatypes.address.GeoCode latLon =
          new com.telenav.ws.datatypes.address.GeoCode();
      latLon.setLatitude(37.37453);
      latLon.setLongitude(-121.99983);
      obReq.setAnchor(latLon);

      // set query
      obReq.setQuery("coffee");
      obReq.setStartIndex(0);
      obReq.setResultCount(10);
      // TODO: check sponsor number
      obReq.setSponsorStartIndex(0);
      obReq.setSponsorResultCount(1);
      obReq.setLocale(CommonUtil.getTnLocal(userProfile.getLocale()));
      obReq.setSponsorResultCount(100);
      obReq.setTransactionId(System.currentTimeMillis() + "");

      stub = new OneboxSearchServiceStub(WebServiceConfigurator.getUrlOfOneBox());
      OneboxSearchResponse response = stub.oneboxSearch(obReq);

      if (response != null && "RESULT_FOUND".equals(response.getResponseStatus().getStatusCode())) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.msg =
            response == null
                ? "Response is null."
                : "StatusCode = "
                    + response.getResponseStatus().getStatusCode()
                    + ", StatusMessage = "
                    + response.getResponseStatus().getStatusMessage();
      }

    } catch (Exception e) {
      logger.fatal("#monitorOneBoxSearchServer", e);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when one box search"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(e);
    } finally {
      if (stub != null) {
        WebServiceUtils.cleanupStub(stub);
      }
    }
    return result;
  }