コード例 #1
0
  /**
   * TODO add a new record about nickname
   *
   * @param nickNameRequest
   * @param nickNameResponse
   * @param tnContext
   * @return
   */
  public HtmlNickNameResponse addNickName(
      HtmlNickNameRequest nickNameRequest,
      HtmlNickNameResponse nickNameResponse,
      TnContext tnContext) {

    CliTransaction cli = new CliTransaction(CliConstants.TYPE_MODULE);
    cli.setFunctionName("addNickName");
    nickNameResponse.setStatus(ExecutorResponse.STATUS_OK);
    long userId = nickNameRequest.getUserId();
    String userName = nickNameRequest.getNickName();
    nickNameResponse.setNickName(userName);
    UserManagementServiceStub stub = null;
    try {

      logger.debug("addNickName userId:" + userId + ",userName" + userName);
      // set conditions
      GetUserRequestDTO getUserRequest = new GetUserRequestDTO();
      getUserRequest.setParam(Long.toString(userId));
      getUserRequest.setParamType(UserQueryBy.USER_ID);
      getUserRequest.setClientName(HtmlConstants.clientName);
      getUserRequest.setClientVersion(HtmlConstants.clientVersion);
      getUserRequest.setContextString(tnContext.toContextString());
      getUserRequest.setTransactionId(HtmlPoiUtil.getTrxId());

      // get user
      stub = getServer();
      GetUserResponseDTO responseDto = stub.getUser(getUserRequest);
      User user = responseDto.getUser();
      user.setUserName(userName);

      // update user
      UpdateUserRequestDTO updateRequest = new UpdateUserRequestDTO();
      updateRequest.setUser(user);
      updateRequest.setClientName(HtmlConstants.clientName);
      updateRequest.setClientVersion(HtmlConstants.clientVersion);
      updateRequest.setContextString(tnContext.toContextString());
      updateRequest.setTransactionId(HtmlPoiUtil.getTrxId());

      UserManagementResponseDTO updateResponse = stub.updateUser(updateRequest);

    } catch (Exception e) {
      logger.error(e);
      e.printStackTrace();
      cli.setStatus(e);
      cli.setState(CliConstants.STATUS_FAIL);
    } finally {
      cli.complete();
      WebServiceUtils.cleanupStub(stub);
    }

    return nickNameResponse;
  }
コード例 #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
  /**
   * @TODO query nickname
   *
   * @param nickNameRequest
   * @param nickNameResponse
   * @param tnContext
   * @return
   */
  public HtmlNickNameResponse queryNickName(
      HtmlNickNameRequest nickNameRequest,
      HtmlNickNameResponse nickNameResponse,
      TnContext tnContext) {

    CliTransaction cli = new CliTransaction(CliConstants.TYPE_MODULE);
    cli.setFunctionName("queryNickName");
    long userId = nickNameRequest.getUserId();
    nickNameResponse.setStatus(ExecutorResponse.STATUS_OK);
    nickNameResponse.setUserId(userId);
    nickNameResponse.setNickName("");
    UserManagementServiceStub stub = null;
    try {
      // set query conditions
      GetUserRequestDTO getUserRequest = new GetUserRequestDTO();
      getUserRequest.setParam(Long.toString(userId));
      getUserRequest.setParamType(UserQueryBy.USER_ID);

      getUserRequest.setClientName(HtmlConstants.clientName);
      getUserRequest.setClientVersion(HtmlConstants.clientVersion);
      getUserRequest.setContextString(tnContext.toContextString());
      getUserRequest.setTransactionId(HtmlPoiUtil.getTrxId());
      // get userInfo
      stub = getServer();
      GetUserResponseDTO responseDto = stub.getUser(getUserRequest);
      if (responseDto != null) {
        User user = responseDto.getUser();
        if (user != null) // set response param
        {
          logger.debug("queryNickName userId:" + userId + ",user name:" + user.getUserName());
          // set query result
          nickNameResponse.setNickName(user.getUserName());
        }
        cli.addData("Response", "Status Code:" + responseDto.getResponseStatus());
      }
      // nickNameResponse.setMessage("Status Code =" + statusCode + " Message=" + statusMsg);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      logger.error(e);
      e.printStackTrace();
      cli.setStatus(e);
      cli.setState(CliConstants.STATUS_FAIL);
    } finally {
      cli.complete();
      WebServiceUtils.cleanupStub(stub);
    }

    return nickNameResponse;
  }
