public String addSorPerson(
      final ReconciliationCriteria reconciliationCriteria, final RequestContext context) {
    reconciliationCriteria.getSorPerson().setSourceSor(AbstractPersonServiceAction.STATIC_SOR_NAME);
    try {
      final ServiceExecutionResult<Person> result =
          getPersonService().addPerson(reconciliationCriteria);

      getSpringErrorValidationErrorConverter()
          .convertValidationErrors(result.getValidationErrors(), context.getMessageContext());

      if (context.getMessageContext().hasErrorMessages()) {
        return "validationError";
      }

      context.getFlowScope().put("serviceExecutionResult", result);
      return "success";
    } catch (final ReconciliationException e) {
      context.getFlowScope().put("reconciliationResult", e);
      return "reconciliation";
    }
    // TODO Need to add logic here to handle case where SoR already provided an SorPerson.
    // For example if OR is the SoR and reconciliation determines that OR
    // get the sorPerson that already exists from SorPersonAlreadyExistsException, update it with
    // the values from reconciliation.SorPerson
    // call updateSorPerson
    catch (final SorPersonAlreadyExistsException e) {
      return "error";
    }
  }
  public Event checkHomeLocation(RequestContext context) {
    // check location values
    UserAccount userAccount = (UserAccount) context.getFlowScope().get("userAccount");
    Location loc = userAccount.getLocation();

    // do we have lat/lon already?
    //		StringUtils.hasLength(loc.getLatitude());
    if (loc.getLatitude() != null && loc.getLongitude() != null) return success();

    try {
      Assert.hasLength(loc.getCity(), "City is empty");
      Assert.hasLength(loc.getStateInitial(), "State is empty");
      //			Assert.hasLength(loc.getZip(), "Zip is empty");
    } catch (IllegalArgumentException e) {
      context
          .getMessageContext()
          .addMessage(new MessageBuilder().error().defaultText(e.getMessage()).build());
      return result("needHomeLocation");
    }

    String homeLoc = loc.getAddress() + " " + loc.getCity() + " " + loc.getStateInitial();

    // get lat/lon from yahoo
    List<YahooPlaceResult> places = yahooPlaceFinderService.searchPlaceResult(homeLoc);
    Location location = userAccount.getLocation();
    if (places.size() > 0) {
      YahooPlaceResult place = places.get(0);
      location.setLatitude(place.getLatitude().floatValue());
      location.setLongitude(place.getLongitude().floatValue());
      location.setStateInitial(place.getStateCode());
      Zip zip = null;
      try {
        zip = Zip.findZipsByZipCode(place.getUzip().toString()).getSingleResult();
      } catch (Exception e) {
        zip = new Zip();
        zip.setZipCode(place.getUzip().toString());
        zip.setLatitude(place.getLatitude().floatValue());
        zip.setLongitude(place.getLongitude().floatValue());
        zip.persist();
      }
      location.setZip(zip);
      userAccount.setWktLocation(place.getLongitude(), place.getLatitude());
      // save
      userAccount = userAccountService.updateUserAccount(userAccount);
      // set to flow
      context.getFlowScope().asMap().put("userAccount", userAccount);
    } else {
      context
          .getMessageContext()
          .addMessage(
              new MessageBuilder()
                  .error()
                  .defaultText("Could not find Lat/Lon. Returned " + places.size() + " places.")
                  .build());
      return result("needHomeLocation");
    }

    return result("needBabysitterAvailableTimes");
  }
  /**
   * Grant ticket granting ticket.
   *
   * @param context the context
   * @param authenticationResultBuilder the authentication result builder
   * @param service the service
   * @return the event
   * @throws Exception the exception
   */
  protected Event grantTicketGrantingTicketToAuthenticationResult(
      final RequestContext context,
      final AuthenticationResultBuilder authenticationResultBuilder,
      final Service service)
      throws Exception {

    logger.debug("Finalizing authentication transactions and issuing ticket-granting ticket");
    final AuthenticationResult authenticationResult =
        this.authenticationSystemSupport.finalizeAllAuthenticationTransactions(
            authenticationResultBuilder, service);

    boolean issueTicketGrantingTicket = true;
    final Authentication authentication = authenticationResult.getAuthentication();
    final String ticketGrantingTicket = WebUtils.getTicketGrantingTicketId(context);
    if (StringUtils.isNotBlank(ticketGrantingTicket)) {
      logger.debug(
          "Located ticket-granting ticket in the context. Retrieving associated authentication");
      final Authentication authenticationFromTgt =
          this.ticketRegistrySupport.getAuthenticationFrom(ticketGrantingTicket);
      if (authenticationFromTgt == null) {
        logger.debug(
            "Authentication session associated with {} is no longer valid", ticketGrantingTicket);
        this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicket);
      } else if (authentication.getPrincipal().equals(authenticationFromTgt.getPrincipal())) {
        logger.debug("Resulting authentication matches the authentication from context");
        issueTicketGrantingTicket = false;
      } else {
        logger.debug("Resulting authentication is different from the context");
      }
    }

    final TicketGrantingTicket tgt;
    if (issueTicketGrantingTicket) {
      tgt = this.centralAuthenticationService.createTicketGrantingTicket(authenticationResult);

    } else {
      tgt =
          this.centralAuthenticationService.getTicket(
              ticketGrantingTicket, TicketGrantingTicket.class);
      tgt.getAuthentication().update(authentication);
      this.centralAuthenticationService.updateTicket(tgt);
    }

    WebUtils.putTicketGrantingTicketInScopes(context, tgt);
    WebUtils.putAuthenticationResult(authenticationResult, context);
    WebUtils.putAuthentication(tgt.getAuthentication(), context);

    if (addWarningMessagesToMessageContextIfNeeded(tgt, context.getMessageContext())) {
      return newEvent(SUCCESS_WITH_WARNINGS);
    }

    return newEvent(CasWebflowConstants.TRANSITION_ID_SUCCESS);
  }