19 package org.sleuthkit.autopsy.report.modules.datasourcesummaryexport;
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.stream.Collectors;
25 import java.util.stream.Stream;
26 import org.apache.commons.lang.StringUtils;
27 import org.openide.util.NbBundle.Messages;
42 class ExportContainerInfo {
44 private final ContainerSummary containerSummary;
49 ExportContainerInfo() {
50 containerSummary =
new ContainerSummary();
61 private static List<? extends ExcelItemExportable> getAcquisitionDetails(String acquisitionDetails) {
62 if (StringUtils.isBlank(acquisitionDetails)) {
63 return Collections.emptyList();
65 return Stream.of(acquisitionDetails.split(
"\\r?\\n"))
66 .map((line) -> (StringUtils.isBlank(line)) ? null :
new SingleCellExportable(line))
67 .filter(item -> item != null)
68 .collect(Collectors.toList());
73 "ExportContainerInfo_setFieldsForNonImageDataSource_na=N/A",
74 "ExportContainerInfo_tabName=Container",
75 "ExportContainerInfo_export_displayName=Display Name:",
76 "ExportContainerInfo_export_originalName=Name:",
77 "ExportContainerInfo_export_deviceId=Device ID:",
78 "ExportContainerInfo_export_timeZone=Time Zone:",
79 "ExportContainerInfo_export_acquisitionDetails=Acquisition Details:",
80 "ExportContainerInfo_export_imageType=Image Type:",
81 "ExportContainerInfo_export_size=Size:",
82 "ExportContainerInfo_export_sectorSize=Sector Size:",
83 "ExportContainerInfo_export_md5=MD5:",
84 "ExportContainerInfo_export_sha1=SHA1:",
85 "ExportContainerInfo_export_sha256=SHA256:",
86 "ExportContainerInfo_export_unallocatedSize=Unallocated Space:",
87 "ExportContainerInfo_export_filePaths=File Paths:",})
88 List<ExcelSheetExport> getExports(DataSource ds) {
89 DataFetcher<DataSource, ContainerDetails> containerDataFetcher = (dataSource) -> containerSummary.getContainerDetails(dataSource);
90 ContainerDetails containerDetails = ExcelExportAction.getFetchResult(containerDataFetcher,
"Container sheets", ds);
91 if (ds == null || containerDetails == null) {
92 return Collections.emptyList();
95 String NA = Bundle.ExportContainerInfo_setFieldsForNonImageDataSource_na();
96 DefaultCellModel<?> NACell =
new DefaultCellModel<>(NA);
98 ImageDetails imageDetails = containerDetails.getImageDetails();
99 boolean hasImage = imageDetails != null;
101 DefaultCellModel<?> timeZone = hasImage ?
new DefaultCellModel<>(imageDetails.getTimeZone()) : NACell;
102 DefaultCellModel<?> imageType = hasImage ?
new DefaultCellModel<>(imageDetails.getImageType()) : NACell;
103 DefaultCellModel<?> size = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getSize()) : NACell;
104 DefaultCellModel<?> sectorSize = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getSectorSize()) : NACell;
105 DefaultCellModel<?> md5 = hasImage ?
new DefaultCellModel<>(imageDetails.getMd5Hash()) : NACell;
106 DefaultCellModel<?> sha1 = hasImage ?
new DefaultCellModel<>(imageDetails.getSha1Hash()) : NACell;
107 DefaultCellModel<?> sha256 = hasImage ?
new DefaultCellModel<>(imageDetails.getSha256Hash()) : NACell;
108 DefaultCellModel<?> unallocatedSize = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getUnallocatedSize()) : NACell;
109 List<String> paths = containerDetails.getImageDetails() == null ? Collections.singletonList(NA) : containerDetails.getImageDetails().getPaths();
110 List<SingleCellExportable> cellPaths = paths.stream()
111 .map(SingleCellExportable::new)
112 .collect(Collectors.toList());
114 return Arrays.asList(
new ExcelSpecialFormatExport(Bundle.ExportContainerInfo_tabName(), Arrays.asList(
new KeyValueItemExportable(Bundle.ExportContainerInfo_export_displayName(),
new DefaultCellModel<>(containerDetails.getDisplayName())),
115 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_originalName(),
new DefaultCellModel<>(containerDetails.getOriginalName())),
116 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_deviceId(),
new DefaultCellModel<>(containerDetails.getDeviceId())),
117 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_timeZone(), timeZone),
118 new TitledExportable(Bundle.ExportContainerInfo_export_acquisitionDetails(), getAcquisitionDetails(containerDetails.getAcquisitionDetails())),
119 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_imageType(), imageType),
120 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_size(), size),
121 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sectorSize(), sectorSize),
122 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_md5(), md5),
123 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha1(), sha1),
124 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha256(), sha256),
125 new KeyValueItemExportable(Bundle.ExportContainerInfo_export_unallocatedSize(), unallocatedSize),
126 new TitledExportable(Bundle.ExportContainerInfo_export_filePaths(), cellPaths)