Package org.apache.roller.weblogger.business.search

Examples of org.apache.roller.weblogger.business.search.IndexManager


       
        log.debug("task started");
       
        try {
            WeblogManager wMgr = WebloggerFactory.getWeblogger().getWeblogManager();
            IndexManager searchMgr = WebloggerFactory.getWeblogger().getIndexManager();
           
            Date now = new Date();
           
            log.debug("looking up scheduled entries older than "+now);
           
            // get all published entries older than current time
            List scheduledEntries = wMgr.getWeblogEntries(
                   
                    null,   // website
                    null,   // user
                    null,   // startDate
                    now,    // endDate
                    null,   // catName
                    null,WeblogEntry.SCHEDULED, // status
                    null,   // text
                    null,   // sortBy
                    null,   // sortOrder
                    null,   // locale
                    0, -1); // offset, length
                   
            log.debug("promoting "+scheduledEntries.size()+" entries to PUBLISHED state");
           
            WeblogEntry entry = null;
            Iterator it = scheduledEntries.iterator();
            while(it.hasNext()) {
                entry = (WeblogEntry) it.next();
               
                // update status to PUBLISHED and save
                entry.setStatus(WeblogEntry.PUBLISHED);
                wMgr.saveWeblogEntry(entry);
            }
           
            // commit the changes
            WebloggerFactory.getWeblogger().flush();
           
            // take a second pass to trigger reindexing and cache invalidations
            // this is because we need the updated entries flushed first
            it = scheduledEntries.iterator();
            while(it.hasNext()) {
                entry = (WeblogEntry) it.next();
               
                // trigger a cache invalidation
                CacheManager.invalidate(entry);
               
                // trigger search index on entry
                searchMgr.addEntryReIndexOperation(entry);
            }
           
        } catch (WebloggerException e) {
            log.error("Error getting scheduled entries", e);
        } catch(Exception e) {
View Full Code Here


        }
       
        this.entryCount = WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
       
        // setup the search
        IndexManager indexMgr = WebloggerFactory.getWeblogger().getIndexManager();
       
        SearchOperation search = new SearchOperation(indexMgr);
        search.setTerm(feedRequest.getTerm());
       
        if(WebloggerRuntimeConfig.isSiteWideWeblog(feedRequest.getWeblogHandle())) {
            this.websiteSpecificSearch  = false;
        } else {
            search.setWebsiteHandle(feedRequest.getWeblogHandle());
        }
       
        if(StringUtils.isNotEmpty(feedRequest.getWeblogCategoryName())) {
            search.setCategory(feedRequest.getWeblogCategoryName());
        }
       
        // execute search
        indexMgr.executeIndexOperationNow(search);
       
        if (search.getResultsCount() > -1) {
            Hits hits = search.getResults();
            this.hits = search.getResultsCount();
           
View Full Code Here

            pager = new SearchResultsPager(urlStrategy, searchRequest, results, false);
            return;
        }
       
        // setup the search
        IndexManager indexMgr = WebloggerFactory.getWeblogger().getIndexManager();
       
        SearchOperation search = new SearchOperation(indexMgr);
        search.setTerm(searchRequest.getQuery());
       
        if(WebloggerRuntimeConfig.isSiteWideWeblog(searchRequest.getWeblogHandle())) {
            this.websiteSpecificSearch = false;
        } else {
            search.setWebsiteHandle(searchRequest.getWeblogHandle());
        }
       
        if(StringUtils.isNotEmpty(searchRequest.getWeblogCategoryName())) {
            search.setCategory(searchRequest.getWeblogCategoryName());
        }
       
        // execute search
        indexMgr.executeIndexOperationNow(search);
       
        if (search.getResultsCount() == -1) {
            // this means there has been a parsing (or IO) error
            this.errorMessage = I18nMessages.getMessages(searchRequest.getLocaleInstance()).getString("error.searchProblem");
        } else {
View Full Code Here

    public static Test suite() {
        return new TestSuite(IndexManagerTest.class);
    }
       
    public void testSearch() throws Exception {
        IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();

        Weblog website = new Weblog();
        website.setHandle("trekker");

        User user = new User();
        user.setUserName("nimoy");

        WeblogEntry wd1 = new WeblogEntry();           
        wd1.setId("dummy1");
        wd1.setAnchor("dummy1");
        wd1.setCreator(user);
        wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd1.setTitle("The Tholian Web");
        wd1.setWebsite(website);
        wd1.setText(
         "When the Enterprise attempts to ascertain the fate of the  "
        +"U.S.S. Defiant which vanished 3 weeks ago, the warp engines  "
        +"begin to lose power, and Spock reports strange sensor readings.");
        imgr.executeIndexOperationNow(
            new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd1));

        WeblogEntry wd2 = new WeblogEntry();
        wd2.setId("dummy2");
        wd2.setAnchor("dummy2");
        wd2.setCreator(user);
        wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd2.setTitle("A Piece of the Action");
        wd2.setWebsite(website);
        wd2.setText(
          "The crew of the Enterprise attempts to make contact with "
          +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
          +"in communication with Boss Oxmyx.");
         imgr.executeIndexOperationNow(
             new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd2));

        Thread.sleep(1000);

        SearchOperation search = new SearchOperation(imgr);
        search.setTerm("Enterprise");
        imgr.executeIndexOperationNow(search);
        assertEquals(2, search.getResultsCount());

        SearchOperation search2 = new SearchOperation(imgr);
        search2.setTerm("Tholian");
        imgr.executeIndexOperationNow(search2);
        assertEquals(1, search2.getResultsCount());

        // Clean up
        imgr.removeEntryIndexOperation(wd1);
        imgr.removeEntryIndexOperation(wd2);

        SearchOperation search3 = new SearchOperation(imgr);
        search3.setTerm("Enterprise");
        imgr.executeIndexOperationNow(search3);
        assertEquals(0, search3.getResultsCount());
    }   
