Package org.apache.roller.weblogger.business.referrers

Examples of org.apache.roller.weblogger.business.referrers.RefererManager


       
        mLogger.debug("PROCESSING: "+referrer.getRequestUrl());
       
        // process a referrer
        try {
            RefererManager refMgr = WebloggerFactory.getWeblogger().getRefererManager();
            refMgr.processReferrer(referrer.getRequestUrl(),
                                   referrer.getReferrerUrl(),
                                   referrer.getWeblogHandle(),
                                   referrer.getWeblogAnchor(),
                                   referrer.getWeblogDateString());
           
View Full Code Here


    /**
     * Show list of weblog referrers.
     */
    public String execute() {
       
        RefererManager refmgr = WebloggerFactory.getWeblogger().getRefererManager();
        try {
            setDayHits(refmgr.getDayHits(getActionWeblog()));
            setReferrers(refmgr.getTodaysReferers(getActionWeblog()));
        } catch (Exception ex) {
            log.error("Error getting referrer data for weblog - "+getActionWeblog().getHandle(), ex);
            // TODO: i18n
            addError("Error loading referrer data");
        }
View Full Code Here

     * Reset all referrer counts.
     */
    public String reset() {
       
        try {
            RefererManager refmgr = WebloggerFactory.getWeblogger().getRefererManager();
            refmgr.clearReferrers(getActionWeblog());
            WebloggerFactory.getWeblogger().flush();
           
            CacheManager.invalidate(getActionWeblog());
        } catch (Exception ex) {
            log.error("Error resetting referrers", ex);
View Full Code Here

     */
    public String remove() {
       
        String[] removeIds = getRemoveIds();
        if(removeIds != null) {
            RefererManager refmgr = WebloggerFactory.getWeblogger().getRefererManager();
           
            try {
                WeblogReferrer referer = null;
                for (int i=0; i < removeIds.length; i++) {
                    referer = refmgr.getReferer(removeIds[i]);
                   
                    // make sure referrer belongs to action weblog
                    if(getActionWeblog().equals(referer.getWebsite())) {
                        refmgr.removeReferer(referer);
                    }
                }
               
                // flush
                WebloggerFactory.getWeblogger().flush();
View Full Code Here

            this.origSpamWords = spamprop.getValue();
            spamprop.setValue(spamprop.getValue() + ", spamtest");
            pmgr.saveProperty(spamprop);
           
            // add a number of referers to play with
            RefererManager rmgr = WebloggerFactory.getWeblogger().getRefererManager();
            Calendar lCalendar = Calendar.getInstance();
            lCalendar.setTime(new Date());
            for (int i = 0; i < count; i++) {
                lCalendar.add(Calendar.DATE, -1);
                Timestamp day = new Timestamp(lCalendar.getTime().getTime());
                testDay = DateUtil.format8chars(day);
               
                rmgr.processReferrer("http://test"+i, "http://test"+i,
                    testWeblog.getHandle(), null, testDay);
                if (i % 2 == 0) { // half the referrers from weblog 2
                    rmgr.processReferrer("http://test"+i, "http://test"+i,
                        testWeblog2.getHandle(), null, testDay);
                }
            }
           
            TestUtils.endSession(true);
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testRefererCRUD() throws Exception {
       
        RefererManager mgr = WebloggerFactory.getWeblogger().getRefererManager();
        WeblogReferrer referer = null;
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        WeblogReferrer testReferer = new WeblogReferrer();
        testReferer.setWebsite(testWeblog);
        testReferer.setDateString("20060420");
        testReferer.setRefererUrl("blah");
        testReferer.setRefererPermalink("blah");
        testReferer.setRequestUrl("foo");
        testReferer.setTitle("lksdjf");
        testReferer.setTotalHits(new Integer(3));
        testReferer.setDayHits(new Integer(2));
        testReferer.setVisible(Boolean.TRUE);
        testReferer.setDuplicate(Boolean.FALSE);
        testReferer.setExcerpt("");
       
        // save referer
        mgr.saveReferer(testReferer);
        String id = testReferer.getId();
        TestUtils.endSession(true);
       
        // check that create was successful
        referer = null;
        referer = mgr.getReferer(id);
        assertNotNull(referer);
        assertEquals(testReferer, referer);
       
        // update referer
        referer.setTitle("testtesttest");
        mgr.saveReferer(referer);
        TestUtils.endSession(true);
       
        // check that update was successful
        referer = null;
        referer = mgr.getReferer(id);
        assertNotNull(referer);
        assertEquals("testtesttest", referer.getTitle());
       
        // delete referer
        mgr.removeReferer(referer);
        TestUtils.endSession(true);
       
        // check that delete was successful
        referer = null;
        referer = mgr.getReferer(id);
        assertNull(referer);
    }
View Full Code Here

    }
   
   
    public void testGetReferersToDate() throws Exception {
       
        RefererManager rmgr = WebloggerFactory.getWeblogger().getRefererManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        List referers = rmgr.getReferersToDate(testWeblog, testDay);
        assertEquals("Should be one Referer.", referers.size(), 1);
    }
View Full Code Here

    }
   
   
    public void testRefererProcessing() throws WebloggerException {
       
        RefererManager rmgr = WebloggerFactory.getWeblogger().getRefererManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        List refs = rmgr.getReferers(testWeblog);
        assertEquals("number of referers should equal count", count, refs.size());
       
        int hits = rmgr.getDayHits(testWeblog);
        assertEquals("There should be one fewer hits than referers", count, hits);
    }
View Full Code Here

   
    public void testApplyRefererFilters() throws Exception {
       
        log.info("Test apply referers (global)");
       
        RefererManager rmgr = WebloggerFactory.getWeblogger().getRefererManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        List refs = rmgr.getReferers(testWeblog);
        assertEquals(count, refs.size());
       
        PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
        RuntimeConfigProperty spamprop = pmgr.getProperty("spam.blacklist");
        String origWords = spamprop.getValue();
        spamprop.setValue(spamprop.getValue() + ", test");
        pmgr.saveProperty(spamprop);
        TestUtils.endSession(true);
       
        rmgr.applyRefererFilters();
        TestUtils.endSession(true);
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        refs = rmgr.getReferers(testWeblog);
        assertEquals(0, refs.size());
       
        spamprop = pmgr.getProperty("spam.blacklist");
        spamprop.setValue(origWords);
        pmgr.saveProperty(spamprop);
View Full Code Here

   
    public void testApplyRefererFiltersWebsite() throws Exception {
       
        log.info("Test apply referers (weblog)");
       
        RefererManager rmgr = WebloggerFactory.getWeblogger().getRefererManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        List refs = rmgr.getReferers(testWeblog);
        assertEquals(count, refs.size());
        String origWords = null;
       
        UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        origWords = testWeblog.getBlacklist();
        testWeblog.setBlacklist("test");
        umgr.saveWebsite(testWeblog);
        TestUtils.endSession(true);
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        rmgr.applyRefererFilters(testWeblog);
        TestUtils.endSession(true);
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        refs = rmgr.getReferers(testWeblog);
        assertEquals(0, refs.size());
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.referrers.RefererManager

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.