From 33c5c08a43b54613f19fc60c3b01ccd3ed0394dc Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 6 Oct 2021 13:24:33 -0400 Subject: [PATCH] search result children and loading in DataResultTopComponent --- .../DataResultTopComponent.java | 21 ++- .../datamodel/Bundle.properties-MERGED | 4 + .../datamodel/DataArtifactFactoryv2.java | 60 +------ .../autopsy/datamodel/DataArtifactNodev2.java | 10 +- .../datamodel/DataArtifactTypeNodev2.java | 34 ++-- .../autopsy/datamodel/FileNodev2.java | 14 +- .../datamodel/SearchResultChildFactory.java | 108 ++++++++++++ .../autopsy/datamodel/ThreePanelDAO.java | 75 +++++++-- .../autopsy/datamodel/VolumeNodev2.java | 154 ++++++++++++++++++ 9 files changed, 384 insertions(+), 96 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java create mode 100644 Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java index fbaddefd93..cb1cc43114 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java @@ -18,10 +18,12 @@ */ package org.sleuthkit.autopsy.corecomponents; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.logging.Level; import javax.swing.JComponent; import org.openide.explorer.ExplorerManager; @@ -39,6 +41,9 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.DataArtifactTypeNodev2; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableDTO; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableSearchResultsDTO; import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -361,9 +366,21 @@ public final class DataResultTopComponent extends TopComponent implements DataRe public void setNode(Node selectedNode) { dataResultPanel.setNode(selectedNode); } - + + private final ThreePanelDAO threePanelDAO = ThreePanelDAO.getInstance(); + public void displayDataArtifact(BlackboardArtifact.Type artifactType, Long dataSourceId) { - setNode(new TableFilterNode(new DataArtifactTypeNodev2(artifactType, dataSourceId), true)); + try { + DataArtifactTableSearchResultsDTO table = threePanelDAO.getDataArtifactsForTable(artifactType, dataSourceId); + dataResultPanel.setNode(new DataArtifactTypeNodev2(table)); + dataResultPanel.setNumberOfChildNodes(table.getTotalResultsCount()); + } catch (ExecutionException | IllegalArgumentException ex) { + logger.log(Level.WARNING, MessageFormat.format( + "There was an error fetching data for artifact type: {0} and data source id: {1}.", + artifactType.getTypeName(), + dataSourceId == null ? "" : dataSourceId), + ex); + } } @Override diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED index bb9d1b4344..9fcc801417 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED @@ -175,6 +175,10 @@ FileNode.getActions.openInExtViewer.text=Open in External Viewer Ctrl+E FileNode.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash FileNode.getActions.viewFileInDir.text=View File in Directory FileNode.getActions.viewInNewWin.text=View Item in New Window +FileNodev2.getActions.openInExtViewer.text=Open in External Viewer Ctrl+E +FileNodev2.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash +FileNodev2.getActions.viewFileInDir.text=View File in Directory +FileNodev2.getActions.viewInNewWin.text=View Item in New Window FileTypeExtensionFilters.tskDatabaseFilter.text=Databases FileTypes.bgCounting.placeholder=\ (counting...) FileTypes.createSheet.name.desc=no description diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactFactoryv2.java b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactFactoryv2.java index 16cacf08d0..38fe93fe6f 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactFactoryv2.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactFactoryv2.java @@ -5,71 +5,25 @@ */ package org.sleuthkit.autopsy.datamodel; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.logging.Level; -import java.util.stream.Collectors; -import org.openide.nodes.ChildFactory; import org.openide.nodes.Node; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.datamodel.DataArtifactFactoryv2.ChildData; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactRow; import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableDTO; -import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableSearchResultsDTO; /** * * @author gregd */ -public class DataArtifactFactoryv2 extends ChildFactory.Detachable { +public class DataArtifactFactoryv2 extends SearchResultChildFactory { - public static class ChildData { - - private final DataArtifactTableDTO tableData; - private final DataArtifactRow artifactRow; - - public ChildData(DataArtifactTableDTO tableData, DataArtifactRow artifactRow) { - this.tableData = tableData; - this.artifactRow = artifactRow; - } - - public DataArtifactTableDTO getTableData() { - return tableData; - } - - public DataArtifactRow getArtifactRow() { - return artifactRow; - } + public DataArtifactFactoryv2() { } - private static final Logger logger = Logger.getLogger(DataArtifactFactoryv2.class.getName()); - - private final BlackboardArtifact.Type type; - private final Long filteringDSObjId; - private final ThreePanelDAO dao = ThreePanelDAO.getInstance(); - - DataArtifactFactoryv2(BlackboardArtifact.Type type, Long filteringDSObjId) { - this.type = type; - this.filteringDSObjId = filteringDSObjId; + public DataArtifactFactoryv2(DataArtifactTableSearchResultsDTO initialResults) { + super(initialResults); } @Override - protected boolean createKeys(List toPopulate) { - try { - DataArtifactTableDTO table = dao.getDataArtifactsForTable(type, filteringDSObjId); - List keys = table.getRows().stream() - .map((row) -> new ChildData(table, row)) - .collect(Collectors.toList()); - toPopulate.addAll(keys); - return true; - } catch (ExecutionException ex) { - logger.log(Level.WARNING, "There was an error fetching data for type: " + type, ex); - return false; - } - } - - @Override - protected Node createNodeForKey(ChildData key) { - return new DataArtifactNodev2(key.getTableData(), key.getArtifactRow()); + protected Node createNodeForKey(DataArtifactTableSearchResultsDTO searchResults, DataArtifactTableDTO itemData) { + return new DataArtifactNodev2(searchResults, itemData); } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java index 49deb2beba..2557e8cfa8 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java @@ -61,8 +61,8 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactRow; import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableDTO; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableSearchResultsDTO; import org.sleuthkit.autopsy.texttranslation.TextTranslationService; import org.sleuthkit.autopsy.directorytree.ExportCSVAction; import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; @@ -88,7 +88,7 @@ public class DataArtifactNodev2 extends AbstractNode { private static final Logger logger = Logger.getLogger(DataArtifactNodev2.class.getName()); - private static Lookup createLookup(DataArtifactRow row) { + private static Lookup createLookup(DataArtifactTableDTO row) { DataArtifactItem artifactItem = new DataArtifactItem(row.getDataArtifact(), row.getSrcContent()); if (row.getSrcContent() == null) { return Lookups.fixed(row.getDataArtifact(), artifactItem); @@ -99,15 +99,15 @@ public class DataArtifactNodev2 extends AbstractNode { private final BlackboardArtifact.Type artifactType; private final Map attributeTypes; - private final DataArtifactRow artifactRow; + private final DataArtifactTableDTO artifactRow; private final boolean hasSupportedTimeStamp; private String translatedSourceName = null; - public DataArtifactNodev2(DataArtifactTableDTO tableData, DataArtifactRow artifactRow) { + public DataArtifactNodev2(DataArtifactTableSearchResultsDTO tableData, DataArtifactTableDTO artifactRow) { this(tableData, artifactRow, IconsUtil.getIconFilePath(tableData.getArtifactType().getTypeID())); } - public DataArtifactNodev2(DataArtifactTableDTO tableData, DataArtifactRow artifactRow, String iconPath) { + public DataArtifactNodev2(DataArtifactTableSearchResultsDTO tableData, DataArtifactTableDTO artifactRow, String iconPath) { super(Children.LEAF, createLookup(artifactRow)); setDisplayName(artifactRow.getSrcContent().getName()); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactTypeNodev2.java b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactTypeNodev2.java index 5098b7d1c0..3d523c4a36 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactTypeNodev2.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactTypeNodev2.java @@ -9,23 +9,26 @@ import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.DataArtifactTableSearchResultsDTO; import org.sleuthkit.autopsy.datamodel.utils.IconsUtil; -import org.sleuthkit.datamodel.BlackboardArtifact; /** * * @author gregd */ public class DataArtifactTypeNodev2 extends AbstractNode { - - private final BlackboardArtifact.Type artifactType; - - public DataArtifactTypeNodev2(BlackboardArtifact.Type artifactType, Long dataSourceId) { - super(Children.create(new DataArtifactFactoryv2(artifactType, dataSourceId), true)); - setName(artifactType.getTypeName()); - setDisplayName(artifactType.getDisplayName()); - this.artifactType = artifactType; - String iconPath = IconsUtil.getIconFilePath(artifactType.getTypeID()); + private final SearchResultChildFactory factory; + + public DataArtifactTypeNodev2(DataArtifactTableSearchResultsDTO initialResults) { + this(initialResults, new DataArtifactFactoryv2(initialResults)); + } + + private DataArtifactTypeNodev2(DataArtifactTableSearchResultsDTO initialResults, DataArtifactFactoryv2 factory) { + super(Children.create(factory, true)); + this.factory = factory; + setName(initialResults.getArtifactType().getTypeName()); + setDisplayName(initialResults.getArtifactType().getDisplayName()); + String iconPath = IconsUtil.getIconFilePath(initialResults.getArtifactType().getTypeID()); setIconBaseWithExtension(iconPath != null && iconPath.charAt(0) == '/' ? iconPath.substring(1) : iconPath); } @@ -41,12 +44,13 @@ public class DataArtifactTypeNodev2 extends AbstractNode { sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.artType.name"), NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.artType.displayName"), NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.artType.desc"), - this.artifactType.getDisplayName())); + getDisplayName())); -// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.childCnt.name"), -// NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.childCnt.displayName"), -// NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.childCnt.desc"), -// getChildCount())); + sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.childCnt.name"), + NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.childCnt.displayName"), + NbBundle.getMessage(this.getClass(), "ArtifactTypeNode.createSheet.childCnt.desc"), + this.factory.getResultCount())); + return sheet; } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java b/Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java index 5d0e717c93..a9aa2005ff 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java @@ -197,28 +197,28 @@ public class FileNodev2 extends AbstractNode { */ @Override @NbBundle.Messages({ - "FileNode.getActions.viewFileInDir.text=View File in Directory", - "FileNode.getActions.viewInNewWin.text=View Item in New Window", - "FileNode.getActions.openInExtViewer.text=Open in External Viewer Ctrl+E", - "FileNode.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash"}) + "FileNodev2.getActions.viewFileInDir.text=View File in Directory", + "FileNodev2.getActions.viewInNewWin.text=View Item in New Window", + "FileNodev2.getActions.openInExtViewer.text=Open in External Viewer Ctrl+E", + "FileNodev2.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash"}) public Action[] getActions(boolean context) { List actionsList = new ArrayList<>(); // GVDTODO: action requires node // if (!this.directoryBrowseMode) { -// actionsList.add(new ViewContextAction(Bundle.FileNode_getActions_viewFileInDir_text(), this)); +// actionsList.add(new ViewContextAction(Bundle.FileNodev2_getActions_viewFileInDir_text(), this)); // } actionsList.add(ViewFileInTimelineAction.createViewFileAction(this.fileData.getAbstractFile())); actionsList.add(null); // Creates an item separator - actionsList.add(new NewWindowViewAction(Bundle.FileNode_getActions_viewInNewWin_text(), this)); + actionsList.add(new NewWindowViewAction(Bundle.FileNodev2_getActions_viewInNewWin_text(), this)); final Collection selectedFilesList = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class)); if (selectedFilesList.size() == 1) { actionsList.add(new ExternalViewerAction( - Bundle.FileNode_getActions_openInExtViewer_text(), this)); + Bundle.FileNodev2_getActions_openInExtViewer_text(), this)); } else { actionsList.add(ExternalViewerShortcutAction.getInstance()); } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java b/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java new file mode 100644 index 0000000000..eddb826759 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java @@ -0,0 +1,108 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.datamodel; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import org.openide.nodes.ChildFactory; +import org.openide.nodes.Node; +import org.sleuthkit.autopsy.datamodel.SearchResultChildFactory.ChildKey; +import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; + +/** + * + * @author gregd + */ +public abstract class SearchResultChildFactory, S> extends ChildFactory> { + + private T results; + + public SearchResultChildFactory() { + this(null); + } + + public SearchResultChildFactory(T initialResults) { + this.results = initialResults; + } + + @Override + protected boolean createKeys(List> toPopulate) { + T results = this.results; + + if (results != null) { + List> childKeys = results.getItems().stream() + .map((item) -> new ChildKey<>(results, item)) + .collect(Collectors.toList()); + + toPopulate.addAll(childKeys); + } + + return true; + } + + @Override + protected Node createNodeForKey(ChildKey key) { + return createNodeForKey(key.getSearchResults(), key.getChild()); + } + + protected abstract Node createNodeForKey(T searchResults, S itemData); + + public void update(T newResults) { + this.results = newResults; + this.refresh(false); + } + + public int getResultCount() { + return results == null ? 0 : results.getTotalResultsCount(); + } + + + static class ChildKey> { + + private final T searchResults; + private final S child; + + ChildKey(T searchResults, S child) { + this.searchResults = searchResults; + this.child = child; + } + + T getSearchResults() { + return searchResults; + } + + S getChild() { + return child; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + Objects.hashCode(this.child); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ChildKey other = (ChildKey) obj; + if (!Objects.equals(this.child, other.child)) { + return false; + } + return true; + } + + } +} diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDAO.java b/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDAO.java index 4ab74d697b..190f78e8f0 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDAO.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDAO.java @@ -53,14 +53,14 @@ public class ThreePanelDAO { return instance; } - private final Cache dataArtifactCache = CacheBuilder.newBuilder().maximumSize(1000).build(); + private final Cache dataArtifactCache = CacheBuilder.newBuilder().maximumSize(1000).build(); private final Cache> filesCache = CacheBuilder.newBuilder().maximumSize(1000).build(); private SleuthkitCase getCase() throws NoCurrentCaseException { return Case.getCurrentCaseThrows().getSleuthkitCase(); } - private DataArtifactTableDTO fetchDataArtifactsForTable(DataArtifactCacheKey cacheKey) throws NoCurrentCaseException, TskCoreException { + private DataArtifactTableSearchResultsDTO fetchDataArtifactsForTable(DataArtifactCacheKey cacheKey) throws NoCurrentCaseException, TskCoreException { SleuthkitCase skCase = getCase(); Blackboard blackboard = skCase.getBlackboard(); @@ -74,7 +74,7 @@ public class ThreePanelDAO { // determine all different attribute types present as well as row data for each artifact Set attributeTypes = new HashSet<>(); - List rows = new ArrayList<>(); + List rows = new ArrayList<>(); for (DataArtifact artifact : arts) { long id = artifact.getId(); @@ -91,14 +91,14 @@ public class ThreePanelDAO { Content srcContent = artifact.getParent(); String dataSourceName = getDataSourceName(srcContent); - rows.add(new DataArtifactRow(id, attributeValues, artifact, srcContent, linkedFile, dataSourceName)); + rows.add(new DataArtifactTableDTO(id, attributeValues, artifact, srcContent, linkedFile, dataSourceName)); } List attributeTypeSortedList = attributeTypes.stream() .sorted((a, b) -> a.getDisplayName().compareToIgnoreCase(b.getDisplayName())) .collect(Collectors.toList()); - return new DataArtifactTableDTO(artType, attributeTypeSortedList, rows); + return new DataArtifactTableSearchResultsDTO(artType, attributeTypeSortedList, rows); } private String getDataSourceName(Content srcContent) throws TskCoreException { @@ -181,7 +181,7 @@ public class ThreePanelDAO { } } - public DataArtifactTableDTO getDataArtifactsForTable(BlackboardArtifact.Type artType, Long dataSourceId) throws ExecutionException, IllegalArgumentException { + public DataArtifactTableSearchResultsDTO getDataArtifactsForTable(BlackboardArtifact.Type artType, Long dataSourceId) throws ExecutionException, IllegalArgumentException { if (artType == null || artType.getCategory() != BlackboardArtifact.Category.DATA_ARTIFACT) { throw new IllegalArgumentException(MessageFormat.format("Illegal data. " + "Artifact type must be non-null and data artifact. " @@ -305,7 +305,7 @@ public class ThreePanelDAO { } - public static class DataArtifactRow { + public static class DataArtifactTableDTO { private final long id; @@ -316,7 +316,7 @@ public class ThreePanelDAO { private final Content linkedFile; private String dataSourceName; - public DataArtifactRow(long id, Map attributeValues, DataArtifact dataArtifact, Content srcContent, Content linkedFile, String dataSourceName) { + public DataArtifactTableDTO(long id, Map attributeValues, DataArtifact dataArtifact, Content srcContent, Content linkedFile, String dataSourceName) { this.id = id; this.attributeValues = attributeValues; this.dataArtifact = dataArtifact; @@ -348,18 +348,57 @@ public class ThreePanelDAO { public String getDataSourceName() { return dataSourceName; } + + @Override + public int hashCode() { + int hash = 7; + hash = 67 * hash + (int) (this.id ^ (this.id >>> 32)); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final DataArtifactTableDTO other = (DataArtifactTableDTO) obj; + if (this.id != other.id) { + return false; + } + return true; + } + + + } + + public interface SearchResultsDTO { + int getTotalResultsCount(); + List getItems(); } - public static class DataArtifactTableDTO { + public static class DataArtifactTableSearchResultsDTO implements SearchResultsDTO { private final BlackboardArtifact.Type artifactType; private final List attributeTypes; - private final List rows; + private final List items; + private final int totalResultsCount; - public DataArtifactTableDTO(BlackboardArtifact.Type artifactType, List attributeKeys, List rows) { + public DataArtifactTableSearchResultsDTO(BlackboardArtifact.Type artifactType, List attributeKeys, List items) { + this(artifactType, attributeKeys, items, items.size()); + } + + + public DataArtifactTableSearchResultsDTO(BlackboardArtifact.Type artifactType, List attributeKeys, List items, int totalResultsCount) { this.artifactType = artifactType; this.attributeTypes = attributeKeys; - this.rows = rows; + this.items = items; + this.totalResultsCount = totalResultsCount; } public BlackboardArtifact.Type getArtifactType() { @@ -370,9 +409,17 @@ public class ThreePanelDAO { return attributeTypes; } - public List getRows() { - return rows; + @Override + public List getItems() { + return items; } + + @Override + public int getTotalResultsCount() { + return totalResultsCount; + } + + } public enum FilesType { diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java b/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java new file mode 100644 index 0000000000..fd072b164f --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java @@ -0,0 +1,154 @@ +///* +// * Autopsy Forensic Browser +// * +// * Copyright 2011-2021 Basis Technology Corp. +// * Contact: carrier sleuthkit org +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +//package org.sleuthkit.autopsy.datamodel; +// +//import java.beans.PropertyChangeEvent; +//import java.beans.PropertyChangeListener; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.EnumSet; +//import java.util.List; +//import java.util.Set; +//import java.util.logging.Level; +//import javax.swing.Action; +//import org.openide.nodes.AbstractNode; +//import org.openide.nodes.Sheet; +//import org.openide.util.NbBundle; +//import org.sleuthkit.autopsy.casemodule.Case; +//import org.sleuthkit.autopsy.coreutils.Logger; +//import org.sleuthkit.autopsy.datamodel.BaseChildFactory.NoSuchEventBusException; +//import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; +//import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; +//import org.sleuthkit.autopsy.ingest.IngestManager; +//import org.sleuthkit.autopsy.ingest.ModuleContentEvent; +//import org.sleuthkit.datamodel.Content; +//import org.sleuthkit.datamodel.Pool; +//import org.sleuthkit.datamodel.TskCoreException; +//import org.sleuthkit.datamodel.VirtualDirectory; +//import org.sleuthkit.datamodel.Volume; +//import org.sleuthkit.autopsy.directorytree.FileSystemDetailsAction; +//import org.sleuthkit.datamodel.Tag; +// +///** +// * This class is used to represent the "Node" for the volume. Its child is the +// * root directory of a file system +// */ +//public class VolumeNodev2 extends AbstractNode { +// +// private static final Logger logger = Logger.getLogger(VolumeNodev2.class.getName()); +// +// +// public static class VolumeTableDTO { +// private final long volAddr; +// +// public long getVolAddr() { +// return volAddr; +// } +// } +// +//// +//// static String nameForVolume(VolumeTableDTO vol) { +//// return "vol" + Long.toString(vol.getAddr()); //NON-NLS +//// } +// +// /** +// * +// * @param vol underlying Content instance +// */ +// public VolumeNodev2(VolumeTableDTO vol) { +// super(vol); +// +// // set name, display name, and icon +// String volName = nameForVolume(vol); +// long end = vol.getStart() + (vol.getLength() - 1); +// String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")"; +// +// // If this is a pool volume use a custom display name +// try { +// if (vol.getParent() != null +// && vol.getParent().getParent() instanceof Pool) { +// // Pool volumes are not contiguous so printing a range of blocks is inaccurate +// tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")"; +// } +// } catch (TskCoreException ex) { +// logger.log(Level.WARNING, "Error looking up parent(s) of volume with obj ID = " + vol.getId(), ex); +// } +// this.setDisplayName(tempVolName); +// +// this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); //NON-NLS +// } +// +// +// /** +// * Right click action for volume node +// * +// * @param popup +// * +// * @return +// */ +// @Override +// public Action[] getActions(boolean popup) { +// List actionsList = new ArrayList<>(); +// actionsList.add(new FileSystemDetailsAction(content)); +// actionsList.add(new NewWindowViewAction( +// NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this)); +// actionsList.addAll(ExplorerNodeActionVisitor.getActions(content)); +// actionsList.add(null); +// actionsList.addAll(Arrays.asList(super.getActions(true))); +// +// return actionsList.toArray(new Action[actionsList.size()]); +// } +// +// @Override +// protected Sheet createSheet() { +// Sheet sheet = super.createSheet(); +// Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES); +// if (sheetSet == null) { +// sheetSet = Sheet.createPropertiesSet(); +// sheet.put(sheetSet); +// } +// +// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.name"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.displayName"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.desc"), +// this.getDisplayName())); +// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.name"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.displayName"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.desc"), +// content.getAddr())); +// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.name"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.displayName"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.desc"), +// content.getStart())); +// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.name"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.displayName"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.desc"), +// content.getLength())); +// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.name"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.displayName"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.desc"), +// content.getDescription())); +// sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.name"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.displayName"), +// NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.desc"), +// content.getFlagsAsString())); +// +// return sheet; +// } +//}