Example #1
0
  /**
   * Creates a new case (create the XML config file and database)
   *
   * @param caseDir The directory to store case data in. Will be created if it doesn't already
   *     exist. If it exists, it should have all of the needed sub dirs that createCaseDirectory()
   *     will create.
   * @param caseName the name of case
   * @param caseNumber the case number
   * @param examiner the examiner for this case
   */
  public static void create(String caseDir, String caseName, String caseNumber, String examiner)
      throws CaseActionException {
    logger.log(
        Level.INFO,
        "Creating new case.\ncaseDir: {0}\ncaseName: {1}",
        new Object[] {caseDir, caseName});

    // create case directory if it doesn't already exist.
    if (new File(caseDir).exists() == false) {
      Case.createCaseDirectory(caseDir);
    }

    String configFilePath = caseDir + File.separator + caseName + CASE_DOT_EXTENSION;

    XMLCaseManagement xmlcm = new XMLCaseManagement();
    xmlcm.create(caseDir, caseName, examiner, caseNumber); // create a new XML config file
    xmlcm.writeFile();

    String dbPath = caseDir + File.separator + "autopsy.db";
    SleuthkitCase db = null;
    try {
      db = SleuthkitCase.newCase(dbPath);
    } catch (TskCoreException ex) {
      logger.log(Level.SEVERE, "Error creating a case: " + caseName + " in dir " + caseDir, ex);
      throw new CaseActionException(
          "Error creating a case: " + caseName + " in dir " + caseDir, ex);
    }

    Case newCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db);

    changeCase(newCase);
  }
Example #2
0
 /**
  * get the created date of this case
  *
  * @return case creation date
  */
 public String getCreatedDate() {
   if (xmlcm == null) {
     return "";
   } else {
     return xmlcm.getCreatedDate();
   }
 }
Example #3
0
 /**
  * Gets the full path to the cache directory of this case
  *
  * @return cacheDirectoryPath
  */
 public String getCacheDirectory() {
   if (xmlcm == null) {
     return "";
   } else {
     return xmlcm.getCacheDir();
   }
 }
Example #4
0
  /**
   * Updates the case number
   *
   * @param oldCaseNumber the old case number
   * @param newCaseNumber the new case number
   */
  void updateCaseNumber(String oldCaseNumber, String newCaseNumber) throws CaseActionException {
    try {
      xmlcm.setCaseNumber(newCaseNumber); // set the case number
      number = newCaseNumber;

      pcs.firePropertyChange(CASE_NUMBER, oldCaseNumber, newCaseNumber);
    } catch (Exception e) {
      throw new CaseActionException("Error while trying to update the case number.", e);
    }
  }
Example #5
0
  /**
   * Updates the case examiner
   *
   * @param oldExaminer the old examiner
   * @param newExaminer the new examiner
   */
  void updateExaminer(String oldExaminer, String newExaminer) throws CaseActionException {
    try {
      xmlcm.setCaseExaminer(newExaminer); // set the examiner
      examiner = newExaminer;

      pcs.firePropertyChange(CASE_EXAMINER, oldExaminer, newExaminer);
    } catch (Exception e) {
      throw new CaseActionException("Error while trying to update the examiner.", e);
    }
  }
Example #6
0
  /**
   * Updates the case name.
   *
   * @param oldCaseName the old case name that wants to be updated
   * @param oldPath the old path that wants to be updated
   * @param newCaseName the new case name
   * @param newPath the new path
   */
  void updateCaseName(String oldCaseName, String oldPath, String newCaseName, String newPath)
      throws CaseActionException {
    try {
      xmlcm.setCaseName(newCaseName); // set the case
      name = newCaseName; // change the local value
      RecentCases.getInstance()
          .updateRecentCase(oldCaseName, oldPath, newCaseName, newPath); // update the recent case

      pcs.firePropertyChange(CASE_NAME, oldCaseName, newCaseName);
      doCaseNameChange(newCaseName);

    } catch (Exception e) {
      throw new CaseActionException("Error while trying to update the case name.", e);
    }
  }
Example #7
0
  /**
   * Delete this case. This methods delete all folders and files of this case.
   *
   * @param caseDir case dir to delete
   * @throws CaseActionException exception throw if case could not be deleted
   */
  void deleteCase(File caseDir) throws CaseActionException {
    logger.log(Level.INFO, "Deleting case.\ncaseDir: {0}", caseDir);

    try {

      xmlcm.close(); // close the xmlcm
      boolean result = deleteCaseDirectory(caseDir); // delete the directory

      RecentCases.getInstance()
          .removeRecentCase(this.name, this.configFilePath); // remove it from the recent case
      Case.changeCase(null);
      if (result == false) {
        throw new CaseActionException("Error deleting the case dir: " + caseDir);
      }
    } catch (Exception ex) {
      logger.log(Level.SEVERE, "Error deleting the current case dir: " + caseDir, ex);
      throw new CaseActionException("Error deleting the case dir: " + caseDir, ex);
    }
  }
Example #8
0
  /**
   * Opens the existing case (open the XML config file)
   *
   * @param configFilePath the path of the configuration file that's opened
   * @throws CaseActionException
   */
  static void open(String configFilePath) throws CaseActionException {
    logger.log(Level.INFO, "Opening case.\nconfigFilePath: {0}", configFilePath);

    try {
      XMLCaseManagement xmlcm = new XMLCaseManagement();

      xmlcm.open(
          configFilePath); // open and load the config file to the document handler in the XML class
      xmlcm.writeFile(); // write any changes to the config file

      String caseName = xmlcm.getCaseName();
      String caseNumber = xmlcm.getCaseNumber();
      String examiner = xmlcm.getCaseExaminer();
      // if the caseName is "", case / config file can't be opened
      if (caseName.equals("")) {
        throw new CaseActionException("Case name is blank.");
      }

      String caseDir = xmlcm.getCaseDirectory();
      String dbPath = caseDir + File.separator + "autopsy.db";
      SleuthkitCase db = SleuthkitCase.openCase(dbPath);

      checkImagesExist(db);

      Case openedCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db);

      changeCase(openedCase);

    } catch (Exception ex) {
      logger.log(Level.SEVERE, "Error opening the case: ", ex);
      // close the previous case if there's any
      CaseCloseAction closeCase = SystemAction.get(CaseCloseAction.class);
      closeCase.actionPerformed(null);
      if (!configFilePath.endsWith(CASE_DOT_EXTENSION)) {
        throw new CaseActionException(
            "Check that you selected the correct case file (usually with "
                + CASE_DOT_EXTENSION
                + " extension)",
            ex);
      } else {
        throw new CaseActionException("Error opening the case", ex);
      }
    }
  }