Package com.liusoft.dlog4j.formbean

Examples of com.liusoft.dlog4j.formbean.MusicForm


   * @ajax_enabled
   */
  protected ActionForward doCollect(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response, String s_music_id)
      throws Exception {
    MusicForm mform = (MusicForm) form;
    int mid = Integer.parseInt(s_music_id);
    String msg = null;
    do{
      //�ж��û��Ƿ��¼���Ƿ����Լ�����վ
      SessionUserObject loginUser = super.getLoginUser(request, response);
      if(loginUser==null){
        msg = getMessage(request, null, "error.user_not_login");
        break;
      }
      if(loginUser.getStatus()!=UserBean.STATUS_NORMAL){
        msg = getMessage(request, null, "error.user_disabled");
        break;
      }
      if(loginUser.getOwnSiteId()<=0){
        msg = getMessage(request, null, "error.user_not_have_a_site");
        break;
      }
      //�ж��û��ĸ��������Ƿ���Ч
      SiteBean toSite = super.getSiteByID(loginUser.getOwnSiteId());
      if(toSite==null){
        msg = super.getMessage(request, null, "error.site_not_available");
        break;
      }
      MusicBean mbean = MusicDAO.getMusicByID(mid);
      if(mbean!=null && mbean.getSite().getId()==mform.getSid())
      {
        MusicBean music = new MusicBean();
        music.setCreateTime(new Date());
        music.setMusicBox(null);
        music.setAlbum(mbean.getAlbum());
        music.setSinger(mbean.getSinger());
        music.setSite(new SiteBean(loginUser.getOwnSiteId()));
        music.setTitle(mbean.getTitle());
        music.setUrl(mbean.getUrl());
        music.setWord(mbean.getWord());
        MusicDAO.addMusic(music);
        msg = getMessage(request, null, "music.collected", music.getTitle());
      }
      break;
    }while(true);
    return msgbox(mapping, form, request, response, msg, mform.getFromPage());
  }
View Full Code Here


   * @throws Exception
   */
  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
        .getFromPage());
  }
View Full Code Here

   * @throws Exception
   */
  protected ActionForward doAdd(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    MusicForm mform = (MusicForm) form;
    super.validateClientId(request, mform);
    ActionMessages msgs = validateSiteOwner(request, response, mform);
    while (msgs.isEmpty()) {
      if (StringUtils.isEmpty(mform.getTitle())) {
        msgs.add("name", new ActionMessage("error.music.title_empty"));
        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.getSiteBean(request);
      MusicBean mbean = new MusicBean();
      mbean.setSite(site);
      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 = StringUtils.abbreviate(super.autoFiltrate(site,
            mform.getWord()), MAX_MUSIC_LENGTH);
        mbean.setWord(super.filterScriptAndStyle(word));
      }
      else
        mbean.setWord("  ");
      mbean.setCreateTime(new Date());
      MusicDAO.addMusic(mbean);
      break;
    }

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

    return makeForward(mapping.findForward("music"), mform.getSid(), "box",
        mform.getBox());
  }
View Full Code Here

   * @throws Exception
   */
  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);
        SearchProxy.remove(mbean);
      }
    }
    return makeForward(mapping.findForward("music"), mform.getSid(), "box",
        mform.getBox());
  }
View Full Code Here

   * @throws Exception
   */
  protected ActionForward doUpdateMusic(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    MusicForm mform = (MusicForm) form;
    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());
      //�ж��Ƿ�Ϊ��վ����
      if(mbean==null ||mbean.getSite().getId()!=site.getId()){
        break;
      }
      if (mbean.getStatus() == MusicBean.STATUS_NORMAL) {
        // ��֤�µ����ֺе���Ч��(�ƶ����������ֺ�)
        if ((mbean.getMusicBox() == null && mform.getBox() > 0)
            || (mbean.getMusicBox() != null && mform.getBox() != mbean
                .getMusicBox().getId())) {
          MusicBoxBean mbox = MusicDAO
              .getMusicBoxByID(mform.getBox());
          //�ж��Ƿ�Ϊ��վ�����ֺ�
          if(mbox!=null && mbox.getSite().getId()!=site.getId()){
            break;
          }
          //�任���ֺ�
          if (mbox != null
              && (mbean.getMusicBox() == null || mbean.getMusicBox()
                  .getId() != mbox.getId())) {
            //�������ֺ�֮���ƶ����ߴ��޵���
            if (mbean.getMusicBox() != null)
              mbean.getMusicBox().incMusicCount(-1);
            mbean.setMusicBox(mbox);
            mbox.incMusicCount(1);
          } else if (mbox == null && mbean.getMusicBox() != null) {
            //���е���
            mbean.getMusicBox().incMusicCount(-1);
            mbean.setMusicBox(null);
          }
        }
      }

      //����ֵ
      if(!StringUtils.equals(mbean.getTitle(), mform.getTitle()))
        mbean.setTitle(super.autoFiltrate(site,mform.getTitle()));
      if (StringUtils.isNotEmpty(mform.getAlbum()))
        mbean.setAlbum(super.autoFiltrate(site,mform.getAlbum()));
      if (StringUtils.isNotEmpty(mform.getSinger()))
        mbean.setSinger(super.autoFiltrate(site,mform.getSinger()));
      if (StringUtils.isNotEmpty(mform.getUrl()))
        mbean.setUrl(mform.getUrl());
      if (StringUtils.isNotEmpty(mform.getWord())){
        String word = StringUtils.abbreviate(super.autoFiltrate(site,
          mform.getWord()), MAX_MUSIC_LENGTH);
        mbean.setWord(super.filterScriptAndStyle(word));
      }
      else
        mbean.setWord("  ");
      if (mbean.getStatus() != MusicBean.STATUS_NORMAL) {
        // �����Ƽ����������
        mbean.getMusicBox().incMusicCount(1);
        mbean.setStatus(MusicBean.STATUS_NORMAL);
      }
      MusicDAO.flush();
      break;
    }while(true);
   
    return makeForward(mapping.findForward("music"), mform.getSid(), "box",
        mform.getBox());
  }
View Full Code Here

   * @throws Exception
   */
  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",
        mform.getBox());
  }
View Full Code Here

TOP

Related Classes of com.liusoft.dlog4j.formbean.MusicForm

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.