View Full Code Here

                    boolean notifySubscribers = (validationScore == 100);
                    MailUtil.sendEmailNotification(comment, messages, messageUtils, notifySubscribers);
                   
                    // only re-index/invalidate the cache if comment isn't moderated
                    if(!weblog.getCommentModerationRequired()) {
                        IndexManager manager = WebloggerFactory.getWeblogger().getIndexManager();
                       
                        // remove entry before (re)adding it, or in case it isn't Published
                        manager.removeEntryIndexOperation(entry);
                       
                        // if published, index the entry
                        if (entry.isPublished()) {
                            manager.addEntryIndexOperation(entry);
                        }
                       
                        // Clear all caches associated with comment
                        CacheManager.invalidate(comment);
                    }
View Full Code Here

     * Rebuild search index for weblog.
     */
    public String index() {
       
        try {
            IndexManager manager = WebloggerFactory.getWeblogger().getIndexManager();
            manager.rebuildWebsiteIndex(getActionWeblog());
           
            addMessage("maintenance.message.indexed");
        } catch (Exception ex) {
            log.error("Error doing index rebuild", ex);
            // TODO: i18n
View Full Code Here

        }
       
        this.entryCount = WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
       
        // setup the search
        IndexManager indexMgr = WebloggerFactory.getWeblogger().getIndexManager();
       
        SearchOperation search = new SearchOperation(indexMgr);
        search.setTerm(feedRequest.getTerm());
       
        if(WebloggerRuntimeConfig.isSiteWideWeblog(feedRequest.getWeblogHandle())) {
            this.websiteSpecificSearch  = false;
        } else {
            search.setWebsiteHandle(feedRequest.getWeblogHandle());
        }
       
        if(StringUtils.isNotEmpty(feedRequest.getWeblogCategoryName())) {
            search.setCategory(feedRequest.getWeblogCategoryName());
        }
       
        // execute search
        indexMgr.executeIndexOperationNow(search);
       
        if (search.getResultsCount() > -1) {
            Hits hits = search.getResults();
            this.hits = search.getResultsCount();
           
View Full Code Here

            pager = new SearchResultsPager(urlStrategy, searchRequest, results, false);
            return;
        }
       
        // setup the search
        IndexManager indexMgr = WebloggerFactory.getWeblogger().getIndexManager();
       
        SearchOperation search = new SearchOperation(indexMgr);
        search.setTerm(searchRequest.getQuery());
       
        if(WebloggerRuntimeConfig.isSiteWideWeblog(searchRequest.getWeblogHandle())) {
            this.websiteSpecificSearch = false;
        } else {
            search.setWebsiteHandle(searchRequest.getWeblogHandle());
        }
       
        if(StringUtils.isNotEmpty(searchRequest.getWeblogCategoryName())) {
            search.setCategory(searchRequest.getWeblogCategoryName());
        }
       
        // execute search
        indexMgr.executeIndexOperationNow(search);
       
        if (search.getResultsCount() == -1) {
            // this means there has been a parsing (or IO) error
            this.errorMessage = I18nMessages.getMessages(searchRequest.getLocaleInstance()).getString("error.searchProblem");
        } else {
View Full Code Here

        wem.saveWeblogEntry(wd1);
        TestUtils.endSession(true);
        wd1 = TestUtils.getManagedWeblogEntry(wd1);

        IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();
        imgr.executeIndexOperationNow(
            new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd1));

        WeblogEntry wd2 = new WeblogEntry();
        wd2.setTitle("A Piece of the Action");
        wd2.setText(
          "The crew of the Enterprise attempts to make contact with "
          +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
          +"in communication with Boss Oxmyx.");
        wd2.setAnchor("dummy2");
        wd2.setStatus(WeblogEntry.PUBLISHED);
        wd2.setCreatorUserName(testUser.getUserName());
        wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd2.setWebsite(TestUtils.getManagedWebsite(testWeblog));

        cat = wem.getWeblogCategory(testWeblog.getDefaultCategory().getId());
        wd2.setCategory(cat);

        wem.saveWeblogEntry(wd2);
        TestUtils.endSession(true);
        wd2 = TestUtils.getManagedWeblogEntry(wd2);

         imgr.executeIndexOperationNow(
             new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd2));

        Thread.sleep(1000);

        SearchOperation search = new SearchOperation(imgr);
        search.setTerm("Enterprise");
        imgr.executeIndexOperationNow(search);
        assertEquals(2, search.getResultsCount());

        SearchOperation search2 = new SearchOperation(imgr);
        search2.setTerm("Tholian");
        imgr.executeIndexOperationNow(search2);
        assertEquals(1, search2.getResultsCount());

        // Clean up
        imgr.removeEntryIndexOperation(wd1);
        imgr.removeEntryIndexOperation(wd2);

        SearchOperation search3 = new SearchOperation(imgr);
        search3.setTerm("Enterprise");
        imgr.executeIndexOperationNow(search3);
        assertEquals(0, search3.getResultsCount());
    }   
View Full Code Here

            try {
                // remove the entry from the search index
                // TODO: can we do this in a better way?
                String originalStatus = entry.getStatus();
                entry.setStatus(WeblogEntry.DRAFT);
                IndexManager manager = WebloggerFactory.getWeblogger().getIndexManager();
                manager.addEntryReIndexOperation(entry);
                entry.setStatus(originalStatus);
            } catch (WebloggerException ex) {
                log.warn("Trouble triggering entry indexing", ex);
            }
           
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.search.IndexManager

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.