roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r395347 - in /incubator/roller/branches/roller-newbackend: src/org/roller/business/hibernate/ src/org/roller/config/ src/org/roller/model/ src/org/roller/presentation/weblog/actions/ src/org/roller/presentation/website/actions/ tests/org/ro...
Date Wed, 19 Apr 2006 18:47:14 GMT
Author: agilliland
Date: Wed Apr 19 11:47:12 2006
New Revision: 395347

URL: http://svn.apache.org/viewcvs?rev=395347&view=rev
Log:
manager method name refactorings for PingTargetManager.

storeXXX() -> saveXXX()
retrieveXXX() -> getXXX()
createXXX() -> addXXX() (or is removed)

plus:
removed method removePingTarget(id)
added method removePingTarget(pingTarget)
removed method removeCustomPingTargets()


Modified:
    incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePingTargetManagerImpl.java
    incubator/roller/branches/roller-newbackend/src/org/roller/config/PingConfig.java
    incubator/roller/branches/roller-newbackend/src/org/roller/model/PingTargetManager.java
    incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/BasePingTargetsAction.java
    incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java
    incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/PingSetupAction.java
    incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java
    incubator/roller/branches/roller-newbackend/tests/org/roller/TestUtils.java
    incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePingTargetManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePingTargetManagerImpl.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePingTargetManagerImpl.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePingTargetManagerImpl.java
Wed Apr 19 11:47:12 2006
@@ -51,7 +51,7 @@
     
     public void removePingTarget(String id) throws RollerException {
         
-        PingTargetData pingTarget = retrievePingTarget(id);
+        PingTargetData pingTarget = getPingTarget(id);
         
         // remove contents and then target
         this.removePingTargetContents(pingTarget);
@@ -59,6 +59,11 @@
     }
     
     
+    public void removePingTarget(PingTargetData pingTarget) throws RollerException {
+        this.strategy.remove(pingTarget);
+    }
+    
+    
     /**
      * Convenience method which removes any queued pings or auto pings that
      * reference the given ping target.
@@ -84,15 +89,6 @@
     
     
     /**
-     * @see org.roller.model.PingTargetManager#removeCustomPingTargets(org.roller.pojos.WebsiteData)
-     */
-    public void removeCustomPingTargets(WebsiteData website) throws RollerException {
-        List customTargets = getCustomPingTargets(website);
-        removeTargets(customTargets);
-    }
-    
-    
-    /**
      * @see org.roller.model.PingTargetManager#removeAllCustomPingTargets()
      */
     public void removeAllCustomPingTargets() throws RollerException {
@@ -120,23 +116,12 @@
     }
     
     
