Merge pull request #3520 from zhhl/2229-Part24UsegetOpenCaseInsteadOfgetCurrentCase

2229 Part 24 use getOpenCase() instead of getCurrentCase()
This commit is contained in:
Richard Cordovano 2018-03-09 18:23:12 -05:00 committed by GitHub
commit c985e09dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 18 deletions

View File

@ -20,9 +20,11 @@ package org.sleuthkit.autopsy.casemodule;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import javax.swing.JDialog;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.WindowManager;
@ -51,7 +53,11 @@ class CaseInformationPanel extends javax.swing.JPanel {
"CaseInformationPanel.editDetailsDialog.title=Edit Case Details"
})
private void customizeComponents() {
propertiesPanel = new CasePropertiesPanel(Case.getCurrentCase());
try {
propertiesPanel = new CasePropertiesPanel(Case.getOpenCase());
} catch (NoCurrentCaseException ex) {
Logger.getLogger(CaseInformationPanel.class.getName()).log(Level.INFO, "Exception while getting open case.", ex);
}
propertiesPanel.setSize(propertiesPanel.getPreferredSize());
this.tabbedPane.addTab(Bundle.CaseInformationPanel_caseDetails_header(), propertiesPanel);
this.tabbedPane.addTab(Bundle.CaseInformationPanel_ingestJobInfo_header(), new IngestJobInfoPanel());

View File

@ -49,7 +49,12 @@ final class CasePropertiesPanel extends javax.swing.JPanel {
}
void updateCaseInfo() {
theCase = Case.getCurrentCase();
try {
theCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
lbCaseNameText.setText(theCase.getDisplayName());
lbCaseNumberText.setText(theCase.getNumber());
lbExaminerNameText.setText(theCase.getExaminer());
@ -78,9 +83,9 @@ final class CasePropertiesPanel extends javax.swing.JPanel {
try {
EamDb dbManager = EamDb.getInstance();
if (dbManager != null) {
CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCase());
CorrelationCase correlationCase = dbManager.getCase(theCase);
if (null == correlationCase) {
correlationCase = dbManager.newCase(Case.getCurrentCase());
correlationCase = dbManager.newCase(theCase);
}
currentOrg = correlationCase.getOrg();
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-15 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -59,6 +59,7 @@ import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
import org.openide.util.lookup.ServiceProviders;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.Installer;
import org.sleuthkit.autopsy.corecomponents.FrameCapture;
import org.sleuthkit.autopsy.corecomponents.VideoFrame;
@ -136,7 +137,13 @@ public class FXVideoPanel extends MediaViewVideoPanel {
mediaPane.setInfoLabelText(path);
mediaPane.setInfoLabelToolTipText(path);
final File tempFile = VideoUtils.getTempVideoFile(currentFile);
final File tempFile;
try {
tempFile = VideoUtils.getTempVideoFile(currentFile);
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
new Thread(mediaPane.new ExtractMedia(currentFile, tempFile)).start();

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-15 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -55,6 +55,7 @@ import org.netbeans.api.progress.ProgressHandle;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
import org.openide.util.lookup.ServiceProviders;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponents.FrameCapture;
import org.sleuthkit.autopsy.corecomponents.VideoFrame;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -181,6 +182,7 @@ public class GstVideoPanel extends MediaViewVideoPanel {
}
@Override
@NbBundle.Messages ({"GstVideoPanel.noOpenCase.errMsg=No open case available."})
void setupVideo(final AbstractFile file, final Dimension dims) {
reset();
infoLabel.setText("");
@ -194,6 +196,18 @@ public class GstVideoPanel extends MediaViewVideoPanel {
return;
}
java.io.File ioFile;
try {
ioFile = VideoUtils.getTempVideoFile(file);
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
infoLabel.setText(Bundle.GstVideoPanel_noOpenCase_errMsg());
pauseButton.setEnabled(false);
progressSlider.setEnabled(false);
return;
}
String path = "";
try {
path = file.getUniquePath();
@ -205,7 +219,6 @@ public class GstVideoPanel extends MediaViewVideoPanel {
pauseButton.setEnabled(true);
progressSlider.setEnabled(true);
java.io.File ioFile = VideoUtils.getTempVideoFile(file);
gstVideoComponent = new VideoComponent();
synchronized (playbinLock) {
@ -537,7 +550,14 @@ public class GstVideoPanel extends MediaViewVideoPanel {
return;
}
} else if (state.equals(State.READY)) {
final File tempVideoFile = VideoUtils.getTempVideoFile(currentFile);
final File tempVideoFile;
try {
tempVideoFile = VideoUtils.getTempVideoFile(currentFile);
} catch (NoCurrentCaseException ex) {
logger.log(Level.WARNING, "Exception while getting open case."); //NON-NLS
infoLabel.setText(MEDIA_PLAYER_ERROR_STRING);
return;
}
new ExtractMedia(currentFile, tempVideoFile).execute();

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015-16 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -34,6 +34,7 @@ import org.opencv.core.Mat;
import org.opencv.highgui.VideoCapture;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corelibs.ScalrWrapper;
import static org.sleuthkit.autopsy.coreutils.ImageUtils.isMediaThumbnailSupported;
import org.sleuthkit.autopsy.datamodel.ContentUtils;
@ -90,8 +91,8 @@ public class VideoUtils {
private VideoUtils() {
}
public static File getTempVideoFile(AbstractFile file) {
return Paths.get(Case.getCurrentCase().getTempDirectory(), "videos", file.getId() + "." + file.getNameExtension()).toFile(); //NON-NLS
public static File getTempVideoFile(AbstractFile file) throws NoCurrentCaseException {
return Paths.get(Case.getOpenCase().getTempDirectory(), "videos", file.getId() + "." + file.getNameExtension()).toFile(); //NON-NLS
}
public static boolean isVideoThumbnailSupported(AbstractFile file) {
@ -101,7 +102,13 @@ public class VideoUtils {
@NbBundle.Messages({"# {0} - file name",
"VideoUtils.genVideoThumb.progress.text=extracting temporary file {0}"})
static BufferedImage generateVideoThumbnail(AbstractFile file, int iconSize) {
java.io.File tempFile = getTempVideoFile(file);
java.io.File tempFile;
try {
tempFile = getTempVideoFile(file);
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.WARNING, "Exception while getting open case.", ex); //NON-NLS
return null;
}
if (tempFile.exists() == false || tempFile.length() < file.getSize()) {
ProgressHandle progress = ProgressHandle.createHandle(Bundle.VideoUtils_genVideoThumb_progress_text(file.getName()));
progress.start(100);

View File

@ -29,6 +29,7 @@ import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -144,7 +145,12 @@ public class HashDbIngestModule implements FileIngestModule {
@Override
public ProcessResult process(AbstractFile file) {
blackboard = Case.getCurrentCase().getServices().getBlackboard();
try {
blackboard = Case.getOpenCase().getServices().getBlackboard();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return ProcessResult.ERROR;
}
// Skip unallocated space files.
if ((file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS) ||

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -29,6 +29,7 @@ import java.util.List;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.FileManager;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -99,7 +100,7 @@ class PhotoRecCarverOutputParser {
NodeList fileRanges;
Element entry;
Path filePath;
FileManager fileManager = Case.getCurrentCase().getServices().getFileManager();
FileManager fileManager = Case.getOpenCase().getServices().getFileManager();
// create and initialize the list to put into the database
List<CarvingResult.CarvedFile> carvedFiles = new ArrayList<>();
@ -156,7 +157,7 @@ class PhotoRecCarverOutputParser {
}
}
return fileManager.addCarvedFiles(new CarvingResult(af, carvedFiles));
} catch (NumberFormatException | TskCoreException ex) {
} catch (NumberFormatException | TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error parsing PhotoRec output and inserting it into the database", ex); //NON-NLS
}

View File

@ -29,7 +29,9 @@ import javafx.scene.image.Image;
import javafx.scene.media.Media;
import javafx.scene.media.MediaException;
import org.netbeans.api.progress.ProgressHandle;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.ImageUtils;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.VideoUtils;
@ -85,7 +87,7 @@ public class VideoFile extends DrawableFile {
* @throws MediaException
*/
@NbBundle.Messages({"VideoFile.getMedia.progress=writing temporary file to disk"})
public Media getMedia() throws IOException, MediaException {
public Media getMedia() throws IOException, MediaException, NoCurrentCaseException {
Media media = (mediaRef != null) ? mediaRef.get() : null;
if (media != null) {
@ -119,6 +121,8 @@ public class VideoFile extends DrawableFile {
logger.log(Level.SEVERE, "Error writing video file to disk.", ex); //NON-NLS
} catch (MediaException ex) {
logger.log(Level.SEVERE, "Error creating media from source file.", ex); //NON-NLS
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
}
return retValue;
@ -141,6 +145,8 @@ public class VideoFile extends DrawableFile {
logger.log(Level.SEVERE, "Error writing video file to disk.", ex); //NON-NLS
} catch (MediaException ex) {
logger.log(Level.SEVERE, "Error creating media from source file.", ex); //NON-NLS
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
}
return retValue;