Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMessages$ActionMessageItem


   */
  protected ActionForward doDeleteMusic(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response, String mid)
      throws Exception {
    MusicForm mform = (MusicForm) form;
    ActionMessages msgs = validateSiteOwner(request, response, mform);
    if (msgs.isEmpty()) {
      int music_id = Integer.parseInt(mid);
      MusicBean mbean = MusicDAO.getMusicByID(music_id);
      SiteBean site = super.getSiteBean(request);
      if (mbean != null && mbean.getSite().getId() == site.getId()) {
        MusicDAO.deleteMusic(mbean);
View Full Code Here


    super.validateClientId(request, mform);
    do{
      if (StringUtils.isEmpty(mform.getTitle())){
        break;     
      }
      ActionMessages msgs = super.validateSiteOwner(request, response, mform);
      if(!msgs.isEmpty()){
        saveMessages(request, msgs);
        break;
      }
      SiteBean site = super.getSiteBean(request);
      MusicBean mbean = MusicDAO.getMusicByID(mform.getId());
View Full Code Here

   */
  protected ActionForward doDeleteSelected(ActionMapping mapping,
      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    MusicForm mform = (MusicForm) form;
    ActionMessages msgs = validateSiteOwner(request, response, mform);
    if (msgs.isEmpty() && mform.getMid() != null
        && mform.getMid().length > 0) {
      SiteBean site = super.getSiteBean(request);
      MusicDAO.deleteMusics(site.getId(), mform.getMid());
    }
    return makeForward(mapping.findForward("music"), mform.getSid(), "box",
View Full Code Here

   */
  protected ActionForward doDeleteBox(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response,
      String mboxid) throws Exception {
    MusicBoxForm mform = (MusicBoxForm) form;
    ActionMessages msgs = validateSiteOwner(request, response, mform);
    if (msgs.isEmpty()) {
      SiteBean site = super.getSiteBean(request);
      MusicBoxBean mbox = MusicDAO.getMusicBoxByID(Integer
          .parseInt(mboxid));
      if (mbox.getSite().getId() == site.getId())
        MusicDAO.deleteMusicBox(mbox);
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    MusicBoxForm mform = (MusicBoxForm) form;
    super.validateClientId(request, mform);
    if (StringUtils.isNotEmpty(mform.getName())) {
      ActionMessages msgs = validateSiteOwner(request, response, mform);
      if (msgs.isEmpty()) {
        SiteBean site = super.getSiteBean(request);
        MusicBoxBean mbox = MusicDAO.getMusicBoxByID(mform.getId());
        if (mbox.getSite().getId() == site.getId()) {
          mbox.setName(super.autoFiltrate(site,mform.getName()));
          if (StringUtils.isNotEmpty(mform.getDesc())){
View Full Code Here

      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception      
  {
    CatalogForm catalog = (CatalogForm) form;
    super.validateClientId(request, catalog);
    ActionMessages msgs = new ActionMessages();
    UserBean loginUser = super.getLoginUserAfterValidateSiteOwner(request);
    //���userid�Ƿ����
    if (catalog.getUserid() < 1
        || UserDAO.getUserByID(catalog.getUserid()) == null) {
      msgs.add("userid", new ActionMessage("error.user_not_found",
          new Integer(catalog.getUserid())));
    }
    else if(catalog.getUserid()== loginUser.getId()){
      //��������Լ�
    }
    else{
      SiteBean site = getSiteBean(request);
      //���catalog_id�Ƿ���Ч
      CatalogBean bean = CatalogDAO.getCatalogByID(catalog.getId());
      if(bean==null){
        msgs.add("userid", new ActionMessage("error.catalog_not_found",
            new Integer(catalog.getId())));
      }
      //���sid��catalog_id�Ƿ��Ӧ
      else if(bean.getSite().getId()!=site.getId()){
        msgs.add("userid", new ActionMessage("error.catalog_deny",
            new Integer(catalog.getId())));
      }
      else{
        //�ж��Ƿ��Ѿ�����Ȩ����Ϣ
        int role = CatalogDAO.getUserRoleInCatalog(catalog.getId(), catalog.getUserid());
        if(role < 0){
          //������Ȩ��
          CatalogDAO.createPermission(catalog.getId(), catalog
              .getUserid(), catalog.getRole());
        }
        else if (role < catalog.getRole()){
          CatalogDAO.updatePermission(catalog.getId(), catalog
              .getUserid(), catalog.getRole());
        }
      }
    }
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      return mapping.findForward("adduser");
    }
    return makeForward(mapping.findForward("catalog-users"), catalog
        .getSid(), "cat_id", catalog.getId());
View Full Code Here

  protected ActionForward doCreateCatalog(ActionMapping mapping,
      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) throws Exception      
  {
    CatalogForm catalog = (CatalogForm)form;
    ActionMessages msgs = new ActionMessages();
   
    if(StringUtils.isEmpty(catalog.getName()))
      msgs.add("name", new ActionMessage("error.empty_not_allowed"));
    else if(DLOGSecurityManager.IllegalGlossary.existIllegalWord(catalog.getName()))
      msgs.add("name", new ActionMessage("error.illegal_glossary"));
    else if(DLOGSecurityManager.IllegalGlossary.existIllegalWord(catalog.getDetail()))
      msgs.add("detail", new ActionMessage("error.illegal_glossary"));
    else{
      SiteBean site = super.getSiteBean(request);
      CatalogBean cbean = new CatalogBean();
      cbean.setName(super.autoFiltrate(site, catalog.getName()));
      if(StringUtils.isNotEmpty(catalog.getDetail())){
        String detail = super.autoFiltrate(site, catalog.getDetail());
        cbean.setDetail(super.filterScriptAndStyle(detail));
      }
      cbean.setType(catalog.getType());
      cbean.setSite(site);
      cbean.setCreateTime(new Date());
      if(catalog.getCatalog()>0){
        cbean.setCatalog(new TypeBean(catalog.getCatalog()));
      }
      try{
        CatalogDAO.create(cbean, catalog.getId(), catalog.getDirection()==1);
      }catch(Exception e){
        msgs.add("catalog", new ActionMessage("error.database", e.getMessage()));
      }     
    }
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      return mapping.getInputForward();
    }
    return makeForward(mapping.findForward(CATALOGS), catalog.getSid());
  }
View Full Code Here

   */
  protected ActionForward doAutoCreateCatalogAndWrite(ActionMapping mapping,
      ActionForm form, HttpServletRequest request,
      HttpServletResponse response, String s_log_id) throws Exception {
    DiaryForm dform = (DiaryForm) form;
    ActionMessages msgs = super.validateSiteOwner(request, response, dform);
   
    do{
      if (!msgs.isEmpty())
        break;
      String catalog = dform.getCatalog();
      if (StringUtils.isEmpty(catalog))
        break;
      SiteBean site = super.getSiteBean(request);     
View Full Code Here

   * @throws Exception
   */
  protected ActionForward doUpdateLog(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    ActionMessages msgs = new ActionMessages();
    DiaryForm diaryForm = (DiaryForm) form;
    //super.validateClientId(request, diaryForm);
    UserBean loginUser = super.getLoginUser(request, response);
    if (loginUser == null) {
      msgs.add("editlog", new ActionMessage("error.user_not_login"));
    } else {
      DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
      if (diary == null) {
        msgs
            .add("editlog", new ActionMessage(
                "error.diary_not_exists"));
      } else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
        msgs.add("editlog", new ActionMessage("error.access_deny"));
      } else {
        boolean catalog_can_access = false;
        if (diary.getCatalog().getId() != diaryForm.getCatalogId()) {
          SiteBean site = diary.getSite();
          CatalogBean catalog = null;
          // վ�����Է���վ�ڵ��κη���
          if (site.isOwner(loginUser)) {
            catalog = CatalogDAO.getCatalogByID(diaryForm
                .getCatalogId());
            if (catalog.getSite().getId() == site.getId())
              catalog_can_access = true;
          } else {
            // �г��û��ڸ�վ��ɷ��ʵ��ռǷ���
            List catalogs = CatalogDAO.listCatalogs(site, loginUser, true);
            for (int i = 0; catalogs != null && i < catalogs.size(); i++) {
              CatalogBean t_catalog = (CatalogBean) catalogs
                  .get(i);
              if (t_catalog.getId() == diaryForm.getCatalogId()) {
                catalog = t_catalog;
                catalog_can_access = true;
                break;
              }
            }
          }
          // �����ռ���������
          if (catalog != null) {
            diary.getCatalog().incArticleCount(-1);
            diary.setCatalog(catalog);
            catalog.incArticleCount(1);
          }
        } else
          catalog_can_access = true;
        if (catalog_can_access) {
          SiteBean site = diary.getSite();
          // �����ռ�
          boolean updateTags = false;
          if (!StringUtils.equals(diary.getKeyword(), diaryForm
              .getTags())) {
            updateTags = true;
            if (StringUtils.isNotEmpty(diaryForm.getTags()))
              diary.setKeyword(super.autoFiltrate(site, diaryForm.getTags()));
            else {
              diary.setKeyword(null);
            }
          }
          diary.setTitle(super.autoFiltrate(site,diaryForm.getTitle()));
          if (!StringUtils.equals(diaryForm.getContent(), diary.getContent())) {
            diary.setContent(super.autoFiltrate(site,diaryForm.getContent()));
            diary.setSize(diaryForm.getContent().getBytes().length);
            //�����ı�����(Winter Lau, 2006-5-12)
            if(diary.getStatus() == DiaryBean.STATUS_NORMAL)
              TextCacheManager.updateTextContent(DiaryBean.TYPE_DIARY, diary.getId(), diary.getContent());
          }
          diary.setAuthor(diaryForm.getAuthor());
          if (StringUtils.isNotEmpty(diaryForm.getAuthorUrl()))
            diary.setAuthorUrl(diaryForm.getAuthorUrl());
          diary.setMoodLevel(diaryForm.getMoodLevel());
          if (StringUtils.isNotEmpty(diaryForm.getRefUrl()))
            diary.setRefUrl(diaryForm.getRefUrl());
          diary.setReplyNotify(diaryForm.getNotify());
          diary.setWeather(diaryForm.getWeather());
          diary.setModifyTime(new Date());
          if (diaryForm.getBgSound() != -1) {
            // ��鱳�������Ƿ���Ч
            MusicBean song = MusicDAO.getMusicByID(diaryForm.getBgSound());
            if (song != null
                && song.getSite().getId() == diary.getSite().getId()) {
              diary.setBgSound(song);
            }
          }
          try {
            // �����ϴ�����Ϣ
            pickupUploadFileItems(request, response, loginUser
                .getId(), diary.getSite(), diary.getId(), DiaryBean.TYPE_DIARY);
            DiaryDAO.update(diary, updateTags);
          } catch (Exception e) {
            context().log("update diary failed.", e);
            msgs.add("editlog", new ActionMessage("error.database",
                e.getMessage()));
          }
        } else
          msgs.add("log", new ActionMessage("error.catalog_deny",
              new Integer(diaryForm.getCatalogId())));
      }
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("editlog");
    }
    if (diaryForm.getStatus() == DiaryBean.STATUS_DRAFT) {
      return makeForward(mapping.findForward("draft"), diaryForm.getSid());
View Full Code Here

   * @throws Exception
   */
  protected ActionForward doPublishLog(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response, String identity)
      throws Exception {
    ActionMessages msgs = new ActionMessages();
    DiaryForm log = (DiaryForm) form;
    //super.validateClientId(request, log);
    while (true) {
      // ����ռDZ����ֵ
      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;
      }
      UserBean loginUser = super.getLoginUser(request, response);
      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;
      }
      SiteBean site = super.getSiteByID(log.getSid());
      if (site == null) {
        msgs.add("log", new ActionMessage("error.site_not_available"));
        break;
      }
      boolean catalog_can_access = false;
      CatalogBean catalog = null;
      // վ�����Է���վ�ڵ��κη���
      if (site.isOwner(loginUser)) {
        catalog = CatalogDAO.getCatalogByID(log.getCatalogId());
        if (catalog!=null && catalog.getSite().getId() == site.getId())
          catalog_can_access = true;
      } else {
        // �г��û��ڸ�վ��ɷ��ʵ��ռǷ���
        List catalogs = CatalogDAO.listCatalogs(site, loginUser, true);
        for (int i = 0; catalogs != null && i < catalogs.size(); i++) {
          CatalogBean t_catalog = (CatalogBean) catalogs.get(i);
          if (t_catalog.getId() == log.getCatalogId()) {
            catalog = t_catalog;
            catalog_can_access = true;
            break;
          }
        }
      }
      if (!catalog_can_access) {
        msgs.add("log", new ActionMessage("error.catalog_deny",
            new Integer(log.getCatalogId())));
        break;
      }
      // �û����������ռǷ��౻����
      if (StringUtils.isEmpty(log.getWeather()))
        log.setWeather(DEFAULT_WEATHER);
      if (StringUtils.isEmpty(log.getAuthor()))
        log.setAuthor(loginUser.getNickname());
      if (StringUtils.isEmpty(log.getTags()))
        log.setTags(null);
      if (StringUtils.isEmpty(log.getAuthorUrl()))
        log.setAuthorUrl(null);
      if (StringUtils.isEmpty(log.getRefUrl()))
        log.setRefUrl(null);
      // ����JournalBean
      DiaryBean journal = new DiaryBean();
      journal.setOwner(loginUser);
      journal.setSite(site);
      journal.setAuthor(super.autoFiltrate(site, log.getAuthor()));
      journal.setAuthorUrl(log.getAuthorUrl());
      journal.setCatalog(catalog);
      journal.setClient(new ClientInfo(request, log.getClientType()));
      // ������վ�İ�ȫ��־�����Ƿ�����ݽ��������ִʹ���

      String ssn_id = RequestUtils.getDlogSessionId(request);
      boolean wml = WML_IDENTITY.equalsIgnoreCase(identity);
      String content = autoCompileContent(request, site, log.getContent(), loginUser.getId(), ssn_id, wml);
      journal.setContent(content);
      journal.setSize(content.getBytes().length);
      journal.setTitle(super.autoFiltrate(site, log.getTitle()));
      journal.setKeyword(super.autoFiltrate(site, log.getTags()));
     
      journal.setMoodLevel(log.getMoodLevel());
      journal.setRefUrl(log.getRefUrl());
      journal.setReplyNotify(log.getNotify());
      journal.setStatus(DiaryBean.STATUS_NORMAL);
      journal.setWeather(log.getWeather());
      journal.setWriteTime(DateUtils.mergeDateTime(log.getWriteDate(), log.getWriteTime()).getTime());
      Date curTime = new Date();
      if(journal.getWriteTime().after(curTime))
        journal.setWriteTime(curTime);
      // ��鱳�������Ƿ���Ч
      MusicBean song = MusicDAO.getMusicByID(log.getBgSound());
      if (song != null && song.getSite().getId() == site.getId()) {
        journal.setBgSound(song);
      }
      DiaryDAO.create(journal, log.getBookmark() == 1);
      // �����ϴ�����Ϣ
      pickupUploadFileItems(request, response, loginUser.getId(), site, journal
          .getId(), DiaryBean.TYPE_DIARY);

      if (log.getRefUrl() != null) {
        trackBack(journal, log.getRefUrl());
      }
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("addlog");
    }
    return makeForward(mapping.findForward("diary"), log.getSid());
  }
View Full Code Here

TOP

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

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.