Examples of ActionMessages


Examples of com.dotcms.repackage.org.apache.struts.action.ActionMessages

        /*This was created for CSU-604
         * This code let it send messages of warning between pages, when
         * the session or request messages doesn't work
         * */
        if(UtilMethods.isSet(request.getParameter("message"))){
          ActionMessages message = new ActionMessages();
      message.add("message", new ActionMessage(request.getParameter("message")));
      saveMessages(request, message);
        }else if(UtilMethods.isSet(request.getParameter("error"))){
          ActionMessages errors = new ActionMessages();
      errors.add("errors", new ActionMessage(request.getParameter("error")));
      saveErrors(request, errors);
        }

        ActionForward af = (mapping.findForward("loginPage"));

View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      final HttpServletResponse response, String s_photo_id) throws Exception      
  {
    PhotoForm pform = (PhotoForm)form;
    super.validateClientId(request, pform);
   
    ActionMessages msgs = new ActionMessages();
    do{
      SessionUserObject loginUser = super.getLoginUser(request,response,false);
      if(loginUser==null){
        msgs.add("photo", new ActionMessage("error.user_not_login"));
        break;
      }
      PhotoOutlineBean pbean = PhotoDAO.getPhotoOutlineByID(pform.getId());
      if(pbean==null||pbean.getStatus()!=PhotoBean.STATUS_NORMAL){
        msgs.add("photo", new ActionMessage("error.invalid_photo", new Integer(pform.getId())));
        break;
      }
      //�����ʼ�
      String s_mails = request.getParameter("mails");     
      String[] emails = StringUtils.split(s_mails, ";",MAX_MAIL_COUNT);
      if(emails==null || emails.length==0){
        msgs.add("photo", new ActionMessage("error.no_share_mails"));
        break;
      }
      List vtMails = new ArrayList();
      for(int i=0;i<emails.length;i++){
        String sm = emails[i].trim();
        if(StringUtils.isEmail(sm) && !vtMails.contains(sm))
          vtMails.add(sm);
      }
      if(vtMails.size()==0){
        msgs.add("photo", new ActionMessage("error.no_valid_mail"));
        break;
      }
      sendMails(request, loginUser, pbean, vtMails);
      msgs.add("share", new ActionMessage("mail.sent"));
      break;
    }while(true);
   
    if(!msgs.isEmpty())
      saveMessages(request, msgs);
   
    return mapping.findForward("photo_share");
  }
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      final HttpServletResponse response) throws Exception      
  {
    PhotoForm photo1 = (PhotoForm)form;
    validateClientId(request, photo1);
   
    ActionMessages msgs = new ActionMessages();
    do{
      FormFile[] files = new FormFile[5];
      files[0] = photo1.getImage();
      files[1] = photo1.getImage2();
      files[2] = photo1.getImage3();
      files[3] = photo1.getImage4();
      files[4] = photo1.getImage5();
     
      //����ಾ�Ƿ���Ч
      AlbumBean album = AlbumDAO.getAlbumByID(photo1.getAlbum());
      if (album == null) {
        msgs.add(ERROR_KEY, new ActionMessage(
            "error.object_not_found", String.valueOf(photo1
                .getAlbum())));
        break;
      }

      SiteBean site = super.getSiteBean(request);
      UserBean loginUser = super.getLoginUserAfterValidateSiteOwner(request);

      String photo_desc;
      if(StringUtils.isNotEmpty(photo1.getDesc())){
        photo_desc = StringUtils.abbreviate(super.autoFiltrate(
            site, photo1.getDesc()), MAX_PHOTO_DESC_LENGTH);
        photo_desc = super.filterScriptAndStyle(photo_desc);
      }
      else
        photo_desc = " ";
     
      for(int i=0;i<files.length;i++){
        if(files[i]==null || files[i].getFileSize()<=0 || StringUtils.isEmpty(files[i].getFileName()))
          continue;
        //�жϵ���ͼƬ�Ĵ�С
        /*
        if(files[i].getFileSize()>4194304){//4*1024*1024
          msgs.add(ERROR_KEY, new ActionMessage("error.file_too_large"));
          break;
        }*/
        if(!accept(files[i])){
          msgs.add(ERROR_KEY, new ActionMessage("error.upload_file_not_supported"));
          break;
        }
        //����ϴ��ռ�����
        int photo_size = DLOG4JUtils.sizeInKbytes(files[i].getFileSize());
        int max_photo_size = site.getCapacity().getPhotoTotal();
        if(max_photo_size >= 0){       
          int current_size = site.getCapacity().getPhotoUsed();
          if((current_size + photo_size) > max_photo_size){
            msgs.add(ERROR_KEY, new ActionMessage("error.photo_space_full"));
            break;
          }
        }
        //������Ƭ����������ͼ
        Photo img = null;
        try{
          img = getPhotoSaver().save(
              getHttpContext(mapping, form, request, response),
              files[i], photo1.getAutoRotate() == 1);
          if(img == null){
            msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed"));
            break;       
          }
          //д�뵽���ݿ�
          PhotoBean pbean = new PhotoBean();
          pbean.setSite(site);
          pbean.setUser(loginUser);
          if(StringUtils.isNotEmpty(photo1.getName())){
            pbean.setName(super.autoFiltrate(site, photo1.getName()));
          }
          else
            pbean.setName(img.getName());
          pbean.setDesc(photo_desc);
          if(StringUtils.isNotEmpty(photo1.getKeyword())){
            if(site.isFlagSet(SiteBean.Flag.ILLEGAL_GLOSSARY_IGNORE))
              pbean.setKeyword(photo1.getKeyword());
            else
              pbean.setKeyword(DLOGSecurityManager.IllegalGlossary
                  .deleteIllegalWord(photo1.getKeyword()));
          }
          pbean.setPreviewURL(img.getPreviewURL());
          pbean.setImageURL(img.getImageURL());
         
          pbean.setPhotoInfo(img);
          pbean.setFileName(super.autoFiltrate(site,img.getFileName()));
          pbean.setStatus(photo1.getStatus());//������������
          PhotoDAO.create(album, pbean, (photo1.getCover()==1));
        }catch(IllegalAccessException e){
          msgs.add(ERROR_KEY, new ActionMessage("error.access_deny", e.getMessage()));
          break;
        }catch(Exception e){
          log.error("Upload photo file failed.", e);
          msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed", e.getMessage()));
          break;
        }
      }
      break;
    }while(true);
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      ActionForward upload = makeForward(mapping.findForward("photo_upload"), photo1.getSid());
      upload.setRedirect(false);
      return upload;
    }
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      final ActionForm form, HttpServletRequest request,
      final HttpServletResponse response) throws Exception      
  {
    PhotoForm photo = (PhotoForm)form;
    validateClientId(request, photo);
    ActionMessages msgs = new ActionMessages();
   
    if(StringUtils.isEmpty(photo.getName()))
      msgs.add("name", new ActionMessage("error.photo.name_empty"));
    else{
      PhotoBean pbean = PhotoDAO.getPhotoByID(photo.getId());
      if(pbean != null){
        if(!StringUtils.equals(pbean.getName(), photo.getName())){
          pbean.setName(super.autoFiltrate(pbean.getSite(), photo.getName()));
        }
       
        if(!StringUtils.equals(pbean.getDesc(),photo.getDesc())){
          String desc = StringUtils.abbreviate(super.autoFiltrate(
              pbean.getSite(), photo.getDesc()),
              MAX_PHOTO_DESC_LENGTH);
          pbean.setDesc(super.filterScriptAndStyle(desc));
        }
        else
          pbean.setDesc(" ");
        pbean.setStatus(photo.getStatus());
        int new_album = photo.getAlbum();
        String new_Keyword = photo.getKeyword();
        if(!pbean.getSite().isFlagSet(SiteBean.Flag.ILLEGAL_GLOSSARY_IGNORE))
          new_Keyword = DLOGSecurityManager.IllegalGlossary.deleteIllegalWord(new_Keyword);
        PhotoDAO.update(new_album, pbean, new_Keyword, (photo.getCover()==1));
      }
    }
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      return mapping.findForward("photo_edit");
    }
   
    String ext = "aid=" + photo.getAlbum() +"&pid=" + photo.getId();
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    ReplyForm reply = (ReplyForm) form;
    //��֤�ͻ��˰�ȫʶ����
    validateClientId(request, reply);
    ActionMessages msgs = new ActionMessages();
    UserBean loginUser = super.getLoginUser(request, response);
    while (loginUser != null) {
      if (StringUtils.isEmpty(reply.getContent())) {
        msgs.add("reply", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      SiteBean site = super.getSiteByID(reply.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      _ReplyBean rbean = ReplyDAO.getReply(PhotoReplyBean.class, reply
          .getReply_id());
      if (rbean!=null && rbean.getSite().getId() == site.getId()) {
        String content = StringUtils.abbreviate(super.autoFiltrate(
          null, reply.getContent()), MAX_REPLY_LENGTH);
        rbean.setContent(super.filterScriptAndStyle(content));
        rbean.setAuthor(reply.getAuthor());       
        rbean.setOwnerOnly(reply.getOwnerOnly());
        if (StringUtils.isNotEmpty(reply.getAuthorURL()))
          rbean.setAuthorURL(reply.getAuthorURL());
        if (StringUtils.isNotEmpty(reply.getAuthorEmail()))
          rbean.setAuthorEmail(reply.getAuthorEmail());
        ReplyDAO.updateReply(rbean);
      }
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("showphoto");
    }
    StringBuffer ext = new StringBuffer("pid=");
    ext.append(reply.getParentId());
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    ReplyForm reply = (ReplyForm) form;
    //��֤�ͻ��˰�ȫʶ����
    validateClientId(request, reply);
    ActionMessages msgs = new ActionMessages();
    UserBean loginUser = super.getLoginUser(request, response);
    while (loginUser != null) {
      if (StringUtils.isEmpty(reply.getContent())) {
        msgs.add("reply", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      SiteBean site = super.getSiteByID(reply.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      _ReplyBean rbean = ReplyDAO.getReply(DiaryReplyBean.class, reply.getReply_id());
      if (rbean!=null && rbean.getSite().getId() == site.getId()) {
        String content = StringUtils.abbreviate(super.autoFiltrate(
            null, reply.getContent()), MAX_REPLY_LENGTH);
        rbean.setContent(super.filterScriptAndStyle(content));
        rbean.setAuthor(reply.getAuthor());       
        rbean.setOwnerOnly(reply.getOwnerOnly());
        if (StringUtils.isNotEmpty(reply.getAuthorURL()))
          rbean.setAuthorURL(reply.getAuthorURL());
        if (StringUtils.isNotEmpty(reply.getAuthorEmail()))
          rbean.setAuthorEmail(reply.getAuthorEmail());
        ReplyDAO.updateReply(rbean);
      }
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("showlog");
    }
    return makeForward(mapping.findForward("showlog"), reply.getSid(),
        "log_id", reply.getParentId());
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    ReplyForm reply = (ReplyForm) form;
    //��֤�ͻ��˰�ȫʶ����
    validateClientId(request, reply);
    ActionMessages msgs = new ActionMessages();
    do{
      if (StringUtils.isEmpty(reply.getContent())){
        msgs.add("reply", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if(reply.getContent().getBytes().length >= 3000){
        msgs.add("reply", new ActionMessage("error.reply_too_long"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      SiteBean site = super.getSiteByID(reply.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      //��������
      if(loginUser!=null && isUserInBlackList(site, loginUser)){
        msgs.add("topic", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      DiaryOutlineBean diary = DiaryDAO.getDiaryOutlineByID(reply.getParentId());
      if (diary == null || diary.getSite().getId() != reply.getSid()) {
        msgs.add("reply", new ActionMessage("error.param"));
        break;
      }      
      if(diary.getLock()==1) {
        msgs.add("reply", new ActionMessage("error.diary.locked"));
        break;
      }
      // ���������д������
      DiaryReplyBean rbean = new DiaryReplyBean();
      rbean.setUser(loginUser);     
      rbean.setAuthor(super.autoFiltrate(site,reply.getAuthor()));
      if (StringUtils.isNotEmpty(reply.getAuthorURL()))
        rbean.setAuthorURL(reply.getAuthorURL());
      if (StringUtils.isNotEmpty(reply.getAuthorEmail()))
        rbean.setAuthorEmail(reply.getAuthorEmail());
      rbean.setClient(new ClientInfo(request, reply
          .getClientType()));
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          reply.getContent()), MAX_REPLY_LENGTH);
      rbean.setContent(super.filterScriptAndStyle(content));
      rbean.setDiary(diary);
      rbean.setReplyTime(new Date());
      rbean.setSite(site);
      rbean.setStatus(DiaryReplyBean.STATUS_NORMAL);
      rbean.setOwnerOnly(reply.getOwnerOnly());
      DiaryDAO.createDiaryReply(rbean);
      // �ж��Ƿ���Ҫ�ʼ�����
      if (diary.getReplyNotify() == 1) {
        String email = diary.getOwner().getContactInfo()
            .getEmail();
        if (StringUtils.isEmail(email)) {
          this.sendReplyNotify(request, rbean.getSite().getId(), rbean);
        }
      }
      break;
    }while(true);
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("diary-enter-reply");
    }
    return makeForward(mapping.findForward("showlog"), reply.getSid(),
        "log_id", reply.getParentId());
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    ReplyForm reply = (ReplyForm) form;
    //��֤�ͻ��˰�ȫʶ����
    validateClientId(request, reply);
    ActionMessages msgs = new ActionMessages();
    PhotoReplyBean rbean = new PhotoReplyBean();
    do{
      if (StringUtils.isEmpty(reply.getContent())){
        msgs.add("reply", new ActionMessage("error.empty_not_allowed"));
        break;
      }
      if(reply.getContent().getBytes().length >= 3000){
        msgs.add("reply", new ActionMessage("error.reply_too_long"));
        break;
      }
      SiteBean site = super.getSiteByID(reply.getSid());
      if (site == null) {
        msgs.add("reply", new ActionMessage("error.site_not_available"));
        break;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      //��������
      if(loginUser!=null && isUserInBlackList(site, loginUser)){
        msgs.add("photo", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      PhotoOutlineBean photo = PhotoDAO.getPhotoOutlineByID(reply.getParentId());
      if (photo == null || photo.getSite().getId() != reply.getSid()) {
        msgs.add("reply", new ActionMessage("error.param"));
        break;
      }
      if(photo.getLock()==1) {
        msgs.add("reply", new ActionMessage("error.photo.locked"));
        break;
      }
      // ���������д������
      rbean.setUser(loginUser);
      rbean.setAuthor(super.autoFiltrate(site,reply.getAuthor()));
      if (StringUtils.isNotEmpty(reply.getAuthorURL()))
        rbean.setAuthorURL(reply.getAuthorURL());
      if (StringUtils.isNotEmpty(reply.getAuthorEmail()))
        rbean.setAuthorEmail(reply.getAuthorEmail());
      rbean.setClient(new ClientInfo(request, reply
          .getClientType()));
      String content = StringUtils.abbreviate(super.autoFiltrate(null,
          reply.getContent()), MAX_REPLY_LENGTH);
      rbean.setContent(super.filterScriptAndStyle(content));
      rbean.setPhoto(photo);
      rbean.setReplyTime(new Date());
      rbean.setSite(site);
      rbean.setStatus(DiaryReplyBean.STATUS_NORMAL);
      rbean.setOwnerOnly(reply.getOwnerOnly());
      PhotoDAO.createPhotoReply(rbean);
      break;
    }while(true);
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("showphoto");
    }
    StringBuffer ext = new StringBuffer("pid=");
    ext.append(reply.getParentId());
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

  protected ActionForward doCreate(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    MusicBoxForm mbox = (MusicBoxForm) form;
    super.validateClientId(request, mbox);
    ActionMessages msgs = validateSiteOwner(request, response, mbox);
    int mboxid = -1;
    if (msgs.isEmpty() && StringUtils.isEmpty(mbox.getName()))
      msgs.add("name", new ActionMessage("error.mbox.name_empty"));
    else if (msgs.isEmpty()) {
      SiteBean site = super.getSiteBean(request);
      MusicBoxBean mbean = new MusicBoxBean();
      mbean.setName(super.autoFiltrate(site, mbox.getName()));
      if (StringUtils.isNotEmpty(mbox.getDesc())){
        String desc = super.autoFiltrate(site, mbox.getDesc());
        mbean.setDesc(super.filterScriptAndStyle(desc));
      }
      mbean.setCreateTime(new Date());
      mbean.setSite(site);
      MusicDAO.createBox(mbean, mbox.getId(), mbox.getDirection() == 1);
      mboxid = mbean.getId();
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("mbox_add");
    }

    return makeForward(mapping.findForward("music"), mbox.getSid(), "box",
View Full Code Here

Examples of org.apache.struts.action.ActionMessages

  protected ActionForward doRecommend(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    MusicForm mform = (MusicForm) form;
    super.validateClientId(request, mform);
    ActionMessages msgs = new ActionMessages();
    do{
      if (StringUtils.isEmpty(mform.getTitle())) {
        msgs.add("name", new ActionMessage("error.music.title_empty"));
        break;
      }
      if (StringUtils.isEmpty(mform.getUrl())) {
        msgs.add("url", new ActionMessage("error.music.url_empty"));
        break;
      }
      // ��֤�Ƿ��¼�û�
      UserBean loginUser = super.getLoginUser(request, response);
      if (loginUser == null) {
        msgs.add("url", new ActionMessage("error.user_not_login"));
        break;
      }
      if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
        msgs.add("url", new ActionMessage("error.user_not_available"));
        break;
      }
      // ��֤���ֺе���Ч��
      MusicBoxBean mbox = MusicDAO.getMusicBoxByID(mform.getBox());
      if (mbox == null || mbox.getSite().getId() != mform.getSid()) {
        msgs.add("name", new ActionMessage("error.mbox_not_available",
            new Integer(mform.getBox())));
        break;
      }
      SiteBean site = super.getSiteByID(mform.getSid());
      if(site==null){
        msgs.add("site", new ActionMessage("error.site_not_available"));
        break;
      }
      //��������
      if(isUserInBlackList(site, loginUser)){
        msgs.add("music", new ActionMessage("error.user_in_blacklist"));
        break;
      }
      MusicBean mbean = new MusicBean();
      mbean.setSite(site);
      mbean.setIntroducer(loginUser);
      mbean.setMusicBox(mbox);
      mbean.setTitle(super.autoFiltrate(site, mform.getTitle()));
      if (StringUtils.isNotEmpty(mform.getAlbum()))
        mbean.setAlbum(mform.getAlbum());
      if (StringUtils.isNotEmpty(mform.getSinger()))
        mbean.setSinger(mform.getSinger());
      if (StringUtils.isNotEmpty(mform.getUrl()))
        mbean.setUrl(mform.getUrl());
      if (StringUtils.isNotEmpty(mform.getWord())){
        String word = super.autoFiltrate(site, mform.getWord());
        mbean.setWord(super.filterScriptAndStyle(word));
      }
      else
        mbean.setWord("&nbsp;");
      mbean.setCreateTime(new Date());
      mbean.setStatus(MusicBean.STATUS_RECOMMEND);
      MusicDAO.addMusic(mbean);
      break;
    }while(true);

    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("music_intro");
    }
    String msg = getMessage(request, null, "music.recommend.submitted");
    return msgbox(mapping, form, request, response, msg, mform
View Full Code Here
TOP
Copyright © 2015 www.massapi.com. 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.