diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchEditListPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchEditListPanel.java index 2ae8349c76..1d3462ffdb 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchEditListPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchEditListPanel.java @@ -663,7 +663,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec List toWrite = new ArrayList(); toWrite.add(reader.getList(currentKeywordList.getName())); final KeywordSearchListsXML exporter = new KeywordSearchListsXML(fileAbs); - boolean written = exporter.writeLists(toWrite); + boolean written = exporter.saveLists(toWrite); if (written) { KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword lists exported", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListsAbstract.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListsAbstract.java index 004bb9ab27..5762956c3e 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListsAbstract.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchListsAbstract.java @@ -125,11 +125,11 @@ public abstract class KeywordSearchListsAbstract { } return ret; } - + List getListsL(boolean locked) { List ret = new ArrayList(); for (KeywordSearchList list : theLists.values()) { - if(list.isLocked().equals(locked)) { + if (list.isLocked().equals(locked)) { ret.add(list); } } @@ -138,14 +138,16 @@ public abstract class KeywordSearchListsAbstract { /** * Get list names of all loaded keyword list names + * * @return List of keyword list names */ List getListNames() { return new ArrayList(theLists.keySet()); } - + /** * Get list names of all locked or unlocked loaded keyword list names + * * @param locked true if look for locked lists, false otherwise * @return List of keyword list names */ @@ -153,15 +155,17 @@ public abstract class KeywordSearchListsAbstract { ArrayList lists = new ArrayList(); for (String listName : theLists.keySet()) { KeywordSearchList list = theLists.get(listName); - if (locked == list.isLocked()) + if (locked == list.isLocked()) { lists.add(listName); + } } - + return lists; } /** * return first list that contains the keyword + * * @param keyword * @return found list or null */ @@ -178,6 +182,7 @@ public abstract class KeywordSearchListsAbstract { /** * return first list that contains the keyword + * * @param keyword * @return found list or null */ @@ -194,14 +199,16 @@ public abstract class KeywordSearchListsAbstract { /** * get number of lists currently stored + * * @return number of lists currently stored */ int getNumberLists() { return theLists.size(); } - + /** * get number of unlocked or locked lists currently stored + * * @param locked true if look for locked lists, false otherwise * @return number of unlocked lists currently stored */ @@ -209,14 +216,16 @@ public abstract class KeywordSearchListsAbstract { int numLists = 0; for (String listName : theLists.keySet()) { KeywordSearchList list = theLists.get(listName); - if (locked == list.isLocked()) - ++ numLists; + if (locked == list.isLocked()) { + ++numLists; + } } return numLists; } /** * get list by name or null + * * @param name id of the list * @return keyword list representation */ @@ -226,6 +235,7 @@ public abstract class KeywordSearchListsAbstract { /** * check if list with given name id exists + * * @param name id to check * @return true if list already exists or false otherwise */ @@ -234,8 +244,9 @@ public abstract class KeywordSearchListsAbstract { } /** - * adds the new word list using name id - * replacing old one if exists with the same name + * adds the new word list using name id replacing old one if exists with the + * same name + * * @param name the name of the new list or list to replace * @param newList list of keywords * @param useForIngest should this list be used for ingest @@ -270,17 +281,18 @@ public abstract class KeywordSearchListsAbstract { boolean addList(String name, List newList) { return addList(name, newList, true, true); } - + boolean addList(KeywordSearchList list) { return addList(list.getName(), list.getKeywords(), list.getUseForIngest(), list.getIngestMessages(), list.isLocked()); } /** - * write out multiple lists + * save multiple lists + * * @param lists - * @return + * @return */ - boolean writeLists(List lists) { + boolean saveLists(List lists) { int oldSize = this.getNumberLists(); List overwritten = new ArrayList(); @@ -302,11 +314,44 @@ public abstract class KeywordSearchListsAbstract { changeSupport.firePropertyChange(ListsEvt.LIST_UPDATED.toString(), null, over.getName()); } } + return saved; } + /** + * write out multiple lists + * + * @param lists + * @return + */ + boolean writeLists(List lists) { + int oldSize = this.getNumberLists(); + + List overwritten = new ArrayList(); + List newLists = new ArrayList(); + for (KeywordSearchList list : lists) { + if (this.listExists(list.getName())) { + overwritten.add(list); + } else { + newLists.add(list); + } + theLists.put(list.getName(), list); + } + //boolean saved = save(); + + for (KeywordSearchList list : newLists) { + changeSupport.firePropertyChange(ListsEvt.LIST_ADDED.toString(), null, list.getName()); + } + for (KeywordSearchList over : overwritten) { + changeSupport.firePropertyChange(ListsEvt.LIST_UPDATED.toString(), null, over.getName()); + } + + return true; + } + /** * delete list if exists and save new list + * * @param name of list to delete * @return true if deleted */ @@ -339,8 +384,7 @@ public abstract class KeywordSearchListsAbstract { } /** - * a representation of a single keyword list - * created or loaded + * a representation of a single keyword list created or loaded */ class KeywordSearchList {