diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java index e417a11076a9fae47d18c882d1c35d7d8aad6886..fc7ac32885fc84024476ea85be80d6814fb1834a 100644 --- a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java @@ -63,13 +63,14 @@ * */ public class FileSystemDAO { + private static final int CACHE_SIZE = 15; // rule of thumb: 5 entries times number of cached SearchParams sub-types private static final long CACHE_DURATION = 2; private static final TimeUnit CACHE_DURATION_UNITS = TimeUnit.MINUTES; private final Cache<SearchParams<?>, BaseSearchResultsDTO> searchParamsCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).expireAfterAccess(CACHE_DURATION, CACHE_DURATION_UNITS).build(); private static final String FILE_SYSTEM_TYPE_ID = "FILE_SYSTEM"; - + private static FileSystemDAO instance = null; synchronized static FileSystemDAO getInstance() { @@ -78,7 +79,7 @@ synchronized static FileSystemDAO getInstance() { } return instance; } - + private BaseSearchResultsDTO fetchContentForTableFromContent(SearchParams<FileSystemContentSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException { SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); @@ -90,15 +91,15 @@ private BaseSearchResultsDTO fetchContentForTableFromContent(SearchParams<FileSy if (parentContent == null) { throw new TskCoreException("Error loading children of object with ID " + objectId); } - + parentName = parentContent.getName(); for (Content content : parentContent.getChildren()) { contentForTable.addAll(FileSystemColumnUtils.getNextDisplayableContent(content)); - } + } return fetchContentForTable(cacheKey, contentForTable, parentName); } - + private BaseSearchResultsDTO fetchContentForTableFromHost(SearchParams<FileSystemHostSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException { SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); @@ -114,8 +115,8 @@ private BaseSearchResultsDTO fetchContentForTableFromHost(SearchParams<FileSyste throw new TskCoreException("Error loading host with ID " + objectId); } return fetchContentForTable(cacheKey, contentForTable, parentName); - } - + } + private BaseSearchResultsDTO fetchHostsForTable(SearchParams<FileSystemPersonSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException { SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); @@ -123,7 +124,7 @@ private BaseSearchResultsDTO fetchHostsForTable(SearchParams<FileSystemPersonSea Long objectId = cacheKey.getParamData().getPersonObjectId(); List<Host> hostsForTable = new ArrayList<>(); String parentName = ""; - + if (objectId != null) { Optional<Person> person = skCase.getPersonManager().getPerson(objectId); if (person.isPresent()) { @@ -135,10 +136,10 @@ private BaseSearchResultsDTO fetchHostsForTable(SearchParams<FileSystemPersonSea } else { hostsForTable.addAll(skCase.getPersonManager().getHostsWithoutPersons()); } - + Stream<Host> pagedHostsStream = hostsForTable.stream() - .sorted(Comparator.comparing((host) -> host.getHostId())) - .skip(cacheKey.getStartItem()); + .sorted(Comparator.comparing((host) -> host.getHostId())) + .skip(cacheKey.getStartItem()); if (cacheKey.getMaxResultsCount() != null) { pagedHostsStream = pagedHostsStream.limit(cacheKey.getMaxResultsCount()); @@ -146,84 +147,83 @@ private BaseSearchResultsDTO fetchHostsForTable(SearchParams<FileSystemPersonSea List<Host> pagedHosts = pagedHostsStream.collect(Collectors.toList()); List<ColumnKey> columnKeys = FileSystemColumnUtils.getColumnKeysForHost(); - + List<RowDTO> rows = new ArrayList<>(); for (Host host : pagedHosts) { List<Object> cellValues = FileSystemColumnUtils.getCellValuesForHost(host); rows.add(new BaseRowDTO(cellValues, FILE_SYSTEM_TYPE_ID, host.getHostId())); } return new BaseSearchResultsDTO(FILE_SYSTEM_TYPE_ID, parentName, columnKeys, rows, cacheKey.getStartItem(), hostsForTable.size()); - } - - + } + private BaseSearchResultsDTO fetchContentForTable(SearchParams<?> cacheKey, List<Content> contentForTable, String parentName) throws NoCurrentCaseException, TskCoreException { // Ensure consistent columns for each page by doing this before paging List<FileSystemColumnUtils.ContentType> displayableTypes = FileSystemColumnUtils.getDisplayableTypesForContentList(contentForTable); - + List<Content> pagedContent = getPaged(contentForTable, cacheKey); List<ColumnKey> columnKeys = FileSystemColumnUtils.getColumnKeysForContent(displayableTypes); - + List<RowDTO> rows = new ArrayList<>(); for (Content content : pagedContent) { List<Object> cellValues = FileSystemColumnUtils.getCellValuesForContent(content, displayableTypes); - if(content instanceof Image) { - rows.add(new ImageRowDTO((Image)content, cellValues, content.getId())); + if (content instanceof Image) { + rows.add(new ImageRowDTO((Image) content, cellValues)); } else if (content instanceof LocalFilesDataSource) { - rows.add(new LocalFileDataSourceRowDTO((LocalFilesDataSource)content, cellValues, content.getId())); - } else if(content instanceof LocalDirectory) { - rows.add(new LocalDirectoryRowDTO((LocalDirectory)content, cellValues, content.getId())); - }else if(content instanceof VirtualDirectory) { - rows.add(new VirtualDirectoryRowDTO((VirtualDirectory)content, cellValues, content.getId())); - }else if(content instanceof Volume) { - rows.add(new VolumeRowDTO((Volume)content, cellValues, content.getId())); - } else if(content instanceof Directory) { - rows.add(new DirectoryRowDTO((Directory)content, cellValues, content.getId())); - } else if(content instanceof Pool) { - rows.add(new PoolRowDTO((Pool)content, cellValues, content.getId())); + rows.add(new LocalFileDataSourceRowDTO((LocalFilesDataSource) content, cellValues)); + } else if (content instanceof LocalDirectory) { + rows.add(new LocalDirectoryRowDTO((LocalDirectory) content, cellValues)); + } else if (content instanceof VirtualDirectory) { + rows.add(new VirtualDirectoryRowDTO((VirtualDirectory) content, cellValues)); + } else if (content instanceof Volume) { + rows.add(new VolumeRowDTO((Volume) content, cellValues)); + } else if (content instanceof Directory) { + rows.add(new DirectoryRowDTO((Directory) content, cellValues)); + } else if (content instanceof Pool) { + rows.add(new PoolRowDTO((Pool) content, cellValues)); } else if (content instanceof SlackFile) { - AbstractFile file = (AbstractFile)content; + AbstractFile file = (AbstractFile) content; rows.add(new SlackFileRowDTO( - (SlackFile)file, - file.getId(), - file.getName(), - file.getNameExtension(), - getExtensionMediaType(file.getNameExtension()), - file.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.ALLOC), - file.getType(), - cellValues)); + (SlackFile) file, + file.getId(), + file.getName(), + file.getNameExtension(), + getExtensionMediaType(file.getNameExtension()), + file.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.ALLOC), + file.getType(), + cellValues)); } else if (content instanceof LayoutFile) { - AbstractFile file = (AbstractFile)content; + AbstractFile file = (AbstractFile) content; rows.add(new LayoutFileRowDTO( - (LayoutFile)file, - file.getId(), - file.getName(), - file.getNameExtension(), - getExtensionMediaType(file.getNameExtension()), - file.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.ALLOC), - file.getType(), - cellValues)); + (LayoutFile) file, + file.getId(), + file.getName(), + file.getNameExtension(), + getExtensionMediaType(file.getNameExtension()), + file.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.ALLOC), + file.getType(), + cellValues)); } else if (content instanceof AbstractFile) { - AbstractFile file = (AbstractFile)content; + AbstractFile file = (AbstractFile) content; rows.add(new FileRowDTO( - file, - file.getId(), - file.getName(), - file.getNameExtension(), - getExtensionMediaType(file.getNameExtension()), - file.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.ALLOC), - file.getType(), - cellValues)); + file, + file.getId(), + file.getName(), + file.getNameExtension(), + getExtensionMediaType(file.getNameExtension()), + file.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.ALLOC), + file.getType(), + cellValues)); } } return new BaseSearchResultsDTO(FILE_SYSTEM_TYPE_ID, parentName, columnKeys, rows, cacheKey.getStartItem(), contentForTable.size()); - } - + } + /** * Returns a list of paged content. * - * @param contentObjects The content objects. - * @param searchParams The search parameters including the paging. + * @param contentObjects The content objects. + * @param searchParams The search parameters including the paging. * * @return The list of paged content. */ @@ -237,8 +237,8 @@ private List<Content> getPaged(List<? extends Content> contentObjects, SearchPar } return pagedArtsStream.collect(Collectors.toList()); - } - + } + public BaseSearchResultsDTO getContentForTable(FileSystemContentSearchParam objectKey, long startItem, Long maxCount, boolean hardRefresh) throws ExecutionException, IllegalArgumentException { SearchParams<FileSystemContentSearchParam> searchParams = new SearchParams<>(objectKey, startItem, maxCount); @@ -248,7 +248,7 @@ public BaseSearchResultsDTO getContentForTable(FileSystemContentSearchParam obje return searchParamsCache.get(searchParams, () -> fetchContentForTableFromContent(searchParams)); } - + public BaseSearchResultsDTO getContentForTable(FileSystemHostSearchParam objectKey, long startItem, Long maxCount, boolean hardRefresh) throws ExecutionException, IllegalArgumentException { SearchParams<FileSystemHostSearchParam> searchParams = new SearchParams<>(objectKey, startItem, maxCount); @@ -258,7 +258,7 @@ public BaseSearchResultsDTO getContentForTable(FileSystemHostSearchParam objectK return searchParamsCache.get(searchParams, () -> fetchContentForTableFromHost(searchParams)); } - + public BaseSearchResultsDTO getHostsForTable(FileSystemPersonSearchParam objectKey, long startItem, Long maxCount, boolean hardRefresh) throws ExecutionException, IllegalArgumentException { SearchParams<FileSystemPersonSearchParam> searchParams = new SearchParams<>(objectKey, startItem, maxCount); @@ -268,7 +268,8 @@ public BaseSearchResultsDTO getHostsForTable(FileSystemPersonSearchParam objectK return searchParamsCache.get(searchParams, () -> fetchHostsForTable(searchParams)); } - /** + + /** * Handles fetching and paging of data for file types by mime type. */ public static class FileSystemFetcher extends DAOFetcher<FileSystemContentSearchParam> { @@ -298,7 +299,7 @@ public boolean isRefreshRequired(PropertyChangeEvent evt) { return false; } } - + public static class FileSystemHostFetcher extends DAOFetcher<FileSystemHostSearchParam> { /** diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemRowDTO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemRowDTO.java index 3e0b1d006a8a6f7a796181884783cf7f7846cd1c..b73b36117e9494114743e606c4f72891d1aecd99 100755 --- a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemRowDTO.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemRowDTO.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.mainui.datamodel; import java.util.List; +import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Directory; import org.sleuthkit.datamodel.Image; import org.sleuthkit.datamodel.LocalDirectory; @@ -28,27 +29,48 @@ import org.sleuthkit.datamodel.Volume; /* - * + * A base class for FileSystem table row DTOs. */ -public abstract class FileSystemRowDTO<T> extends BaseRowDTO { +abstract class FileSystemRowDTO<T extends Content> extends BaseRowDTO { private final T content; - private FileSystemRowDTO(T content, List<Object> cellValues, String typeId, long id) { - super(cellValues, typeId, id); + /** + * Constructs a new FileSystemRowDTO. + * + * @param content The content represented by this object. + * @param cellValues The table cell values. + * @param typeId The string type id for this DTO. + */ + private FileSystemRowDTO(T content, List<Object> cellValues, String typeId) { + super(cellValues, typeId, content.getId()); this.content = content; } + /** + * Returns the content object for this row. + * + * @return The content. + */ public T getContent() { return content; } + /** + * DTO Representing an Volume in the results view. + */ public static class VolumeRowDTO extends FileSystemRowDTO<Volume> { private static final String TYPE_ID = "VOLUME"; - public VolumeRowDTO(Volume volume, List<Object> cellValues, long id) { - super(volume, cellValues, TYPE_ID, id); + /** + * Constructs a new VolumeRowDTO. + * + * @param volume The volume represented by this DTO. + * @param cellValues The table cell values. + */ + public VolumeRowDTO(Volume volume, List<Object> cellValues) { + super(volume, cellValues, TYPE_ID); } public static String getTypeIdForClass() { @@ -63,8 +85,14 @@ public static class ImageRowDTO extends FileSystemRowDTO<Image> { private static final String TYPE_ID = "IMAGE"; - public ImageRowDTO(Image image, List<Object> cellValues, long id) { - super(image, cellValues, TYPE_ID, id); + /** + * Constructs a new ImageRowDTO. + * + * @param image The image represented by this DTO. + * @param cellValues The table cell values. + */ + public ImageRowDTO(Image image, List<Object> cellValues) { + super(image, cellValues, TYPE_ID); } public static String getTypeIdForClass() { @@ -79,8 +107,14 @@ public static class LocalDirectoryRowDTO extends FileSystemRowDTO<LocalDirectory private static final String TYPE_ID = "LOCAL_DIRECTORY"; - public LocalDirectoryRowDTO(LocalDirectory localDir, List<Object> cellValues, long id) { - super(localDir, cellValues, TYPE_ID, id); + /** + * Constructs a new LocalDirectoryRowDTO. + * + * @param localDir The LocalDirectory represented by this DTO. + * @param cellValues The table cell values. + */ + public LocalDirectoryRowDTO(LocalDirectory localDir, List<Object> cellValues) { + super(localDir, cellValues, TYPE_ID); } public static String getTypeIdForClass() { @@ -95,12 +129,25 @@ public static class VirtualDirectoryRowDTO extends FileSystemRowDTO<VirtualDirec private static final String TYPE_ID = "VIRTUAL_DIRECTORY"; - public VirtualDirectoryRowDTO(VirtualDirectory localDir, List<Object> cellValues, long id) { - this(localDir, cellValues, TYPE_ID, id); + /** + * Constructs a new VirtualDirectoryRowDTO. + * + * @param virtualDir The VirtualDirectory represented by this DTO. + * @param cellValues The table cell values. + */ + public VirtualDirectoryRowDTO(VirtualDirectory virtualDir, List<Object> cellValues) { + this(virtualDir, cellValues, TYPE_ID); } - VirtualDirectoryRowDTO(VirtualDirectory localDir, List<Object> cellValues, String typeId, long id) { - super(localDir, cellValues, typeId, id); + /** + * Constructs a new VirtualDirectoryRowDTO. + * + * @param virtualDir The VirtualDirectory represented by this DTO. + * @param cellValues The table cell values. + * @param typeId The type id for this object. + */ + private VirtualDirectoryRowDTO(VirtualDirectory localDir, List<Object> cellValues, String typeId) { + super(localDir, cellValues, typeId); } public static String getTypeIdForClass() { @@ -115,8 +162,15 @@ public static class LocalFileDataSourceRowDTO extends VirtualDirectoryRowDTO { private static final String TYPE_ID = "LOCAL_FILE_DATA_SOURCE"; - public LocalFileDataSourceRowDTO(LocalFilesDataSource localFilesDataSource, List<Object> cellValues, long id) { - super(localFilesDataSource, cellValues, TYPE_ID, id); + /** + * Constructs a new LocalFileDataSourceRowDTO. + * + * @param localFilesDataSource The LocalFilesDataSource represented by + * this DTO. + * @param cellValues The table cell values. + */ + public LocalFileDataSourceRowDTO(LocalFilesDataSource localFilesDataSource, List<Object> cellValues) { + super(localFilesDataSource, cellValues, TYPE_ID); } public static String getTypeIdForClass() { @@ -131,25 +185,38 @@ public static class DirectoryRowDTO extends FileSystemRowDTO<Directory> { private static final String TYPE_ID = "DIRECTORY"; - public DirectoryRowDTO(Directory localDir, List<Object> cellValues, long id) { - super(localDir, cellValues, TYPE_ID, id); + /** + * Constructs a new DirectoryRowDTO. + * + * @param dir The directory represented by this DTO. + * @param cellValues The table cell values. + */ + public DirectoryRowDTO(Directory dir, List<Object> cellValues) { + super(dir, cellValues, TYPE_ID); } public static String getTypeIdForClass() { return TYPE_ID; } } - + /** * DTO representing a pool in the results view. */ public static class PoolRowDTO extends FileSystemRowDTO<Pool> { + private static final String TYPE_ID = "POOL"; - - public PoolRowDTO(Pool pool, List<Object> cellValues, long id) { - super(pool, cellValues, TYPE_ID, id); + + /** + * Constructs a new PoolRowDTO. + * + * @param pool The pool represented by this DTO. + * @param cellValues The table cell values. + */ + public PoolRowDTO(Pool pool, List<Object> cellValues) { + super(pool, cellValues, TYPE_ID); } - + public static String getTypeIdForClass() { return TYPE_ID; } diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/DirectoryNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/DirectoryNode.java index 811d523a480266178028461163c62eb1bd3439ec..03be438aa3dec4301d6f2194010f6e83729c80aa 100755 --- a/Core/src/org/sleuthkit/autopsy/mainui/nodes/DirectoryNode.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/DirectoryNode.java @@ -30,18 +30,24 @@ * A node representing a row for a Directory in the results table. */ public class DirectoryNode extends BaseNode<SearchResultsDTO, DirectoryRowDTO> { - + + /** + * Simple node constructor. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ public DirectoryNode(SearchResultsDTO results, DirectoryRowDTO row) { super(Children.LEAF, ContentNodeUtil.getLookup(row.getContent()), results, row); setDisplayName(row.getContent().getName()); setShortDescription(row.getContent().getName()); setIcon(); - } - + } + /** * Sets the Icon that appears for the directory based on the FLAG state. - * - * @param dir + * + * @param dir */ private void setIcon() { // set name, display name, and icon @@ -51,27 +57,27 @@ private void setIcon() { this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS } } - + @Override public boolean supportsViewInTimeline() { return true; } - + @Override public Optional<AbstractFile> getFileForViewInTimelineAction() { return Optional.of(getRowDTO().getContent()); } - + @Override public boolean supportsExtractActions() { return true; } - + @Override public Optional<Content> getContentForRunIngestionModuleAction() { return Optional.of(getRowDTO().getContent()); } - + @Override public boolean supportsContentTagAction() { return true; diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/ImageNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/ImageNode.java index 159de0bc561964b8afa332e5d2f7aca1068d4df9..e509593c6ac29a98edcc4407c1c33a0be0219811 100755 --- a/Core/src/org/sleuthkit/autopsy/mainui/nodes/ImageNode.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/ImageNode.java @@ -33,6 +33,12 @@ */ public class ImageNode extends BaseNode<SearchResultsDTO, ImageRowDTO> { + /** + * Simple node constructor. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ public ImageNode(SearchResultsDTO results, ImageRowDTO row) { super(Children.LEAF, ContentNodeUtil.getLookup(row.getContent()), results, row); setDisplayName(row.getContent().getName()); diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/PoolNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/PoolNode.java index 56852ec7b65e21d2c419c19382b83302672d7634..a59a829dcedc3f2fc6631894db10304236865012 100755 --- a/Core/src/org/sleuthkit/autopsy/mainui/nodes/PoolNode.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/PoolNode.java @@ -1,7 +1,20 @@ /* - * 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 <at> sleuthkit <dot> 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; @@ -12,14 +25,21 @@ import org.sleuthkit.autopsy.mainui.datamodel.SearchResultsDTO; /** - * + * A node representing a Pool. */ public class PoolNode extends BaseNode<SearchResultsDTO, PoolRowDTO> { + + /** + * Pool node constructor. + * + * @param results Search Result DTO. + * @param row Pool table row DTO. + */ public PoolNode(SearchResultsDTO results, PoolRowDTO row) { - super(Children.LEAF, - Lookups.fixed(row.getContent(), new TskContentItem<>(row.getContent())), + super(Children.LEAF, + Lookups.fixed(row.getContent(), new TskContentItem<>(row.getContent())), results, row); - + String name = row.getContent().getType().getName(); setDisplayName(name); setShortDescription(name); diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java index e7e29388f7fd35be36fe90cab7bc0e492e18a365..971929e310475953d0b5c91f511d1aa935a1bc7a 100644 --- a/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SearchResultChildFactory.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.mainui.nodes; - import java.text.MessageFormat; import java.util.List; import java.util.Objects; @@ -54,6 +53,7 @@ * Factory for populating results in a results viewer with a SearchResultsDTO. */ public class SearchResultChildFactory extends ChildFactory<ChildKey> { + private static final Logger logger = Logger.getLogger(SearchResultChildFactory.class.getName()); private SearchResultsDTO results; @@ -84,28 +84,28 @@ protected Node createNodeForKey(ChildKey key) { return new DataArtifactNode((DataArtifactTableSearchResultsDTO) key.getSearchResults(), (DataArtifactRowDTO) key.getRow()); } else if (FileRowDTO.getTypeIdForClass().equals(typeId)) { return new FileNode(key.getSearchResults(), (FileRowDTO) key.getRow(), true); - } else if(AnalysisResultRowDTO.getTypeIdForClass().equals(typeId)) { - return new AnalysisResultNode((AnalysisResultTableSearchResultsDTO)key.getSearchResults(), (AnalysisResultRowDTO) key.getRow()); - } else if(ContentTagsRowDTO.getTypeIdForClass().equals(typeId)) { - return new ContentTagNode(key.getSearchResults(), (ContentTagsRowDTO)key.getRow()); - } else if(BlackboardArtifactTagsRowDTO.getTypeIdForClass().equals(typeId)) { - return new BlackboardArtifactTagNode(key.getSearchResults(), (BlackboardArtifactTagsRowDTO)key.getRow()); + } else if (AnalysisResultRowDTO.getTypeIdForClass().equals(typeId)) { + return new AnalysisResultNode((AnalysisResultTableSearchResultsDTO) key.getSearchResults(), (AnalysisResultRowDTO) key.getRow()); + } else if (ContentTagsRowDTO.getTypeIdForClass().equals(typeId)) { + return new ContentTagNode(key.getSearchResults(), (ContentTagsRowDTO) key.getRow()); + } else if (BlackboardArtifactTagsRowDTO.getTypeIdForClass().equals(typeId)) { + return new BlackboardArtifactTagNode(key.getSearchResults(), (BlackboardArtifactTagsRowDTO) key.getRow()); } else if (ImageRowDTO.getTypeIdForClass().equals(typeId)) { - return new ImageNode(key.getSearchResults(), (ImageRowDTO)key.getRow()); + return new ImageNode(key.getSearchResults(), (ImageRowDTO) key.getRow()); } else if (LocalFileDataSourceRowDTO.getTypeIdForClass().equals(typeId)) { - return new LocalFileDataSourceNode(key.getSearchResults(), (LocalFileDataSourceRowDTO)key.getRow()); + return new LocalFileDataSourceNode(key.getSearchResults(), (LocalFileDataSourceRowDTO) key.getRow()); } else if (DirectoryRowDTO.getTypeIdForClass().equals(typeId)) { - return new DirectoryNode(key.getSearchResults(), (DirectoryRowDTO)key.getRow()); + return new DirectoryNode(key.getSearchResults(), (DirectoryRowDTO) key.getRow()); } else if (VolumeRowDTO.getTypeIdForClass().equals(typeId)) { - return new VolumeNode(key.getSearchResults(), (VolumeRowDTO)key.getRow()); + return new VolumeNode(key.getSearchResults(), (VolumeRowDTO) key.getRow()); } else if (LocalDirectoryRowDTO.getTypeIdForClass().equals(typeId)) { - return new LocalDirectoryNode(key.getSearchResults(), (LocalDirectoryRowDTO)key.getRow()); + return new LocalDirectoryNode(key.getSearchResults(), (LocalDirectoryRowDTO) key.getRow()); } else if (VirtualDirectoryRowDTO.getTypeIdForClass().equals(typeId)) { - return new VirtualDirectoryNode(key.getSearchResults(), (VirtualDirectoryRowDTO)key.getRow()); + return new VirtualDirectoryNode(key.getSearchResults(), (VirtualDirectoryRowDTO) key.getRow()); } else if (LayoutFileRowDTO.getTypeIdForClass().equals(typeId)) { - return new LayoutFileNode(key.getSearchResults(), (LayoutFileRowDTO)key.getRow()); + return new LayoutFileNode(key.getSearchResults(), (LayoutFileRowDTO) key.getRow()); } else if (PoolRowDTO.getTypeIdForClass().equals(typeId)) { - return new PoolNode(key.getSearchResults(), (PoolRowDTO)key.getRow()); + return new PoolNode(key.getSearchResults(), (PoolRowDTO) key.getRow()); } else { logger.log(Level.WARNING, MessageFormat.format("No known node for type id: {0} provided by row result: {1}", typeId, key.getRow())); } diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/SpecialDirectoryNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SpecialDirectoryNode.java index 2ca49eaf2149ef8d2e06fec770debf30b430994e..4d01153ae8fcec3c756ad522c5e5868a696a2a61 100755 --- a/Core/src/org/sleuthkit/autopsy/mainui/nodes/SpecialDirectoryNode.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/SpecialDirectoryNode.java @@ -34,7 +34,14 @@ */ abstract class SpecialDirectoryNode extends BaseNode<SearchResultsDTO, FileSystemRowDTO<? extends SpecialDirectory>> { - SpecialDirectoryNode(SearchResultsDTO results, FileSystemRowDTO<? extends SpecialDirectory> row) { + /** + * An abstract base class for FileSystem objects that are subclasses of + * SpecialDirectory. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ + private SpecialDirectoryNode(SearchResultsDTO results, FileSystemRowDTO<? extends SpecialDirectory> row) { super(Children.LEAF, ContentNodeUtil.getLookup(row.getContent()), results, row); setDisplayName(row.getContent().getName()); setShortDescription(row.getContent().getName()); @@ -77,6 +84,12 @@ public Optional<Content> getDataSourceForActions() { */ public static class LocalDirectoryNode extends SpecialDirectoryNode { + /** + * Simple node constructor. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ public LocalDirectoryNode(SearchResultsDTO results, LocalDirectoryRowDTO row) { super(results, row); setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); @@ -88,6 +101,12 @@ public LocalDirectoryNode(SearchResultsDTO results, LocalDirectoryRowDTO row) { */ public static class VirtualDirectoryNode extends SpecialDirectoryNode { + /** + * Simple node constructor. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ public VirtualDirectoryNode(SearchResultsDTO results, VirtualDirectoryRowDTO row) { super(results, row); setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-virtual.png"); @@ -101,6 +120,12 @@ public VirtualDirectoryNode(SearchResultsDTO results, VirtualDirectoryRowDTO row */ public static class LocalFileDataSourceNode extends VirtualDirectoryNode { + /** + * Simple node constructor. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ public LocalFileDataSourceNode(SearchResultsDTO results, LocalFileDataSourceRowDTO row) { super(results, row); this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java b/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java index 38eb5ef88a529abeaad7824d77e85579a041b535..9efc1796c53cb581a7ffe9d17649f2050d622a8e 100644 --- a/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java +++ b/Core/src/org/sleuthkit/autopsy/mainui/nodes/VolumeNode.java @@ -29,8 +29,17 @@ import org.sleuthkit.autopsy.mainui.nodes.actions.ActionsFactory; import org.sleuthkit.autopsy.mainui.nodes.actions.ActionsFactory.ActionGroup; +/** + * A node representing a Volume. + */ public class VolumeNode extends BaseNode<SearchResultsDTO, VolumeRowDTO> { + /** + * Simple node constructor. + * + * @param results The search result DTO. + * @param row The table row DTO. + */ public VolumeNode(SearchResultsDTO results, VolumeRowDTO row) { super(Children.LEAF, ContentNodeUtil.getLookup(row.getContent()), results, row); setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); //NON-NLS