📄 editthreadlinkaction.java
字号:
/*
* XP Forum
*
* Copyright (c) 2002-2003 RedSoft Group. All rights reserved.
*
*/
package org.redsoft.forum.web;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.util.RequestUtils;
import org.redsoft.forum.exception.ThreadNotFoundException;
import org.redsoft.forum.ForumConstants;
import org.redsoft.forum.security.User;
import org.redsoft.forum.util.ForumUtils;
import org.redsoft.forum.dao.ThreadDAO;
import org.redsoft.forum.dao.DAOFactory;
import org.redsoft.forum.dao.PersistentThread;
import org.redsoft.forum.exception.AccountNotFoundException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.security.auth.Subject;
import java.io.IOException;
import java.sql.SQLException;
/**
* an action that wraps the link to editThread.jsp
*
* @@author <a href="mailto:chjxm@msn.com">cinc</a>
*
* @@version $Id: EditThreadLinkAction.java,v 1.1.1.1 2003/07/08 08:25:17 cinc Exp $
*/
public class EditThreadLinkAction extends Action {
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Get the user from session
final Subject subject = (Subject)request.getSession().getAttribute(ForumConstants.USER_KEY);
final String user = ( (User)subject.getPrincipals( User.class ).iterator().next() ).getName();
ActionErrors errors = new ActionErrors();
final String threadID = request.getParameter(ForumConstants.THREAD_ID_PARAM);
if ((threadID == null) || (threadID.equals(""))) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.threadID.invalid"));
} else {
try {
final ThreadDAO dao = DAOFactory.getInstance().getThreadDAO();
final PersistentThread thread = dao.findByUID( Long.parseLong( threadID ) );
// Return a immutable thread object back to jsp instead of a mutable PersistentThread object
request.setAttribute( ForumConstants.MY_THREAD_PARAM,
new Thread( thread.getTitle(),
thread.getContent(),
thread.getNotify()));
}catch( final SQLException sqlException ){
sqlException.printStackTrace();
return (mapping.findForward("error"));
}catch( final ThreadNotFoundException threadNotFoundException ){
threadNotFoundException.printStackTrace();
return (mapping.findForward("error"));
}
}
// Report any errors we have discovered back to the original form
if (!errors.empty()) {
saveErrors(request, errors);
}
/*
// If user is null then user has not loged in,forward to log on screen
if ( user == null || user.length() == 0 ){
final String url = "/editThreadLink.go?" + request.getQueryString();
request.setAttribute( ForumConstants.DEST_URL, url );
return (mapping.findForward("logon"));
}else{
// Forward control to the specified success URI
return (mapping.findForward("success"));
}
*/
// Forward control to the specified success URI
return (mapping.findForward("success"));
}
}//EOC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -