1 package com.dotmarketing.portlets.contentlet.factories; 2 3 import java.io.Serializable ; 4 import java.util.Date ; 5 import java.util.Hashtable ; 6 import java.util.Map ; 7 8 import com.dotmarketing.util.LuceneUtils; 9 import com.dotmarketing.util.UtilMethods; 10 11 12 public class ReindexationProcessStatus implements Serializable { 13 14 private static final long serialVersionUID = 1L; 15 16 private static boolean inFullReindexation = false; 17 18 private static int contentCountToIndex = -1; 19 20 private static int contentCountIndexed = -1; 21 22 private static Date lastIndexationStartTime = null; 23 24 private static Date lastIndexationEndTime = null; 25 26 public synchronized static boolean inFullReindexation () { 27 return inFullReindexation; 28 } 29 30 public synchronized static void setInFullReindexation (boolean newValue) { 31 inFullReindexation = newValue; 32 if (!newValue) { 33 contentCountToIndex = -1; 34 lastIndexationEndTime = new Date (); 35 } else { 36 lastIndexationStartTime = new Date (); 37 } 38 } 39 40 public synchronized static int getContentCountToIndex () { 41 return contentCountToIndex; 42 } 43 44 public synchronized static void setContentCountToIndex (int count) { 45 contentCountToIndex = count; 46 contentCountIndexed = 0; 47 setInFullReindexation (true); 48 } 49 50 public synchronized static int getLastIndexationProgress () { 51 return contentCountIndexed; 52 } 53 54 public synchronized static void updateIndexationProgress (int increment) { 55 contentCountIndexed += increment; 56 } 57 58 public synchronized static String currentIndexPath () { 59 return LuceneUtils.getCurrentLuceneDirPath(); 60 } 61 62 public synchronized static String getNewIndexPath () { 63 return LuceneUtils.getNewLuceneDirPath(); 64 } 65 66 public synchronized static Map getProcessIndexationMap () { 67 Map theMap = new Hashtable (); 68 theMap.put("inFullReindexation", inFullReindexation()); 69 theMap.put("contentCountToIndex", getContentCountToIndex()); 70 theMap.put("lastIndexationProgress", getLastIndexationProgress()); 71 theMap.put("currentIndexPath", currentIndexPath()); 72 theMap.put("newIndexPath", getNewIndexPath()); 73 theMap.put("lastIndexationStartTime", UtilMethods.dateToHTMLDate(lastIndexationStartTime) + " " + 74 UtilMethods.dateToHTMLTime(lastIndexationStartTime)); 75 theMap.put("lastIndexationEndTime", UtilMethods.dateToHTMLDate(lastIndexationEndTime) + " " + 76 UtilMethods.dateToHTMLTime(lastIndexationEndTime)); 77 return theMap; 78 } 79 } | Popular Tags |