Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
EamDbPlatformEnum.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2017 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.centralrepository.datamodel;
20 
22 
26 public enum EamDbPlatformEnum {
27  DISABLED("Disabled", true),
28  SQLITE("SQLite", false),
29  POSTGRESQL("PostgreSQL", false);
30 
31  private final String platformName;
32  private Boolean selected;
33 
34  EamDbPlatformEnum(String name, Boolean selected) {
35  this.platformName = name;
36  this.selected = selected;
37  loadSettings();
38  }
39 
43  private void loadSettings() {
44  String selectedPlatformString = ModuleSettings.getConfigSetting("CentralRepository", "db.selectedPlatform"); // NON-NLS
45 
46  if (null != selectedPlatformString) {
47  selected = this.toString().equalsIgnoreCase(selectedPlatformString);
48  } else if (this == DISABLED) {
49  selected = true;
50  }
51  }
52 
53  @Override
54  public String toString() {
55  return platformName;
56  }
57 
58  private void setSelected(Boolean selected) {
59  this.selected = selected;
60  }
61 
62  public Boolean isSelected() {
63  return selected;
64  }
65 
66  public static EamDbPlatformEnum fromString(String pName) {
67  if (null == pName) {
68  return DISABLED;
69  }
70 
71  for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) {
72  if (p.toString().equalsIgnoreCase(pName)) {
73  return p;
74  }
75  }
76  return DISABLED;
77  }
78 
82  public static void saveSelectedPlatform() {
83  EamDbPlatformEnum selectedPlatform = DISABLED;
84  for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) {
85  if (p.isSelected()) {
86  selectedPlatform = p;
87  }
88  }
89  ModuleSettings.setConfigSetting("CentralRepository", "db.selectedPlatform", selectedPlatform.name()); // NON-NLS
90  }
91 
98  public static void setSelectedPlatform(String platformString) {
99  EamDbPlatformEnum pSelected = EamDbPlatformEnum.fromString(platformString);
100  for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) {
101  p.setSelected(p == pSelected);
102  }
103  }
104 
112  for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) {
113  if (p.isSelected()) {
114  return p;
115  }
116  }
117  return DISABLED;
118  }
119 }
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static String getConfigSetting(String moduleName, String settingName)

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.