private void setUserProfileToTnContext( TnContext tc, UserProfile userProfile, ExecutorContext context) { String loginName = userProfile.getMin(); String carrier = userProfile.getCarrier(); String device = userProfile.getDevice(); String product = userProfile.getPlatform(); String version = userProfile.getVersion(); String userID = userProfile.getUserId(); String applicationName = userProfile.getProduct(); String mapDpi = userProfile.getMapDpi(); String locale = userProfile.getLocale(); String programCode = userProfile.getProgramCode(); tc.addProperty(TnContext.PROP_LOGIN_NAME, loginName); tc.addProperty(TnContext.PROP_CARRIER, carrier); tc.addProperty(TnContext.PROP_DEVICE, device); tc.addProperty(TnContext.PROP_PRODUCT, product); tc.addProperty(TnContext.PROP_VERSION, version); // tc.addProperty("user_family", // Long.toString(ResourceLoader.getInstance().getUserFamily(userProfile))); tc.addProperty("application", applicationName); // "application" should defined in TnContext tc.addProperty("c-server class", Constants.CSERVER_CLASS); tc.addProperty("c-server url", context.getServerUrl()); tc.addProperty("map_dpi", mapDpi); tc.addProperty("locale", locale); tc.addProperty(PROP_PROGRAM_CODE, programCode); tc.addProperty(TnContext.PROP_REQUESTOR, TnContext.TT_REQUESTOR_TNCLIENT); tc.addProperty(PROP_REGION, userProfile.getRegion()); }
@Monitor( server = POISEARCH_SERVER, parserClass = ServiceUrlParserFactory.CLASS_XML_WEBSERVICE, serviceUrlKeys = "POI_SEARCH") private DetectResult monitorPoiSearchServer() { DetectResult result = new DetectResult(); try { UserProfile userProfile = BackendServerMonitorUtil.createUserProfile(); PoiSearchProxy proxy = new PoiSearchProxy(new TnContext()); PoiSearchRequest poiReq = new PoiSearchRequest(); poiReq.setRegion(userProfile.getRegion()); Address anchor = new Address(); anchor.setLatitude(37.37453); anchor.setLongitude(-121.99983); poiReq.setAnchor(anchor); poiReq.setCategoryId(-1); poiReq.setCategoryVersion("YP50"); poiReq.setHierarchyId(1); poiReq.setNeedUserPreviousRating(false); poiReq.setPoiQuery("coff"); // poiReq.setPoiSortType(); poiReq.setRadiusInMeter(7000); poiReq.setUserId(Long.parseLong(userProfile.getUserId())); poiReq.setPageNumber(0); poiReq.setPageSize(10); poiReq.setMaxResult(10); poiReq.setOnlyMostPopular(false); poiReq.setAutoExpandSearchRadius(true); // poiReq.setSponsorListingNumber(poiRequest.getSponsorListingNumber()); poiReq.setNeedUserGeneratePois(true); poiReq.setNeedSponsoredPois(true); poiReq.setTransactionId(System.currentTimeMillis() + ""); PoiSearchResponse response = proxy.searchWithinDistance(poiReq); if (response != null && response.getPoiSearchStatus() == ErrorCode.POI_STATUS_SUCCESS) { if (response.getPois().size() != 0) { result.isSuccess = true; this.samplePoiId = response.getPois().get(0).getPoiId(); } else { result.isSuccess = false; result.msg = "Status is successful. But response don't contain any poi"; } } else { result.isSuccess = false; result.msg = response == null ? "response is null" : "StatusCode = " + response.getPoiSearchStatus(); } } catch (Exception ex) { logger.fatal("#monitorPoiSearchServer", ex); result.isSuccess = false; result.msg = "Exception occurs when search poi" + ". Exception msg->" + ExceptionUtil.collectExceptionMsg(ex); } return result; }