-    public PingTargetData createCommonPingTarget(String name, String pingUrl) throws RollerException
{
-        return new PingTargetData(null, name, pingUrl, null);
-    }
-    
-    
-    public PingTargetData createCustomPingTarget(String name, String pingUrl, WebsiteData
website) throws RollerException {
-        if (website == null) throw new RollerException(new IllegalArgumentException("website
== null"));
-        return new PingTargetData(null, name, pingUrl, website);
-    }
-    
-    
-    public void storePingTarget(PingTargetData pingTarget) throws RollerException {
+    public void savePingTarget(PingTargetData pingTarget) throws RollerException {
         strategy.store(pingTarget);
     }
     
     
-    public PingTargetData retrievePingTarget(String id) throws RollerException {
+    public PingTargetData getPingTarget(String id) throws RollerException {
         return (PingTargetData) strategy.load(id, PingTargetData.class);
     }
 

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/config/PingConfig.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/config/PingConfig.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/config/PingConfig.java (original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/config/PingConfig.java Wed
Apr 19 11:47:12 2006
@@ -192,8 +192,8 @@
                 String name = m.group(1);
                 String url = m.group(2);
                 logger.info("Creating common ping target '" + name + "' from configuration
properties.");
-                PingTargetData pingTarget = pingTargetMgr.createCommonPingTarget(name, url);
-                pingTargetMgr.storePingTarget(pingTarget);
+                PingTargetData pingTarget = new PingTargetData(null, name, url, null);
+                pingTargetMgr.savePingTarget(pingTarget);
             }
             else
             {

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/model/PingTargetManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/model/PingTargetManager.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/model/PingTargetManager.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/model/PingTargetManager.java
Wed Apr 19 11:47:12 2006
@@ -8,7 +8,6 @@
 
 package org.roller.model;
 
-import java.io.Serializable;
 import java.util.List;
 import org.roller.RollerException;
 import org.roller.pojos.PingTargetData;
@@ -18,31 +17,7 @@
 /**
  * Manages ping targets.
  */
-public interface PingTargetManager extends Serializable {
-    
-    
-    /**
-     * Create a common (shared) ping target.  This method does not persist the new instance.
-     *
-     * @param name
-     * @param pingUrl
-     * @return the new ping target.
-     * @throws RollerException
-     */
-    public PingTargetData createCommonPingTarget(String name, String pingUrl) throws RollerException;
-    
-    
-    /**
-     * Create a custom ping target for the specified website.  This method does not persist
the new instance.
-     *
-     * @param name    a short descriptive name of the ping target
-     * @param pingUrl the URL to which to send pings
-     * @param website the website for which the custom target is created.
-     * @return the new ping target.
-     * @throws RollerException
-     */
-    public PingTargetData createCustomPingTarget(String name, String pingUrl,
-            WebsiteData website) throws RollerException;
+public interface PingTargetManager {
     
     
     /**
@@ -51,25 +26,16 @@
      * @param pingTarget ping target data object.
      * @throws RollerException
      */
-    public void storePingTarget(PingTargetData pingTarget) throws RollerException;
+    public void savePingTarget(PingTargetData pingTarget) throws RollerException;
     
     
     /**
-     * Remove a ping target by id.
+     * Remove a ping target.
      *
      * @param id id of the ping target to be removed
      * @throws RollerException
      */
-    public void removePingTarget(String id) throws RollerException;
-    
-    
-    /**
-     * Remove all of the custom ping targets for the given website.
-     *
-     * @param website the website whose custom ping targets should be removed
-     * @throws RollerException
-     */
-    public void removeCustomPingTargets(WebsiteData website) throws RollerException;
+    public void removePingTarget(PingTargetData pingTarget) throws RollerException;
     
     
     /**
@@ -85,7 +51,7 @@
      * @return the ping target whose id is specified.
      * @throws RollerException
      */
-    public PingTargetData retrievePingTarget(String id) throws RollerException;
+    public PingTargetData getPingTarget(String id) throws RollerException;
     
     
     /**

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/BasePingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/BasePingTargetsAction.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/BasePingTargetsAction.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/BasePingTargetsAction.java
Wed Apr 19 11:47:12 2006
@@ -141,7 +141,7 @@
             String pingTargetId = pingTargetForm.getId();
             if (pingTargetId != null && pingTargetId.length() > 0)
             {
-                pingTarget = pingTargetMgr.retrievePingTarget(
+                pingTarget = pingTargetMgr.getPingTarget(
                         pingTargetForm.getId());
                 if (pingTarget == null) 
                     throw new RollerException(
@@ -163,7 +163,7 @@
 
             // Appears to be ok.  
             // Save it, commit and return refreshed view of target list.
-            pingTargetMgr.storePingTarget(pingTarget);
+            pingTargetMgr.savePingTarget(pingTarget);
             RollerFactory.getRoller().flush();
             
             ActionMessages msgs = new ActionMessages();
@@ -300,7 +300,8 @@
             {
                 throw new RollerException("Missing ping target id.");
             }
-            pingTargetMgr.removePingTarget(pingTargetId);
+            PingTargetData ping = pingTargetMgr.getPingTarget(pingTargetId);
+            pingTargetMgr.removePingTarget(ping);
             RollerFactory.getRoller().flush();
             return view(mapping, form, req, res);
         }
@@ -327,7 +328,7 @@
             throw new RollerException("Missing ping target id: " + pingTargetId);
         }
 
-        PingTargetData pingTarget = pingTargetMgr.retrievePingTarget(pingTargetId);
+        PingTargetData pingTarget = pingTargetMgr.getPingTarget(pingTargetId);
         if (pingTarget == null)
         {
             throw new RollerException("No such ping target id: " + pingTargetId);

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java
Wed Apr 19 11:47:12 2006
@@ -90,10 +90,8 @@
     protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm)
         throws RollerException
     {
-        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
-        return pingTargetMgr.createCustomPingTarget(
-            pingTargetForm.getName(), pingTargetForm.getPingUrl(), 
-            rreq.getWebsite());
+        return new PingTargetData(null, pingTargetForm.getName(), 
+                pingTargetForm.getPingUrl(), rreq.getWebsite());
     }
 
 

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/PingSetupAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/PingSetupAction.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/PingSetupAction.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/presentation/weblog/actions/PingSetupAction.java
Wed Apr 19 11:47:12 2006
@@ -315,7 +315,7 @@
             throw new RollerException("Missing ping target id: " + pingTargetId);
         }
 
-        PingTargetData pingTarget = pingTargetMgr.retrievePingTarget(pingTargetId);
+        PingTargetData pingTarget = pingTargetMgr.getPingTarget(pingTargetId);
         if (pingTarget == null)
         {
             throw new RollerException("No such ping target id: " + pingTargetId);

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java
Wed Apr 19 11:47:12 2006
@@ -68,9 +68,8 @@
     protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm)
         throws RollerException
     {
-        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
-        return pingTargetMgr.createCommonPingTarget(
-            pingTargetForm.getName(), pingTargetForm.getPingUrl());
+        return new PingTargetData(null, pingTargetForm.getName(), 
+                pingTargetForm.getPingUrl(), null);
     }
 
 

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/TestUtils.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/TestUtils.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/TestUtils.java (original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/TestUtils.java Wed Apr 19
11:47:12 2006
@@ -240,10 +240,10 @@
         
         // store ping
         PingTargetManager pingMgr = RollerFactory.getRoller().getPingTargetManager();
-        pingMgr.storePingTarget(testPing);
+        pingMgr.savePingTarget(testPing);
         
         // query for it
-        PingTargetData ping = pingMgr.retrievePingTarget(testPing.getId());
+        PingTargetData ping = pingMgr.getPingTarget(testPing.getId());
         
         if(ping == null)
             throw new RollerException("error setting up ping target");
@@ -257,9 +257,12 @@
      */
     public static void teardownPingTarget(String id) throws Exception {
         
-        // remove the ping
+        // query for it
         PingTargetManager pingMgr = RollerFactory.getRoller().getPingTargetManager();
-        pingMgr.removePingTarget(id);
+        PingTargetData ping = pingMgr.getPingTarget(id);
+        
+        // remove the ping
+        pingMgr.removePingTarget(ping);
     }
     
     

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java?rev=395347&r1=395346&r2=395347&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java (original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java Wed
Apr 19 11:47:12 2006
@@ -94,70 +94,74 @@
         PingTargetData ping = null;
         
         // create common ping
-        mgr.storePingTarget(testCommonPing);
+        mgr.savePingTarget(testCommonPing);
         String commonId = testCommonPing.getId();
         TestUtils.endSession(true);
         
         // make sure common ping was stored
         ping = null;
-        ping = mgr.retrievePingTarget(commonId);
+        ping = mgr.getPingTarget(commonId);
         assertNotNull(ping);
         assertEquals(testCommonPing.getPingUrl(), ping.getPingUrl());
         
         // create custom ping
         testCustomPing.setWebsite(testWeblog);
-        mgr.storePingTarget(testCustomPing);
+        mgr.savePingTarget(testCustomPing);
         String customId = testCustomPing.getId();
         TestUtils.endSession(true);
         
         // make sure custom ping was stored
         ping = null;
-        ping = mgr.retrievePingTarget(customId);
+        ping = mgr.getPingTarget(customId);
         assertNotNull(ping);
         assertEquals(testCustomPing.getPingUrl(), ping.getPingUrl());
         
         // update common ping
         ping = null;
-        ping = mgr.retrievePingTarget(commonId);
+        ping = mgr.getPingTarget(commonId);
         ping.setName("testtestCommon");
-        mgr.storePingTarget(ping);
+        mgr.savePingTarget(ping);
         TestUtils.endSession(true);
         
         // make sure common ping was updated
         ping = null;
-        ping = mgr.retrievePingTarget(commonId);
+        ping = mgr.getPingTarget(commonId);
         assertNotNull(ping);
         assertEquals("testtestCommon", ping.getName());
         
         // update custom ping
         ping = null;
-        ping = mgr.retrievePingTarget(customId);
+        ping = mgr.getPingTarget(customId);
         ping.setName("testtestCustom");
-        mgr.storePingTarget(ping);
+        mgr.savePingTarget(ping);
         TestUtils.endSession(true);
         
         // make sure custom ping was updated
         ping = null;
-        ping = mgr.retrievePingTarget(customId);
+        ping = mgr.getPingTarget(customId);
         assertNotNull(ping);
         assertEquals("testtestCustom", ping.getName());
         
         // delete common ping
-        mgr.removePingTarget(commonId);
+        ping = null;
+        ping = mgr.getPingTarget(commonId);
+        mgr.removePingTarget(ping);
         TestUtils.endSession(true);
         
         // make sure common ping was deleted
         ping = null;
-        ping = mgr.retrievePingTarget(commonId);
+        ping = mgr.getPingTarget(commonId);
         assertNull(ping);
         
         // delete custom ping
-        mgr.removePingTarget(customId);
+        ping = null;
+        ping = mgr.getPingTarget(customId);
+        mgr.removePingTarget(ping);
         TestUtils.endSession(true);
         
         // make sure custom ping was deleted
         ping = null;
-        ping = mgr.retrievePingTarget(customId);
+        ping = mgr.getPingTarget(customId);
         assertNull(ping);
     }
     
@@ -171,19 +175,19 @@
         PingTargetData ping = null;
         
         // create common ping
-        mgr.storePingTarget(testCommonPing);
+        mgr.savePingTarget(testCommonPing);
         String commonId = testCommonPing.getId();
         TestUtils.endSession(true);
         
         // create custom ping
         testCustomPing.setWebsite(testWeblog);
-        mgr.storePingTarget(testCustomPing);
+        mgr.savePingTarget(testCustomPing);
         String customId = testCustomPing.getId();
         TestUtils.endSession(true);
         
         // lookup by id
         ping = null;
-        ping = mgr.retrievePingTarget(commonId);
+        ping = mgr.getPingTarget(commonId);
         assertNotNull(ping);
         assertEquals(testCommonPing.getName(), ping.getName());
         
@@ -197,17 +201,16 @@
         assertNotNull(customPings);
         assertEquals(1, customPings.size());
         
-        // remove custom pings for weblog
-        mgr.removeCustomPingTargets(testWeblog);
+        // delete common ping
+        ping = null;
+        ping = mgr.getPingTarget(commonId);
+        mgr.removePingTarget(ping);
         TestUtils.endSession(true);
         
-        // make sure remove succeeded
-        customPings = mgr.getCustomPingTargets(testWeblog);
-        assertNotNull(customPings);
-        assertEquals(0, customPings.size());
-        
-        // remove common ping
-        mgr.removePingTarget(commonId);
+        // delete custom ping
+        ping = null;
+        ping = mgr.getPingTarget(customId);
+        mgr.removePingTarget(ping);
         TestUtils.endSession(true);
     }
     



Mime
View raw message