Package ru.org.linux.site

Examples of ru.org.linux.site.Template


  private UserEventService userEventService;

  @ResponseBody
  @RequestMapping(value = "/notifications-count", method= RequestMethod.GET)
  public int getEventsCount(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Template tmpl = Template.getTemplate(request);
    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("not authorized");
    }

    response.setHeader("Cache-control", "no-cache");

    return tmpl.getCurrentUser().getUnreadEvents();
  }
View Full Code Here


  @RequestMapping(value="/notifications-reset", method = RequestMethod.POST)
  @ResponseBody
  public String resetNotifications(
    HttpServletRequest request
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);
    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("not authorized");
    }

    User currentUser = tmpl.getCurrentUser();

    userEventService.resetUnreadReplies(currentUser);

    return "ok";
  }
View Full Code Here

   * @param request текущий http запрос
   * @return текущий модератор
   * @throws Exception если модератора нет
   */
  private static User getModerator(HttpServletRequest request) throws Exception {
    Template tmpl = Template.getTemplate(request);
    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not moderator");
    }
    return tmpl.getCurrentUser();
  }
View Full Code Here

  @RequestMapping(value="/remove-userpic.jsp", method= RequestMethod.POST)
  public ModelAndView removeUserpic(
    ServletRequest request,
    @RequestParam("id") User user
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not autorized");
    }

    User currentUser = tmpl.getCurrentUser();

    // Не модератор не может удалять чужие аватары
    if (!tmpl.isModeratorSession() && currentUser.getId()!=user.getId()) {
      throw new AccessViolationException("Not permitted");
    }

    if (user.getPhoto() != null && userDao.resetUserpic(user, currentUser)) {
      logger.info("Clearing " + user.getNick() + " userpic by " + currentUser.getNick());
View Full Code Here

  @Autowired
  private GroupInfoPrepareService prepareService;

  @RequestMapping(value="/groupmod.jsp", method = RequestMethod.GET)
  public ModelAndView showForm(@RequestParam("group") int id, ServletRequest request) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not moderator");
    }

    Group group = groupDao.getGroup(id);
View Full Code Here

    @RequestParam("longinfo") String longInfo,
    @RequestParam(value = "preview", required = false) String preview,
    @RequestParam(value = "resolvable", required = false) String resolvable,
    ServletRequest request
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
      throw new AccessViolationException("Not moderator");
    }

    Group group = groupDao.getGroup(id);

    if (preview != null) {
      group.setTitle(title);
      group.setInfo(info);
      group.setLongInfo(longInfo);

      Map<String, Object> params = new HashMap<>();
      params.put("group", group);
      params.put("groupInfo", prepareService.prepareGroupInfo(group, request.isSecure()));
      params.put("preview", true);

      return new ModelAndView("groupmod", params);
    }

    groupDao.setParams(group, title, info, longInfo, resolvable!=null, urlName);

    logger.info("Настройки группы {} изменены {}", group.getUrlName(), tmpl.getCurrentUser().getNick());

    return new ModelAndView("action-done", "message", "Параметры изменены");
  }
View Full Code Here

    return new ModelAndView("lostpwd-form");
  }

  @RequestMapping(method=RequestMethod.POST)
  public ModelAndView sendPassword(@RequestParam("email") String email, HttpServletRequest request) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (Strings.isNullOrEmpty(email)) {
      throw new BadInputException("email не задан");
    }

    User user = userDao.getByEmail(email, true);
    if (user==null) {
      throw new BadInputException("Этот email не зарегистрирован!");
    }

    user.checkBlocked();
    user.checkAnonymous();

    if (user.isModerator() && !tmpl.isModeratorSession()) {
      throw new AccessViolationException("этот пароль могут сбросить только модераторы");
    }

    if (!tmpl.isModeratorSession() && !userDao.canResetPassword(user)) {
      throw new BadInputException("Нельзя запрашивать пароль чаще одного раза в неделю!");
    }

    Timestamp now = new Timestamp(System.currentTimeMillis());
View Full Code Here

  public ModelAndView showList(
    HttpServletRequest request,
    @RequestParam(value = "newFavoriteTagName", required = false) String newFavoriteTagName,
    @RequestParam(value = "newIgnoredTagName", required = false) String newIgnoredTagName
  ) throws AccessViolationException {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    User user = tmpl.getCurrentUser();
    user.checkAnonymous();

    ModelAndView modelAndView = new ModelAndView("user-filter-list");

    Map<Integer, User> ignoreMap = createIgnoreMap(ignoreListDao.get(user));

    Map<Integer, Remark> ignoreRemarks = getIgnoreRemarks(user, ignoreMap.values());
    modelAndView.addObject("ignoreRemarks", ignoreRemarks);

    modelAndView.addObject("ignoreList", ignoreMap);
    modelAndView.addObject("favoriteTags", userTagService.favoritesGet(user));
    if (!tmpl.isModeratorSession()) {
      modelAndView.addObject("ignoreTags", userTagService.ignoresGet(user));
    } else {
      modelAndView.addObject("isModerator", true);
    }
View Full Code Here

  @RequestMapping(value = "/user-filter/ignore-user", method = RequestMethod.POST, params = "add")
  public ModelAndView listAdd(
    HttpServletRequest request,
    @RequestParam String nick
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    User user = tmpl.getCurrentUser();
    user.checkAnonymous();

    User addUser = userDao.getUser(nick);

    // Add nick to ignore list
View Full Code Here

  @RequestMapping(value = "/user-filter/ignore-user", method = RequestMethod.POST, params = "del")
  public ModelAndView listDel(
    ServletRequest request,
    @RequestParam int id
  ) throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }

    User user = tmpl.getCurrentUser();
    user.checkAnonymous();

    User delUser = userDao.getUserCached(id);

    ignoreListDao.remove(user, delUser);
View Full Code Here

TOP

Related Classes of ru.org.linux.site.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.