Package org.apache.roller.weblogger.business.pings

Examples of org.apache.roller.weblogger.business.pings.AutoPingManager


     * Enable a ping target.
     */
    public String enable() {
       
        if(getPingTarget() != null) try {
            AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
            AutoPing autoPing = new AutoPing(null, getPingTarget(), getActionWeblog());
            autoPingMgr.saveAutoPing(autoPing);
            WebloggerFactory.getWeblogger().flush();
        } catch(Exception ex) {
            log.error("Error saving auto ping for target - "+getPingTargetId(), ex);
            // TODO: i18n
            addError("Error enabling auto ping");
View Full Code Here


     * Disable a ping target.
     */
    public String disable() {
       
        if(getPingTarget() != null) try {
            AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
            autoPingMgr.removeAutoPing(getPingTarget(), getActionWeblog());
            WebloggerFactory.getWeblogger().flush();
        } catch (Exception ex) {
            log.error("Error removing auto ping for target - "+getPingTargetId(), ex);
            // TODO: i18n
            addError("Error disabling auto ping");
View Full Code Here

     * Private helper to build a map indexed by ping target id with values Boolean.TRUE and Boolean.FALSE
     * based on whether the ping target is enabled (has a corresponding auto ping configuration).
     */
    private void buildIsEnabledMap() {
       
        AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
       
        // Build isEnabled map (keyed by ping target id and values Boolean.TRUE/Boolean.FALSE)
        Map isEnabled = new HashMap();
       
        List autopings = Collections.EMPTY_LIST;
        try {
            autopings = autoPingMgr.getAutoPingsByWebsite(getActionWeblog());
        } catch (WebloggerException ex) {
            log.error("Error looking up auto pings for weblog - "+getActionWeblog().getHandle(), ex);
        }
       
        // Add the enabled auto ping configs with TRUE
View Full Code Here

     * Convenience method for creating an auto ping.
     */
    public static AutoPing setupAutoPing(PingTarget ping, Weblog weblog)
            throws Exception {
       
        AutoPingManager mgr = WebloggerFactory.getWeblogger().getAutopingManager();
       
        // store auto ping
        AutoPing autoPing = new AutoPing(null, ping, getManagedWebsite(weblog) );
        mgr.saveAutoPing(autoPing);
       
        // flush to db
        WebloggerFactory.getWeblogger().flush();
       
        // query for it
        autoPing = mgr.getAutoPing(autoPing.getId());
       
        if(autoPing == null)
            throw new WebloggerException("error setting up auto ping");
       
        return autoPing;
View Full Code Here

     * Convenience method for removing an auto ping.
     */
    public static void teardownAutoPing(String id) throws Exception {
       
        // query for it
        AutoPingManager mgr = WebloggerFactory.getWeblogger().getAutopingManager();
        AutoPing autoPing = mgr.getAutoPing(id);
       
        // remove the auto ping
        mgr.removeAutoPing(autoPing);
       
        // flush to db
        WebloggerFactory.getWeblogger().flush();
    }
View Full Code Here

        while(it.hasNext()) {
            this.strategy.remove((PingQueueEntry) it.next());
        }
       
        // Remove the website's auto ping configurations
        AutoPingManager autoPingMgr = roller
        .getAutopingManager();
        List autopings = autoPingMgr.getAutoPingsByWebsite(website);
        it = autopings.iterator();
        while(it.hasNext()) {
            this.strategy.remove((AutoPing) it.next());
        }
       
View Full Code Here

        }
       
        // add any auto enabled ping targets
        PingTargetManager pingTargetMgr = roller
        .getPingTargetManager();
        AutoPingManager autoPingMgr = roller
        .getAutopingManager();
       
        Iterator pingTargets = pingTargetMgr.getCommonPingTargets().iterator();
        PingTarget pingTarget = null;
        while(pingTargets.hasNext()) {
            pingTarget = (PingTarget) pingTargets.next();
           
            if(pingTarget.isAutoEnabled()) {
                AutoPing autoPing = new AutoPing(
                        null, pingTarget, newWeblog);
                autoPingMgr.saveAutoPing(autoPing);
            }
        }
    }
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testAutoPingCRUD() throws Exception {
       
        AutoPingManager mgr = WebloggerFactory.getWeblogger().getAutopingManager();
        AutoPing autoPing = null;
       
        // create ping target to use for tests
        PingTarget pingTarget = TestUtils.setupPingTarget("fooPing", "http://foo/null");
        PingTarget pingTarget2 = TestUtils.setupPingTarget("blahPing", "http://blah/null");
        TestUtils.endSession(true);
       
        // create autoPing
        autoPing = new AutoPing(null, pingTarget, testWeblog);
        mgr.saveAutoPing(autoPing);
        String id = autoPing.getId();
        TestUtils.endSession(true);
       
        // make sure autoPing was stored
        autoPing = null;
        autoPing = mgr.getAutoPing(id);
        assertNotNull(autoPing);
        assertEquals(pingTarget, autoPing.getPingTarget());
       
        // update autoPing
        autoPing.setPingTarget(pingTarget2);
        mgr.saveAutoPing(autoPing);
        TestUtils.endSession(true);
       
        // make sure autoPing was updated
        autoPing = null;
        autoPing = mgr.getAutoPing(id);
        assertNotNull(autoPing);
        assertEquals(pingTarget2, autoPing.getPingTarget());
       
        // delete autoPing
        mgr.removeAutoPing(autoPing);
        TestUtils.endSession(true);
       
        // make sure common autoPing was deleted
        autoPing = null;
        autoPing = mgr.getAutoPing(id);
        assertNull(autoPing);
       
        // teardown test ping target
        TestUtils.teardownPingTarget(pingTarget.getId());
        TestUtils.teardownPingTarget(pingTarget2.getId());
View Full Code Here

    /**
     * Test special ping target removal methods ... by weblog/target, collection, all
     */
    public void testPingTargetRemovals() throws Exception {
       
        AutoPingManager mgr = WebloggerFactory.getWeblogger().getAutopingManager();
        PingTargetManager ptmgr = WebloggerFactory.getWeblogger().getPingTargetManager();
        AutoPing testAutoPing = null;
       
        // create ping target to use for tests
        PingTarget pingTarget = TestUtils.setupPingTarget("fooPing", "http://foo/null");
        PingTarget pingTarget2 = TestUtils.setupPingTarget("blahPing", "http://blah/null");
        PingTarget pingTarget3 = TestUtils.setupPingTarget("gahPing", "http://gah/null");
       
        try {
       
            // create auto pings for test
            testWeblog = TestUtils.getManagedWebsite(testWeblog);
            AutoPing autoPing = TestUtils.setupAutoPing(pingTarget, testWeblog);
            AutoPing autoPing2 = TestUtils.setupAutoPing(pingTarget2, testWeblog);
            AutoPing autoPing3 = TestUtils.setupAutoPing(pingTarget3, testWeblog);
            TestUtils.endSession(true);

            // remove by weblog/target
            testWeblog = TestUtils.getManagedWebsite(testWeblog);
            pingTarget = ptmgr.getPingTarget(pingTarget.getId());
            mgr.removeAutoPing(pingTarget, testWeblog);
            TestUtils.endSession(true);

            // make sure remove succeeded
            testAutoPing = null;
            testAutoPing = mgr.getAutoPing(autoPing.getId());
            assertNull(testAutoPing);

            // remove a collection
            List autoPings = new ArrayList();
            autoPing2 = mgr.getAutoPing(autoPing2.getId()); //Get managed version of autoPing2
            autoPings.add(autoPing2);
            autoPing3 = mgr.getAutoPing(autoPing3.getId()); //Get managed version of autoPing2
            autoPings.add(autoPing3);
            mgr.removeAutoPings(autoPings);
            TestUtils.endSession(true);

            // make sure delete was successful
            testWeblog = TestUtils.getManagedWebsite(testWeblog);
            autoPings = mgr.getAutoPingsByWebsite(testWeblog);
            assertNotNull(autoPings);
            assertEquals(0, autoPings.size());

            // need to create more test pings
            autoPing = TestUtils.setupAutoPing(pingTarget, testWeblog);
            autoPing2 = TestUtils.setupAutoPing(pingTarget2, testWeblog);
            autoPing3 = TestUtils.setupAutoPing(pingTarget3, testWeblog);
            TestUtils.endSession(true);

            // remove all
            mgr.removeAllAutoPings();
            TestUtils.endSession(true);

            // make sure remove succeeded
            testWeblog = TestUtils.getManagedWebsite(testWeblog);
            autoPings = mgr.getAutoPingsByWebsite(testWeblog);
            assertNotNull(autoPings);
            assertEquals(0, autoPings.size());
       
        } finally {
            // teardown test ping target
View Full Code Here

    /**
     * Test lookup mechanisms ... id, ping target, weblog
     */
    public void testAutoPingLookups() throws Exception {
       
        AutoPingManager mgr = WebloggerFactory.getWeblogger().getAutopingManager();
        PingTargetManager ptmgr = WebloggerFactory.getWeblogger().getPingTargetManager();
        AutoPing autoPing = null;
       
        // create autoPing target to use for tests
        PingTarget pingTarget = TestUtils.setupPingTarget("fooPing", "http://foo/null");
        TestUtils.endSession(true);
       
        // create autoPing
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        pingTarget = ptmgr.getPingTarget(pingTarget.getId());
        autoPing = new AutoPing(null, pingTarget, testWeblog);
        mgr.saveAutoPing(autoPing);
        String id = autoPing.getId();
        TestUtils.endSession(true);
       
        // lookup by id
        autoPing = null;
        autoPing = mgr.getAutoPing(id);
        assertNotNull(autoPing);
        assertEquals(pingTarget, autoPing.getPingTarget());
       
        // lookup by ping target
        pingTarget = ptmgr.getPingTarget(pingTarget.getId());
        List autoPings = mgr.getAutoPingsByTarget(pingTarget);
        assertNotNull(autoPings);
        assertEquals(1, autoPings.size());
       
        // lookup by weblog
        autoPings = null;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        autoPings = mgr.getAutoPingsByWebsite(testWeblog);
        assertNotNull(autoPing);
        assertEquals(1, autoPings.size());
       
        // delete autoPing
        autoPing = mgr.getAutoPing(autoPing.getId());
        mgr.removeAutoPing(autoPing);
        TestUtils.endSession(true);
       
        // teardown test ping target
        TestUtils.teardownPingTarget(pingTarget.getId());
        TestUtils.endSession(true);
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.pings.AutoPingManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.