diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java index e9fab8ed6f..57f1a3452a 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java @@ -355,11 +355,11 @@ public class DataResultViewerTable extends AbstractDataResultViewer { return; } - if(currentRoot != null && !propertiesAcc.isEmpty()) { - storeProperties(currentRoot); - } + storeState(); + + // set the new root as current currentRoot = root; - List> props = loadProperties(currentRoot); + List> props = loadState(); /* * OutlineView makes the first column be the result of @@ -432,23 +432,44 @@ public class DataResultViewerTable extends AbstractDataResultViewer { } } - // Store the column arrangements of the given Node. - private void storeProperties(Node root) { + // Store the state of current root Node. + private void storeState() { + if(currentRoot == null || propertiesAcc.isEmpty()) + return; + + TableFilterNode tfn; + if(currentRoot instanceof TableFilterNode) + tfn = (TableFilterNode) currentRoot; + else + return; + List> props = new ArrayList<>(propertiesAcc); for (int i = 0; i < props.size(); i++) { Property prop = props.get(i); - NbPreferences.forModule(this.getClass()).put(getUniqueName(root, prop), String.valueOf(i)); + NbPreferences.forModule(this.getClass()).put(getUniqueColName(prop, tfn.getItemType()), String.valueOf(i)); } } - // Load the column arrangement stored for the given node if exists. - private List> loadProperties(Node root) { + // Load the state of current root Node if exists. + private List> loadState() { propertiesAcc.clear(); - this.getAllChildPropertyHeadersRec(root, 100); + this.getAllChildPropertyHeadersRec(currentRoot, 100); List> props = new ArrayList<>(propertiesAcc); + + // If node is not table filter node, use default order for columns + TableFilterNode tfn; + if(currentRoot instanceof TableFilterNode) { + tfn = (TableFilterNode) currentRoot; + } + else { + Logger.getLogger(DataResultViewerTable.class.getName()).log(Level.INFO, + "Node {0} is not TableFilterNode, columns are going to be in default order", currentRoot.getName()); + return props; + } + List> orderedProps = new ArrayList<>(propertiesAcc); for (Property prop : props) { - Integer value = Integer.valueOf(NbPreferences.forModule(this.getClass()).get(getUniqueName(root, prop), "-1")); + Integer value = Integer.valueOf(NbPreferences.forModule(this.getClass()).get(getUniqueColName(prop, tfn.getItemType()), "-1")); if (value >= 0) { /** * The original contents of orderedProps do not matter when setting the new ordered values. The reason @@ -465,16 +486,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer { } // Get unique name for node and it's property. - private String getUniqueName(Node root, Property prop) { - String type = "Generic"; - if(root instanceof TableFilterNode) { - TableFilterNode filterNode = (TableFilterNode) root; - type = filterNode.getItemType(); - } - else { - Logger.getLogger(DataResultViewerTable.class.getName()).log(Level.SEVERE, "Node is not TableFilterNode"); - } - + private String getUniqueColName(Property prop, String type) { return Case.getCurrentCase().getName() + "." + type + "." + prop.getName().replaceAll("[^a-zA-Z0-9_]", "") + ".columnOrder"; } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java b/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java index e622ee09b6..11caf66c75 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/TableFilterNode.java @@ -40,7 +40,7 @@ public class TableFilterNode extends FilterNode { public TableFilterNode(Node arg, boolean crChild) { super(arg, TableFilterChildren.createInstance(arg, crChild)); this.createChild = crChild; - this.itemType = "Generic"; + this.itemType = ""; } public TableFilterNode(Node arg, boolean crChild, String itemType) { diff --git a/test/script/config.xml b/test/script/config.xml index d11f973649..6762cdd5ce 100644 --- a/test/script/config.xml +++ b/test/script/config.xml @@ -9,8 +9,6 @@ indir: the path to input directory outdir: the path to output directory global_csv: path to global csv file golddir: the path to gold directory -jenkins: can be set to True or False. If enabled, check for diffdir -diffdir: (only if jenkins tag is true) the diff directory timing: can be set to True or False. If enabled, record the timing. NOTE: Make sure to use windows style for paths! diff --git a/test/script/regression.py b/test/script/regression.py index 4a69295dc2..27532c50f7 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -415,8 +415,6 @@ class TestRunner(object): test_data.ant.append("-Dnsrl_path=" + test_config.nsrl_path) test_data.ant.append("-Dgold_path=" + test_config.gold) test_data.ant.append("-Dout_path=" + make_local_path(test_data.output_path)) - if test_config.jenkins: - test_data.ant.append("-Ddiff_dir="+ test_config.diff_dir) test_data.ant.append("-Dignore_unalloc=" + "%s" % test_config.args.unallocated) test_data.ant.append("-Dtest.timeout=" + str(test_config.timeout)) @@ -728,12 +726,6 @@ class TestConfiguration(object): self.global_csv = make_local_path(self.global_csv) if parsed_config.getElementsByTagName("golddir"): self.gold = parsed_config.getElementsByTagName("golddir")[0].getAttribute("value").encode().decode("utf_8") - if parsed_config.getElementsByTagName("jenkins"): - self.jenkins = parsed_config.getElementsByTagName("jenkins")[0].getAttribute("value").encode().decode("utf_8") - if self.jenkins and parsed_config.getElementsByTagName("diffdir"): - self.diff_dir = parsed_config.getElementsByTagName("diffdir")[0].getAttribute("value").encode().decode("utf_8") - else: - self.jenkins = False if parsed_config.getElementsByTagName("timing"): self.timing = parsed_config.getElementsByTagName("timing")[0].getAttribute("value").encode().decode("utf_8") self._init_imgs(parsed_config) @@ -1297,7 +1289,7 @@ class Logs(object): log.close() common_log.write("\n") common_log.close() - srtcmdlst = ["sort", "--ignore-case", test_data.common_log_path, "-o", test_data.common_log_path] + srtcmdlst = ["sort", test_data.common_log_path, "-o", test_data.common_log_path] subprocess.call(srtcmdlst) except (OSError, IOError) as e: Errors.print_error("Error: Unable to generate the common log.") @@ -1974,31 +1966,6 @@ def find_file_in_dir(dir, name, ext): raise DirNotFoundException(dir) -def copyErrorFiles(attachments, test_config): - """Move email attachments to the location specified in the config file. - Used for Jenkins build. - - Args: - attachments: a listof_String, the files to be moved - test_config: TestConfiguration, used to determine where to move the files to - """ - call = ['pwd'] - subprocess.call(call) - - # remove old diff files - filelist = [f for f in os.listdir(test_config.diff_dir) if (f.endswith(".txt") or f.endswith(".html"))] - for f in filelist: - if os.path.isfile(test_config.diff_dir + "/" + f): - os.remove(test_config.diff_dir + "/" + f) - - # move in the new diff files - for file in attachments: - filename = ntpath.basename(file) - destination = os.path.join(test_config.diff_dir, filename) - call = ['cp', file, destination] - subprocess.call(call) - - class OS: LINUX, MAC, WIN, CYGWIN = range(4) diff --git a/test/script/tskdbdiff.py b/test/script/tskdbdiff.py index b061007036..5f2095d7a7 100755 --- a/test/script/tskdbdiff.py +++ b/test/script/tskdbdiff.py @@ -87,9 +87,16 @@ class TskDbDiff(object): self._dump = os.path.join(self.output_dir, "DBDump.txt") self._dump_diff = os.path.join(self.output_dir, "DBDump-Diff.txt") - if self.gold_bb_dump is None: - self.gold_bb_dump = TskDbDiff._get_tmp_file("GoldBlackboardDump", ".txt") - self.gold_dump = TskDbDiff._get_tmp_file("GoldDBDump", ".txt") + # Sorting gold before comparing (sort behaves differently in different environments) + new_bb = TskDbDiff._get_tmp_file("GoldBlackboardDump", ".txt") + new_db = TskDbDiff._get_tmp_file("GoldDBDump", ".txt") + if self.gold_bb_dump is not None: + srtcmdlst = ["sort", self.gold_bb_dump, "-o", new_bb] + subprocess.call(srtcmdlst) + srtcmdlst = ["sort", self.gold_dump, "-o", new_db] + subprocess.call(srtcmdlst) + self.gold_bb_dump = new_bb + self.gold_dump = new_db def _cleanup_diff(self): @@ -251,7 +258,7 @@ class TskDbDiff(object): conn.close() # Now sort the file - srtcmdlst = ["sort", "--ignore-case", unsorted_dump, "-o", bb_dump_file] + srtcmdlst = ["sort", unsorted_dump, "-o", bb_dump_file] subprocess.call(srtcmdlst) @@ -286,7 +293,7 @@ class TskDbDiff(object): db_log.write('%s\n' % line) # Now sort the file - srtcmdlst = ["sort", "--ignore-case", dump_file, "-o", dump_file] + srtcmdlst = ["sort", dump_file, "-o", dump_file] subprocess.call(srtcmdlst) conn.close()