コード例 #4
0
  /**
   * TODO add a new record about nickname
   *
   * @param nickNameRequest
   * @param nickNameResponse
   * @param tnContext
   * @return
   */
  public HtmlNickNameResponse checkAndaddNickName(
      HtmlNickNameRequest nickNameRequest,
      HtmlNickNameResponse nickNameResponse,
      TnContext tnContext) {

    CliTransaction cli = new CliTransaction(CliConstants.TYPE_MODULE);
    cli.setFunctionName("checkAndaddNickName");
    nickNameResponse.setStatus(ExecutorResponse.STATUS_OK);
    UserManagementServiceStub stub = null;
    try {

      String userName = nickNameRequest.getNickName();
      // set conditions
      IsUniqueUsernameRequestDTO isUniqueRequest = new IsUniqueUsernameRequestDTO();
      isUniqueRequest.setUserName(userName);
      isUniqueRequest.setClientName(HtmlConstants.clientName);
      isUniqueRequest.setClientVersion(HtmlConstants.clientVersion);
      isUniqueRequest.setContextString(tnContext.toContextString());
      isUniqueRequest.setTransactionId(HtmlPoiUtil.getTrxId());

      // check NickName
      stub = getServer();
      IsUniqueUsernameResponseDTO isUniqueResponse = stub.isUniqueUsername(isUniqueRequest);
      nickNameResponse.setNickName(userName);

      if (isUniqueResponse != null) {
        boolean isUnique = isUniqueResponse.getUnique();

        logger.debug("checkNickName userName:"******",isUnique" + isUnique);
        cli.addData("data", "checkNickName userName:"******",isUnique" + isUnique);
        if (isUnique) { // the nick name is unique
          nickNameResponse.setIsUniqueNickName(HtmlConstants.OPERATE_UNIQUE_NICKNAME);

          long userId = nickNameRequest.getUserId();

          logger.debug("addNickName userId:" + userId + ",userName" + userName);
          // set conditions
          GetUserRequestDTO getUserRequest = new GetUserRequestDTO();
          getUserRequest.setParam(Long.toString(userId));
          getUserRequest.setParamType(UserQueryBy.USER_ID);
          getUserRequest.setClientName(HtmlConstants.clientName);
          getUserRequest.setClientVersion(HtmlConstants.clientVersion);
          getUserRequest.setContextString(tnContext.toContextString());
          getUserRequest.setTransactionId(HtmlPoiUtil.getTrxId());

          // get user
          GetUserResponseDTO responseDto = stub.getUser(getUserRequest);
          User user = responseDto.getUser();
          if (user != null) {
            user.setUserName(userName);
            // update user
            UpdateUserRequestDTO updateRequest = new UpdateUserRequestDTO();
            updateRequest.setUser(user);
            updateRequest.setClientName(HtmlConstants.clientName);
            updateRequest.setClientVersion(HtmlConstants.clientVersion);
            updateRequest.setContextString(tnContext.toContextString());
            updateRequest.setTransactionId(HtmlPoiUtil.getTrxId());

            UserManagementResponseDTO updateResponse = stub.updateUser(updateRequest);
          }
        } else { // the nick name has exist
          nickNameResponse.setIsUniqueNickName(HtmlConstants.OPERATE_NOT_UNIQUE_NICKNAME);
        }
      } else {
        nickNameResponse.setIsUniqueNickName(HtmlConstants.OPERATE_UNIQUE_NICKNAME);
      }
    } catch (Exception e) {
      logger.error(e);
      e.printStackTrace();
      cli.setStatus(e);
      cli.setState(CliConstants.STATUS_FAIL);
    } finally {
      cli.complete();
      WebServiceUtils.cleanupStub(stub);
    }

    return nickNameResponse;
  }