* @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(" ");
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());
}