mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-06 02:24:30 +00:00
Fixes: CaseCloseAction, event pacakge concurrency
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2014 Basis Technology Corp.
|
||||
* Copyright 2011-2015 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -31,23 +31,6 @@ import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.actions.CallableSystemAction;
|
||||
import org.openide.util.actions.Presenter;
|
||||
;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.actions.CallableSystemAction;
|
||||
import org.openide.util.actions.Presenter;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.actions.CallableSystemAction;
|
||||
import org.openide.util.actions.Presenter;
|
||||
|
||||
/**
|
||||
* The action to close the current Case. This class should be disabled on
|
||||
@@ -83,21 +66,23 @@ import org.openide.util.actions.Presenter;
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (Case.existsCurrentCase() == false)
|
||||
if (Case.existsCurrentCase() == false) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Case result = Case.getCurrentCase();
|
||||
try {
|
||||
result.closeCase();
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
StartupWindowProvider.getInstance().open();
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(CaseCloseAction.class.getName()).log(Level.WARNING, "Error closing case.", ex); //NON-NLS
|
||||
Logger.getLogger(CaseCloseAction.class.getName()).log(Level.SEVERE, "Error closing case.", ex); //NON-NLS
|
||||
}
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
StartupWindowProvider.getInstance().open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,10 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
* event system.
|
||||
*/
|
||||
public final class AutopsyEventPublisher {
|
||||
|
||||
|
||||
/**
|
||||
* Composed of thread-safe objects.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger(AutopsyEventPublisher.class.getName());
|
||||
private final LocalEventPublisher localPublisher;
|
||||
private RemoteEventPublisher remotePublisher;
|
||||
@@ -56,7 +59,7 @@ public final class AutopsyEventPublisher {
|
||||
* @param channelName The name of the event channel.
|
||||
* @throws AutopsyEventException if the channel was not opened.
|
||||
*/
|
||||
synchronized public void openRemoteEventChannel(String channelName) throws AutopsyEventException {
|
||||
public void openRemoteEventChannel(String channelName) throws AutopsyEventException {
|
||||
if (null != remotePublisher) {
|
||||
closeRemoteEventChannel();
|
||||
}
|
||||
@@ -64,8 +67,8 @@ public final class AutopsyEventPublisher {
|
||||
remotePublisher = new RemoteEventPublisher(channelName, localPublisher, UserPreferences.getMessageServiceConnectionInfo());
|
||||
} catch (URISyntaxException | JMSException ex) {
|
||||
String message = "Failed to open remote event channel"; //NON-NLS
|
||||
logger.log(Level.SEVERE, message, ex);
|
||||
throw new AutopsyEventException(message, ex);
|
||||
logger.log(Level.SEVERE, message, ex);
|
||||
throw new AutopsyEventException(message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +76,7 @@ public final class AutopsyEventPublisher {
|
||||
* Closes the event channel used for publishing events to and receiving
|
||||
* events from other Autopsy nodes.
|
||||
*/
|
||||
synchronized public void closeRemoteEventChannel() {
|
||||
public void closeRemoteEventChannel() {
|
||||
if (null != remotePublisher) {
|
||||
try {
|
||||
remotePublisher.stop();
|
||||
@@ -90,7 +93,7 @@ public final class AutopsyEventPublisher {
|
||||
* @param eventNames The events the subscriber is interested in.
|
||||
* @param subscriber The subscriber to add.
|
||||
*/
|
||||
synchronized public void addSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
public void addSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
localPublisher.addSubscriber(eventNames, subscriber);
|
||||
}
|
||||
|
||||
@@ -100,7 +103,7 @@ public final class AutopsyEventPublisher {
|
||||
* @param eventName The event the subscriber is interested in.
|
||||
* @param subscriber The subscriber to add.
|
||||
*/
|
||||
synchronized public void addSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
public void addSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
localPublisher.addSubscriber(eventName, subscriber);
|
||||
}
|
||||
|
||||
@@ -110,7 +113,7 @@ public final class AutopsyEventPublisher {
|
||||
* @param eventNames The events the subscriber is no longer interested in.
|
||||
* @param subscriber The subscriber to remove.
|
||||
*/
|
||||
synchronized public void removeSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
public void removeSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
localPublisher.removeSubscriber(eventNames, subscriber);
|
||||
}
|
||||
|
||||
@@ -120,7 +123,7 @@ public final class AutopsyEventPublisher {
|
||||
* @param eventNames The event the subscriber is no longer interested in.
|
||||
* @param subscriber The subscriber to remove.
|
||||
*/
|
||||
synchronized public void removeSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
public void removeSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
localPublisher.removeSubscriber(eventName, subscriber);
|
||||
}
|
||||
|
||||
@@ -129,7 +132,7 @@ public final class AutopsyEventPublisher {
|
||||
*
|
||||
* @param event The event to publish.
|
||||
*/
|
||||
synchronized public void publish(AutopsyEvent event) {
|
||||
public void publish(AutopsyEvent event) {
|
||||
publishLocally(event);
|
||||
if (null != remotePublisher) {
|
||||
try {
|
||||
@@ -139,14 +142,14 @@ public final class AutopsyEventPublisher {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Publishes an event to this Autopsy node only.
|
||||
*
|
||||
* @param event The event to publish.
|
||||
*/
|
||||
synchronized public void publishLocally(AutopsyEvent event) {
|
||||
localPublisher.publish(event);
|
||||
public void publishLocally(AutopsyEvent event) {
|
||||
localPublisher.publish(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
package org.sleuthkit.autopsy.events;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
|
||||
@@ -43,7 +42,7 @@ final class LocalEventPublisher {
|
||||
* this Autopsy node.
|
||||
*/
|
||||
LocalEventPublisher() {
|
||||
subscribersByEvent = new HashMap<>();
|
||||
subscribersByEvent = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +51,7 @@ final class LocalEventPublisher {
|
||||
* @param eventNames The events the subscriber is interested in.
|
||||
* @param subscriber The subscriber to add.
|
||||
*/
|
||||
synchronized void addSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
void addSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
for (String eventName : eventNames) {
|
||||
addSubscriber(eventName, subscriber);
|
||||
}
|
||||
@@ -64,8 +63,8 @@ final class LocalEventPublisher {
|
||||
* @param eventName The event the subscriber is interested in.
|
||||
* @param subscriber The subscriber to add.
|
||||
*/
|
||||
synchronized void addSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
subscribersByEvent.putIfAbsent(eventName, new HashSet<>());
|
||||
void addSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
subscribersByEvent.putIfAbsent(eventName, ConcurrentHashMap.<PropertyChangeListener>newKeySet());
|
||||
Set<PropertyChangeListener> subscribers = subscribersByEvent.get(eventName);
|
||||
subscribers.add(subscriber);
|
||||
}
|
||||
@@ -76,7 +75,7 @@ final class LocalEventPublisher {
|
||||
* @param eventNames The events the subscriber is no longer interested in.
|
||||
* @param subscriber The subscriber to remove.
|
||||
*/
|
||||
synchronized void removeSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
void removeSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
|
||||
for (String eventName : eventNames) {
|
||||
removeSubscriber(eventName, subscriber);
|
||||
}
|
||||
@@ -88,7 +87,7 @@ final class LocalEventPublisher {
|
||||
* @param eventNames The event the subscriber is no longer interested in.
|
||||
* @param subscriber The subscriber to remove.
|
||||
*/
|
||||
synchronized void removeSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
void removeSubscriber(String eventName, PropertyChangeListener subscriber) {
|
||||
Set<PropertyChangeListener> subscribers = subscribersByEvent.getOrDefault(eventName, null);
|
||||
if (null != subscribers) {
|
||||
subscribers.remove(subscriber);
|
||||
@@ -101,7 +100,7 @@ final class LocalEventPublisher {
|
||||
*
|
||||
* @param event The event to be published.
|
||||
*/
|
||||
synchronized void publish(AutopsyEvent event) {
|
||||
void publish(AutopsyEvent event) {
|
||||
Set<PropertyChangeListener> subscribers = subscribersByEvent.getOrDefault(event.getPropertyName(), null);
|
||||
if (null != subscribers) {
|
||||
for (PropertyChangeListener subscriber : subscribers) {
|
||||
|
||||
Reference in New Issue
Block a user