Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMessages


  protected ActionForward doPublishReply(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSReplyForm rform = (BBSReplyForm) form;
    super.validateClientId(request, rform);
    ActionMessages msgs = new ActionMessages();
    while (true) {
      if (StringUtils.isEmpty(rform.getTitle())) {
        msgs.add("title", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if (StringUtils.isEmpty(rform.getContent())) {
        msgs.add("content", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if (loginUser == null) {
        msgs.add("reply", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("reply", new ActionMessage("error.user_not_available"));
        break;
      }
      SiteBean site = getSiteByID(rform.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      //��������
      if(isUserInBlackList(site, loginUser)){
        msgs.add("reply", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      TopicOutlineBean topic = BBSTopicDAO.getTopicOutlineByID(rform.getTid());
      if (topic == null
          || topic.getStatus() != TopicBean.STATUS_NORMAL
          || topic.getSite().getId() != site.getId()
          || !topic.getForum().canCreateOrUpdateTopic(loginUser)) {
        msgs.add("log", new ActionMessage("error.topic_not_available",
            new Integer(rform.getTid())));
        break;
      }
      // ����TopicBean
      TopicReplyBean reply = new TopicReplyBean();
      reply.setClient(new ClientInfo(request, rform.getClientType()));
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          rform.getContent()), MAX_REPLY_LENGTH);
      reply.setContent(super.filterScriptAndStyle(content));
      reply.setReplyTime(new Date());
      reply.setSite(site);
      reply.setTitle(super.autoFiltrate(site, rform.getTitle()));
      reply.setTopic(topic);
      reply.setUser(loginUser);
      BBSReplyDAO.create(reply);
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("new_reply");
    }
    StringBuffer ext = new StringBuffer();
    ext.append("fid=");
View Full Code Here


  protected ActionForward doEditReply(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSReplyForm rform = (BBSReplyForm) form;
    super.validateClientId(request, rform);
    ActionMessages msgs = new ActionMessages();
    while (true) {
      if (StringUtils.isEmpty(rform.getTitle())) {
        msgs.add("title", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if (StringUtils.isEmpty(rform.getContent())) {
        msgs.add("content",
            new ActionMessage("error.empty_not_allowed"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if (loginUser == null) {
        msgs.add("reply", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("reply", new ActionMessage("error.user_not_available"));
        break;
      }
      SiteBean site = super.getSiteByID(rform.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      TopicReplyBean rbean = BBSReplyDAO.getTopicReplyByID(rform.getId());
      if (rbean != null
          && rbean.getStatus() == TopicReplyBean.STATUS_NORMAL) {
        String title = super.autoFiltrate(site, rform.getTitle());
        if (!StringUtils.equals(title, rbean.getTitle()))
          rbean.setTitle(title);
        String content = StringUtils.abbreviate(super.autoFiltrate(
            null, rform.getContent()), MAX_REPLY_LENGTH);
        if (!StringUtils.equals(content, rbean.getContent()))
          rbean.setContent(super.filterScriptAndStyle(content));
        BBSReplyDAO.flush();
      }
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("new_reply");
    }
    StringBuffer ext = new StringBuffer();
    ext.append("fid=");
View Full Code Here

  protected ActionForward doPublishTopic(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSTopicForm log = (BBSTopicForm) form;
    super.validateClientId(request, log);
    ActionMessages msgs = new ActionMessages();
    UserBean loginUser = super.getLoginUser(request, response);
    while (true) {
      if (loginUser == null) {
        msgs.add("topic", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("topic", new ActionMessage("error.user_not_available"));
        break;
      }
      if (StringUtils.isEmpty(log.getTitle())) {
        msgs.add("title", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if (StringUtils.isEmpty(log.getContent())) {
        msgs.add("content",
            new ActionMessage("error.empty_not_allowed"));
        break;
      }
      SiteBean site = super.getSiteByID(log.getSid());
      if (site == null) {
        msgs.add("topic", new ActionMessage("error.site_not_available"));
        break;
      }
      //��������
      if(isUserInBlackList(site, loginUser)){
        msgs.add("topic", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      ForumBean forum = BBSForumDAO.getForumByID(log.getForum());
      if (forum == null || forum.getSite().getId() != site.getId()
          || !forum.canCreateOrUpdateTopic(loginUser)) {
        msgs.add("topic", new ActionMessage("error.forum_not_available",
            new Integer(log.getForum())));
        break;
      }     
     
      // ����TopicBean
      TopicBean topic = new TopicBean();
      topic.setUser(loginUser);
      topic.setUsername(loginUser.getName());
      topic.setSite(site);
      // �Է����ı����Լ������Զ����������ִʹ���
      topic.setTitle(super.autoFiltrate(site, log.getTitle()));
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          log.getContent()), MAX_TOPIC_LENGTH);
      topic.setContent(super.filterScriptAndStyle(content));
      // FIXME: �����ؼ���̫���������ݿ�д��ʧ�ܵ�����
      topic.setKeyword(DLOGSecurityManager.IllegalGlossary
          .deleteIllegalWord(log.getSearchKey()));
      topic.setClient(new ClientInfo(request, log.getClientType()));
      topic.setCreateTime(new Date());
      topic.setForum(forum);
      topic.setStatus(TopicBean.STATUS_NORMAL);
      if(site.getOwner().getId()==loginUser.getId()){
        if (log.getTop() == 1)
          topic.setTop(true);
        if (log.getElite() == 1)
          topic.setElite(true);
      }
      BBSTopicDAO.create(topic, (log.getBookmark() == 1));

      // �����ϴ�����Ϣ
      pickupUploadFileItems(request, response, loginUser.getId(), site, topic
          .getId(), TopicBean.TYPE_BBS);
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("new_topic");
    }
    return makeForward(mapping.findForward("forum"), log.getSid(), "fid",
        log.getForum());
View Full Code Here

  protected ActionForward doEditTopic(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSTopicForm log = (BBSTopicForm) form;
    super.validateClientId(request, log);
    ActionMessages msgs = new ActionMessages();
    UserBean loginUser = super.getLoginUser(request, response);
    while (true) {
      if (loginUser == null) {
        msgs.add("log", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("log", new ActionMessage("error.user_not_available"));
        break;
      }
      if (StringUtils.isEmpty(log.getTitle())) {
        msgs.add("title", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if (StringUtils.isEmpty(log.getContent())) {
        msgs.add("content",
            new ActionMessage("error.empty_not_allowed"));
        break;
      }
      // ����û���Ȩ��
      TopicBean topic = BBSTopicDAO.getTopicByID(log.getId());
      if (topic != null) {
        if (topic.getUser().getId() != loginUser.getId()
            && loginUser.getOwnSiteId() != log.getSid()) {
          msgs.add("bbs", new ActionMessage("error.access_deny"));
          break;
        }
        // �Է����ı����Լ������Զ����������ִʹ���
        String title = super.autoFiltrate(topic.getSite(),log.getTitle());
        if (!StringUtils.equals(title, topic.getTitle()))
          topic.setTitle(title);
        String content = StringUtils.abbreviate(super.autoFiltrate(
            null, log.getContent()), MAX_TOPIC_LENGTH);       
        if (!StringUtils.equals(content, topic.getContent())){
          topic.setContent(super.filterScriptAndStyle(content));
          //�����ı�����(Winter Lau, 2006-5-12)
          TextCacheManager.updateTextContent(
              TopicBean.TYPE_BBS, topic.getId(), topic.getContent());
        }
        String keyword = super.autoFiltrate(topic.getSite(),log.getSearchKey());
        boolean updateTags = false;
        if (!StringUtils.equals(keyword, topic.getKeyword())) {
          topic.setKeyword(keyword);
          updateTags = true;
        }
        topic.setModifyTime(new Date());
        if(topic.getSite().getOwner().getId()==loginUser.getId()){
          topic.setTop(log.getTop() == 1);
          topic.setElite(log.getElite() == 1);
        }
        BBSTopicDAO.update(topic, updateTags);
      }
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("edit_topic");
    }

    StringBuffer ext = new StringBuffer("fid=");
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
      throws Exception
  {
    GuestBookForm msgform = (GuestBookForm)form;
    super.validateClientId(request, msgform);
    ActionMessages msgs = new ActionMessages();
    while(true){
      if(StringUtils.isEmpty(msgform.getContent())){
        msgs.add("content", new ActionMessage("error.empty_content"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if(loginUser==null){
        msgs.add("message", new ActionMessage("error.user_not_login"));
        break;
      }
      else if(loginUser.getStatus()!=UserBean.STATUS_NORMAL){
        msgs.add("message", new ActionMessage("error.user_not_available"));
        break;
      }
      SiteBean site = super.getSiteByID(msgform.getSid());
      if(site==null){
        msgs.add("message", new ActionMessage("error.site_not_available"));
        break;
      }
      //��������
      if(isUserInBlackList(site, loginUser)){
        msgs.add("message", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      GuestBookBean msgbean = new GuestBookBean();
      String content = super.autoFiltrate(site,msgform.getContent());
      if(content.length()>MAX_GB_COUNT_LENGTH)
        content = content.substring(0, MAX_GB_COUNT_LENGTH);
      msgbean.setContent(super.filterScriptAndStyle(content));
      msgbean.setClient(new ClientInfo(request, 0));
      msgbean.setUser(loginUser);
      msgbean.setSiteId(site.getId());
      try{
        GuestBookDAO.createMsg(msgbean);
      }catch(HibernateException e){
        context().log("undelete diary failed.", e);
        msgs.add("message", new ActionMessage("error.database", e.getMessage()));
      }
      break;
    }
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      return mapping.findForward("pub");
    }
   
    return makeForward(mapping.findForward("list"), msgform.getSid());
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
      throws Exception
  {
    MessageForm msgform = (MessageForm)form;
    super.validateClientId(request, msgform);
    ActionMessages msgs = new ActionMessages();
    while(true){
      if(msgform.getExpiredTime()!=null && msgform.getExpiredTime().before(new Date())){
        msgs.add("message", new ActionMessage("error.expired_time_not_available"));
        break;
      }
      if(StringUtils.isEmpty(msgform.getContent())){
        msgs.add("content", new ActionMessage("error.empty_content"));
        break;
      }
      if(msgform.getReceiverId()==0 || msgform.getSid()==0){
        msgs.add("message", new ActionMessage("error.param"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if(loginUser==null){
        msgs.add("message", new ActionMessage("error.user_not_login"));
        break;
      }
      else if(loginUser.getStatus()!=UserBean.STATUS_NORMAL){
        msgs.add("message", new ActionMessage("error.user_not_available"));
        break;
      }
      else if(DLOGSecurityManager.IllegalGlossary.existIllegalWord(msgform.getContent())){
        msgs.add("message", new ActionMessage("error.illegal_glossary"));
        break;
      }
      UserBean receiver = UserDAO.getUserByID(msgform.getReceiverId());
      if(receiver==null || receiver.getStatus()!=UserBean.STATUS_NORMAL){
        msgs.add("message", new ActionMessage("error.user_not_available"));
        break;
      }
      //�жϽ������Ƿ��Ѿ��������߼�Ϊ������
      if(UserDAO.isUserInBlackList(receiver.getId(), loginUser.getId())){
        msgs.add("message", new ActionMessage("message.sent"));
        break;
      }
      MessageBean msgbean = new MessageBean();
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          msgform.getContent()), MAX_MESSAGE_LENGTH);
      msgbean.setContent(super.filterScriptAndStyle(content));
      msgbean.setExpiredTime(msgform.getExpiredTime());
      msgbean.setFromUser(loginUser);
      msgbean.setToUser(receiver);
      msgbean.setStatus(MessageBean.STATUS_NEW);
      msgbean.setSendTime(new Date());
      try{
        MessageDAO.save(msgbean);
        msgs.add("message", new ActionMessage("message.sent"));
      }catch(HibernateException e){
        context().log("undelete diary failed.", e);
        msgs.add("message", new ActionMessage("error.database", e.getMessage()));
      }
      break;
    }
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
    }
   
    return mapping.findForward("send");
  }
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
      throws Exception
  {
    MessageForm msgform = (MessageForm)form;
    super.validateClientId(request, msgform);
    ActionMessages msgs = new ActionMessages();
    while(true){
      if(msgform.getExpiredTime()!=null && msgform.getExpiredTime().before(new Date())){
        msgs.add("message", new ActionMessage("error.expired_time_not_available"));
        break;
      }
      if(StringUtils.isEmpty(msgform.getContent())){
        msgs.add("content", new ActionMessage("error.empty_content"));
        break;
      }
      if(msgform.getReceiverId()==0 || msgform.getSid()==0){
        msgs.add("message", new ActionMessage("error.param"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      if(loginUser==null){
        msgs.add("message", new ActionMessage("error.user_not_login"));
        break;
      }
      else if(loginUser.getStatus()!=UserBean.STATUS_NORMAL){
        msgs.add("message", new ActionMessage("error.user_not_available"));
        break;
      }
      else if(DLOGSecurityManager.IllegalGlossary.existIllegalWord(msgform.getContent())){
        msgs.add("message", new ActionMessage("error.illegal_glossary"));
        break;
      }
      UserBean receiver = UserDAO.getUserByID(msgform.getReceiverId());
      if(receiver==null || receiver.getStatus()!=UserBean.STATUS_NORMAL){
        msgs.add("message", new ActionMessage("error.user_not_available"));
        break;
      }
      //�жϽ������Ƿ��Ѿ��������߼�Ϊ������
      if(UserDAO.isUserInBlackList(receiver.getId(), loginUser.getId())){
        msgs.add("message", new ActionMessage("message.sent"));
        break;
      }
      MessageBean msgbean = new MessageBean();
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          msgform.getContent()), MAX_MESSAGE_LENGTH);
      msgbean.setContent(super.filterScriptAndStyle(content));
      msgbean.setExpiredTime(msgform.getExpiredTime());
      msgbean.setFromUser(loginUser);
      msgbean.setToUser(receiver);
      msgbean.setStatus(MessageBean.STATUS_NEW);
      msgbean.setSendTime(new Date());
      try{
        MessageDAO.replyAndDeleteMessage(msgform.getMsgID(), msgbean);
        msgs.add("message", new ActionMessage("message.sent"));
      }catch(HibernateException e){
        context().log("undelete diary failed.", e);
        msgs.add("message", new ActionMessage("error.database", e.getMessage()));
      }
      break;
    }
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
    }
   
    return mapping.findForward("send");
  }
View Full Code Here

  protected ActionForward doFetchPwd(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UserForm uform = (UserForm) form;
    validateClientId(request, uform);
    ActionMessages msgs = new ActionMessages();
    do{
      if(StringUtils.isEmpty(uform.getName())){
        msgs.add("name", new ActionMessage("error.username_empty"));
        break;
      }
      UserBean ubean = UserDAO.getUserByName(uform.getName());
      if(ubean==null){
        msgs.add("name", new ActionMessage("error.user_not_found"));
        break;
      }
      if (ubean.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("name", new ActionMessage("error.user_disabled"));
        break;
      }
      if(!StringUtils.isEmail(ubean.getEmail())){
        msgs.add("name", new ActionMessage("error.email_format"));
        break;
      }
      //�����ʼ�
      int siteid = (ubean.getSite()!=null)?ubean.getSite().getId():-1;
      sendPasswordNotify(request, siteid, ubean);
      msgs.add("name", new ActionMessage("mail.sent"));
      break;
    }while(true);
     
    if(!msgs.isEmpty())
      saveMessages(request, msgs);
   
    return mapping.findForward("fetchpwd");
  }
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    int own_site_id = -1;
    UserForm user = (UserForm) form;
    validateClientId(request, user);
    ActionMessages msgs = new ActionMessages();
    if (StringUtils.isEmpty(user.getName()))
      msgs.add("username", new ActionMessage("error.username_empty"));
    else if (StringUtils.isEmpty(user.getPassword()))
      msgs.add("password", new ActionMessage("error.password_empty"));
    else {
      UserBean ubean = DLOGUserManager.getUserByName(user.getName());
      if (ubean == null
          || !StringUtils.equals(ubean.getPassword(), user
              .getPassword()))
        msgs.add("password",
            new ActionMessage("error.user_auth_failed"));
      else if (ubean.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("password", new ActionMessage("error.user_disabled"));
      } else {
        // ִ�е�¼����
        UserLoginManager.loginUser(request, response, ubean, user.getKeepDays());
        own_site_id = ubean.getOwnSiteId();
      }
    }

    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("login");
    }
   
    String fromPage = user.getFromPage();
View Full Code Here

  protected ActionForward doUpdateBirth(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UserForm user = (UserForm) form;
    super.validateClientId(request, user);
    ActionMessages msgs = new ActionMessages();
   
    while (msgs.isEmpty()) {
      UserBean loginUser = super.getLoginUser(request, response);
      if(loginUser == null) {
        msgs.add("user", new ActionMessage("error.user_not_login"));
        break;
      }
      if(loginUser.getId() != user.getId()){
        msgs.add("user", new ActionMessage("error.access_deny"));
        break;
      }
      UserBean ubean = UserDAO.getUserByID(user.getId());
      if (ubean == null || ubean.getStatus()!=UserBean.STATUS_NORMAL) {
        msgs.add("id", new ActionMessage("error.user_not_available",
            new Integer(user.getId())));
        break;
      }
      if (!StringUtils.equals(ubean.getPassword(), user
          .getPassword())){
        msgs.add("password",
            new ActionMessage("error.user_auth_failed"));
        break;
      }
      boolean update = false;
      if(StringUtils.isNotEmpty(user.getSbirth())){
        try{
          int birth = Integer.parseInt(user.getSbirth());
          int year = birth / 10000;
          int month = (birth % 10000) / 100;
          int date = birth % 100;
          long lbirth = DateUtils.getDateBegin(year,month,date).getTime().getTime();
          ubean.setBirth(new java.sql.Date(lbirth));
          System.out.println("=================  new birth is " + ubean.getBirth());
          update = true;
        }catch(Exception e){}
      }
      if(update){
        try {
          DLOGUserManager.update(ubean);
          //����session�е��û�����
          UserLoginManager.updateLoginUser(request, ubean);   
        } catch (Exception e) {
          msgs.add("result", new ActionMessage("error.database", e
              .getMessage()));
        }
      }     
      break;
    }

    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("edituser");
    }

    StringBuffer ext = new StringBuffer();
View Full Code Here

TOP

Related Classes of org.apache.struts.action.ActionMessages

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.