mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-20 03:24:55 +00:00
Extend time stamping to all notifications
This commit is contained in:
parent
571e2985e3
commit
8799601627
@ -242,11 +242,11 @@ LocalFilesPanel.errorLabel.text=Error Label
|
|||||||
NewCaseVisualPanel1.errorLabel.text=Error Label
|
NewCaseVisualPanel1.errorLabel.text=Error Label
|
||||||
CollaborationMonitor.addingDataSourceStatus.msg={0} adding data source
|
CollaborationMonitor.addingDataSourceStatus.msg={0} adding data source
|
||||||
CollaborationMonitor.analyzingDataSourceStatus.msg={0} analyzing {1}
|
CollaborationMonitor.analyzingDataSourceStatus.msg={0} analyzing {1}
|
||||||
CollaborationMonitor.failedService.notify.title={0} Collaboration Service Failed
|
CollaborationMonitor.failedService.notify.title=Collaboration Service Failed
|
||||||
CollaborationMonitor.failedDbService.notify.msg=Lost connection to database server
|
CollaborationMonitor.failedDbService.notify.msg=Lost connection to database server
|
||||||
CollaborationMonitor.failedSolrService.notify.msg=Lost connection to keyword search server
|
CollaborationMonitor.failedSolrService.notify.msg=Lost connection to keyword search server
|
||||||
CollaborationMonitor.failedMessageService.notify.msg=Lost connection to messaging server
|
CollaborationMonitor.failedMessageService.notify.msg=Lost connection to messaging server
|
||||||
CollaborationMonitor.restoredService.notify.title={0} Collaboration Service Restored
|
CollaborationMonitor.restoredService.notify.title=Collaboration Service Restored
|
||||||
CollaborationMonitor.restoredDbService.notify.msg=Connection to database server restored
|
CollaborationMonitor.restoredDbService.notify.msg=Connection to database server restored
|
||||||
CollaborationMonitor.restoredSolrService.notify.msg=Connection to keyword search server restored
|
CollaborationMonitor.restoredSolrService.notify.msg=Connection to keyword search server restored
|
||||||
CollaborationMonitor.restoredMessageService.notify.msg=Connection to messaging server restored
|
CollaborationMonitor.restoredMessageService.notify.msg=Connection to messaging server restored
|
||||||
|
@ -24,11 +24,9 @@ import java.beans.PropertyChangeListener;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -78,7 +76,6 @@ final class CollaborationMonitor {
|
|||||||
private static final long STALE_TASKS_DETECTION_INTERVAL_MINUTES = 2;
|
private static final long STALE_TASKS_DETECTION_INTERVAL_MINUTES = 2;
|
||||||
private static final long CRASH_DETECTION_INTERVAL_MINUTES = 2;
|
private static final long CRASH_DETECTION_INTERVAL_MINUTES = 2;
|
||||||
private static final long EXECUTOR_TERMINATION_WAIT_SECS = 30;
|
private static final long EXECUTOR_TERMINATION_WAIT_SECS = 30;
|
||||||
private static final SimpleDateFormat SERVICE_MSG_DATE_FORMAT = new SimpleDateFormat("MM/dd HH:mm:ss z");
|
|
||||||
private static final Logger logger = Logger.getLogger(CollaborationMonitor.class.getName());
|
private static final Logger logger = Logger.getLogger(CollaborationMonitor.class.getName());
|
||||||
private final String hostName;
|
private final String hostName;
|
||||||
private final LocalTasksManager localTasksManager;
|
private final LocalTasksManager localTasksManager;
|
||||||
@ -541,13 +538,13 @@ final class CollaborationMonitor {
|
|||||||
if (!dbServerIsRunning) {
|
if (!dbServerIsRunning) {
|
||||||
dbServerIsRunning = true;
|
dbServerIsRunning = true;
|
||||||
logger.log(Level.INFO, "Connection to PostgreSQL server restored"); //NON-NLS
|
logger.log(Level.INFO, "Connection to PostgreSQL server restored"); //NON-NLS
|
||||||
MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredDbService.notify.msg"));
|
MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredDbService.notify.msg"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (dbServerIsRunning) {
|
if (dbServerIsRunning) {
|
||||||
dbServerIsRunning = false;
|
dbServerIsRunning = false;
|
||||||
logger.log(Level.SEVERE, "Failed to connect to PostgreSQL server"); //NON-NLS
|
logger.log(Level.SEVERE, "Failed to connect to PostgreSQL server"); //NON-NLS
|
||||||
MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedDbService.notify.msg"));
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedDbService.notify.msg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,14 +554,14 @@ final class CollaborationMonitor {
|
|||||||
if (!solrServerIsRunning) {
|
if (!solrServerIsRunning) {
|
||||||
solrServerIsRunning = true;
|
solrServerIsRunning = true;
|
||||||
logger.log(Level.INFO, "Connection to Solr server restored"); //NON-NLS
|
logger.log(Level.INFO, "Connection to Solr server restored"); //NON-NLS
|
||||||
MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredSolrService.notify.msg"));
|
MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredSolrService.notify.msg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (solrServerIsRunning) {
|
if (solrServerIsRunning) {
|
||||||
solrServerIsRunning = false;
|
solrServerIsRunning = false;
|
||||||
logger.log(Level.SEVERE, "Failed to connect to Solr server"); //NON-NLS
|
logger.log(Level.SEVERE, "Failed to connect to Solr server"); //NON-NLS
|
||||||
MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedSolrService.notify.msg"));
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedSolrService.notify.msg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,13 +574,13 @@ final class CollaborationMonitor {
|
|||||||
if (!messageServerIsRunning) {
|
if (!messageServerIsRunning) {
|
||||||
messageServerIsRunning = true;
|
messageServerIsRunning = true;
|
||||||
logger.log(Level.INFO, "Connection to ActiveMQ server restored"); //NON-NLS
|
logger.log(Level.INFO, "Connection to ActiveMQ server restored"); //NON-NLS
|
||||||
MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredMessageService.notify.msg"));
|
MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredMessageService.notify.msg"));
|
||||||
}
|
}
|
||||||
} catch (URISyntaxException | JMSException ex) {
|
} catch (URISyntaxException | JMSException ex) {
|
||||||
if (messageServerIsRunning) {
|
if (messageServerIsRunning) {
|
||||||
messageServerIsRunning = false;
|
messageServerIsRunning = false;
|
||||||
logger.log(Level.SEVERE, "Failed to connect to ActiveMQ server", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Failed to connect to ActiveMQ server", ex); //NON-NLS
|
||||||
MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedMessageService.notify.msg"));
|
MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedMessageService.notify.msg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2013 Basis Technology Corp.
|
* Copyright 2013-2015 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -20,8 +20,10 @@ package org.sleuthkit.autopsy.coreutils;
|
|||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@ -52,8 +54,8 @@ public class MessageNotifyUtil {
|
|||||||
INFO(NotifyDescriptor.INFORMATION_MESSAGE, "info-icon-16.png"), //NON-NLS
|
INFO(NotifyDescriptor.INFORMATION_MESSAGE, "info-icon-16.png"), //NON-NLS
|
||||||
ERROR(NotifyDescriptor.ERROR_MESSAGE, "error-icon-16.png"), //NON-NLS
|
ERROR(NotifyDescriptor.ERROR_MESSAGE, "error-icon-16.png"), //NON-NLS
|
||||||
WARNING(NotifyDescriptor.WARNING_MESSAGE, "warning-icon-16.png"); //NON-NLS
|
WARNING(NotifyDescriptor.WARNING_MESSAGE, "warning-icon-16.png"); //NON-NLS
|
||||||
private int notifyDescriptorType;
|
private final int notifyDescriptorType;
|
||||||
private Icon icon;
|
private final Icon icon;
|
||||||
|
|
||||||
private MessageType(int notifyDescriptorType, String resourceName) {
|
private MessageType(int notifyDescriptorType, String resourceName) {
|
||||||
this.notifyDescriptorType = notifyDescriptorType;
|
this.notifyDescriptorType = notifyDescriptorType;
|
||||||
@ -142,6 +144,8 @@ public class MessageNotifyUtil {
|
|||||||
*/
|
*/
|
||||||
public static class Notify {
|
public static class Notify {
|
||||||
|
|
||||||
|
private static final SimpleDateFormat TIME_STAMP_FORMAT = new SimpleDateFormat("MM/dd/yy HH:mm:ss z");
|
||||||
|
|
||||||
//notifications to keep track of and to reset when case is closed
|
//notifications to keep track of and to reset when case is closed
|
||||||
private static final List<Notification> notifications = Collections.synchronizedList(new ArrayList<Notification>());
|
private static final List<Notification> notifications = Collections.synchronizedList(new ArrayList<Notification>());
|
||||||
|
|
||||||
@ -149,13 +153,12 @@ public class MessageNotifyUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear pending notifications
|
* Clear pending notifications Should really only be used by Case
|
||||||
* Should really only be used by Case
|
|
||||||
*/
|
*/
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
for (Notification n : notifications) {
|
notifications.stream().forEach((n) -> {
|
||||||
n.clear();
|
n.clear();
|
||||||
}
|
});
|
||||||
notifications.clear();
|
notifications.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,8 +166,8 @@ public class MessageNotifyUtil {
|
|||||||
* Show message with the specified type and action listener
|
* Show message with the specified type and action listener
|
||||||
*/
|
*/
|
||||||
public static void show(String title, String message, MessageType type, ActionListener actionListener) {
|
public static void show(String title, String message, MessageType type, ActionListener actionListener) {
|
||||||
Notification newNotification =
|
Notification newNotification
|
||||||
NotificationDisplayer.getDefault().notify(title, type.getIcon(), message, actionListener);
|
= NotificationDisplayer.getDefault().notify(addTimeStampToTitle(title), type.getIcon(), message, actionListener);
|
||||||
notifications.add(newNotification);
|
notifications.add(newNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,11 +181,8 @@ public class MessageNotifyUtil {
|
|||||||
* @param type type of the message
|
* @param type type of the message
|
||||||
*/
|
*/
|
||||||
public static void show(String title, final String message, final MessageType type) {
|
public static void show(String title, final String message, final MessageType type) {
|
||||||
ActionListener actionListener = new ActionListener() {
|
ActionListener actionListener = (ActionEvent e) -> {
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
MessageNotifyUtil.Message.show(message, type);
|
MessageNotifyUtil.Message.show(message, type);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
show(title, message, type, actionListener);
|
show(title, message, type, actionListener);
|
||||||
@ -217,5 +217,17 @@ public class MessageNotifyUtil {
|
|||||||
public static void warn(String title, String message) {
|
public static void warn(String title, String message) {
|
||||||
show(title, message, MessageType.WARNING);
|
show(title, message, MessageType.WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a time stamp prefix to the title of notifications so that they
|
||||||
|
* will be in order (they are sorted alphabetically) in the
|
||||||
|
* notifications area.
|
||||||
|
*
|
||||||
|
* @param title A notification title without a time stamp prefix.
|
||||||
|
* @return The notification title with a time stamp prefix.
|
||||||
|
*/
|
||||||
|
private static String addTimeStampToTitle(String title) {
|
||||||
|
return TIME_STAMP_FORMAT.format(new Date()) + " " + title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user