mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +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.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.datamodel.ContainerSummary;
|
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.getFetchResult;
|
||||||
import static org.sleuthkit.autopsy.datasourcesummary.ui.BaseDataSourceSummaryPanel.getTableExport;
|
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchResult.ResultType;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchResult.ResultType;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker.DataFetchComponents;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetcher;
|
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.DefaultUpdateGovernor;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelExport;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelExport;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelSpecialFormatExport;
|
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelSpecialFormatExport;
|
||||||
import org.sleuthkit.autopsy.datasourcesummary.uiutils.ExcelSpecialFormatExport.KeyValueItemExportable;
|
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.autopsy.datasourcesummary.uiutils.UpdateGovernor;
|
||||||
import org.sleuthkit.datamodel.DataSource;
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
@ -289,6 +292,31 @@ class ContainerPanel extends BaseDataSourceSummaryPanel {
|
|||||||
((DefaultTableModel) filePathsTable.getModel()).setRowCount(0);
|
((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
|
@Override
|
||||||
List<ExcelExport.ExcelSheetExport> getExports(DataSource ds) {
|
List<ExcelExport.ExcelSheetExport> getExports(DataSource ds) {
|
||||||
ContainerPanelData result = getFetchResult(containerDataFetcher, "Container sheets", 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_originalName(), ds.getName()),
|
||||||
new KeyValueItemExportable(Bundle.ContainerPanel_export_deviceId(), ds.getDeviceId()),
|
new KeyValueItemExportable(Bundle.ContainerPanel_export_deviceId(), ds.getDeviceId()),
|
||||||
new KeyValueItemExportable(Bundle.ContainerPanel_export_timeZone(), ds.getTimeZone()),
|
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
|
* @author gregd
|
||||||
*/
|
*/
|
||||||
public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
||||||
|
|
||||||
public static class ExcelItemResult {
|
public static class ExcelItemResult {
|
||||||
|
|
||||||
private final int rowStart;
|
private final int rowStart;
|
||||||
private final int rowEnd;
|
private final int rowEnd;
|
||||||
private final int colStart;
|
private final int colStart;
|
||||||
@ -48,12 +50,13 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface ExcelItemExportable {
|
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 {
|
public static class KeyValueItemExportable implements ExcelItemExportable {
|
||||||
|
|
||||||
private final ExcelCellModel key;
|
private final ExcelCellModel key;
|
||||||
private final ExcelCellModel value;
|
private final ExcelCellModel value;
|
||||||
private final int colStart;
|
private final int colStart;
|
||||||
@ -69,13 +72,12 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Row row = sheet.getRow(rowStart);
|
||||||
ExcelExport.createCell(row, colStart, key, Optional.of(env.getHeaderStyle()));
|
ExcelExport.createCell(row, colStart, key, Optional.of(env.getHeaderStyle()));
|
||||||
ExcelExport.createCell(row, colStart + 1, value, Optional.empty());
|
ExcelExport.createCell(row, colStart + 1, value, Optional.empty());
|
||||||
return rowStart + 1;
|
return rowStart + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String sheetName;
|
private final String sheetName;
|
||||||
@ -86,7 +88,35 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
|||||||
this.exports = exports == null ? Collections.emptyList() : exports;
|
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
|
@Override
|
||||||
public String getSheetName() {
|
public String getSheetName() {
|
||||||
@ -101,7 +131,7 @@ public class ExcelSpecialFormatExport implements ExcelExport.ExcelSheetExport {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int endRow = export.write(sheet, rowStart, env);
|
int endRow = export.write(sheet, rowStart, 1, env);
|
||||||
rowStart = endRow + 1;
|
rowStart = endRow + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ public class ExcelTableExport<T, C extends ExcelCellModel> implements ExcelSheet
|
|||||||
private final String sheetName;
|
private final String sheetName;
|
||||||
private final List<ColumnModel<T, C>> columns;
|
private final List<ColumnModel<T, C>> columns;
|
||||||
private final List<T> data;
|
private final List<T> data;
|
||||||
private final int colStart;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main constructor.
|
* Main constructor.
|
||||||
@ -63,14 +62,9 @@ public class ExcelTableExport<T, C extends ExcelCellModel> implements ExcelSheet
|
|||||||
* @param data The data to export.
|
* @param data The data to export.
|
||||||
*/
|
*/
|
||||||
public ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data) {
|
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.sheetName = sheetName;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.colStart = colStart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,12 +74,12 @@ public class ExcelTableExport<T, C extends ExcelCellModel> implements ExcelSheet
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderSheet(Sheet sheet, ExcelExport.WorksheetEnv style) throws ExcelExport.ExcelExportException {
|
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
|
@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);
|
int rowsWritten = renderSheet(sheet, env, rowStart, colStart, columns, data);
|
||||||
return rowStart + rowsWritten - 1;
|
return rowStart + rowsWritten - 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user