View Javadoc
1   package fr.paris.lutece.plugins.blog.modules.solr.daemon;
2   
3   import java.util.Date;
4   import java.util.List;
5   
6   import fr.paris.lutece.plugins.blog.business.BlogHome;
7   import fr.paris.lutece.plugins.blog.business.portlet.BlogPublicationHome;
8   import fr.paris.lutece.plugins.blog.service.BlogService;
9   import fr.paris.lutece.portal.service.daemon.Daemon;
10  
11  /**
12   * This Daemon checks if a blog has no current publication.<br>
13   * If this is the case, it will signal the solr indexer so that the blog is removed from the index.
14   */
15  public class OutdatedBlogDaemon extends Daemon
16  {
17      @Override
18      public void run( )
19      {
20          List<Integer> idList = BlogHome.getIdBlogsList( );
21          for ( Integer idBlog : idList )
22          {
23              int nbPublication = BlogPublicationHome.countPublicationByIdBlogAndDate( idBlog, new Date( ) );
24              if ( nbPublication == 0 )
25              {
26                  BlogService.getInstance( ).fireDeleteBlogEvent( idBlog );
27              }
28          }
29      }
30  }