Beispiel #1
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    // TODO Auto-generated method stub
    super.doGet(req, resp);

    String username = getUserName();
    String password = getPassword();
    String twitterUserName = getTwitterUserName();
    String twitterPassword = getTwitterUserPassword();
    String email = getEmail();

    if (Utils.isEmpty(username) || Utils.isEmpty(password)) {
      sendRegisterHtml();
    } else {
      boolean result = false;

      // Add an new user.
      result =
          SqliteManager.getInstance()
              .addUser(username, password, "", "", email, CONSUMER_KEY, CONSUMER_SECRET);
      if (result) {
        out.println("Register success");

        try {
          AccountInfo accountInfo = getAccountInfo();
          accountInfo.setTwitterConsumerKey(CONSUMER_KEY);
          accountInfo.setTwitterConsumerSecret(CONSUMER_SECRET);
        } catch (Exception e) {
          e.printStackTrace();
        }
      } else {
        out.println("Register failed,maybe the user already existed,please use another name.");
      }
    }
  }