1 package org.roller.presentation.weblog.actions; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 import org.apache.struts.action.Action; 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionForward; 8 import org.apache.struts.action.ActionMapping; 9 import org.roller.model.RefererManager; 10 import org.roller.pojos.RefererData; 11 import org.roller.presentation.RollerContext; 12 import org.roller.presentation.RollerRequest; 13 import org.roller.presentation.pagecache.PageCacheFilter; 14 15 import javax.servlet.ServletException ; 16 import javax.servlet.http.HttpServletRequest ; 17 import javax.servlet.http.HttpServletResponse ; 18 19 20 24 public class ToggleLinkbackDisplayAction extends Action 25 { 26 private static Log mLogger = LogFactory.getFactory().getInstance( 27 ToggleLinkbackDisplayAction.class); 28 29 32 public ActionForward execute( 33 ActionMapping mapping, ActionForm form, 34 HttpServletRequest req, HttpServletResponse res) 35 throws Exception 36 { 37 38 RollerRequest rreq = RollerRequest.getRollerRequest(req); 39 String userName = rreq.getUser().getUserName(); 40 41 try 42 { 43 if ( rreq.isUserAuthorizedToEdit() ) 44 { 45 String refid = req.getParameter(RollerRequest.REFERERID_KEY); 46 if ( refid != null ) 47 { 48 RefererManager refmgr = 49 rreq.getRoller().getRefererManager(); 50 RefererData ref = refmgr.retrieveReferer(refid); 51 boolean was = ref.getVisible()==null ? 52 false : ref.getVisible().booleanValue(); 53 ref.setVisible(Boolean.valueOf( !was )); ref.save(); 55 56 rreq.getRoller().commit(); 57 58 PageCacheFilter.removeFromCache( req, rreq.getUser() ); 59 } 60 } 61 } 62 catch (Exception e) 63 { 64 mLogger.error("Toggling linkback display",e); 65 throw new ServletException (e); 66 } 67 68 String url = null; 70 try 71 { 72 RollerContext rctx = RollerContext.getRollerContext( 73 rreq.getServletContext()); 74 url = rctx.getContextUrl( req, userName); 75 res.sendRedirect(url); 76 } 77 catch (Exception e) 78 { 79 mLogger.error("Unexpected exception",e); 80 } 81 82 return null; 83 } 84 } 85 86 | Popular Tags |