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

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


       
        if(getPingTarget() != null) {
            try {
                getPingTarget().setAutoEnabled(true);
               
                PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
                pingTargetMgr.savePingTarget(getPingTarget());
                WebloggerFactory.getWeblogger().flush();
            } catch (Exception ex) {
                getLogger().error("Error saving ping target", ex);
                addError("commonPingTargets.error.saving");
            }
View Full Code Here


       
        if(getPingTarget() != null) {
            try {
                getPingTarget().setAutoEnabled(false);
               
                PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
                pingTargetMgr.savePingTarget(getPingTarget());
                WebloggerFactory.getWeblogger().flush();
            } catch (Exception ex) {
                getLogger().error("Error saving ping target", ex);
                addError("commonPingTargets.error.saving");
            }
View Full Code Here

    /**
     * Prepare action by loading ping target to work on.
     */
    public void myPrepare() {
       
        PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
        if(!StringUtils.isEmpty(getBean().getId())) {
           
            try {
                setPingTarget(pingTargetMgr.getPingTarget(getBean().getId()));
            } catch (WebloggerException ex) {
                getLogger().error("Error looking up ping target - "+getBean().getId());
            }
           
            if(getPingTarget() == null) {
View Full Code Here

        // If there are errors, go back to the target edit page.
        myValidate(getPingTarget());
       
        if(!hasActionErrors()) try {
            // Appears to be ok.  Save it and flush.
            PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
            pingTargetMgr.savePingTarget(getPingTarget());
            WebloggerFactory.getWeblogger().flush();
           
            addMessage("pingTarget.saved");
           
        } catch (WebloggerException ex) {
View Full Code Here

     * Private helper to validate a ping target.
     */
    protected void myValidate(PingTarget pingTarget) {
       
        try {
            PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
            if (!pingTargetMgr.isNameUnique(pingTarget)) {
                addError("pingTarget.nameNotUnique");
            }
           
            if (!pingTargetMgr.isUrlWellFormed(pingTarget)) {
                addError("pingTarget.malformedUrl");
            } else if (!pingTargetMgr.isHostnameKnown(pingTarget)) {
                addError("pingTarget.unknownHost");
            }
        } catch (WebloggerException ex) {
            getLogger().error("Error validating ping target", ex);
            // TODO: i18n
View Full Code Here

        loadPingTargets();
       
        // load specified ping target if possible
        if(!StringUtils.isEmpty(getPingTargetId())) {
            try {
                PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
                setPingTarget(pingTargetMgr.getPingTarget(getPingTargetId()));
            } catch (WebloggerException ex) {
                getLogger().error("Error looking up ping target - "+getPingTargetId(), ex);
            }
        }
    }
View Full Code Here

    public String delete() {
       
        if(getPingTarget() != null) {
           
            try {
                PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
                pingTargetMgr.removePingTarget(getPingTarget());
                WebloggerFactory.getWeblogger().flush();
               
                // remove deleted target from list
                getPingTargets().remove(getPingTarget());
               
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testPingTargetCRUD() throws Exception {
       
        PingTargetManager mgr = WebloggerFactory.getWeblogger().getPingTargetManager();
        PingTarget ping = null;
       
        // create common ping
        mgr.savePingTarget(testCommonPing);
        String commonId = testCommonPing.getId();
        TestUtils.endSession(true);
       
        // make sure common ping was stored
        ping = null;
        ping = mgr.getPingTarget(commonId);
        assertNotNull(ping);
        assertEquals(testCommonPing.getPingUrl(), ping.getPingUrl());
       
        // create custom ping
        testCustomPing.setWebsite(TestUtils.getManagedWebsite(testWeblog));
        mgr.savePingTarget(testCustomPing);
        String customId = testCustomPing.getId();
        TestUtils.endSession(true);
       
        // make sure custom ping was stored
        ping = null;
        ping = mgr.getPingTarget(customId);
        assertNotNull(ping);
        assertEquals(testCustomPing.getPingUrl(), ping.getPingUrl());
       
        // update common ping
        ping = null;
        ping = mgr.getPingTarget(commonId);
        ping.setName("testtestCommon");
        mgr.savePingTarget(ping);
        TestUtils.endSession(true);
       
        // make sure common ping was updated
        ping = null;
        ping = mgr.getPingTarget(commonId);
        assertNotNull(ping);
        assertEquals("testtestCommon", ping.getName());
       
        // update custom ping
        ping = null;
        ping = mgr.getPingTarget(customId);
        ping.setName("testtestCustom");
        mgr.savePingTarget(ping);
        TestUtils.endSession(true);
       
        // make sure custom ping was updated
        ping = null;
        ping = mgr.getPingTarget(customId);
        assertNotNull(ping);
        assertEquals("testtestCustom", ping.getName());
       
        // delete common ping
        ping = null;
        ping = mgr.getPingTarget(commonId);
        mgr.removePingTarget(ping);
        TestUtils.endSession(true);
       
        // make sure common ping was deleted
        ping = null;
        ping = mgr.getPingTarget(commonId);
        assertNull(ping);
       
        // delete custom ping
        ping = null;
        ping = mgr.getPingTarget(customId);
        mgr.removePingTarget(ping);
        TestUtils.endSession(true);
       
        // make sure custom ping was deleted
        ping = null;
        ping = mgr.getPingTarget(customId);
        assertNull(ping);
    }
View Full Code Here

    /**
     * Test lookup mechanisms ... id, all common, all custom for weblog
     */
    public void testPingTargetLookups() throws Exception {
       
        PingTargetManager mgr = WebloggerFactory.getWeblogger().getPingTargetManager();
        PingTarget ping = null;
       
        // create common ping
        mgr.savePingTarget(testCommonPing);
        String commonId = testCommonPing.getId();
        TestUtils.endSession(true);
       
        // create custom ping
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        testCustomPing.setWebsite(testWeblog);
        mgr.savePingTarget(testCustomPing);
        String customId = testCustomPing.getId();
        TestUtils.endSession(true);
       
        // lookup by id
        ping = null;
        ping = mgr.getPingTarget(commonId);
        assertNotNull(ping);
        assertEquals(testCommonPing.getName(), ping.getName());
       
        // lookup all common pings
        List commonPings = mgr.getCommonPingTargets();
        assertNotNull(commonPings);
        // correct answer is: 6 pings in config + 1 new one = 7
        assertEquals(7, commonPings.size());
       
        // lookup all custom pings for weblog
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        List customPings = mgr.getCustomPingTargets(testWeblog);
        assertNotNull(customPings);
        assertEquals(1, customPings.size());
       
        // delete common ping
        ping = null;
        ping = mgr.getPingTarget(commonId);
        mgr.removePingTarget(ping);
        TestUtils.endSession(true);
       
        // delete custom ping
        ping = null;
        ping = mgr.getPingTarget(customId);
        mgr.removePingTarget(ping);
        TestUtils.endSession(true);
    }
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;
View Full Code Here

TOP

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

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.