1 18 19 package org.apache.roller.ui.authoring.struts.actions; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 import org.apache.roller.RollerException; 24 import org.apache.roller.config.PingConfig; 25 import org.apache.roller.model.PingTargetManager; 26 import org.apache.roller.model.RollerFactory; 27 import org.apache.roller.pojos.PingTargetData; 28 import org.apache.roller.pojos.WebsiteData; 29 import org.apache.roller.ui.authoring.struts.forms.PingTargetForm; 30 import org.apache.roller.ui.core.RollerRequest; 31 import org.apache.roller.ui.core.RollerSession; 32 import org.apache.struts.action.ActionForm; 33 import org.apache.struts.action.ActionForward; 34 import org.apache.struts.action.ActionMapping; 35 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 import java.util.Collections ; 39 import java.util.List ; 40 41 42 51 public class CustomPingTargetsAction extends BasePingTargetsAction { 52 private static Log mLogger = LogFactory.getFactory().getInstance(CustomPingTargetsAction.class); 53 54 public String getPingTargetsTitle() { 55 return "customPingTargets.customPingTargets"; 56 } 57 58 public String getPingTargetEditTitle() { 59 return "pingTarget.pingTarget"; 60 } 61 62 public String getPingTargetDeleteOKTitle() { 63 return "pingTarget.confirmRemoveTitle"; 64 } 65 66 public CustomPingTargetsAction() { 67 super(); 68 } 69 70 protected Log getLogger() { 71 return mLogger; 72 } 73 74 79 protected List getPingTargets(RollerRequest rreq) throws RollerException { 80 HttpServletRequest req = rreq.getRequest(); 81 PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager(); 82 83 Boolean allowCustomTargets = new Boolean (!PingConfig.getDisallowCustomTargets()); 84 req.setAttribute("allowCustomTargets", allowCustomTargets); 85 86 List customPingTargets = allowCustomTargets.booleanValue() ? pingTargetMgr.getCustomPingTargets(rreq.getWebsite()) : Collections.EMPTY_LIST; 87 88 return customPingTargets; 89 } 90 91 94 protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm) throws RollerException { 95 return new PingTargetData(null, pingTargetForm.getName(), pingTargetForm.getPingUrl(), rreq.getWebsite(), false); 96 } 97 98 99 102 protected boolean hasRequiredRights(RollerRequest rreq, WebsiteData website) throws RollerException { 103 RollerSession rses = RollerSession.getRollerSession(rreq.getRequest()); 104 return (rses.isUserAuthorizedToAdmin(website) && !PingConfig.getDisallowCustomTargets()); 105 } 106 107 public ActionForward cancel(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { 108 return view(mapping, actionForm, request, response); 109 } 110 } 111 | Popular Tags |