diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataResultViewer.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataResultViewer.java index 35663c326d..75af2635c0 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataResultViewer.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataResultViewer.java @@ -20,7 +20,7 @@ package org.sleuthkit.autopsy.corecomponentinterfaces; import java.awt.Component; import org.openide.nodes.Node; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; /** * An interface for result viewers. A result viewer uses a Swing Component to @@ -76,7 +76,7 @@ public interface DataResultViewer { */ public void setNode(Node node); - default public void setNode(Node node, SearchResultsDTO searchResults) { + default public void setNode(Node node, SearchResultsDTO searchResults) { setNode(node, null); } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java index 2416fc8955..b4c0e02e59 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java @@ -43,9 +43,9 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; import org.sleuthkit.autopsy.datamodel.NodeSelectionInfo; -import org.sleuthkit.autopsy.datamodel.SearchResultTableNode; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.mainui.nodes.SearchResultRootNode; +import org.sleuthkit.autopsy.mainui.datamodel.ThreePanelDAO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; /** * A result view panel is a JPanel with a JTabbedPane child component that @@ -88,7 +88,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C private DataContent contentView; private ExplorerManager explorerManager; private Node currentRootNode; - private SearchResultsDTO searchResults; + private SearchResultsDTO searchResults; private boolean listeningToTabbedPane; /** @@ -363,7 +363,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C setNode(rootNode, null); } - void setNode(Node rootNode, SearchResultsDTO searchResults) { + void setNode(Node rootNode, SearchResultsDTO searchResults) { this.searchResults = searchResults; if (this.currentRootNode != null) { diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java index d51d29ff8a..03b5030151 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java @@ -40,16 +40,14 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.datamodel.DataArtifactKeyv2; -import org.sleuthkit.autopsy.datamodel.DataArtifactNodev2; -import org.sleuthkit.autopsy.datamodel.FileNodev2; -import org.sleuthkit.autopsy.datamodel.FileTypeExtensionsKeyv2; -import org.sleuthkit.autopsy.datamodel.SearchResultChildFactory.NodeCreator; -import org.sleuthkit.autopsy.datamodel.SearchResultTableNode; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.RowResultDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDataArtifactDAO.DataArtifactTableSearchResultsDTO; +import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactSearchParam; +import org.sleuthkit.autopsy.mainui.nodes.DataArtifactNode; +import org.sleuthkit.autopsy.mainui.nodes.FileNode; +import org.sleuthkit.autopsy.mainui.datamodel.FileTypeExtensionsSearchParam; +import org.sleuthkit.autopsy.mainui.nodes.SearchResultRootNode; +import org.sleuthkit.autopsy.mainui.datamodel.ThreePanelDAO; +import org.sleuthkit.autopsy.mainui.datamodel.RowResultDTO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -375,9 +373,9 @@ public final class DataResultTopComponent extends TopComponent implements DataRe private final ThreePanelDAO threePanelDAO = ThreePanelDAO.getInstance(); - public void displayDataArtifact(DataArtifactKeyv2 dataArtifactKey) { + public void displayDataArtifact(DataArtifactSearchParam dataArtifactKey) { try { - displaySearchResults(threePanelDAO.getDataArtifactsDAO().getDataArtifactsForTable(dataArtifactKey), (table, row) -> new DataArtifactNodev2(table, row)); + displaySearchResults(threePanelDAO.getDataArtifactsDAO().getDataArtifactsForTable(dataArtifactKey)); } 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}.", @@ -388,9 +386,9 @@ public final class DataResultTopComponent extends TopComponent implements DataRe } - public void displayFileExtensions(FileTypeExtensionsKeyv2 fileExtensionsKey) { + public void displayFileExtensions(FileTypeExtensionsSearchParam fileExtensionsKey) { try { - displaySearchResults(threePanelDAO.getViewsDAO().getFilesByExtension(fileExtensionsKey), FileNodev2::new); + displaySearchResults(threePanelDAO.getViewsDAO().getFilesByExtension(fileExtensionsKey)); } catch (ExecutionException | IllegalArgumentException ex) { logger.log(Level.WARNING, MessageFormat.format( "There was an error fetching data for files of extension filter: {0} and data source id: {1}.", @@ -400,8 +398,8 @@ public final class DataResultTopComponent extends TopComponent implements DataRe } } - public , S extends RowResultDTO> void displaySearchResults(T searchResults, NodeCreator nodeCreator) { - dataResultPanel.setNode(new SearchResultTableNode<>(nodeCreator, searchResults), searchResults); + private void displaySearchResults(SearchResultsDTO searchResults) { + dataResultPanel.setNode(new SearchResultRootNode(searchResults), searchResults); dataResultPanel.setNumberOfChildNodes( searchResults.getTotalResultsCount() > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) searchResults.getTotalResultsCount()); } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java index 5a580b049e..971f971714 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java @@ -87,9 +87,9 @@ import org.sleuthkit.autopsy.datamodel.BaseChildFactory; import org.sleuthkit.autopsy.datamodel.BaseChildFactory.PageChangeEvent; import org.sleuthkit.autopsy.datamodel.BaseChildFactory.PageCountChangeEvent; import org.sleuthkit.autopsy.datamodel.BaseChildFactory.PageSizeChangeEvent; -import org.sleuthkit.autopsy.datamodel.SearchResultTableNode; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.mainui.nodes.SearchResultRootNode; +import org.sleuthkit.autopsy.mainui.datamodel.ThreePanelDAO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; import org.sleuthkit.datamodel.Score.Significance; /** @@ -145,7 +145,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer { private final TableListener outlineViewListener; private final IconRendererTableListener iconRendererListener; private Node rootNode; - private SearchResultsDTO searchResults; + private SearchResultsDTO searchResults; /** * Multiple nodes may have been visited in the context of this @@ -319,7 +319,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer { */ @Override @ThreadConfined(type = ThreadConfined.ThreadType.AWT) - public void setNode(Node rootNode, SearchResultsDTO searchResults) { + public void setNode(Node rootNode, SearchResultsDTO searchResults) { this.searchResults = searchResults; if (!SwingUtilities.isEventDispatchThread()) { @@ -1539,7 +1539,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer { private void exportCSVButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportCSVButtonActionPerformed Node currentRoot = this.getExplorerManager().getRootContext(); // GVDTODO disabled for Search Result node - if (currentRoot != null && (!(currentRoot instanceof SearchResultTableNode)) && currentRoot.getChildren().getNodesCount() > 0) { + if (currentRoot != null && (!(currentRoot instanceof SearchResultRootNode)) && currentRoot.getChildren().getNodesCount() > 0) { org.sleuthkit.autopsy.directorytree.ExportCSVAction.saveNodesToCSV(java.util.Arrays.asList(currentRoot.getChildren().getNodes()), this); } else { MessageNotifyUtil.Message.info(Bundle.DataResultViewerTable_exportCSVButtonActionPerformed_empty()); diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerThumbnail.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerThumbnail.java index 01defc0070..c2a533bc2b 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerThumbnail.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerThumbnail.java @@ -56,7 +56,7 @@ import static org.sleuthkit.autopsy.corecomponents.Bundle.*; import org.sleuthkit.autopsy.corecomponents.ResultViewerPersistence.SortCriterion; import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; import org.sleuthkit.autopsy.guiutils.WrapLayout; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; @@ -457,7 +457,7 @@ public final class DataResultViewerThumbnail extends AbstractDataResultViewer { } @Override - public void setNode(Node givenNode, SearchResultsDTO searchResults) { + public void setNode(Node givenNode, SearchResultsDTO searchResults) { // GVDTODO givenNode cannot be assumed to be a table filter node and search results needs to be captured. setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Artifacts.java b/Core/src/org/sleuthkit/autopsy/datamodel/Artifacts.java index 8d37890509..6ac796e581 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Artifacts.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Artifacts.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.datamodel; +import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactSearchParam; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; @@ -530,13 +531,12 @@ public class Artifacts { * no filtering will occur. */ TypeNode(BlackboardArtifact.Type type, long filteringDSObjId) { - super( - type.getCategory() == Category.DATA_ARTIFACT + super(type.getCategory() == Category.DATA_ARTIFACT ? new Children.Array() : Children.create(new ArtifactFactory(type, filteringDSObjId), true), type.getCategory() == Category.DATA_ARTIFACT - ? Lookups.fixed(type.getDisplayName(), new DataArtifactKeyv2(type, filteringDSObjId > 0 ? filteringDSObjId : null)) + ? Lookups.fixed(type.getDisplayName(), new DataArtifactSearchParam(type, filteringDSObjId > 0 ? filteringDSObjId : null)) : Lookups.singleton(type.getDisplayName()), type.getDisplayName(), diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactItem.java b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactItem.java index 8de75de287..ce1702dcff 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactItem.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactItem.java @@ -36,7 +36,7 @@ public class DataArtifactItem extends BlackboardArtifactItem { * @param sourceContent The source content of the DataArtifact. */ @Beta - DataArtifactItem(DataArtifact dataArtifact, Content sourceContent) { + public DataArtifactItem(DataArtifact dataArtifact, Content sourceContent) { super(dataArtifact, sourceContent); } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java b/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java index 4d238376e2..fcd770b887 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.datamodel; +import org.sleuthkit.autopsy.mainui.datamodel.FileTypeExtensionsSearchParam; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Arrays; @@ -37,10 +38,9 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.DocumentFilter; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.ExecutableFilter; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.RootFilter; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.SearchFilterInterface; +import org.sleuthkit.autopsy.mainui.datamodel.FileExtDocumentFilter; +import org.sleuthkit.autopsy.mainui.datamodel.FileExtExecutableFilter; +import org.sleuthkit.autopsy.mainui.datamodel.FileExtRootFilter; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.ModuleContentEvent; import org.sleuthkit.datamodel.AbstractFile; @@ -48,6 +48,7 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.autopsy.guiutils.RefreshThrottler; +import org.sleuthkit.autopsy.mainui.datamodel.FileExtSearchFilter; /** * Filters database results by file extension. @@ -195,7 +196,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { */ class FileTypesByExtNode extends DisplayableItemNode { - private final RootFilter filter; + private final FileExtRootFilter filter; /** * @@ -203,7 +204,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { * @param filter null to display root node of file type tree, pass in * something to provide a sub-node. */ - FileTypesByExtNode(SleuthkitCase skCase, RootFilter filter) { + FileTypesByExtNode(SleuthkitCase skCase, FileExtRootFilter filter) { this(skCase, filter, null); } @@ -214,7 +215,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { * @param o Observable that was created by a higher-level node that * provides updates on events */ - private FileTypesByExtNode(SleuthkitCase skCase, RootFilter filter, FileTypesByExtObservable o) { + private FileTypesByExtNode(SleuthkitCase skCase, FileExtRootFilter filter, FileTypesByExtObservable o) { super(Children.create(new FileTypesByExtNodeChildren(skCase, filter, o), true), Lookups.singleton(filter == null ? FNAME : filter.getDisplayName())); @@ -250,7 +251,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { sheetSet = Sheet.createPropertiesSet(); sheet.put(sheetSet); } - if (filter != null && (filter.equals(RootFilter.TSK_DOCUMENT_FILTER) || filter.equals(RootFilter.TSK_EXECUTABLE_FILTER))) { + if (filter != null && (filter.equals(FileExtRootFilter.TSK_DOCUMENT_FILTER) || filter.equals(FileExtRootFilter.TSK_EXECUTABLE_FILTER))) { String extensions = ""; for (String ext : filter.getFilter()) { extensions += "'" + ext + "', "; @@ -272,7 +273,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { if (filter == null) { return getClass().getName(); } - if (filter.equals(RootFilter.TSK_DOCUMENT_FILTER) || filter.equals(RootFilter.TSK_EXECUTABLE_FILTER)) { + if (filter.equals(FileExtRootFilter.TSK_DOCUMENT_FILTER) || filter.equals(FileExtRootFilter.TSK_EXECUTABLE_FILTER)) { return getClass().getName() + filter.getName(); } return getClass().getName(); @@ -280,10 +281,10 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { } - private class FileTypesByExtNodeChildren extends ChildFactory { + private class FileTypesByExtNodeChildren extends ChildFactory { private final SleuthkitCase skCase; - private final RootFilter filter; + private final FileExtRootFilter filter; private final FileTypesByExtObservable notifier; /** @@ -293,7 +294,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { * @param o Observable that provides updates based on events being * fired (or null if one needs to be created) */ - private FileTypesByExtNodeChildren(SleuthkitCase skCase, RootFilter filter, FileTypesByExtObservable o) { + private FileTypesByExtNodeChildren(SleuthkitCase skCase, FileExtRootFilter filter, FileTypesByExtObservable o) { super(); this.skCase = skCase; this.filter = filter; @@ -305,26 +306,26 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { } @Override - protected boolean createKeys(List list) { + protected boolean createKeys(List list) { // root node if (filter == null) { - list.addAll(Arrays.asList(RootFilter.values())); + list.addAll(Arrays.asList(FileExtRootFilter.values())); } // document and executable has another level of nodes - else if (filter.equals(RootFilter.TSK_DOCUMENT_FILTER)) { - list.addAll(Arrays.asList(DocumentFilter.values())); - } else if (filter.equals(RootFilter.TSK_EXECUTABLE_FILTER)) { - list.addAll(Arrays.asList(ExecutableFilter.values())); + else if (filter.equals(FileExtRootFilter.TSK_DOCUMENT_FILTER)) { + list.addAll(Arrays.asList(FileExtDocumentFilter.values())); + } else if (filter.equals(FileExtRootFilter.TSK_EXECUTABLE_FILTER)) { + list.addAll(Arrays.asList(FileExtExecutableFilter.values())); } return true; } @Override - protected Node createNodeForKey(SearchFilterInterface key) { + protected Node createNodeForKey(FileExtSearchFilter key) { // make new nodes for the sub-nodes - if (key.getName().equals(RootFilter.TSK_DOCUMENT_FILTER.getName())) { - return new FileTypesByExtNode(skCase, RootFilter.TSK_DOCUMENT_FILTER, notifier); - } else if (key.getName().equals(RootFilter.TSK_EXECUTABLE_FILTER.getName())) { - return new FileTypesByExtNode(skCase, RootFilter.TSK_EXECUTABLE_FILTER, notifier); + if (key.getName().equals(FileExtRootFilter.TSK_DOCUMENT_FILTER.getName())) { + return new FileTypesByExtNode(skCase, FileExtRootFilter.TSK_DOCUMENT_FILTER, notifier); + } else if (key.getName().equals(FileExtRootFilter.TSK_EXECUTABLE_FILTER.getName())) { + return new FileTypesByExtNode(skCase, FileExtRootFilter.TSK_EXECUTABLE_FILTER, notifier); } else { return new FileExtensionNode(key, skCase, notifier); } @@ -337,7 +338,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { */ final class FileExtensionNode extends FileTypes.BGCountUpdatingNode { - private final SearchFilterInterface filter; + private final FileExtSearchFilter filter; /** * @@ -346,10 +347,10 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { * @param o Observable that sends updates when the child factories * should refresh */ - FileExtensionNode(SearchFilterInterface filter, SleuthkitCase skCase, FileTypesByExtObservable o) { + FileExtensionNode(FileExtSearchFilter filter, SleuthkitCase skCase, FileTypesByExtObservable o) { super(typesRoot, Children.LEAF, Lookups.fixed(filter.getDisplayName(), - new FileTypeExtensionsKeyv2( + new FileTypeExtensionsSearchParam( filter, filteringDataSourceObjId() > 0 ? filteringDataSourceObjId() : null, !UserPreferences.hideKnownFilesInViewsTree()))); @@ -417,7 +418,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { } } - private String createQuery(SearchFilterInterface filter) { + private String createQuery(FileExtSearchFilter filter) { if (filter.getFilter().isEmpty()) { // We should never be given a search filter without extensions // but if we are it is clearly a programming error so we throw diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java b/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java deleted file mode 100644 index d6127069a6..0000000000 --- a/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultChildFactory.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.RowResultDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; - -/** - * - * @author gregd - */ -public class SearchResultChildFactory, S extends RowResultDTO> extends ChildFactory> { - - private final NodeCreator nodeCreator; - private T results; - - public SearchResultChildFactory(NodeCreator nodeCreator, T initialResults) { - this.nodeCreator = nodeCreator; - 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 this.nodeCreator.create(key.getSearchResults(), key.getChild()); - } - - public void update(T newResults) { - this.results = newResults; - this.refresh(false); - } - - public long getResultCount() { - return results == null ? 0 : results.getTotalResultsCount(); - } - - - - - public static interface NodeCreator, S extends RowResultDTO> { - Node create(T searchResults, S itemData); - } - - 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 deleted file mode 100644 index 99b00d94cb..0000000000 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDAO.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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 com.google.common.collect.ImmutableList; -import java.util.Arrays; -import java.util.List; -import org.openide.util.NbBundle.Messages; - -public class ThreePanelDAO { - private static ThreePanelDAO instance = null; - - public synchronized static ThreePanelDAO getInstance() { - if (instance == null) { - instance = new ThreePanelDAO(); - } - - return instance; - } - - private final ThreePanelDataArtifactDAO dataArtifactDAO = ThreePanelDataArtifactDAO.getInstance(); - private final ThreePanelViewsDAO viewsDAO = ThreePanelViewsDAO.getInstance(); - - public ThreePanelDataArtifactDAO getDataArtifactsDAO() { - return dataArtifactDAO; - } - - public ThreePanelViewsDAO getViewsDAO() { - return viewsDAO; - } - - - public static class ColumnKey { - - private final String fieldName; - private final String displayName; - private final String description; - - public ColumnKey(String fieldName, String displayName, String description) { - this.fieldName = fieldName; - this.displayName = displayName; - this.description = description; - } - - public String getFieldName() { - return fieldName; - } - - public String getDisplayName() { - return displayName; - } - - public String getDescription() { - return description; - } - } - - public interface RowResultDTO { - - List getCellValues(); - - long getId(); - } - - public static class BaseRowResultDTO implements RowResultDTO { - - private final List cellValues; - private final long id; - - public BaseRowResultDTO(List cellValues, long id) { - this.cellValues = cellValues; - this.id = id; - } - - @Override - public List getCellValues() { - return cellValues; - } - - @Override - public long getId() { - return id; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 23 * 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 BaseRowResultDTO other = (BaseRowResultDTO) obj; - if (this.id != other.id) { - return false; - } - return true; - } - } - - @Messages({ - "CountsRowResultDTO_columns_displayName_name=displayName", - "CountsRowResultDTO_columns_displayName_displayName=Name", - "CountsRowResultDTO_columns_displayName_description=Name", - "CountsRowResultDTO_columns_count_name=displayName", - "CountsRowResultDTO_columns_count_displayName=Name", - "CountsRowResultDTO_columns_count_description=Name",}) - public static class CountsRowResultDTO implements RowResultDTO { - - public static ColumnKey DISPLAY_NAME_COL = new ColumnKey( - Bundle.CountsRowResultDTO_columns_displayName_name(), - Bundle.CountsRowResultDTO_columns_displayName_displayName(), - Bundle.CountsRowResultDTO_columns_displayName_description() - ); - - public static ColumnKey COUNT_COL = new ColumnKey( - Bundle.CountsRowResultDTO_columns_count_name(), - Bundle.CountsRowResultDTO_columns_count_displayName(), - Bundle.CountsRowResultDTO_columns_count_description() - ); - - private final long id; - private final String displayName; - private final long count; - private final List cellValues; - - public CountsRowResultDTO(long id, String displayName, long count) { - this.id = id; - this.displayName = displayName; - this.count = count; - this.cellValues = ImmutableList.of(Arrays.asList(displayName, count)); - } - - @Override - public long getId() { - return id; - } - - public String getDisplayName() { - return displayName; - } - - public long getCount() { - return count; - } - - @Override - public List getCellValues() { - return cellValues; - } - } - - public static interface SearchResultsDTO { - - String getTypeId(); - - String getDisplayName(); - - List getColumns(); - - List getItems(); - - long getTotalResultsCount(); - } - - public static class BaseSearchResultsDTO implements SearchResultsDTO { - - private final String typeId; - private final String displayName; - private final List columns; - private final List items; - private final long totalResultsCount; - - public BaseSearchResultsDTO(String typeId, String displayName, List columns, List items) { - this(typeId, displayName, columns, items, items == null ? 0 : items.size()); - } - - public BaseSearchResultsDTO(String typeId, String displayName, List columns, List items, long totalResultsCount) { - this.typeId = typeId; - this.displayName = displayName; - this.columns = columns; - this.items = items; - this.totalResultsCount = totalResultsCount; - } - - @Override - public String getTypeId() { - return typeId; - } - - @Override - public String getDisplayName() { - return displayName; - } - - @Override - public List getColumns() { - return columns; - } - - @Override - public List getItems() { - return items; - } - - @Override - public long getTotalResultsCount() { - return totalResultsCount; - } - - } -} diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/TskContentItem.java b/Core/src/org/sleuthkit/autopsy/datamodel/TskContentItem.java index 21652c85d9..775ab7ddef 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/TskContentItem.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/TskContentItem.java @@ -42,7 +42,7 @@ public class TskContentItem { * */ @Beta - TskContentItem(T content) { + public TskContentItem(T content) { this.content = content; } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java b/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java deleted file mode 100644 index ec4c8b153c..0000000000 --- a/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNodev2.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import javax.swing.Action; -import org.openide.nodes.AbstractNode; -import org.openide.nodes.Sheet; -import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; -import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; -import org.sleuthkit.datamodel.Volume; -import org.sleuthkit.autopsy.directorytree.FileSystemDetailsAction; -import org.sleuthkit.datamodel.TskData; -import org.sleuthkit.datamodel.TskData.TSK_VS_PART_FLAG_ENUM; - -/** - * 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 Volume volume; - private final long id; - private final long addr; - private final long start; - private final long length; - private final String description; - private final boolean contiguousVolume; // based on vol.getParent() != null && vol.getParent().getParent() instanceof Pool - private final TskData.TSK_VS_PART_FLAG_ENUM partitionFlag; // see Volume.vsFlagToString - - public VolumeTableDTO(Volume volume, long id, long addr, long start, long length, String description, boolean contiguousVolume, TSK_VS_PART_FLAG_ENUM partitionFlag) { - this.volume = volume; - this.id = id; - this.addr = addr; - this.start = start; - this.length = length; - this.description = description; - this.contiguousVolume = contiguousVolume; - this.partitionFlag = partitionFlag; - } - - - public long getAddr() { - return addr; - } - - public long getStart() { - return start; - } - - public long getLength() { - return length; - } - - public String getDescription() { - return description; - } - - public boolean isContiguousVolume() { - return contiguousVolume; - } - - public TSK_VS_PART_FLAG_ENUM getPartitionFlag() { - return partitionFlag; - } - - public long getId() { - return id; - } - - public Volume getVolume() { - return volume; - } - - } - - private final VolumeTableDTO volData; - - /** - * - * @param vol underlying Content instance - */ - public VolumeNodev2(VolumeTableDTO vol) { - super(ContentNodeUtilv2.getChildren(vol.getId()), ContentNodeUtilv2.getLookup(vol.getVolume())); - setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); - setDisplayName(getDisplayName(vol)); - setName(ContentNodeUtilv2.getContentName(vol.getId())); - this.volData = vol; - - } - - private String getDisplayName(VolumeTableDTO vol) { - // set name, display name, and icon - String volName = "vol" + Long.toString(vol.getAddr()); - long end = vol.getStart() + (vol.getLength() - 1); - return vol.isContiguousVolume() - ? volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")" - : volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")"; - } - - /** - * Right click action for volume node - * - * @param popup - * - * @return - */ - @Override - public Action[] getActions(boolean popup) { - List actionsList = new ArrayList<>(); - actionsList.add(new FileSystemDetailsAction(volData.getVolume())); - actionsList.add(new NewWindowViewAction( - NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this)); - actionsList.addAll(ExplorerNodeActionVisitor.getActions(volData.getVolume())); - 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"), - volData.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"), - volData.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"), - volData.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"), - volData.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"), - Volume.vsFlagToString(volData.getPartitionFlag().getVsFlag()))); - - return sheet; - } -} diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java index d0d4a3563d..2505abd2fd 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java @@ -82,9 +82,9 @@ import org.sleuthkit.autopsy.datamodel.EmptyNode; import org.sleuthkit.autopsy.datamodel.FileTypesByMimeType; import org.sleuthkit.autopsy.datamodel.KeywordHits; import org.sleuthkit.autopsy.datamodel.AutopsyTreeChildFactory; -import org.sleuthkit.autopsy.datamodel.DataArtifactKeyv2; +import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactSearchParam; import org.sleuthkit.autopsy.datamodel.DataArtifacts; -import org.sleuthkit.autopsy.datamodel.FileTypeExtensionsKeyv2; +import org.sleuthkit.autopsy.mainui.datamodel.FileTypeExtensionsSearchParam; import org.sleuthkit.autopsy.datamodel.OsAccounts; import org.sleuthkit.autopsy.datamodel.PersonNode; import org.sleuthkit.autopsy.datamodel.Tags; @@ -871,8 +871,8 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat //set node, wrap in filter node first to filter out children Node drfn = new DataResultFilterNode(originNode, DirectoryTreeTopComponent.this.em); // Create a TableFilterNode with knowledge of the node's type to allow for column order settings - DataArtifactKeyv2 dataArtifactKey = originNode.getLookup().lookup(DataArtifactKeyv2.class); - FileTypeExtensionsKeyv2 fileExtensionsKey = originNode.getLookup().lookup(FileTypeExtensionsKeyv2.class); + DataArtifactSearchParam dataArtifactKey = originNode.getLookup().lookup(DataArtifactSearchParam.class); + FileTypeExtensionsSearchParam fileExtensionsKey = originNode.getLookup().lookup(FileTypeExtensionsSearchParam.class); if (dataArtifactKey != null) { dataResult.displayDataArtifact(dataArtifactKey); } else if (fileExtensionsKey != null) { diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/BaseRowResultDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/BaseRowResultDTO.java new file mode 100644 index 0000000000..1d3214a480 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/BaseRowResultDTO.java @@ -0,0 +1,78 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; + +/** + * Base implementation for a row result. + */ +public class BaseRowResultDTO implements RowResultDTO { + + private final List cellValues; + private final long id; + private final String typeId; + + public BaseRowResultDTO(List cellValues, String typeId, long id) { + this.cellValues = cellValues; + this.id = id; + this.typeId = typeId; + } + + @Override + public List getCellValues() { + return cellValues; + } + + @Override + public long getId() { + return id; + } + + @Override + public String getTypeId() { + return typeId; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 23 * 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 BaseRowResultDTO other = (BaseRowResultDTO) obj; + if (this.id != other.id) { + return false; + } + return true; + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/BaseSearchResultsDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/BaseSearchResultsDTO.java new file mode 100644 index 0000000000..cda5fa2b32 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/BaseSearchResultsDTO.java @@ -0,0 +1,77 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; + +/** + * Base implementation for a series of results to be displayed in the results viewer. + */ +public class BaseSearchResultsDTO implements SearchResultsDTO { + + private final String typeId; + private final String displayName; + private final List columns; + private final List items; + private final long totalResultsCount; + private final long startItem; + + public BaseSearchResultsDTO(String typeId, String displayName, List columns, List items) { + this(typeId, displayName, columns, items, 0, items == null ? 0 : items.size()); + } + + public BaseSearchResultsDTO(String typeId, String displayName, List columns, List items, long startItem, long totalResultsCount) { + this.typeId = typeId; + this.displayName = displayName; + this.columns = columns; + this.items = items; + this.startItem = startItem; + this.totalResultsCount = totalResultsCount; + } + + @Override + public String getTypeId() { + return typeId; + } + + @Override + public String getDisplayName() { + return displayName; + } + + @Override + public List getColumns() { + return columns; + } + + @Override + public List getItems() { + return items; + } + + @Override + public long getTotalResultsCount() { + return totalResultsCount; + } + + @Override + public long getStartItem() { + return startItem; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ColumnKey.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ColumnKey.java new file mode 100644 index 0000000000..b46aa658c9 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ColumnKey.java @@ -0,0 +1,49 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +/** + * Describes a column to be displayed in the results table including the display + * name and description. + */ +public class ColumnKey { + + private final String fieldName; + private final String displayName; + private final String description; + + public ColumnKey(String fieldName, String displayName, String description) { + this.fieldName = fieldName; + this.displayName = displayName; + this.description = description; + } + + public String getFieldName() { + return fieldName; + } + + public String getDisplayName() { + return displayName; + } + + public String getDescription() { + return description; + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/CountsRowResultDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/CountsRowResultDTO.java new file mode 100644 index 0000000000..9088e3a64a --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/CountsRowResultDTO.java @@ -0,0 +1,92 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import com.google.common.collect.ImmutableList; +import java.util.Arrays; +import java.util.List; +import org.openide.util.NbBundle.Messages; + +/** + * + * A row result providing a category and a count for that category. + */ +@Messages({ + "CountsRowResultDTO_columns_displayName_name=displayName", + "CountsRowResultDTO_columns_displayName_displayName=Name", + "CountsRowResultDTO_columns_displayName_description=Name", + "CountsRowResultDTO_columns_count_name=displayName", + "CountsRowResultDTO_columns_count_displayName=Name", + "CountsRowResultDTO_columns_count_description=Name" +}) +public class CountsRowResultDTO implements RowResultDTO { + + private static final String DEFAULT_TYPE_ID = "COUNTS"; + + public static ColumnKey DISPLAY_NAME_COL = new ColumnKey( + Bundle.CountsRowResultDTO_columns_displayName_name(), + Bundle.CountsRowResultDTO_columns_displayName_displayName(), + Bundle.CountsRowResultDTO_columns_displayName_description()); + + public static ColumnKey COUNT_COL = new ColumnKey( + Bundle.CountsRowResultDTO_columns_count_name(), + Bundle.CountsRowResultDTO_columns_count_displayName(), + Bundle.CountsRowResultDTO_columns_count_description()); + + private final long id; + private final String displayName; + private final long count; + private final List cellValues; + private final String typeId; + + public CountsRowResultDTO(long id, String displayName, long count) { + this(DEFAULT_TYPE_ID, id, displayName, count); + } + + public CountsRowResultDTO(String typeId, long id, String displayName, long count) { + this.typeId = typeId; + this.id = id; + this.displayName = displayName; + this.count = count; + this.cellValues = ImmutableList.of(Arrays.asList(displayName, count)); + } + + @Override + public long getId() { + return id; + } + + public String getDisplayName() { + return displayName; + } + + public long getCount() { + return count; + } + + @Override + public List getCellValues() { + return cellValues; + } + + @Override + public String getTypeId() { + return typeId; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactKeyv2.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactSearchParam.java similarity index 54% rename from Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactKeyv2.java rename to Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactSearchParam.java index 6a64b447bb..7abee2ba2e 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactKeyv2.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactSearchParam.java @@ -1,22 +1,34 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 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; +package org.sleuthkit.autopsy.mainui.datamodel; import java.util.Objects; import org.sleuthkit.datamodel.BlackboardArtifact; /** - * - * @author gregd + * Key for data artifact in order to retrieve data from DAO. */ -public class DataArtifactKeyv2 { +public class DataArtifactSearchParam { private final BlackboardArtifact.Type artifactType; private final Long dataSourceId; - public DataArtifactKeyv2(BlackboardArtifact.Type artifactType, Long dataSourceId) { + public DataArtifactSearchParam(BlackboardArtifact.Type artifactType, Long dataSourceId) { this.artifactType = artifactType; this.dataSourceId = dataSourceId; } @@ -48,7 +60,7 @@ public class DataArtifactKeyv2 { if (getClass() != obj.getClass()) { return false; } - final DataArtifactKeyv2 other = (DataArtifactKeyv2) obj; + final DataArtifactSearchParam other = (DataArtifactSearchParam) obj; if (!Objects.equals(this.artifactType, other.artifactType)) { return false; } diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactTableDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactTableDTO.java new file mode 100644 index 0000000000..79409c7bb8 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactTableDTO.java @@ -0,0 +1,65 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; +import org.sleuthkit.datamodel.Content; +import org.sleuthkit.datamodel.DataArtifact; + +/** + * A result for a data artifact. + */ +public class DataArtifactTableDTO extends BaseRowResultDTO { + + private static final String TYPE_ID = "DATA_ARTIFACT"; + + public static String getTypeIdForClass() { + return TYPE_ID; + } + + + final DataArtifact dataArtifact; + final Content srcContent; + final Content linkedFile; + final boolean isTimelineSupported; + + public DataArtifactTableDTO(DataArtifact dataArtifact, Content srcContent, Content linkedFile, boolean isTimelineSupported, List cellValues, long id) { + super(cellValues, TYPE_ID, id); + this.dataArtifact = dataArtifact; + this.srcContent = srcContent; + this.linkedFile = linkedFile; + this.isTimelineSupported = isTimelineSupported; + } + + public DataArtifact getDataArtifact() { + return dataArtifact; + } + + public Content getSrcContent() { + return srcContent; + } + + public Content getLinkedFile() { + return linkedFile; + } + + public boolean isIsTimelineSupported() { + return isTimelineSupported; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactTableSearchResultsDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactTableSearchResultsDTO.java new file mode 100644 index 0000000000..ff6ccfca37 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/DataArtifactTableSearchResultsDTO.java @@ -0,0 +1,41 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; +import org.sleuthkit.datamodel.BlackboardArtifact; + +/** + * Search results for data artifacts. + */ +public class DataArtifactTableSearchResultsDTO extends BaseSearchResultsDTO { + + private static final String TYPE_ID = "DATA_ARTIFACT"; + + private final BlackboardArtifact.Type artifactType; + + public DataArtifactTableSearchResultsDTO(BlackboardArtifact.Type artifactType, List columns, List items) { + super(TYPE_ID, artifactType.getDisplayName(), columns, items); + this.artifactType = artifactType; + } + + public BlackboardArtifact.Type getArtifactType() { + return artifactType; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtDocumentFilter.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtDocumentFilter.java new file mode 100644 index 0000000000..e0acc427d1 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtDocumentFilter.java @@ -0,0 +1,70 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.datamodel.FileTypesByExtension; + + +/** + * Document sub-node filters + */ +public enum FileExtDocumentFilter implements FileExtSearchFilter { + AUT_DOC_HTML(0, "AUT_DOC_HTML", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocHtmlFilter.text"), Arrays.asList(".htm", ".html")), //NON-NLS + AUT_DOC_OFFICE(1, "AUT_DOC_OFFICE", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocOfficeFilter.text"), Arrays.asList(".doc", ".docx", ".odt", ".xls", ".xlsx", ".ppt", ".pptx")), //NON-NLS + AUT_DOC_PDF(2, "AUT_DOC_PDF", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autoDocPdfFilter.text"), Arrays.asList(".pdf")), //NON-NLS + AUT_DOC_TXT(3, "AUT_DOC_TXT", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocTxtFilter.text"), Arrays.asList(".txt")), //NON-NLS + AUT_DOC_RTF(4, "AUT_DOC_RTF", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocRtfFilter.text"), Arrays.asList(".rtf")); + //NON-NLS + final int id; + final String name; + final String displayName; + final List filter; + + private FileExtDocumentFilter(int id, String name, String displayName, List filter) { + this.id = id; + this.name = name; + this.displayName = displayName; + this.filter = filter; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public int getId() { + return this.id; + } + + @Override + public String getDisplayName() { + return this.displayName; + } + + @Override + public List getFilter() { + return Collections.unmodifiableList(this.filter); + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtExecutableFilter.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtExecutableFilter.java new file mode 100644 index 0000000000..b7a3f2bad1 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtExecutableFilter.java @@ -0,0 +1,67 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Executable sub-node filters. + */ +public enum FileExtExecutableFilter implements FileExtSearchFilter { + ExecutableFilter_EXE(0, "ExecutableFilter_EXE", ".exe", Arrays.asList(".exe")), //NON-NLS + ExecutableFilter_DLL(1, "ExecutableFilter_DLL", ".dll", Arrays.asList(".dll")), //NON-NLS + ExecutableFilter_BAT(2, "ExecutableFilter_BAT", ".bat", Arrays.asList(".bat")), //NON-NLS + ExecutableFilter_CMD(3, "ExecutableFilter_CMD", ".cmd", Arrays.asList(".cmd")), //NON-NLS + ExecutableFilter_COM(4, "ExecutableFilter_COM", ".com", Arrays.asList(".com")); + //NON-NLS + final int id; + final String name; + final String displayName; + final List filter; + + private FileExtExecutableFilter(int id, String name, String displayName, List filter) { + this.id = id; + this.name = name; + this.displayName = displayName; + this.filter = filter; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public int getId() { + return this.id; + } + + @Override + public String getDisplayName() { + return this.displayName; + } + + @Override + public List getFilter() { + return Collections.unmodifiableList(this.filter); + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtRootFilter.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtRootFilter.java new file mode 100644 index 0000000000..9e50ab8482 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtRootFilter.java @@ -0,0 +1,68 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.datamodel.FileTypeExtensions; +import org.sleuthkit.autopsy.datamodel.FileTypesByExtension; + +/** + * Root node filters + */ +@NbBundle.Messages(value = {"FileTypeExtensionFilters.tskDatabaseFilter.text=Databases"}) +public enum FileExtRootFilter implements FileExtSearchFilter { + TSK_IMAGE_FILTER(0, "TSK_IMAGE_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskImgFilter.text"), FileTypeExtensions.getImageExtensions()), TSK_VIDEO_FILTER(1, "TSK_VIDEO_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskVideoFilter.text"), FileTypeExtensions.getVideoExtensions()), TSK_AUDIO_FILTER(2, "TSK_AUDIO_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskAudioFilter.text"), FileTypeExtensions.getAudioExtensions()), TSK_ARCHIVE_FILTER(3, "TSK_ARCHIVE_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskArchiveFilter.text"), FileTypeExtensions.getArchiveExtensions()), TSK_DATABASE_FILTER(4, "TSK_DATABASE_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskDatabaseFilter.text"), FileTypeExtensions.getDatabaseExtensions()), TSK_DOCUMENT_FILTER(5, "TSK_DOCUMENT_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskDocumentFilter.text"), Arrays.asList(".htm", ".html", ".doc", ".docx", ".odt", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".rtf")), //NON-NLS + TSK_EXECUTABLE_FILTER(6, "TSK_EXECUTABLE_FILTER", NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskExecFilter.text"), FileTypeExtensions.getExecutableExtensions()); + //NON-NLS + final int id; + final String name; + final String displayName; + final List filter; + + private FileExtRootFilter(int id, String name, String displayName, List filter) { + this.id = id; + this.name = name; + this.displayName = displayName; + this.filter = filter; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public int getId() { + return this.id; + } + + @Override + public String getDisplayName() { + return this.displayName; + } + + @Override + public List getFilter() { + return Collections.unmodifiableList(this.filter); + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtSearchFilter.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtSearchFilter.java new file mode 100644 index 0000000000..7fcbecfae5 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileExtSearchFilter.java @@ -0,0 +1,36 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; + +/** + * Interface for filters by file extensions. + */ +public interface FileExtSearchFilter { + + public String getName(); + + public int getId(); + + public String getDisplayName(); + + public List getFilter(); + +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileRowDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileRowDTO.java new file mode 100644 index 0000000000..c4078b7e06 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileRowDTO.java @@ -0,0 +1,87 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; +import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.datamodel.TskData; + +/** + * DTO Representing an abstract file in the results view. + */ +public class FileRowDTO extends BaseRowResultDTO { + + public enum ExtensionMediaType { + IMAGE, VIDEO, AUDIO, DOC, EXECUTABLE, TEXT, WEB, PDF, ARCHIVE, UNCATEGORIZED + } + + private static String TYPE_ID = "FILE"; + + public static String getTypeIdForClass() { + return TYPE_ID; + } + + final AbstractFile abstractFile; + final String fileName; + final String extension; + final ExtensionMediaType extensionMediaType; + final boolean allocated; + final TskData.TSK_DB_FILES_TYPE_ENUM fileType; + final boolean encryptionDetected; + + public FileRowDTO(AbstractFile abstractFile, long id, String fileName, String extension, ExtensionMediaType extensionMediaType, boolean allocated, TskData.TSK_DB_FILES_TYPE_ENUM fileType, boolean encryptionDetected, List cellValues) { + super(cellValues, TYPE_ID, id); + this.abstractFile = abstractFile; + this.fileName = fileName; + this.extension = extension; + this.extensionMediaType = extensionMediaType; + this.allocated = allocated; + this.fileType = fileType; + this.encryptionDetected = encryptionDetected; + } + + public ExtensionMediaType getExtensionMediaType() { + return extensionMediaType; + } + + public boolean getAllocated() { + return allocated; + } + + public TskData.TSK_DB_FILES_TYPE_ENUM getFileType() { + return fileType; + } + + public AbstractFile getAbstractFile() { + return abstractFile; + } + + public String getExtension() { + return extension; + } + + public boolean isEncryptionDetected() { + return encryptionDetected; + } + + public String getFileName() { + return fileName; + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypeExtensionsKeyv2.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileTypeExtensionsSearchParam.java similarity index 54% rename from Core/src/org/sleuthkit/autopsy/datamodel/FileTypeExtensionsKeyv2.java rename to Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileTypeExtensionsSearchParam.java index 01755d4384..b3d43ba8fb 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypeExtensionsKeyv2.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileTypeExtensionsSearchParam.java @@ -1,30 +1,42 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 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; +package org.sleuthkit.autopsy.mainui.datamodel; import java.util.Objects; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.SearchFilterInterface; /** - * - * @author gregd + * Key for accessing data about file type extensions from the DAO. */ -public class FileTypeExtensionsKeyv2 { - private final SearchFilterInterface filter; +public class FileTypeExtensionsSearchParam { + + private final FileExtSearchFilter filter; private final Long dataSourceId; private final boolean knownShown; // this assumes that filters implicitly or explicitly implement hashCode and equals to work - public FileTypeExtensionsKeyv2(SearchFilterInterface filter, Long dataSourceId, boolean showKnown) { + public FileTypeExtensionsSearchParam(FileExtSearchFilter filter, Long dataSourceId, boolean showKnown) { this.filter = filter; this.dataSourceId = dataSourceId; this.knownShown = showKnown; } - public SearchFilterInterface getFilter() { + public FileExtSearchFilter getFilter() { return filter; } @@ -56,7 +68,7 @@ public class FileTypeExtensionsKeyv2 { if (getClass() != obj.getClass()) { return false; } - final FileTypeExtensionsKeyv2 other = (FileTypeExtensionsKeyv2) obj; + final FileTypeExtensionsSearchParam other = (FileTypeExtensionsSearchParam) obj; if (this.knownShown != other.knownShown) { return false; } @@ -68,6 +80,5 @@ public class FileTypeExtensionsKeyv2 { } return true; } - - + } diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/RowResultDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/RowResultDTO.java new file mode 100644 index 0000000000..14f768ec9f --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/RowResultDTO.java @@ -0,0 +1,33 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; + +/** + * DTO representing an individual row in search results. + */ +public interface RowResultDTO { + + List getCellValues(); + + long getId(); + + String getTypeId(); +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/SearchResultsDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/SearchResultsDTO.java new file mode 100644 index 0000000000..c0dbab4d9d --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/SearchResultsDTO.java @@ -0,0 +1,40 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +import java.util.List; + +/** + * + * @author gregd + */ +public interface SearchResultsDTO { + + String getTypeId(); + + String getDisplayName(); + + List getColumns(); + + List getItems(); + + long getTotalResultsCount(); + + long getStartItem(); +} diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelDAO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelDAO.java new file mode 100644 index 0000000000..3d18b8f481 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelDAO.java @@ -0,0 +1,47 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.datamodel; + +/** + * Main entry point for DAO for providing data to populate the data results + * viewer. + */ +public class ThreePanelDAO { + + private static ThreePanelDAO instance = null; + + public synchronized static ThreePanelDAO getInstance() { + if (instance == null) { + instance = new ThreePanelDAO(); + } + + return instance; + } + + private final ThreePanelDataArtifactDAO dataArtifactDAO = ThreePanelDataArtifactDAO.getInstance(); + private final ThreePanelViewsDAO viewsDAO = ThreePanelViewsDAO.getInstance(); + + public ThreePanelDataArtifactDAO getDataArtifactsDAO() { + return dataArtifactDAO; + } + + public ThreePanelViewsDAO getViewsDAO() { + return viewsDAO; + } +} diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDataArtifactDAO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelDataArtifactDAO.java similarity index 84% rename from Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDataArtifactDAO.java rename to Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelDataArtifactDAO.java index 3bcaad5342..d903f3873b 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelDataArtifactDAO.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelDataArtifactDAO.java @@ -1,9 +1,22 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 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; +package org.sleuthkit.autopsy.mainui.datamodel; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -22,9 +35,6 @@ import java.util.stream.Collectors; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.BaseRowResultDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.BaseSearchResultsDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.ColumnKey; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Blackboard; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -36,8 +46,7 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; /** - * - * @author gregd + * DAO for providing data about data artifacts to populate the results viewer. */ @Messages({ "ThreePanelDataArtifactDAO.dataArtifact.columnKeys.srcFile.name=Source Name", @@ -110,7 +119,7 @@ public class ThreePanelDataArtifactDAO { private static ThreePanelDataArtifactDAO instance = null; - public synchronized static ThreePanelDataArtifactDAO getInstance() { + synchronized static ThreePanelDataArtifactDAO getInstance() { if (instance == null) { instance = new ThreePanelDataArtifactDAO(); } @@ -118,13 +127,13 @@ public class ThreePanelDataArtifactDAO { return instance; } - private final Cache dataArtifactCache = CacheBuilder.newBuilder().maximumSize(1000).build(); + private final Cache dataArtifactCache = CacheBuilder.newBuilder().maximumSize(1000).build(); private SleuthkitCase getCase() throws NoCurrentCaseException { return Case.getCurrentCaseThrows().getSleuthkitCase(); } - private DataArtifactTableSearchResultsDTO fetchDataArtifactsForTable(DataArtifactKeyv2 cacheKey) throws NoCurrentCaseException, TskCoreException { + private DataArtifactTableSearchResultsDTO fetchDataArtifactsForTable(DataArtifactSearchParam cacheKey) throws NoCurrentCaseException, TskCoreException { SleuthkitCase skCase = getCase(); Blackboard blackboard = skCase.getBlackboard(); @@ -165,7 +174,7 @@ public class ThreePanelDataArtifactDAO { columnKeys.add(DATASOURCE_COL); // determine all different attribute types present as well as row data for each artifact - List rows = new ArrayList<>(); + List rows = new ArrayList<>(); for (DataArtifact artifact : arts) { List cellValues = new ArrayList<>(); @@ -300,7 +309,7 @@ public class ThreePanelDataArtifactDAO { } } - public DataArtifactTableSearchResultsDTO getDataArtifactsForTable(DataArtifactKeyv2 artifactKey) throws ExecutionException, IllegalArgumentException { + public DataArtifactTableSearchResultsDTO getDataArtifactsForTable(DataArtifactSearchParam artifactKey) throws ExecutionException, IllegalArgumentException { BlackboardArtifact.Type artType = artifactKey.getArtifactType(); if (artType == null || artType.getCategory() != BlackboardArtifact.Category.DATA_ARTIFACT @@ -316,55 +325,4 @@ public class ThreePanelDataArtifactDAO { public void dropDataArtifactCache() { dataArtifactCache.invalidateAll(); } - - public static class DataArtifactTableDTO extends BaseRowResultDTO { - - //private final Map attributeValues; - //private final String dataSourceName; - private final DataArtifact dataArtifact; - private final Content srcContent; - private final Content linkedFile; - private final boolean isTimelineSupported; - - public DataArtifactTableDTO(DataArtifact dataArtifact, Content srcContent, Content linkedFile, boolean isTimelineSupported, List cellValues, long id) { - super(cellValues, id); - this.dataArtifact = dataArtifact; - this.srcContent = srcContent; - this.linkedFile = linkedFile; - this.isTimelineSupported = isTimelineSupported; - } - - public DataArtifact getDataArtifact() { - return dataArtifact; - } - - public Content getSrcContent() { - return srcContent; - } - - public Content getLinkedFile() { - return linkedFile; - } - - public boolean isIsTimelineSupported() { - return isTimelineSupported; - } - - } - - public static class DataArtifactTableSearchResultsDTO extends BaseSearchResultsDTO { - - private static final String TYPE_ID = "DATA_ARTIFACT"; - - private final BlackboardArtifact.Type artifactType; - - public DataArtifactTableSearchResultsDTO(BlackboardArtifact.Type artifactType, List columns, List items) { - super(TYPE_ID, artifactType.getDisplayName(), columns, items); - this.artifactType = artifactType; - } - - public BlackboardArtifact.Type getArtifactType() { - return artifactType; - } - } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelViewsDAO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelViewsDAO.java similarity index 52% rename from Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelViewsDAO.java rename to Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelViewsDAO.java index 091635dd52..69e0037170 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ThreePanelViewsDAO.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/ThreePanelViewsDAO.java @@ -1,36 +1,49 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 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; +package org.sleuthkit.autopsy.mainui.datamodel; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; -import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.BaseRowResultDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.BaseSearchResultsDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.ColumnKey; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.datamodel.FileTypeExtensions; +import org.sleuthkit.autopsy.mainui.datamodel.FileRowDTO.ExtensionMediaType; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +/** + * Provides information to populate the results viewer for data in the views + * section. + */ @Messages({"ThreePanelViewsDAO.fileColumns.nameColLbl=Name", "ThreePanelViewsDAO.fileColumns.originalName=Original Name", "ThreePanelViewsDAO.fileColumns.scoreName=S", @@ -61,7 +74,7 @@ import org.sleuthkit.datamodel.TskData; public class ThreePanelViewsDAO { private static final String FILE_VIEW_EXT_TYPE_ID = "FILE_VIEW_BY_EXT"; - + private static final List FILE_COLUMNS = Arrays.asList( getFileColumnKey(Bundle.ThreePanelViewsDAO_fileColumns_nameColLbl()), getFileColumnKey(Bundle.ThreePanelViewsDAO_fileColumns_originalName()), @@ -92,7 +105,7 @@ public class ThreePanelViewsDAO { private static ThreePanelViewsDAO instance = null; - public synchronized static ThreePanelViewsDAO getInstance() { + synchronized static ThreePanelViewsDAO getInstance() { if (instance == null) { instance = new ThreePanelViewsDAO(); } @@ -137,18 +150,18 @@ public class ThreePanelViewsDAO { return Case.getCurrentCaseThrows().getSleuthkitCase(); } - private final Cache> fileTypeByExtensionCache = CacheBuilder.newBuilder().maximumSize(1000).build(); - - public SearchResultsDTO getFilesByExtension(FileTypeExtensionsKeyv2 key) throws ExecutionException, IllegalArgumentException { + private final Cache fileTypeByExtensionCache = CacheBuilder.newBuilder().maximumSize(1000).build(); + + public SearchResultsDTO getFilesByExtension(FileTypeExtensionsSearchParam key) throws ExecutionException, IllegalArgumentException { if (key.getFilter() == null) { throw new IllegalArgumentException("Must have non-null filter"); } else if (key.getDataSourceId() != null && key.getDataSourceId() <= 0) { throw new IllegalArgumentException("Data source id must be greater than 0 or null"); } - + return fileTypeByExtensionCache.get(key, () -> fetchFileViewFiles(key.getFilter(), key.getDataSourceId(), key.isKnownShown())); } - + // private ViewFileTableSearchResultsDTO fetchFilesForTable(ViewFileCacheKey cacheKey) throws NoCurrentCaseException, TskCoreException { // // } @@ -163,9 +176,9 @@ public class ThreePanelViewsDAO { // ViewFileCacheKey cacheKey = new ViewFileCacheKey(artType, dataSourceId); // return dataArtifactCache.get(cacheKey, () -> fetchFilesForTable(cacheKey)); // } - private Map fetchFileViewCounts(List filters, Long dataSourceId, boolean showKnown) throws NoCurrentCaseException, TskCoreException { + private Map fetchFileViewCounts(List filters, Long dataSourceId, boolean showKnown) throws NoCurrentCaseException, TskCoreException { Map counts = new HashMap<>(); - for (SearchFilterInterface filter : filters) { + for (FileExtSearchFilter filter : filters) { String whereClause = getFileWhereStatement(filter, dataSourceId, showKnown); long count = getCase().countFilesWhere(whereClause); counts.put(filter.getId(), count); @@ -174,7 +187,7 @@ public class ThreePanelViewsDAO { return counts; } - private String getFileWhereStatement(SearchFilterInterface filter, Long dataSourceId, boolean showKnown) { + private String getFileWhereStatement(FileExtSearchFilter filter, Long dataSourceId, boolean showKnown) { String whereClause = "(dir_type = " + TskData.TSK_FS_NAME_TYPE_ENUM.REG.getValue() + ")" + (showKnown ? " " @@ -189,11 +202,11 @@ public class ThreePanelViewsDAO { return whereClause; } - private SearchResultsDTO fetchFileViewFiles(SearchFilterInterface filter, Long dataSourceId, boolean showKnown) throws NoCurrentCaseException, TskCoreException { + private SearchResultsDTO fetchFileViewFiles(FileExtSearchFilter filter, Long dataSourceId, boolean showKnown) throws NoCurrentCaseException, TskCoreException { String whereStatement = getFileWhereStatement(filter, dataSourceId, showKnown); List files = getCase().findAllFilesWhere(whereStatement); - List fileRows = new ArrayList<>(); + List fileRows = new ArrayList<>(); for (AbstractFile file : files) { boolean encryptionDetected = FileTypeExtensions.getArchiveExtensions().contains("." + file.getNameExtension().toLowerCase()) @@ -233,240 +246,7 @@ public class ThreePanelViewsDAO { cellValues)); } - return new BaseSearchResultsDTO<>(FILE_VIEW_EXT_TYPE_ID, filter.getDisplayName(), FILE_COLUMNS, fileRows); + return new BaseSearchResultsDTO(FILE_VIEW_EXT_TYPE_ID, filter.getDisplayName(), FILE_COLUMNS, fileRows); } - // root node filters - @NbBundle.Messages({"FileTypeExtensionFilters.tskDatabaseFilter.text=Databases"}) - public static enum RootFilter implements SearchFilterInterface { - - TSK_IMAGE_FILTER(0, "TSK_IMAGE_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskImgFilter.text"), - FileTypeExtensions.getImageExtensions()), - TSK_VIDEO_FILTER(1, "TSK_VIDEO_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskVideoFilter.text"), - FileTypeExtensions.getVideoExtensions()), - TSK_AUDIO_FILTER(2, "TSK_AUDIO_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskAudioFilter.text"), - FileTypeExtensions.getAudioExtensions()), - TSK_ARCHIVE_FILTER(3, "TSK_ARCHIVE_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskArchiveFilter.text"), - FileTypeExtensions.getArchiveExtensions()), - TSK_DATABASE_FILTER(4, "TSK_DATABASE_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskDatabaseFilter.text"), - FileTypeExtensions.getDatabaseExtensions()), - TSK_DOCUMENT_FILTER(5, "TSK_DOCUMENT_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskDocumentFilter.text"), - Arrays.asList(".htm", ".html", ".doc", ".docx", ".odt", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".rtf")), //NON-NLS - TSK_EXECUTABLE_FILTER(6, "TSK_EXECUTABLE_FILTER", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.tskExecFilter.text"), - FileTypeExtensions.getExecutableExtensions()); //NON-NLS - - private final int id; - private final String name; - private final String displayName; - private final List filter; - - private RootFilter(int id, String name, String displayName, List filter) { - this.id = id; - this.name = name; - this.displayName = displayName; - this.filter = filter; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public int getId() { - return this.id; - } - - @Override - public String getDisplayName() { - return this.displayName; - } - - @Override - public List getFilter() { - return Collections.unmodifiableList(this.filter); - } - } - -// document sub-node filters - public static enum DocumentFilter implements SearchFilterInterface { - - AUT_DOC_HTML(0, "AUT_DOC_HTML", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocHtmlFilter.text"), - Arrays.asList(".htm", ".html")), //NON-NLS - AUT_DOC_OFFICE(1, "AUT_DOC_OFFICE", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocOfficeFilter.text"), - Arrays.asList(".doc", ".docx", ".odt", ".xls", ".xlsx", ".ppt", ".pptx")), //NON-NLS - AUT_DOC_PDF(2, "AUT_DOC_PDF", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autoDocPdfFilter.text"), - Arrays.asList(".pdf")), //NON-NLS - AUT_DOC_TXT(3, "AUT_DOC_TXT", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocTxtFilter.text"), - Arrays.asList(".txt")), //NON-NLS - AUT_DOC_RTF(4, "AUT_DOC_RTF", //NON-NLS - NbBundle.getMessage(FileTypesByExtension.class, "FileTypeExtensionFilters.autDocRtfFilter.text"), - Arrays.asList(".rtf")); //NON-NLS - - private final int id; - private final String name; - private final String displayName; - private final List filter; - - private DocumentFilter(int id, String name, String displayName, List filter) { - this.id = id; - this.name = name; - this.displayName = displayName; - this.filter = filter; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public int getId() { - return this.id; - } - - @Override - public String getDisplayName() { - return this.displayName; - } - - @Override - public List getFilter() { - return Collections.unmodifiableList(this.filter); - } - } - -// executable sub-node filters - public static enum ExecutableFilter implements SearchFilterInterface { - - ExecutableFilter_EXE(0, "ExecutableFilter_EXE", ".exe", Arrays.asList(".exe")), //NON-NLS - ExecutableFilter_DLL(1, "ExecutableFilter_DLL", ".dll", Arrays.asList(".dll")), //NON-NLS - ExecutableFilter_BAT(2, "ExecutableFilter_BAT", ".bat", Arrays.asList(".bat")), //NON-NLS - ExecutableFilter_CMD(3, "ExecutableFilter_CMD", ".cmd", Arrays.asList(".cmd")), //NON-NLS - ExecutableFilter_COM(4, "ExecutableFilter_COM", ".com", Arrays.asList(".com")); //NON-NLS - - private final int id; - private final String name; - private final String displayName; - private final List filter; - - private ExecutableFilter(int id, String name, String displayName, List filter) { - this.id = id; - this.name = name; - this.displayName = displayName; - this.filter = filter; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public int getId() { - return this.id; - } - - @Override - public String getDisplayName() { - return this.displayName; - } - - @Override - public List getFilter() { - return Collections.unmodifiableList(this.filter); - } - } - - public interface SearchFilterInterface { - - public String getName(); - - public int getId(); - - public String getDisplayName(); - - public List getFilter(); - - } - - public enum ExtensionMediaType { - IMAGE, - VIDEO, - AUDIO, - DOC, - EXECUTABLE, - TEXT, - WEB, - PDF, - ARCHIVE, - UNCATEGORIZED - } - - public static class FileRowDTO extends BaseRowResultDTO { - - private final AbstractFile abstractFile; - private final String fileName; - - private final String extension; - private final ExtensionMediaType extensionMediaType; - - private final boolean allocated; - private final TskData.TSK_DB_FILES_TYPE_ENUM fileType; - private final boolean encryptionDetected; - - public FileRowDTO(AbstractFile abstractFile, long id, String fileName, - String extension, ExtensionMediaType extensionMediaType, - boolean allocated, - TskData.TSK_DB_FILES_TYPE_ENUM fileType, - boolean encryptionDetected, List cellValues) { - super(cellValues, id); - this.abstractFile = abstractFile; - this.fileName = fileName; - this.extension = extension; - this.extensionMediaType = extensionMediaType; - this.allocated = allocated; - this.fileType = fileType; - this.encryptionDetected = encryptionDetected; - } - - public ExtensionMediaType getExtensionMediaType() { - return extensionMediaType; - } - - public boolean getAllocated() { - return allocated; - } - - public TskData.TSK_DB_FILES_TYPE_ENUM getFileType() { - return fileType; - } - - public AbstractFile getAbstractFile() { - return abstractFile; - } - - public String getExtension() { - return extension; - } - - public boolean isEncryptionDetected() { - return encryptionDetected; - } - - public String getFileName() { - return fileName; - } - } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ContentNodeUtilv2.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/ContentNodeUtil.java similarity index 63% rename from Core/src/org/sleuthkit/autopsy/datamodel/ContentNodeUtilv2.java rename to Core/src/org/sleuthkit/autopsy/mainui/nodes/ContentNodeUtil.java index 4da62fc59e..c5cbdd580b 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ContentNodeUtilv2.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/ContentNodeUtil.java @@ -1,25 +1,39 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 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; +package org.sleuthkit.autopsy.mainui.nodes; import java.util.Date; import java.util.List; -import org.openide.nodes.Children; import org.openide.nodes.Sheet; import org.openide.util.Lookup; import org.openide.util.lookup.Lookups; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.ColumnKey; +import org.sleuthkit.autopsy.datamodel.DirectoryNode; +import org.sleuthkit.autopsy.datamodel.NodeProperty; +import org.sleuthkit.autopsy.datamodel.TskContentItem; +import org.sleuthkit.autopsy.mainui.datamodel.ColumnKey; import org.sleuthkit.datamodel.Content; /** - * - * @author gregd + * Utilities for setting up nodes that handle content. */ -public class ContentNodeUtilv2 { +public class ContentNodeUtil { public static String getContentDisplayName(String fileName) { switch (fileName) { @@ -40,11 +54,6 @@ public class ContentNodeUtilv2 { return Lookups.fixed(content, new TskContentItem<>(content)); } - public static Children getChildren(long id) { - throw new UnsupportedOperationException("Not supported..."); - //return Children.create(new ContentChildren(content), true); - } - public static Sheet setSheet(Sheet sheet, List columnKeys, List values) { Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES); if (sheetSet == null) { diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/DataArtifactNode.java similarity index 79% rename from Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java rename to Core/src/org/sleuthkit/autopsy/mainui/nodes/DataArtifactNode.java index 101dbc0d05..8ebd806e1c 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataArtifactNodev2.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/DataArtifactNode.java @@ -16,14 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.datamodel; +package org.sleuthkit.autopsy.mainui.nodes; import org.sleuthkit.autopsy.actions.ViewArtifactAction; import org.sleuthkit.autopsy.actions.ViewOsAccountAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Date; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -49,16 +48,25 @@ import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.Content; import org.sleuthkit.autopsy.datamodel.utils.IconsUtil; import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint; -import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.ColumnKey; -import org.sleuthkit.autopsy.datamodel.ThreePanelDataArtifactDAO.DataArtifactTableDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDataArtifactDAO.DataArtifactTableSearchResultsDTO; +import org.sleuthkit.autopsy.datamodel.BlackboardArtifactItem; +import org.sleuthkit.autopsy.datamodel.DataArtifactItem; +import org.sleuthkit.autopsy.datamodel.DataModelActionsFactory; +import org.sleuthkit.autopsy.datamodel.DirectoryNode; +import org.sleuthkit.autopsy.datamodel.FileNode; +import org.sleuthkit.autopsy.datamodel.LayoutFileNode; +import org.sleuthkit.autopsy.datamodel.LocalDirectoryNode; +import org.sleuthkit.autopsy.datamodel.LocalFileNode; +import org.sleuthkit.autopsy.datamodel.SlackFileNode; +import org.sleuthkit.autopsy.datamodel.VirtualDirectoryNode; +import org.sleuthkit.autopsy.mainui.datamodel.ColumnKey; import org.sleuthkit.autopsy.directorytree.ExportCSVAction; import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction; import org.sleuthkit.autopsy.directorytree.ExtractAction; import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; import org.sleuthkit.autopsy.directorytree.ViewContextAction; +import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactTableDTO; +import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactTableSearchResultsDTO; import org.sleuthkit.datamodel.DataArtifact; import org.sleuthkit.datamodel.DerivedFile; import org.sleuthkit.datamodel.Directory; @@ -71,9 +79,12 @@ import org.sleuthkit.datamodel.Report; import org.sleuthkit.datamodel.SlackFile; import org.sleuthkit.datamodel.VirtualDirectory; -public class DataArtifactNodev2 extends AbstractNode { +/** + * node to display a data artifact. + */ +public class DataArtifactNode extends AbstractNode { - private static final Logger logger = Logger.getLogger(DataArtifactNodev2.class.getName()); + private static final Logger logger = Logger.getLogger(DataArtifactNode.class.getName()); private static Lookup createLookup(DataArtifactTableDTO row) { DataArtifactItem artifactItem = new DataArtifactItem(row.getDataArtifact(), row.getSrcContent()); @@ -88,18 +99,18 @@ public class DataArtifactNodev2 extends AbstractNode { private final DataArtifactTableDTO artifactRow; private final List columns; - public DataArtifactNodev2(DataArtifactTableSearchResultsDTO tableData, DataArtifactTableDTO artifactRow) { + public DataArtifactNode(DataArtifactTableSearchResultsDTO tableData, DataArtifactTableDTO artifactRow) { this(tableData, artifactRow, IconsUtil.getIconFilePath(tableData.getArtifactType().getTypeID())); } - public DataArtifactNodev2(DataArtifactTableSearchResultsDTO tableData, DataArtifactTableDTO artifactRow, String iconPath) { + public DataArtifactNode(DataArtifactTableSearchResultsDTO tableData, DataArtifactTableDTO artifactRow, String iconPath) { super(Children.LEAF, createLookup(artifactRow)); // use first cell value for display name String displayName = artifactRow.getCellValues().size() > 0 ? artifactRow.getCellValues().get(0).toString() : ""; - + setDisplayName(displayName); setShortDescription(displayName); setName(Long.toString(artifactRow.getId())); @@ -193,16 +204,16 @@ public class DataArtifactNodev2 extends AbstractNode { * @return The artifact type name. */ @Messages({ - "DataArtifactNodev2_getAssociatedTypeStr_webCache=Cached File", - "DataArtifactNodev2_getAssociatedTypeStr_webDownload=Downloaded File", - "DataArtifactNodev2_getAssociatedTypeStr_associated=Associated File",}) + "DataArtifactNode_getAssociatedTypeStr_webCache=Cached File", + "DataArtifactNode_getAssociatedTypeStr_webDownload=Downloaded File", + "DataArtifactNode_getAssociatedTypeStr_associated=Associated File",}) private String getAssociatedTypeStr(BlackboardArtifact.Type artifactType) { if (BlackboardArtifact.Type.TSK_WEB_CACHE.equals(artifactType)) { - return Bundle.DataArtifactNodev2_getAssociatedTypeStr_webCache(); + return Bundle.DataArtifactNode_getAssociatedTypeStr_webCache(); } else if (BlackboardArtifact.Type.TSK_WEB_DOWNLOAD.equals(artifactType)) { - return Bundle.DataArtifactNodev2_getAssociatedTypeStr_webDownload(); + return Bundle.DataArtifactNode_getAssociatedTypeStr_webDownload(); } else { - return Bundle.DataArtifactNodev2_getAssociatedTypeStr_associated(); + return Bundle.DataArtifactNode_getAssociatedTypeStr_associated(); } } @@ -215,38 +226,38 @@ public class DataArtifactNodev2 extends AbstractNode { * @return The name of the type of content. */ @Messages({ - "DataArtifactNodev2_getViewSrcContentAction_type_File=File", - "DataArtifactNodev2_getViewSrcContentAction_type_DataArtifact=Data Artifact", - "DataArtifactNodev2_getViewSrcContentAction_type_OSAccount=OS Account", - "DataArtifactNodev2_getViewSrcContentAction_type_unknown=Item" + "DataArtifactNode_getViewSrcContentAction_type_File=File", + "DataArtifactNode_getViewSrcContentAction_type_DataArtifact=Data Artifact", + "DataArtifactNode_getViewSrcContentAction_type_OSAccount=OS Account", + "DataArtifactNode_getViewSrcContentAction_type_unknown=Item" }) private String getContentTypeStr(Content content) { if (content instanceof AbstractFile) { - return Bundle.DataArtifactNodev2_getViewSrcContentAction_type_File(); + return Bundle.DataArtifactNode_getViewSrcContentAction_type_File(); } else if (content instanceof DataArtifact) { - return Bundle.DataArtifactNodev2_getViewSrcContentAction_type_DataArtifact(); + return Bundle.DataArtifactNode_getViewSrcContentAction_type_DataArtifact(); } else if (content instanceof OsAccount) { - return Bundle.DataArtifactNodev2_getViewSrcContentAction_type_OSAccount(); + return Bundle.DataArtifactNode_getViewSrcContentAction_type_OSAccount(); } else { - return Bundle.DataArtifactNodev2_getViewSrcContentAction_type_unknown(); + return Bundle.DataArtifactNode_getViewSrcContentAction_type_unknown(); } } @Messages({ "# {0} - type", - "DataArtifactNodev2_getAssociatedFileActions_viewAssociatedFileAction=View {0} in Directory", + "DataArtifactNode_getAssociatedFileActions_viewAssociatedFileAction=View {0} in Directory", "# {0} - type", - "DataArtifactNodev2_getAssociatedFileActions_viewAssociatedFileInTimelineAction=View {0} in Timeline..." + "DataArtifactNode_getAssociatedFileActions_viewAssociatedFileInTimelineAction=View {0} in Timeline..." }) private List getAssociatedFileActions(AbstractFile associatedFile, BlackboardArtifact.Type artifactType) { if (associatedFile != null) { return Arrays.asList( new ViewContextAction( - Bundle.DataArtifactNodev2_getAssociatedFileActions_viewAssociatedFileAction( + Bundle.DataArtifactNode_getAssociatedFileActions_viewAssociatedFileAction( getAssociatedTypeStr(artifactType)), associatedFile), new ViewFileInTimelineAction(associatedFile, - Bundle.DataArtifactNodev2_getAssociatedFileActions_viewAssociatedFileInTimelineAction( + Bundle.DataArtifactNode_getAssociatedFileActions_viewAssociatedFileInTimelineAction( getAssociatedTypeStr(artifactType))) ); } else { @@ -265,22 +276,22 @@ public class DataArtifactNodev2 extends AbstractNode { */ @Messages({ "# {0} - contentType", - "DataArtifactNodev2_getSrcContentAction_actionDisplayName=View Source {0} in Directory" + "DataArtifactNode_getSrcContentAction_actionDisplayName=View Source {0} in Directory" }) private Action getViewSrcContentAction(BlackboardArtifact artifact, Content content) { if (content instanceof DataArtifact) { return new ViewArtifactAction( (BlackboardArtifact) content, - Bundle.DataArtifactNodev2_getSrcContentAction_actionDisplayName( + Bundle.DataArtifactNode_getSrcContentAction_actionDisplayName( getContentTypeStr(content))); } else if (content instanceof OsAccount) { return new ViewOsAccountAction( (OsAccount) content, - Bundle.DataArtifactNodev2_getSrcContentAction_actionDisplayName( + Bundle.DataArtifactNode_getSrcContentAction_actionDisplayName( getContentTypeStr(content))); } else if (content instanceof AbstractFile || artifact instanceof DataArtifact) { return new ViewContextAction( - Bundle.DataArtifactNodev2_getSrcContentAction_actionDisplayName( + Bundle.DataArtifactNode_getSrcContentAction_actionDisplayName( getContentTypeStr(content)), content); } else { @@ -358,15 +369,15 @@ public class DataArtifactNodev2 extends AbstractNode { * @return The list of actions or an empty list. */ @Messages({ - "DataArtifactNodev2_getSrcContentViewerActions_viewInNewWin=View Item in New Window", - "DataArtifactNodev2_getSrcContentViewerActions_openInExtViewer=Open in External Viewer Ctrl+E" + "DataArtifactNode_getSrcContentViewerActions_viewInNewWin=View Item in New Window", + "DataArtifactNode_getSrcContentViewerActions_openInExtViewer=Open in External Viewer Ctrl+E" }) private List getSrcContentViewerActions(Node srcFileNode, int selectedFileCount) { List actionsList = new ArrayList<>(); if (srcFileNode != null) { - actionsList.add(new NewWindowViewAction(Bundle.DataArtifactNodev2_getSrcContentViewerActions_viewInNewWin(), srcFileNode)); + actionsList.add(new NewWindowViewAction(Bundle.DataArtifactNode_getSrcContentViewerActions_viewInNewWin(), srcFileNode)); if (selectedFileCount == 1) { - actionsList.add(new ExternalViewerAction(Bundle.DataArtifactNodev2_getSrcContentViewerActions_openInExtViewer(), srcFileNode)); + actionsList.add(new ExternalViewerAction(Bundle.DataArtifactNode_getSrcContentViewerActions_openInExtViewer(), srcFileNode)); } else { actionsList.add(ExternalViewerShortcutAction.getInstance()); } @@ -384,12 +395,12 @@ public class DataArtifactNodev2 extends AbstractNode { */ @NbBundle.Messages({ "# {0} - contentType", - "DataArtifactNodev2_getTimelineSrcContentAction_actionDisplayName=View Source {0} in Timeline... " + "DataArtifactNode_getTimelineSrcContentAction_actionDisplayName=View Source {0} in Timeline... " }) private Action getTimelineSrcContentAction(Content srcContent) { if (srcContent instanceof AbstractFile) { return new ViewFileInTimelineAction((AbstractFile) srcContent, - Bundle.DataArtifactNodev2_getTimelineSrcContentAction_actionDisplayName( + Bundle.DataArtifactNode_getTimelineSrcContentAction_actionDisplayName( getContentTypeStr(srcContent))); } @@ -398,7 +409,7 @@ public class DataArtifactNodev2 extends AbstractNode { // try { // if (hasSupportedTimeStamp((BlackboardArtifact) srcContent)) { // return new ViewArtifactInTimelineAction((BlackboardArtifact) srcContent, -// Bundle.DataArtifactNodev2_getTimelineSrcContentAction_actionDisplayName( +// Bundle.DataArtifactNode_getTimelineSrcContentAction_actionDisplayName( // getContentTypeStr(srcContent))); // } // } catch (TskCoreException ex) { @@ -418,11 +429,11 @@ public class DataArtifactNodev2 extends AbstractNode { * @return The action or null if no action should exist. */ @Messages({ - "DataArtifactNodev2_getTimelineArtifactAction_displayName=View Selected Item in Timeline... " + "DataArtifactNode_getTimelineArtifactAction_displayName=View Selected Item in Timeline... " }) private Action getTimelineArtifactAction(BlackboardArtifact art, boolean hasSupportedTimeStamp) { if (hasSupportedTimeStamp) { - return new ViewArtifactInTimelineAction(art, Bundle.DataArtifactNodev2_getTimelineArtifactAction_displayName()); + return new ViewArtifactInTimelineAction(art, Bundle.DataArtifactNode_getTimelineArtifactAction_displayName()); } else { return null; } @@ -430,6 +441,6 @@ public class DataArtifactNodev2 extends AbstractNode { @Override protected Sheet createSheet() { - return ContentNodeUtilv2.setSheet(super.createSheet(), this.columns, this.artifactRow.getCellValues()); + return ContentNodeUtil.setSheet(super.createSheet(), this.columns, this.artifactRow.getCellValues()); } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/FileNode.java similarity index 86% rename from Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java rename to Core/src/org/sleuthkit/autopsy/mainui/nodes/FileNode.java index 5358dc9ecc..cfee324978 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileNodev2.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/FileNode.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2019 Basis Technology Corp. + * Copyright 2021 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.datamodel; +package org.sleuthkit.autopsy.mainui.nodes; import java.util.ArrayList; import java.util.Arrays; @@ -32,25 +32,24 @@ import org.openide.util.Utilities; import org.sleuthkit.autopsy.actions.AddContentTagAction; import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction; import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.ExtensionMediaType; -import org.sleuthkit.autopsy.datamodel.ThreePanelViewsDAO.FileRowDTO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; +import org.sleuthkit.autopsy.mainui.datamodel.FileRowDTO; import org.sleuthkit.autopsy.directorytree.ExportCSVAction; import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction; import org.sleuthkit.autopsy.directorytree.ExtractAction; import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; +import org.sleuthkit.autopsy.mainui.datamodel.ColumnKey; +import org.sleuthkit.autopsy.mainui.datamodel.FileRowDTO.ExtensionMediaType; import org.sleuthkit.autopsy.modules.embeddedfileextractor.ExtractArchiveWithPasswordAction; import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM; -import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM; /** - * A node for representing an AbstractFile. It may have derived file node - * children. + * A node for representing an AbstractFile. */ -public class FileNodev2 extends AbstractNode { +public class FileNode extends AbstractNode { /** * Gets the path to the icon file that should be used to visually represent @@ -92,20 +91,20 @@ public class FileNodev2 extends AbstractNode { private final boolean directoryBrowseMode; private final FileRowDTO fileData; - private final List columns; + private final List columns; - public FileNodev2(SearchResultsDTO results, FileRowDTO file) { + public FileNode(SearchResultsDTO results, FileRowDTO file) { this(results, file, true); } - public FileNodev2(SearchResultsDTO results, FileRowDTO file, boolean directoryBrowseMode) { + public FileNode(SearchResultsDTO results, FileRowDTO file, boolean directoryBrowseMode) { // GVDTODO: at some point, this leaf will need to allow for children - super(Children.LEAF, ContentNodeUtilv2.getLookup(file.getAbstractFile())); + super(Children.LEAF, ContentNodeUtil.getLookup(file.getAbstractFile())); setIcon(file); - setDisplayName(ContentNodeUtilv2.getContentDisplayName(file.getFileName())); - setName(ContentNodeUtilv2.getContentName(file.getId())); + setDisplayName(ContentNodeUtil.getContentDisplayName(file.getFileName())); + setName(ContentNodeUtil.getContentName(file.getId())); this.directoryBrowseMode = directoryBrowseMode; this.fileData = file; this.columns = results.getColumns(); @@ -186,6 +185,6 @@ public class FileNodev2 extends AbstractNode { @Override protected Sheet createSheet() { - return ContentNodeUtilv2.setSheet(super.createSheet(), this.columns, this.fileData.getCellValues()); + return ContentNodeUtil.setSheet(super.createSheet(), this.columns, this.fileData.getCellValues()); } } diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java new file mode 100644 index 0000000000..0432689958 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java @@ -0,0 +1,132 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 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.mainui.nodes; + + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; +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.mainui.datamodel.DataArtifactTableDTO; +import org.sleuthkit.autopsy.mainui.datamodel.DataArtifactTableSearchResultsDTO; +import org.sleuthkit.autopsy.mainui.datamodel.FileRowDTO; +import org.sleuthkit.autopsy.mainui.nodes.SearchResultChildFactory.ChildKey; +import org.sleuthkit.autopsy.mainui.datamodel.RowResultDTO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; + +/** + * Factory for populating results in a results viewer with a SearchResultsDTO. + */ +public class SearchResultChildFactory extends ChildFactory { + private static final Logger logger = Logger.getLogger(SearchResultChildFactory.class.getName()); + private SearchResultsDTO results; + + public SearchResultChildFactory(SearchResultsDTO initialResults) { + this.results = initialResults; + } + + @Override + protected boolean createKeys(List toPopulate) { + SearchResultsDTO 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) { + String typeId = key.getRow().getTypeId(); + try { + if (DataArtifactTableDTO.getTypeIdForClass().equals(typeId)) { + return new DataArtifactNode((DataArtifactTableSearchResultsDTO) key.getSearchResults(), (DataArtifactTableDTO) key.getRow()); + } else if (DataArtifactTableDTO.getTypeIdForClass().equals(typeId)) { + return new FileNode(key.getSearchResults(), (FileRowDTO) key.getRow()); + } + } catch (ClassCastException ex) { + logger.log(Level.WARNING, MessageFormat.format("Could not cast item with type id: {0} to valid type.", typeId), ex); + } + + return null; + } + + public void update(SearchResultsDTO newResults) { + this.results = newResults; + this.refresh(false); + } + + public long getResultCount() { + return results == null ? 0 : results.getTotalResultsCount(); + } + + static class ChildKey { + + private final SearchResultsDTO searchResults; + private final RowResultDTO row; + + ChildKey(SearchResultsDTO searchResults, RowResultDTO child) { + this.searchResults = searchResults; + this.row = child; + } + + SearchResultsDTO getSearchResults() { + return searchResults; + } + + RowResultDTO getRow() { + return row; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + Objects.hashCode(this.row); + 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.row, other.row)) { + return false; + } + return true; + } + + } +} diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultTableNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultRootNode.java similarity index 55% rename from Core/src/org/sleuthkit/autopsy/datamodel/SearchResultTableNode.java rename to Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultRootNode.java index 821768a926..23345817f7 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/SearchResultTableNode.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultRootNode.java @@ -1,37 +1,46 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 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; +package org.sleuthkit.autopsy.mainui.nodes; -import java.util.Collections; -import java.util.List; 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.SearchResultChildFactory.NodeCreator; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.ColumnKey; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.RowResultDTO; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.datamodel.NodeProperty; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; /** - * - * @author gregd + * A node whose children will be displayed in the results view and determines + * children based on a SearchResultDTO. */ -public class SearchResultTableNode, S extends RowResultDTO> extends AbstractNode { +public class SearchResultRootNode extends AbstractNode { - private final SearchResultChildFactory factory; + private final SearchResultChildFactory factory; - public SearchResultTableNode(NodeCreator nodeCreator, T initialResults) { - this(initialResults, new SearchResultChildFactory<>(nodeCreator, initialResults)); + public SearchResultRootNode(SearchResultsDTO initialResults) { + this(initialResults, new SearchResultChildFactory(initialResults)); } - private SearchResultTableNode(SearchResultsDTO initialResults, SearchResultChildFactory factory) { + private SearchResultRootNode(SearchResultsDTO initialResults, SearchResultChildFactory factory) { super(Children.create(factory, true)); this.factory = factory; - + setName(initialResults.getTypeId()); setDisplayName(initialResults.getDisplayName()); diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java new file mode 100644 index 0000000000..2a14c60885 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java @@ -0,0 +1,182 @@ +///* +// * 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.mainui.nodes; +// +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import javax.swing.Action; +//import org.openide.nodes.AbstractNode; +//import org.openide.nodes.Sheet; +//import org.openide.util.NbBundle; +//import org.sleuthkit.autopsy.coreutils.Logger; +//import org.sleuthkit.autopsy.datamodel.NodeProperty; +//import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; +//import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; +//import org.sleuthkit.datamodel.Volume; +//import org.sleuthkit.autopsy.directorytree.FileSystemDetailsAction; +//import org.sleuthkit.datamodel.TskData; +//import org.sleuthkit.datamodel.TskData.TSK_VS_PART_FLAG_ENUM; +// +///** +// * 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 Volume volume; +// private final long id; +// private final long addr; +// private final long start; +// private final long length; +// private final String description; +// private final boolean contiguousVolume; // based on vol.getParent() != null && vol.getParent().getParent() instanceof Pool +// private final TskData.TSK_VS_PART_FLAG_ENUM partitionFlag; // see Volume.vsFlagToString +// +// public VolumeTableDTO(Volume volume, long id, long addr, long start, long length, String description, boolean contiguousVolume, TSK_VS_PART_FLAG_ENUM partitionFlag) { +// this.volume = volume; +// this.id = id; +// this.addr = addr; +// this.start = start; +// this.length = length; +// this.description = description; +// this.contiguousVolume = contiguousVolume; +// this.partitionFlag = partitionFlag; +// } +// +// +// public long getAddr() { +// return addr; +// } +// +// public long getStart() { +// return start; +// } +// +// public long getLength() { +// return length; +// } +// +// public String getDescription() { +// return description; +// } +// +// public boolean isContiguousVolume() { +// return contiguousVolume; +// } +// +// public TSK_VS_PART_FLAG_ENUM getPartitionFlag() { +// return partitionFlag; +// } +// +// public long getId() { +// return id; +// } +// +// public Volume getVolume() { +// return volume; +// } +// +// } +// +// private final VolumeTableDTO volData; +// +// /** +// * +// * @param vol underlying Content instance +// */ +// public VolumeNodev2(VolumeTableDTO vol) { +// super(ContentNodeUtilv2.getChildren(vol.getId()), ContentNodeUtilv2.getLookup(vol.getVolume())); +// setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); +// setDisplayName(getDisplayName(vol)); +// setName(ContentNodeUtilv2.getContentName(vol.getId())); +// this.volData = vol; +// +// } +// +// private String getDisplayName(VolumeTableDTO vol) { +// // set name, display name, and icon +// String volName = "vol" + Long.toString(vol.getAddr()); +// long end = vol.getStart() + (vol.getLength() - 1); +// return vol.isContiguousVolume() +// ? volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")" +// : volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")"; +// } +// +// /** +// * Right click action for volume node +// * +// * @param popup +// * +// * @return +// */ +// @Override +// public Action[] getActions(boolean popup) { +// List actionsList = new ArrayList<>(); +// actionsList.add(new FileSystemDetailsAction(volData.getVolume())); +// actionsList.add(new NewWindowViewAction( +// NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this)); +// actionsList.addAll(ExplorerNodeActionVisitor.getActions(volData.getVolume())); +// 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"), +// volData.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"), +// volData.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"), +// volData.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"), +// volData.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"), +// Volume.vsFlagToString(volData.getPartitionFlag().getVsFlag()))); +// +// return sheet; +// } +//} diff --git a/Core/src/org/sleuthkit/autopsy/resultviewers/summary/DataSourceSummaryResultViewer.java b/Core/src/org/sleuthkit/autopsy/resultviewers/summary/DataSourceSummaryResultViewer.java index a35468b5e9..3087bb91a0 100644 --- a/Core/src/org/sleuthkit/autopsy/resultviewers/summary/DataSourceSummaryResultViewer.java +++ b/Core/src/org/sleuthkit/autopsy/resultviewers/summary/DataSourceSummaryResultViewer.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.corecomponents.AbstractDataResultViewer; import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ThreadConfined; -import org.sleuthkit.autopsy.datamodel.ThreePanelDAO.SearchResultsDTO; +import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; /** * A tabular result viewer that displays a summary of the selected Data Source. @@ -106,7 +106,7 @@ public class DataSourceSummaryResultViewer extends AbstractDataResultViewer { } @Override - public void setNode(Node node, SearchResultsDTO searchResults) { + public void setNode(Node node, SearchResultsDTO searchResults) { setNode(node); }