@RequestMapping(method = RequestMethod.POST, value = "/planrecurrent")
  public @ResponseBody RecurrentJourney planRecurrentJourney(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestBody RecurrentJourneyParameters parameters,
      HttpSession session)
      throws InvocationException, AcServiceException {
    try {
      User user = getUser(request);
      String userId = getUserId(user);
      if (userId == null) {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return null;
      }

      List<String> reqs = buildRecurrentJourneyPlannerRequest(parameters);
      List<SimpleLeg> legs = new ArrayList<SimpleLeg>();
      ObjectMapper mapper = new ObjectMapper();
      for (String req : reqs) {
        String plan =
            HTTPConnector.doGet(
                otpURL + SMARTPLANNER + RECURRENT, req, MediaType.APPLICATION_JSON, null, "UTF-8");
        List sl = mapper.readValue(plan, List.class);
        for (Object o : sl) {
          legs.add((SimpleLeg) mapper.convertValue(o, SimpleLeg.class));
        }
      }

      RecurrentJourney journey = new RecurrentJourney();
      journey.setParameters(parameters);
      journey.setLegs(legs);
      journey.setMonitorLegs(buildMonitorMap(legs));

      response.setContentType("application/json; charset=utf-8");

      String result = mapper.writeValueAsString(journey);

      ServletOutputStream sos = response.getOutputStream();
      sos.write(result.getBytes());
    } catch (ConnectorException e0) {
      response.setStatus(e0.getCode());
    } catch (Exception e) {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }

    return null;
  }
  @RequestMapping(method = RequestMethod.POST, value = "/planrecurrent/{clientId}")
  public @ResponseBody RecurrentJourney planRecurrentJourney(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      @RequestBody RecurrentJourneyParameters parameters,
      @PathVariable String clientId)
      throws InvocationException, AcServiceException {
    try {
      User user = getUser(request);
      String userId = getUserId(user);
      if (userId == null) {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return null;
      }

      List<String> reqs = buildRecurrentJourneyPlannerRequest(parameters);
      List<SimpleLeg> legs = new ArrayList<SimpleLeg>();
      ObjectMapper mapper = new ObjectMapper();
      for (String req : reqs) {
        String plan =
            HTTPConnector.doGet(
                otpURL + SMARTPLANNER + RECURRENT, req, MediaType.APPLICATION_JSON, null, "UTF-8");
        List sl = mapper.readValue(plan, List.class);
        for (Object o : sl) {
          legs.add((SimpleLeg) mapper.convertValue(o, SimpleLeg.class));
        }
      }

      DomainObject res =
          getObjectByClientId(
              clientId, "smartcampus.services.journeyplanner.RecurrentJourneyObject");
      if (res != null) {
        String objectId = checkUser(res, userId);
        if (objectId == null) {
          response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        } else {
          RecurrentJourney oldJourney =
              mapper.convertValue(res.getContent().get("data"), RecurrentJourney.class);
          RecurrentJourney journey = new RecurrentJourney();
          journey.setParameters(parameters);
          journey.setLegs(legs);
          journey.setMonitorLegs(buildMonitorMap(legs, oldJourney.getMonitorLegs()));
          return journey;
        }
      } else {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      }

    } catch (ConnectorException e0) {
      response.setStatus(e0.getCode());
    } catch (Exception e) {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }

    return null;
  }