Package ru.org.linux.site

Examples of ru.org.linux.site.Template


  @RequestMapping(value = "/user-filter/favorite-tag", method = RequestMethod.POST, params = "add")
  public ModelAndView favoriteTagAddHTML(
    HttpServletRequest request,
    @RequestParam String tagName
  ) throws AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

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

    List<String> r = userTagService.addMultiplyTags(user, tagName, true);

    if (!r.isEmpty()) {
View Full Code Here


  @ResponseBody
  public Map<String, Object> favoriteTagAddJSON(
    HttpServletRequest request,
    @RequestParam String tagName
  ) throws AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

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

    try {
      int id = userTagService.favoriteAdd(user, tagName);
View Full Code Here

  @RequestMapping(value = "/user-filter/favorite-tag", method = RequestMethod.POST, params = "del")
  public ModelAndView favoriteTagDel(
    ServletRequest request,
    @RequestParam String tagName
  ) throws TagNotFoundException, AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

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

    userTagService.favoriteDel(user, tagName);

    return new ModelAndView(new RedirectView("/user-filter"));
View Full Code Here

  public
  Map<String, Object> favoriteTagDelJSON(
    ServletRequest request,
    @RequestParam String tagName
  ) throws TagNotFoundException, AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

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

    int tagId = userTagService.favoriteDel(user, tagName);

    return ImmutableMap.<String, Object>of("count", userTagService.countFavs(tagId));
View Full Code Here

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

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }
    if (tmpl.isModeratorSession()) {
      throw new AccessViolationException("Модераторам нельзя игнорировать теги");
    }

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

    List<String> errorMessage = userTagService.addMultiplyTags(user, tagName, false);

    if (!errorMessage.isEmpty()) {
View Full Code Here

  public
  Map<String, String> ignoreTagAddJSON(
    HttpServletRequest request,
    @RequestParam String tagName
  ) throws AccessViolationException {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
      throw new AccessViolationException("Not authorized");
    }
    if (tmpl.isModeratorSession()) {
      throw new AccessViolationException("Модераторам нельзя игнорировать теги");
    }

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

    List<String> errorMessage = userTagService.addMultiplyTags(user, tagName, false);
    if (!errorMessage.isEmpty()) {
      return ImmutableMap.of("error", StringUtils.join(errorMessage,"; "));
View Full Code Here

  @RequestMapping(value = "/user-filter/ignore-tag", method = RequestMethod.POST, params = "del")
  public ModelAndView ignoreTagDel(
    ServletRequest request,
    @RequestParam String tagName
  ) throws TagNotFoundException, AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

    if (tmpl.isModeratorSession()) {
      throw new AccessViolationException("Модераторам нельзя игнорировать теги");
    }

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

    userTagService.ignoreDel(user, tagName);

    return new ModelAndView(new RedirectView("/user-filter"));
View Full Code Here

  public
  Map<String, String> ignoreTagDelJSON(
    ServletRequest request,
    @RequestParam String tagName
  ) throws TagNotFoundException, AccessViolationException {
    Template tmpl = Template.getTemplate(request);

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

    if (tmpl.isModeratorSession()) {
      throw new AccessViolationException("Модераторам нельзя игнорировать теги");
    }

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

    userTagService.ignoreDel(user, tagName);

    return ImmutableMap.of();
View Full Code Here

  public ModelAndView showRemarks(ServletRequest request
    , @PathVariable String nick
    , @RequestParam(value = "offset", defaultValue = "0") int offset
    , @RequestParam(value = "sort", defaultValue = "0") int sortorder
    ) throws Exception {
    Template tmpl = Template.getTemplate(request);
    if (!tmpl.isSessionAuthorized() || !tmpl.getCurrentUser().getNick().equals(nick)) {
      throw new AccessViolationException("Not authorized");
    }

    int count = userDao.getRemarkCount(tmpl.getCurrentUser());

    ModelAndView mv = new ModelAndView("view-remarks");

    int limit = tmpl.getProf().getMessages();

    if(count > 0 ){
      if( offset >= count ){
        throw new UserErrorException("Offset is too long");
      }
      if( offset < 0 ) offset=0;

      if( sortorder != 1 ){
        sortorder = 0;
        mv.getModel().put("sortorder","");
      else {
        mv.getModel().put("sortorder","&amp;sort=1");
      }


      List<Remark> remarks = userDao.getRemarkList(tmpl.getCurrentUser(), offset, sortorder, limit);
      List<PreparedRemark> preparedRemarks = prepareService.prepareRemarkList(remarks);

      mv.getModel().put("remarks", preparedRemarks);
    } else {
      mv.getModel().put("remarks", ImmutableList.of() );
View Full Code Here

  @Autowired
  private TopicDao topicDao;

  @RequestMapping(value="/people/{nick}/profile", method = {RequestMethod.GET, RequestMethod.HEAD})
  public ModelAndView getInfoNew(@PathVariable String nick, HttpServletRequest request, HttpServletResponse response) throws Exception {
    Template tmpl = Template.getTemplate(request);

    User user = userDao.getUser(nick);

    if (user.isBlocked() && !tmpl.isSessionAuthorized()) {
      throw new UserBanedException(user, userDao.getBanInfoClass(user));
    }

    ModelAndView mv = new ModelAndView("whois");
    mv.getModel().put("user", user);
    mv.getModel().put("userInfo", userDao.getUserInfoClass(user));

    mv.getModel().put("userpic", userService.getUserpic(
            user,
            request.isSecure(),
            tmpl.getProf().getAvatarMode(),
            true
    ));

    if (user.isBlocked()) {
      mv.getModel().put("banInfo", userDao.getBanInfoClass(user));
    }

    boolean currentUser = tmpl.isSessionAuthorized() && tmpl.getNick().equals(nick);

    if (!user.isAnonymous()) {
      UserStats userStat = userStatisticsService.getStats(user);
      mv.getModel().put("userStat", userStat);
      mv.getModel().put("watchPresent", memoriesDao.isWatchPresetForUser(user));
      mv.getModel().put("favPresent", memoriesDao.isFavPresetForUser(user));

      if (currentUser || tmpl.isModeratorSession()) {
        mv.getModel().put("hasDrafts", topicDao.hasDrafts(user));
      }
    }

    mv.getModel().put("moderatorOrCurrentUser", currentUser || tmpl.isModeratorSession());
    mv.getModel().put("currentUser", currentUser);

    if (tmpl.isSessionAuthorized() && !currentUser) {
      Set<Integer> ignoreList = ignoreListDao.get(tmpl.getCurrentUser());

      mv.getModel().put("ignored", ignoreList.contains(user.getId()));

      mv.getModel().put("remark", userDao.getRemark(tmpl.getCurrentUser() , user) );
    }

    if (tmpl.isSessionAuthorized() && currentUser) {
      mv.getModel().put("hasRemarks", ( userDao.getRemarkCount(tmpl.getCurrentUser()) > 0 ) );
    }

    String userinfo = userDao.getUserInfo(user);

    if (!Strings.isNullOrEmpty(userinfo)) {
      mv.getModel().put(
              "userInfoText",
              lorCodeService.parseComment(
                      userinfo,
                      request.isSecure(),
                      !topicPermissionService.followAuthorLinks(user)
              )
      );
    }

    mv.addObject("favoriteTags", userTagService.favoritesGet(user));
    if (currentUser || tmpl.isModeratorSession()) {
      mv.addObject("ignoreTags", userTagService.ignoresGet(user));
    }

    if (currentUser || tmpl.isModeratorSession()) {
      List<UserLogItem> logItems = userLogDao.getLogItems(user, tmpl.isModeratorSession());

      if (!logItems.isEmpty()) {
        mv.addObject("userlog", userLogPrepareService.prepare(logItems));
      }
    }
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.