コード例 #1
0
  @Monitor(
      server = EMAIL_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_XML_WEBSERVICE,
      serviceUrlKeys = "EMAILSERVICE")
  private DetectResult monitorEmailServer() {
    DetectResult result = new DetectResult();
    try {
      UserProfile userProfile = BackendServerMonitorUtil.createUserProfile();
      TnContext tc = BackendServerMonitorUtil.createTnContext();
      EmailConfirmationRequest request = new EmailConfirmationRequest();
      request.setContextString(tc.toContextString());
      request.setEmail("*****@*****.**");
      request.setEmailType(UserTypeDef.COMMON_EMAIL);
      request.setUserId(userProfile.getUserId());
      EmailConfirmationResponse response =
          TelepersonalizeProxy.getInstance().sendEmail(request, tc);
      if (response.isSuccess()) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.msg = response.getErrorMessage();
      }

    } catch (Exception ex) {
      logger.fatal("#monitorEmailServer", ex);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when sendMail()"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(ex);
    }
    return result;
  }
コード例 #2
0
  @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;
  }
コード例 #3
0
  private void hardCodeTnContext(ExecutorContext execContext, UserProfile userProfile) {
    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();

    TnContext tc = new TnContext();
    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", execContext.getServerUrl());
    // tc.addProperty("map_dpi", mapDpi);
    tc.addProperty("locale", locale);
    // tc.addProperty("program_code", programCode);

    tc.addProperty(TnContext.PROP_REQUESTOR, TnContext.TT_REQUESTOR_TNCLIENT);
  }
コード例 #4
0
  /* used in ShareAddressExecutor */
  @Monitor(
      server = SHAREADDRESS_SERVER,
      parserClass = ServiceUrlParserFactory.CLASS_XML_WEBSERVICE,
      serviceUrlKeys = "ADDRESSSHARING")
  private DetectResult monitorShareAddressServer() {
    DetectResult result = new DetectResult();

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

      AddressSharingRequest addressSharingRequest = new AddressSharingRequest();
      addressSharingRequest.setUserId(PoiUtil.getLongFrom(userProfile.getUserId()));
      addressSharingRequest.setPtn(userProfile.getMin());
      addressSharingRequest.setContextString(tc.toContextString());
      addressSharingRequest.setAddress(BackendServerMonitorUtil.createStop());

      ContactInfo contact = new ContactInfo();
      contact.setName("test");
      contact.setPtn(userProfile.getMin());
      List<ContactInfo> contactlist = new ArrayList<ContactInfo>();
      contactlist.add(contact);
      addressSharingRequest.setContactList(contactlist);

      AddressSharingResponse addressSharingResponse =
          AddressSharingServiceProxy.getInstance().shareAddress(addressSharingRequest, tc);
      String statusCode = addressSharingResponse.getStatusCode();
      String statusMessage = addressSharingResponse.getStatusMessage();

      if ("OK".equalsIgnoreCase(statusCode)) {
        result.isSuccess = true;
      } else {
        result.isSuccess = false;
        result.msg = "statusCode = " + statusCode + ", statusMessage = " + statusMessage;
      }
    } catch (Exception ex) {
      logger.fatal("#monitorShareAddressServer", ex);
      result.isSuccess = false;
      result.msg =
          "Exception occurs when share address"
              + ". Exception msg->"
              + ExceptionUtil.collectExceptionMsg(ex);
    }

    return result;
  }
コード例 #5
0
  @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;
  }
コード例 #6
0
  @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;
  }
コード例 #7
0
  public TnContext getTnContext(UserProfile userProfile, ExecutorContext context) {

    String userID = userProfile.getUserId();

    long lUserID = -1;
    if (userID != null && userID.length() > 0) {
      lUserID = Long.parseLong(userID);
    }

    ContextMgrService cms = new ContextMgrService();
    ContextMgrStatus myStatus = null;

    if (logger.isDebugEnabled()) {
      logger.debug("needRegister:" + needRegister);
    }

    TnContext tc = new TnContext();
    try {
      if (needRegister) {
        // get the tncontext from DSM db
        // tc = getTnContextFromDsmDB(userProfile.getMin());
        // set user profile into tncontext
        setUserProfileToTnContext(tc, userProfile, context);
        // set the need register dsm rule into tncontext
        setNeedRegisterDsmRuleToTnContext(userProfile, tc);
        if (logger.isDebugEnabled()) {
          logger.debug("tc -->" + tc);
          logger.debug("tc.length = " + tc.toContextString().length());
        }
        myStatus = cms.registerContext(lUserID, Constants.CALLER_CSERVER, tc);

      } else {
        // set user profile into tncontext
        setUserProfileToTnContext(tc, userProfile, context);
        myStatus = cms.updateContext(tc);
      }
    } catch (Exception e) {
      logger.fatal(e, e);
    }

    // set all the dsm rules in to tncontext
    setAllDsmRuleToTnContext(userProfile, tc);

    DevicePropertiesHolder deviceHolder =
        (DevicePropertiesHolder) ResourceHolderManager.getResourceHolder(HolderType.DEVICE_TYPE);
    if (deviceHolder != null) {
      DeviceProperties deviceProperties = deviceHolder.getDeviceProperties(userProfile, tc);
      if (deviceProperties != null) {
        tc.addProperty(
            GENERATE_LANE_INFO,
            String.valueOf(deviceProperties.getBooleanDefFalse(NAV_ENABLE_LANE_ASSIST)));
      }
    }

    if (myStatus == null || myStatus.getStatusCode() != Error.NO_ERROR) {
      CliTransaction cli =
          com.telenav.cserver.framework.cli.CliTransactionFactory.getInstance(
              CliConstants.TYPE_MODULE);
      cli.setFunctionName("getTnContext");
      cli.addData(
          "cms_status(has issue)", myStatus != null ? myStatus.getStatusCode() + "" : "null");

      tc = getDefaultTnContext(tc);
      if (logger.isDebugEnabled()) {
        logger.debug("tnContext has issue.");
      }

      cli.complete();
    }
    logger.debug("final tc:>>" + tc);
    return tc;
  }