@RequestMapping(
      method = RequestMethod.PUT,
      value = "/eu.trentorise.smartcampus.journeyplanner.sync.BasicRecurrentJourney/{clientId}")
  public @ResponseBody void updateRecurrentJourney(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      @RequestBody BasicRecurrentJourney recurrent,
      @PathVariable String clientId)
      throws InvocationException, AcServiceException {
    try {
      User user = getUser(request);
      String userId = getUserId(user);
      if (userId == null) {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return;
      }

      String objectClientId = recurrent.getClientId();
      if (!clientId.equals(objectClientId)) {
        response.setStatus(HttpServletResponse.SC_CONFLICT);
        return;
      }
      DomainObject res =
          getObjectByClientId(
              clientId, "smartcampus.services.journeyplanner.RecurrentJourneyObject");
      if (res != null) {
        String objectId = checkUser(res, userId);
        if (objectId == null) {
          response.setStatus(HttpServletResponse.SC_FORBIDDEN);
          return;
        }

        Map<String, Object> pars = new HashMap<String, Object>();
        pars.put("newJourney", recurrent.getData());
        pars.put("newName", recurrent.getName());
        pars.put("newMonitor", recurrent.isMonitor());
        domainClient.invokeDomainOperation(
            "updateRecurrentJourney",
            "smartcampus.services.journeyplanner.RecurrentJourneyObject",
            objectId,
            pars,
            userId,
            "vas_journeyplanner_subscriber");
      } else {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      }
    } catch (Exception e) {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
  }
  @RequestMapping(
      method = RequestMethod.POST,
      value = "/eu.trentorise.smartcampus.journeyplanner.sync.BasicRecurrentJourney")
  public @ResponseBody void saveRecurrentJourney(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      @RequestBody BasicRecurrentJourney recurrent)
      throws InvocationException, AcServiceException {
    try {
      User user = getUser(request);
      String userId = getUserId(user);
      if (userId == null) {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return;
      }

      logger.info("-" + userId + "~AppConsume~monitor");

      Map<String, Object> pars = new HashMap<String, Object>();
      pars.put("recurrentJourney", recurrent.getData());
      pars.put("name", recurrent.getName());
      String clientId = recurrent.getClientId();
      if (clientId == null) {
        clientId = new ObjectId().toString();
      }
      pars.put("clientId", clientId);
      pars.put("userId", userId);
      pars.put("monitor", recurrent.isMonitor());
      domainClient.invokeDomainOperation(
          "saveRecurrentJourney",
          "smartcampus.services.journeyplanner.RecurrentJourneyFactory",
          "smartcampus.services.journeyplanner.RecurrentJourneyFactory.0",
          pars,
          userId,
          "vas_journeyplanner_subscriber");
      storage.storeObject(recurrent);
    } catch (Exception e) {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
  }