@Override
  public List<AbstractFacet> extractFacets(ApiData apiData, ObjectType objectType)
      throws Exception {

    logger.info(
        "guestId="
            + apiData.updateInfo.getGuestId()
            + " connector=bodymedia action=extractFacets objectType="
            + objectType.getName());

    ArrayList<AbstractFacet> facets;
    String name = objectType.getName();
    if (name.equals("steps")) {
      facets = extractStepFacets(apiData);
    } else // If the facet to be extracted wasn't a step facet
    {
      throw new RuntimeException("Step extractor called with illegal ObjectType");
    }
    return facets;
  }
Пример #2
0
  @RequestMapping("/createAccount")
  public ModelAndView createAccount(
      @RequestParam("email") String email,
      @RequestParam("username") String username,
      @RequestParam("firstname") String firstname,
      @RequestParam("lastname") String lastname,
      @RequestParam("password1") String password,
      @RequestParam("password2") String password2,
      //		@RequestParam("recaptchaChallenge") String challenge,
      //		@RequestParam("recaptchaResponse") String uresponse,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    email = email.trim();
    password = password.trim();
    password2 = password2.trim();
    username = username.trim();
    firstname = firstname.trim();
    lastname = lastname.trim();

    List<String> required = new ArrayList<String>();
    List<String> errors = new ArrayList<String>();
    if (email == "") required.add("email");
    if (username == "") {
      required.add("username");
    } else if (guestService.getGuest(username) != null) {
      errors.add("usernameTaken");
    }
    if (password == "") required.add("password");
    if (password2 == "") required.add("password2");
    if (password.length() < 8) errors.add("passwordTooShort");
    if (!password.equals(password2)) errors.add("passwordsDontMatch");
    if (guestService.getGuestByEmail(email) != null) errors.add("userExists");

    //		String remoteAddr = request.getRemoteAddr();
    //        ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
    //        reCaptcha.setPrivateKey("6LeXl8QSAAAAADjPASFlMINNRVwtlpcvGugcr2RI");
    //
    //        ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge,
    // uresponse);
    //
    //		if (!reCaptchaResponse.isValid())
    //		errors.add("wrongCaptcha");

    if (errors.size() == 0 && required.size() == 0) {
      logger.info("action=register success=true username="******" email=" + email);
      guestService.createGuest(username, firstname, lastname, password, email);
      request.setAttribute("username", username);
      request.setAttribute("password", password);
      return new ModelAndView("accountCreationComplete");
    } else {
      logger.info("action=register errors=true");
      ModelAndView mav = new ModelAndView("createAccount");
      mav.addObject("email", email);
      mav.addObject("username", username);
      mav.addObject("firstname", firstname);
      mav.addObject("lastname", lastname);
      mav.addObject("errors", errors);
      mav.addObject("required", required);
      return mav;
    }
  }