1 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 ; 26 import java.util.Iterator ; 27 import java.util.Collection ; 28 29 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 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 id) throws RollerException 64 { 65 persistenceStrategy.remove(id, AutoPingData.class); 67 } 68 69 public void removeAutoPing(AutoPingData autoPing) throws RollerException 70 { 71 persistenceStrategy.remove(autoPing); 73 } 74 75 public void removeAutoPings(Collection autopings) throws RollerException 76 { 77 for(Iterator 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 applicableAutopings = getApplicableAutoPings(changedWeblogEntry); 92 for (Iterator i = applicableAutopings.iterator(); i.hasNext(); ) { 93 AutoPingData autoPing = (AutoPingData) i.next(); 94 pingQueueMgr.addQueueEntry(autoPing); 95 } 96 } 97 98 } 99 | Popular Tags |