KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > website > actions > CommonPingTargetsAction


1 /*
2  * Copyright (c) 2005
3  * Anil R. Gangolli. All rights reserved.
4  *
5  * Distributed with the Roller Weblogger Project under the terms of the Roller Software
6  * License
7  */

8
9 package org.roller.presentation.website.actions;
10
11 import org.apache.commons.logging.Log;
12 import org.apache.commons.logging.LogFactory;
13 import org.roller.RollerException;
14 import org.roller.model.PingTargetManager;
15 import org.roller.pojos.PingTargetData;
16 import org.roller.presentation.RollerRequest;
17 import org.roller.presentation.forms.PingTargetForm;
18 import org.roller.presentation.weblog.actions.BasePingTargetsAction;
19
20 import java.util.List JavaDoc;
21
22 /**
23  * Administer common ping targets.
24  *
25  * @struts.action name="pingTargetForm" path="/admin/commonPingTargets" scope="request" parameter="method"
26  * @struts.action-forward name="pingTargets.page" path="/website/CommonPingTargets.jsp"
27  * @struts.action-forward name="pingTargetEdit.page" path="/website/CommonPingTargetEdit.jsp"
28  * @struts.action-forward name="pingTargetDeleteOK.page" path="/website/CommonPingTargetDeleteOK.jsp"
29  */

30 public class CommonPingTargetsAction extends BasePingTargetsAction
31 {
32     private static Log mLogger =
33         LogFactory.getFactory().getInstance(CommonPingTargetsAction.class);
34
35     protected Log getLogger() {
36         return mLogger;
37     }
38
39     /*
40      * Get the ping targets for the view. Here we return the common ping targets for the
41      * entire site.
42      */

43     protected List JavaDoc getPingTargets(RollerRequest rreq) throws RollerException
44     {
45         PingTargetManager pingTargetMgr = rreq.getRoller().getPingTargetManager();
46         return pingTargetMgr.getCommonPingTargets();
47     }
48
49     /*
50      * Create a new ping target (blank). Here we create a common ping target.
51      */

52     protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm)
53         throws RollerException
54     {
55         PingTargetManager pingTargetMgr = rreq.getRoller().getPingTargetManager();
56         return pingTargetMgr.createCommonPingTarget(
57             pingTargetForm.getName(), pingTargetForm.getPingUrl());
58     }
59
60
61     /*
62      * Check if request carries admin rights.
63      */

64     protected boolean hasRequiredRights(RollerRequest rreq) throws RollerException
65     {
66         // This mimics the check in other admin actions, but not sure why the latter is not sufficient.
67
return (rreq.isUserAuthorizedToEdit() && rreq.isAdminUser());
68     }
69 }
70
Popular Tags