mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
working through container tab
This commit is contained in:
parent
74e330c216
commit
9fdfac8d5a
@ -25,21 +25,24 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.ContainerSummary;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.PastCasesSummary;
|
||||
import static org.sleuthkit.autopsy.datasourcesummary.ui.BaseDataSourceSummaryPanel.getFetchResult;
|
||||
import static org.sleuthkit.autopsy.datasourcesummary.ui.BaseDataSourceSummaryPanel.getTableExport;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchResult.ResultType;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetcher;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultCellModel;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultUpdateGovernor;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelExport;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelSpecialFormatExport;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelSpecialFormatExport.KeyValueItemExportable;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelSpecialFormatExport.TitledExportable;
|
||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.UpdateGovernor;
|
||||
import org.sleuthkit.datamodel.DataSource;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
@ -289,6 +292,31 @@ class ContainerPanel extends BaseDataSourceSummaryPanel {
|
||||
((DefaultTableModel) filePathsTable.getModel()).setRowCount(0);
|
||||
}
|
||||
|
||||
|
||||
private static List<KeyValueItemExportable> getAcquisitionDetails(String acquisitionDetails) {
|
||||
if (StringUtils.isBlank(acquisitionDetails)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return Stream.of(acquisitionDetails.split("\\r?\\n"))
|
||||
.map((line) -> {
|
||||
if (StringUtils.isBlank(line)) {
|
||||
return null;
|
||||
} else {
|
||||
int colonIdx = line.indexOf(':');
|
||||
if (colonIdx >= 0) {
|
||||
return new KeyValueItemExportable(new DefaultCellModel<>(line.substring(0, colonIdx + 1).trim()),
|
||||
new DefaultCellModel<>(line.substring(colonIdx + 1, line.length()).trim()));
|
||||
} else {
|
||||
return new KeyValueItemExportable(new DefaultCellModel<>(""), new DefaultCellModel<>(line));
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(item -> item != null)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
List<ExcelExport.ExcelSheetExport> getExports(DataSource ds) {
|
||||
ContainerPanelData result = getFetchResult(containerDataFetcher, "Container sheets", ds);
|
||||
@ -302,8 +330,18 @@ class ContainerPanel extends BaseDataSourceSummaryPanel {
|
||||
new KeyValueItemExportable(Bundle.ContainerPanel_export_originalName(), ds.getName()),
|
||||
new KeyValueItemExportable(Bundle.ContainerPanel_export_deviceId(), ds.getDeviceId()),
|
||||
new KeyValueItemExportable(Bundle.ContainerPanel_export_timeZone(), ds.getTimeZone()),
|
||||
new KeyValueItemExportable(Bundle.ContainerPanel_export_acquisitionDetails(), null),
|
||||
// ...acquisition details...
|
||||
|
||||
new TitledExportable(Bundle.ContainerPanel_export_acquisitionDetails(), getAcquisitionDetails(ds.getAcquisitionDetails())),
|
||||
|
||||
new KeyValueItemExportable()
|
||||
imageTypeValue.setText("");
|
||||
sizeValue.setText("");
|
||||
sectorSizeValue.setText("");
|
||||
md5HashValue.setText("");
|
||||
sha1HashValue.setText("");
|
||||
sha256HashValue.setText("");
|
||||
unallocatedSizeValue.setText("");
|
||||
((DefaultTableModel) filePathsTable.getModel()).setRowCount(0);
|
||||
))
|
||||
);
|
||||
}
|
||||
|
@ -18,7 +18,9 @@ import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelTableExport.ExcelCel
|
||||
* @author gregd
|
||||
*/
|
||||
public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
||||
|
||||
public static class ExcelItemResult {
|
||||
|
||||
private final int rowStart;
|
||||
private final int rowEnd;
|
||||
private final int colStart;
|
||||
@ -47,13 +49,14 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
||||
return colEnd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface ExcelItemExportable {
|
||||
int write(Sheet sheet, int rowStart, ExcelExport.WorksheetEnv env) throws ExcelExportException;
|
||||
|
||||
int write(Sheet sheet, int rowStart, int colStart, ExcelExport.WorksheetEnv env) throws ExcelExportException;
|
||||
}
|
||||
|
||||
|
||||
public static class KeyValueItemExportable implements ExcelItemExportable {
|
||||
|
||||
private final ExcelCellModel key;
|
||||
private final ExcelCellModel value;
|
||||
private final int colStart;
|
||||
@ -61,23 +64,22 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
||||
public KeyValueItemExportable(ExcelCellModel key, ExcelCellModel value) {
|
||||
this(key, value, 1);
|
||||
}
|
||||
|
||||
|
||||
public KeyValueItemExportable(ExcelCellModel key, ExcelCellModel value, int colStart) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.colStart = colStart;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int write(Sheet sheet, int rowStart, ExcelExport.WorksheetEnv env) throws ExcelExportException {
|
||||
public int write(Sheet sheet, int rowStart, int colStart, ExcelExport.WorksheetEnv env) throws ExcelExportException {
|
||||
Row row = sheet.getRow(rowStart);
|
||||
ExcelExport.createCell(row, colStart, key, Optional.of(env.getHeaderStyle()));
|
||||
ExcelExport.createCell(row, colStart + 1, value, Optional.empty());
|
||||
return rowStart + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private final String sheetName;
|
||||
private final List<ExcelItemExportable> exports;
|
||||
|
||||
@ -85,9 +87,37 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
||||
this.sheetName = sheetName;
|
||||
this.exports = exports == null ? Collections.emptyList() : exports;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class TitledExportable implements ExcelItemExportable {
|
||||
|
||||
private static final int DEFAULT_INDENT = 1;
|
||||
|
||||
private final String title;
|
||||
private final List<? extends ExcelItemExportable> children;
|
||||
|
||||
public TitledExportable(String title, List<? extends ExcelItemExportable> children) {
|
||||
this.title = title;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int write(Sheet sheet, int rowStart, int colStart, ExcelExport.WorksheetEnv env) throws ExcelExportException {
|
||||
ExcelExport.createCell(sheet.getRow(rowStart), colStart, new DefaultCellModel<>(title), Optional.of(env.getHeaderStyle()));
|
||||
int curRow = rowStart + 1;
|
||||
for (ExcelItemExportable export : children) {
|
||||
if (export == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int endRow = export.write(sheet, rowStart, colStart + DEFAULT_INDENT, env);
|
||||
curRow = endRow + 1;
|
||||
}
|
||||
|
||||
return curRow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSheetName() {
|
||||
return sheetName;
|
||||
@ -100,10 +130,10 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
||||
if (export == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int endRow = export.write(sheet, rowStart, env);
|
||||
|
||||
int endRow = export.write(sheet, rowStart, 1, env);
|
||||
rowStart = endRow + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ public class ExcelTableExport<T, C extends ExcelCellModel> implements ExcelSheet
|
||||
private final String sheetName;
|
||||
private final List<ColumnModel<T, C>> columns;
|
||||
private final List<T> data;
|
||||
private final int colStart;
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
@ -63,14 +62,9 @@ public class ExcelTableExport<T, C extends ExcelCellModel> implements ExcelSheet
|
||||
* @param data The data to export.
|
||||
*/
|
||||
public ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data) {
|
||||
this(sheetName, columns, data, 0);
|
||||
}
|
||||
|
||||
public ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data, int colStart) {
|
||||
this.sheetName = sheetName;
|
||||
this.columns = columns;
|
||||
this.data = data;
|
||||
this.colStart = colStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,12 +74,12 @@ public class ExcelTableExport<T, C extends ExcelCellModel> implements ExcelSheet
|
||||
|
||||
@Override
|
||||
public void renderSheet(Sheet sheet, ExcelExport.WorksheetEnv style) throws ExcelExport.ExcelExportException {
|
||||
renderSheet(sheet, style, 1, colStart, columns, data);
|
||||
renderSheet(sheet, style, 1, 1, columns, data);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int write(Sheet sheet, int rowStart, ExcelExport.WorksheetEnv env) throws ExcelExportException {
|
||||
public int write(Sheet sheet, int rowStart, int colStart, ExcelExport.WorksheetEnv env) throws ExcelExportException {
|
||||
int rowsWritten = renderSheet(sheet, env, rowStart, colStart, columns, data);
|
||||
return rowStart + rowsWritten - 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user