private boolean checkingItemType(final EmailItem item) { String folderName = item.getFolder(); if (folderName.equalsIgnoreCase("inbox") && this.type == EMAIL_PROCESSING_TYPE.INBOX) return true; if (folderName.startsWith("sen") || folderName.startsWith("Sen") && this.type == EMAIL_PROCESSING_TYPE.SEND_ITEM) return true; if (this.type == EMAIL_PROCESSING_TYPE.FREQUENCY) return true; return false; }
private void getAllMessageInEmailSource(final String value, final String constant) { IndexReader indexReader = null; try { List<Integer> ids = new ArrayList<Integer>(); Directory dir = FSDirectory.open(new File(this.panel.getCaseFacade().getCaseIndexFolderLocation())); indexReader = IndexReader.open(dir); Map<Entry, Integer> messageCounter = new HashMap<Entry, Integer>(); for (int i = 0; i < indexReader.maxDoc(); i++) { if (this.isCancelledTask()) { break; } Document document = indexReader.document(i); if (document != null) { Field field = document.getField(constant); if (field != null && field.stringValue() != null) { String tmp = field.stringValue(); if (tmp.endsWith(value)) { EmailItem item = (EmailItem) ItemFactory.newInstance(document, panel.getCaseFacade(), false); String to = ""; if (item.getTo() == null || item.getTo().trim().isEmpty()) to = value; else to = item.getTo(); if (checkingItemType(item)) { Entry entry = new Entry(item.getFrom(), to, item.getTime()); Integer indexNo = messageCounter.get(entry); if (indexNo == null) { messageCounter.put(entry, 1); } else { messageCounter.put(entry, indexNo + 1); } ids.add(Integer.valueOf(item.getDocumentId())); } } } } } if (this.type == EMAIL_PROCESSING_TYPE.INBOX || this.type == EMAIL_PROCESSING_TYPE.SEND_ITEM) addResultToTable(messageCounter); else addDateResultToTable(messageCounter); messageCounter.clear(); messageCounter = null; } catch (IOException ex) { ex.printStackTrace(); Logger.getLogger(EmailProcessingTask.class.getName()).log(Level.SEVERE, null, ex); } finally { try { indexReader.close(); } catch (IOException ex) { Logger.getLogger(EmailProcessingTask.class.getName()).log(Level.SEVERE, null, ex); } } }