Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CaseMetadata.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2015 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.casemodule;
20 
21 import java.nio.file.Path;
22 
26 public final class CaseMetadata {
27 
32  public final static class CaseMetadataException extends Exception {
33 
34  private static final long serialVersionUID = 1L;
35 
36  private CaseMetadataException(String message) {
37  super(message);
38  }
39 
40  private CaseMetadataException(String message, Throwable cause) {
41  super(message, cause);
42  }
43  }
44 
45  private final Case.CaseType caseType;
46  private final String caseName;
47  private final String caseNumber;
48  private final String examiner;
49  private final String caseDirectory;
50  private final String caseDatabaseName;
51  private final String caseTextIndexName;
52 
58  public CaseMetadata(Path metadataFilePath) throws CaseMetadataException {
59  try {
60  /*
61  * TODO (RC): This class should eventually replace the non-public
62  * and unsafe XMLCaseManagement class altogether.
63  */
64  XMLCaseManagement metadata = new XMLCaseManagement();
65  metadata.open(metadataFilePath.toString());
66  try {
67  caseType = metadata.getCaseType();
68  } catch (NullPointerException unused) {
69  throw new CaseMetadataException("Case type element missing");
70  }
71  try {
72  caseName = metadata.getCaseName();
73  if (caseName.isEmpty()) {
74  throw new CaseMetadataException("Case name missing");
75  }
76  } catch (NullPointerException unused) {
77  throw new CaseMetadataException("Case name element missing");
78  }
79  try {
80  caseNumber = metadata.getCaseNumber();
81  } catch (NullPointerException unused) {
82  throw new CaseMetadataException("Case number element missing");
83  }
84  try {
85  examiner = metadata.getCaseExaminer();
86  } catch (NullPointerException unused) {
87  throw new CaseMetadataException("Examiner element missing");
88  }
89  try {
90  caseDirectory = metadata.getCaseDirectory();
91  if (caseDirectory.isEmpty()) {
92  throw new CaseMetadataException("Case directory missing");
93  }
94  } catch (NullPointerException unused) {
95  throw new CaseMetadataException("Case directory element missing");
96  }
97  try {
98  caseDatabaseName = metadata.getDatabaseName();
99  } catch (NullPointerException unused) {
100  throw new CaseMetadataException("Case database element missing");
101  }
102  try {
103  caseTextIndexName = metadata.getTextIndexName();
104  if (Case.CaseType.MULTI_USER_CASE == caseType && caseDatabaseName.isEmpty()) {
105  throw new CaseMetadataException("Case keyword search index name missing");
106  }
107  } catch (NullPointerException unused) {
108  throw new CaseMetadataException("Case keyword search index name missing");
109  }
110  } catch (CaseActionException ex) {
111  throw new CaseMetadataException(ex.getLocalizedMessage(), ex);
112  }
113  }
114 
121  return this.caseType;
122  }
123 
129  public String getCaseName() {
130  return caseName;
131  }
132 
138  public String getCaseNumber() {
139  return caseNumber;
140  }
141 
147  public String getExaminer() {
148  return examiner;
149  }
150 
156  public String getCaseDirectory() {
157  return caseDirectory;
158  }
159 
165  public String getCaseDatabaseName() {
166  return caseDatabaseName;
167  }
168 
174  public String getTextIndexName() {
175  return caseTextIndexName;
176  }
177 
178 }

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.