mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #7116 from wschaeferB/7801-NotifyUserOfErrorsInManageHosts
7801 - changes to notify user when errors occur with manage hosts
This commit is contained in:
commit
11ddc1af30
@ -15,6 +15,14 @@ CTL_OpenHosts=Manage Hosts
|
||||
HostNameValidator_getValidationMessage_onDuplicate=Another host already has the same name. Please choose a different name.
|
||||
HostNameValidator_getValidationMessage_onEmpty=Please provide some text for the host name.
|
||||
HostNameValidator_getValidationMessage_sameAsOriginal=Please provide a new name for this host.
|
||||
# {0} - hostname
|
||||
ManageHostsDialog.failureToAdd.txt=Unable to add new host {0} at this time.
|
||||
# {0} - hostname
|
||||
ManageHostsDialog.failureToDelete.txt=Unable to delete host {0} at this time.
|
||||
# {0} - hostname
|
||||
# {1} - hostId
|
||||
ManageHostsDialog.failureToEdit.txt=Unable to update host {0} with id: {1} at this time.
|
||||
ManageHostsDialog.failureToGetHosts.txt=There was an error while fetching hosts for current case.
|
||||
# To change this license header, choose License Headers in Project Properties.
|
||||
# To change this template file, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
@ -30,6 +38,7 @@ AddEditHostDialog.nameLabel.text=Name:
|
||||
AddEditHostDialog.okButton.text=OK
|
||||
AddEditHostDialog.cancelButton.text=Cancel
|
||||
AddEditHostDialog.inputTextField.text=jTextField1
|
||||
ManageHostsDialog.seeLog.txt=\ See log for more information.
|
||||
ManageHostsDialog_title_text=Manage Hosts
|
||||
# {0} - sourceHost
|
||||
# {1} - destHost
|
||||
|
@ -31,10 +31,12 @@ import java.util.stream.Collectors;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.ListModel;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.datamodel.DataSource;
|
||||
import org.sleuthkit.datamodel.Host;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
@ -161,6 +163,9 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
/**
|
||||
* Shows add/edit dialog, and if a value is returned, creates a new Host.
|
||||
*/
|
||||
@NbBundle.Messages({"# {0} - hostname",
|
||||
"ManageHostsDialog.failureToAdd.txt=Unable to add new host {0} at this time.",
|
||||
"ManageHostsDialog.seeLog.txt= See log for more information."})
|
||||
private void addHost() {
|
||||
String newHostName = getAddEditDialogName(null);
|
||||
if (newHostName != null) {
|
||||
@ -169,7 +174,8 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
Host newHost = Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().newHost(newHostName);
|
||||
selectedId = newHost == null ? null : newHost.getHostId();
|
||||
} catch (NoCurrentCaseException | TskCoreException e) {
|
||||
logger.log(Level.WARNING, String.format("Unable to add new host '%s' at this time.", newHostName), e);
|
||||
logger.log(Level.WARNING, Bundle.ManageHostsDialog_failureToAdd_txt(newHostName), e);
|
||||
MessageNotifyUtil.Message.warn(Bundle.ManageHostsDialog_failureToAdd_txt(newHostName) + Bundle.ManageHostsDialog_seeLog_txt());
|
||||
}
|
||||
refresh();
|
||||
setSelectedHostById(selectedId);
|
||||
@ -181,12 +187,15 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
*
|
||||
* @param selectedHost
|
||||
*/
|
||||
@NbBundle.Messages({"# {0} - hostname",
|
||||
"ManageHostsDialog.failureToDelete.txt=Unable to delete host {0} at this time."})
|
||||
private void deleteHost(Host selectedHost) {
|
||||
if (selectedHost != null && selectedHost.getName() != null) {
|
||||
try {
|
||||
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().deleteHost(selectedHost.getName());
|
||||
} catch (NoCurrentCaseException | TskCoreException e) {
|
||||
logger.log(Level.WARNING, String.format("Unable to delete host '%s' at this time.", selectedHost.getName()), e);
|
||||
logger.log(Level.WARNING, Bundle.ManageHostsDialog_failureToDelete_txt(selectedHost.getName()), e);
|
||||
MessageNotifyUtil.Message.error(Bundle.ManageHostsDialog_failureToDelete_txt(selectedHost.getName()) + Bundle.ManageHostsDialog_seeLog_txt());
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
@ -229,6 +238,9 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
*
|
||||
* @param selectedHost The selected host.
|
||||
*/
|
||||
@NbBundle.Messages({"# {0} - hostname",
|
||||
"# {1} - hostId",
|
||||
"ManageHostsDialog.failureToEdit.txt=Unable to update host {0} with id: {1} at this time."})
|
||||
private void editHost(Host selectedHost) {
|
||||
|
||||
if (selectedHost != null) {
|
||||
@ -237,7 +249,8 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
try {
|
||||
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().updateHostName(selectedHost, newHostName);
|
||||
} catch (NoCurrentCaseException | TskCoreException e) {
|
||||
logger.log(Level.WARNING, String.format("Unable to update host '%s' with id: %d at this time.", selectedHost.getName(), selectedHost.getHostId()), e);
|
||||
logger.log(Level.WARNING, Bundle.ManageHostsDialog_failureToEdit_txt(selectedHost.getName(), selectedHost.getHostId()), e);
|
||||
MessageNotifyUtil.Message.warn(Bundle.ManageHostsDialog_failureToEdit_txt(selectedHost.getName(), selectedHost.getHostId()) + Bundle.ManageHostsDialog_seeLog_txt());
|
||||
}
|
||||
|
||||
HostListItem selectedItem = hostList.getSelectedValue();
|
||||
@ -255,6 +268,7 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
*
|
||||
* @param origValue The original values for the host or null if adding a
|
||||
* host.
|
||||
*
|
||||
* @return The new name for the host or null if operation was cancelled.
|
||||
*/
|
||||
private String getAddEditDialogName(Host origValue) {
|
||||
@ -305,6 +319,7 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
* host is null.
|
||||
*
|
||||
* @param h The host.
|
||||
*
|
||||
* @return The name of the host or empty string.
|
||||
*/
|
||||
private String getNameOrEmpty(Host h) {
|
||||
@ -317,6 +332,7 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
* @return The list of hosts to be displayed in the list (sorted
|
||||
* alphabetically).
|
||||
*/
|
||||
@NbBundle.Messages({"ManageHostsDialog.failureToGetHosts.txt=There was an error while fetching hosts for current case."})
|
||||
private Map<Host, List<DataSource>> getHostListData() {
|
||||
Map<Host, List<DataSource>> hostMapping = new HashMap<>();
|
||||
try {
|
||||
@ -339,7 +355,8 @@ public class ManageHostsDialog extends javax.swing.JDialog {
|
||||
}
|
||||
|
||||
} catch (TskCoreException | NoCurrentCaseException ex) {
|
||||
logger.log(Level.WARNING, "There was an error while fetching hosts for current case.", ex);
|
||||
logger.log(Level.WARNING, Bundle.ManageHostsDialog_failureToGetHosts_txt(), ex);
|
||||
MessageNotifyUtil.Message.warn(Bundle.ManageHostsDialog_failureToGetHosts_txt() + Bundle.ManageHostsDialog_seeLog_txt());
|
||||
}
|
||||
|
||||
return hostMapping;
|
||||
|
Loading…
x
Reference in New Issue
Block a user