KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > business > AutoPingManagerImpl


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.business;
10
11 import org.roller.model.AutoPingManager;
12 import org.roller.model.Roller;
13 import org.roller.model.PingQueueManager;
14 import org.roller.model.RollerFactory;
15 import org.roller.pojos.AutoPingData;
16 import org.roller.pojos.PingTargetData;
17 import org.roller.pojos.WebsiteData;
18 import org.roller.pojos.WeblogEntryData;
19 import org.roller.RollerException;
20 import org.roller.config.PingConfig;
21 import org.roller.config.PingConfig;
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25 import java.util.List JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.Collection JavaDoc;
28
29 /**
30  * Abstract implementation of AutoPingManager.
31  */

32 public abstract class AutoPingManagerImpl implements AutoPingManager
33 {
34     protected PersistenceStrategy persistenceStrategy;
35
36     private static Log mLogger =
37         LogFactory.getFactory().getInstance(AutoPingManagerImpl.class);
38
39     public AutoPingManagerImpl(PersistenceStrategy persistenceStrategy)
40     {
41         this.persistenceStrategy = persistenceStrategy;
42     }
43
44     public void release()
45     {
46     }
47
48     public AutoPingData createAutoPing(PingTargetData pingTarget, WebsiteData website) throws RollerException
49     {
50         return new AutoPingData(null, pingTarget, website);
51     }
52
53     public AutoPingData retrieveAutoPing(String JavaDoc id) throws RollerException
54     {
55         return (AutoPingData) persistenceStrategy.load(id, AutoPingData.class);
56     }
57
58     public void storeAutoPing(AutoPingData autoPing) throws RollerException
59     {
60         persistenceStrategy.store(autoPing);
61     }
62
63     public void removeAutoPing(String JavaDoc id) throws RollerException
64     {
65         //TODO: first remove all related category restrictions (category restrictions are not yet implemented)
66
persistenceStrategy.remove(id, AutoPingData.class);
67     }
68
69     public void removeAutoPing(AutoPingData autoPing) throws RollerException
70     {
71         //TODO: first remove all related category restrictions (category restrictions are not yet implemented)
72
persistenceStrategy.remove(autoPing);
73     }
74
75     public void removeAutoPings(Collection JavaDoc autopings) throws RollerException
76     {
77         for(Iterator JavaDoc i = autopings.iterator(); i.hasNext(); ) {
78             removeAutoPing((AutoPingData) i.next());
79         }
80     }
81
82     public void queueApplicableAutoPings(WeblogEntryData changedWeblogEntry) throws RollerException
83     {
84         if (PingConfig.getSuspendPingProcessing())
85         {
86             if (mLogger.isDebugEnabled()) mLogger.debug("Ping processing is suspended. No auto pings will be queued.");
87             return;
88         }
89
90         PingQueueManager pingQueueMgr = RollerFactory.getRoller().getPingQueueManager();
91         List JavaDoc applicableAutopings = getApplicableAutoPings(changedWeblogEntry);
92         for (Iterator JavaDoc i = applicableAutopings.iterator(); i.hasNext(); ) {
93             AutoPingData autoPing = (AutoPingData) i.next();
94             pingQueueMgr.addQueueEntry(autoPing);
95         }
96     }
97
98 }
99
Popular Tags