mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
8062 fix container summary NPE
This commit is contained in:
parent
cc51e9d095
commit
572bfd44f7
@ -22,10 +22,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.DataSource;
|
||||
@ -151,9 +149,9 @@ public class ContainerSummary {
|
||||
* Generates a string which is a concatenation of the value received from
|
||||
* the result set.
|
||||
*
|
||||
* @param query The query.
|
||||
* @param valueParam The parameter for the value in the result set.
|
||||
* @param separator The string separator used in concatenation.
|
||||
* @param query The query.
|
||||
* @param valueParam The parameter for the value in the result set.
|
||||
* @param separator The string separator used in concatenation.
|
||||
*
|
||||
* @return The concatenated string or null if the query could not be
|
||||
* executed.
|
||||
@ -218,7 +216,7 @@ public class ContainerSummary {
|
||||
*/
|
||||
public static class ImageDetails {
|
||||
|
||||
private final long unallocatedSize;
|
||||
private final Long unallocatedSize;
|
||||
private final long size;
|
||||
private final long sectorSize;
|
||||
|
||||
@ -233,7 +231,8 @@ public class ContainerSummary {
|
||||
/**
|
||||
* Main constructor.
|
||||
*
|
||||
* @param unallocatedSize Size in bytes of unallocated space.
|
||||
* @param unallocatedSize Size in bytes of unallocated space or null if
|
||||
* no unallocated space could be determined.
|
||||
* @param size Total size in bytes.
|
||||
* @param sectorSize Sector size in bytes.
|
||||
* @param timeZone The time zone.
|
||||
@ -243,7 +242,7 @@ public class ContainerSummary {
|
||||
* @param sha1Hash The sha1 hash or null.
|
||||
* @param sha256Hash The sha256 hash or null.
|
||||
*/
|
||||
ImageDetails(long unallocatedSize, long size, long sectorSize,
|
||||
ImageDetails(Long unallocatedSize, long size, long sectorSize,
|
||||
String timeZone, String imageType, List<String> paths, String md5Hash,
|
||||
String sha1Hash, String sha256Hash) {
|
||||
this.unallocatedSize = unallocatedSize;
|
||||
@ -258,9 +257,10 @@ public class ContainerSummary {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Size in bytes of unallocated space.
|
||||
* @return Size in bytes of unallocated space or null if no unallocated
|
||||
* space could be determined.
|
||||
*/
|
||||
public long getUnallocatedSize() {
|
||||
public Long getUnallocatedSize() {
|
||||
return unallocatedSize;
|
||||
}
|
||||
|
||||
@ -426,8 +426,8 @@ public class ContainerSummary {
|
||||
|
||||
Long unallocSize = getSizeOfUnallocatedFiles(image);
|
||||
String imageType = image.getType().getName();
|
||||
Long size = image.getSize();
|
||||
Long sectorSize = image.getSsize();
|
||||
long size = image.getSize();
|
||||
long sectorSize = image.getSsize();
|
||||
String timeZone = image.getTimeZone();
|
||||
List<String> paths = image.getPaths() == null ? Collections.emptyList() : Arrays.asList(image.getPaths());
|
||||
String md5 = image.getMd5();
|
||||
|
@ -174,7 +174,13 @@ class ContainerPanel extends BaseDataSourceSummaryPanel {
|
||||
* @param viewModel The image view model data.
|
||||
*/
|
||||
private void setFieldsForImage(ImageDetails viewModel) {
|
||||
unallocatedSizeValue.setText(SizeRepresentationUtil.getSizeString(viewModel.getUnallocatedSize()));
|
||||
Long unallocatedSize = viewModel.getUnallocatedSize();
|
||||
if (unallocatedSize == null) {
|
||||
unallocatedSizeValue.setText(Bundle.ContainerPanel_setFieldsForNonImageDataSource_na());
|
||||
} else {
|
||||
unallocatedSizeValue.setText(SizeRepresentationUtil.getSizeString(unallocatedSize));
|
||||
}
|
||||
|
||||
imageTypeValue.setText(viewModel.getImageType());
|
||||
sizeValue.setText(SizeRepresentationUtil.getSizeString(viewModel.getSize()));
|
||||
sectorSizeValue.setText(SizeRepresentationUtil.getSizeString(viewModel.getSectorSize()));
|
||||
|
@ -55,8 +55,9 @@ class ExportContainerInfo {
|
||||
* separate cells in an excel export.
|
||||
*
|
||||
* @param acquisitionDetails The acquisition details.
|
||||
*
|
||||
* @return The list of key value pairs that can be incorporated into the
|
||||
* excel export.
|
||||
* excel export.
|
||||
*/
|
||||
private static List<? extends ExcelItemExportable> getAcquisitionDetails(String acquisitionDetails) {
|
||||
if (StringUtils.isBlank(acquisitionDetails)) {
|
||||
@ -105,26 +106,38 @@ class ExportContainerInfo {
|
||||
DefaultCellModel<?> md5 = hasImage ? new DefaultCellModel<>(imageDetails.getMd5Hash()) : NACell;
|
||||
DefaultCellModel<?> sha1 = hasImage ? new DefaultCellModel<>(imageDetails.getSha1Hash()) : NACell;
|
||||
DefaultCellModel<?> sha256 = hasImage ? new DefaultCellModel<>(imageDetails.getSha256Hash()) : NACell;
|
||||
DefaultCellModel<?> unallocatedSize = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getUnallocatedSize()) : NACell;
|
||||
|
||||
DefaultCellModel<?> unallocatedSize;
|
||||
if (hasImage) {
|
||||
Long unallocatedSizeVal = imageDetails.getUnallocatedSize();
|
||||
if (unallocatedSizeVal != null) {
|
||||
unallocatedSize = SizeRepresentationUtil.getBytesCell(unallocatedSizeVal);
|
||||
} else {
|
||||
unallocatedSize = NACell;
|
||||
}
|
||||
} else {
|
||||
unallocatedSize = NACell;
|
||||
}
|
||||
|
||||
List<String> paths = containerDetails.getImageDetails() == null ? Collections.singletonList(NA) : containerDetails.getImageDetails().getPaths();
|
||||
List<SingleCellExportable> cellPaths = paths.stream()
|
||||
.map(SingleCellExportable::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return Arrays.asList(new ExcelSpecialFormatExport(Bundle.ExportContainerInfo_tabName(), Arrays.asList(new KeyValueItemExportable(Bundle.ExportContainerInfo_export_displayName(), new DefaultCellModel<>(containerDetails.getDisplayName())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_originalName(), new DefaultCellModel<>(containerDetails.getOriginalName())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_deviceId(), new DefaultCellModel<>(containerDetails.getDeviceId())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_timeZone(), timeZone),
|
||||
new TitledExportable(Bundle.ExportContainerInfo_export_acquisitionDetails(), getAcquisitionDetails(containerDetails.getAcquisitionDetails())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_imageType(), imageType),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_size(), size),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sectorSize(), sectorSize),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_md5(), md5),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha1(), sha1),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha256(), sha256),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_unallocatedSize(), unallocatedSize),
|
||||
new TitledExportable(Bundle.ExportContainerInfo_export_filePaths(), cellPaths)
|
||||
)));
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_originalName(), new DefaultCellModel<>(containerDetails.getOriginalName())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_deviceId(), new DefaultCellModel<>(containerDetails.getDeviceId())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_timeZone(), timeZone),
|
||||
new TitledExportable(Bundle.ExportContainerInfo_export_acquisitionDetails(), getAcquisitionDetails(containerDetails.getAcquisitionDetails())),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_imageType(), imageType),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_size(), size),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sectorSize(), sectorSize),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_md5(), md5),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha1(), sha1),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha256(), sha256),
|
||||
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_unallocatedSize(), unallocatedSize),
|
||||
new TitledExportable(Bundle.ExportContainerInfo_export_filePaths(), cellPaths)
|
||||
)));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user