4700 Correctly set curent case to null when case is closed

This commit is contained in:
Richard Cordovano 2021-04-01 11:23:39 -04:00
parent 9248c9dd7e
commit f135aa8f87

View File

@ -440,45 +440,38 @@ public class Case {
*/ */
OS_ACCOUNT_ADDED, OS_ACCOUNT_ADDED,
/** /**
* OSAccount associated with the current case has changed. * OSAccount associated with the current case has changed. Call
* Call getOsAccount to get the changed account; * getOsAccount to get the changed account;
*/ */
OS_ACCOUNT_CHANGED, OS_ACCOUNT_CHANGED,
/** /**
* OSAccount associated with the current case has been deleted. * OSAccount associated with the current case has been deleted.
*/ */
OS_ACCOUNT_REMOVED, OS_ACCOUNT_REMOVED,
/** /**
* Hosts associated with the current case added. * Hosts associated with the current case added.
*/ */
HOSTS_ADDED, HOSTS_ADDED,
/** /**
* Hosts associated with the current case has changed. * Hosts associated with the current case has changed.
*/ */
HOSTS_CHANGED, HOSTS_CHANGED,
/** /**
* Hosts associated with the current case has been deleted. * Hosts associated with the current case has been deleted.
*/ */
HOSTS_DELETED, HOSTS_DELETED,
/** /**
* Persons associated with the current case added. * Persons associated with the current case added.
*/ */
PERSONS_ADDED, PERSONS_ADDED,
/** /**
* Persons associated with the current case has changed. * Persons associated with the current case has changed.
*/ */
PERSONS_CHANGED, PERSONS_CHANGED,
/** /**
* Persons associated with the current case has been deleted. * Persons associated with the current case has been deleted.
*/ */
PERSONS_DELETED PERSONS_DELETED;
;
}; };
/** /**
@ -511,95 +504,95 @@ public class Case {
event.getArtifacts(artifactType))); event.getArtifacts(artifactType)));
} }
} }
@Subscribe @Subscribe
public void publishOsAccountAddedEvent(OsAccountsCreationEvent event) { public void publishOsAccountAddedEvent(OsAccountsCreationEvent event) {
for(OsAccount account: event.getOsAcounts()) { for (OsAccount account : event.getOsAcounts()) {
eventPublisher.publish(new OsAccountAddedEvent(account)); eventPublisher.publish(new OsAccountAddedEvent(account));
} }
} }
@Subscribe @Subscribe
public void publishOsAccountChangedEvent(OsAccountsUpdateEvent event) { public void publishOsAccountChangedEvent(OsAccountsUpdateEvent event) {
for(OsAccount account: event.getOsAcounts()) { for (OsAccount account : event.getOsAcounts()) {
eventPublisher.publish(new OsAccountChangedEvent(account)); eventPublisher.publish(new OsAccountChangedEvent(account));
} }
} }
@Subscribe @Subscribe
public void publishOsAccountDeletedEvent(OsAccountsDeleteEvent event) { public void publishOsAccountDeletedEvent(OsAccountsDeleteEvent event) {
for(Long accountId: event.getOsAcountObjectIds()) { for (Long accountId : event.getOsAcountObjectIds()) {
eventPublisher.publish(new OsAccountRemovedEvent(accountId)); eventPublisher.publish(new OsAccountRemovedEvent(accountId));
} }
} }
/** /**
* Publishes an autopsy event from the sleuthkit HostCreationEvent * Publishes an autopsy event from the sleuthkit HostCreationEvent
* indicating that hosts have been created. * indicating that hosts have been created.
* *
* @param event The sleuthkit event for the creation of hosts. * @param event The sleuthkit event for the creation of hosts.
*/ */
@Subscribe @Subscribe
public void publishHostsAddedEvent(HostsCreationEvent event) { public void publishHostsAddedEvent(HostsCreationEvent event) {
eventPublisher.publish(new HostsAddedEvent( eventPublisher.publish(new HostsAddedEvent(
event == null ? Collections.emptyList() : event.getHosts())); event == null ? Collections.emptyList() : event.getHosts()));
} }
/** /**
* Publishes an autopsy event from the sleuthkit HostUpdateEvent * Publishes an autopsy event from the sleuthkit HostUpdateEvent
* indicating that hosts have been updated. * indicating that hosts have been updated.
* *
* @param event The sleuthkit event for the updating of hosts. * @param event The sleuthkit event for the updating of hosts.
*/ */
@Subscribe @Subscribe
public void publishHostsChangedEvent(HostsUpdateEvent event) { public void publishHostsChangedEvent(HostsUpdateEvent event) {
eventPublisher.publish(new HostsChangedEvent( eventPublisher.publish(new HostsChangedEvent(
event == null ? Collections.emptyList() : event.getHosts())); event == null ? Collections.emptyList() : event.getHosts()));
} }
/** /**
* Publishes an autopsy event from the sleuthkit HostDeletedEvent * Publishes an autopsy event from the sleuthkit HostDeletedEvent
* indicating that hosts have been deleted. * indicating that hosts have been deleted.
* *
* @param event The sleuthkit event for the deleting of hosts. * @param event The sleuthkit event for the deleting of hosts.
*/ */
@Subscribe @Subscribe
public void publishHostsDeletedEvent(HostsDeletionEvent event) { public void publishHostsDeletedEvent(HostsDeletionEvent event) {
eventPublisher.publish(new HostsRemovedEvent( eventPublisher.publish(new HostsRemovedEvent(
event == null ? Collections.emptyList() : event.getHosts())); event == null ? Collections.emptyList() : event.getHosts()));
} }
/** /**
* Publishes an autopsy event from the sleuthkit PersonCreationEvent * Publishes an autopsy event from the sleuthkit PersonCreationEvent
* indicating that persons have been created. * indicating that persons have been created.
* *
* @param event The sleuthkit event for the creation of persons. * @param event The sleuthkit event for the creation of persons.
*/ */
@Subscribe @Subscribe
public void publishPersonsAddedEvent(PersonsCreationEvent event) { public void publishPersonsAddedEvent(PersonsCreationEvent event) {
eventPublisher.publish(new PersonsAddedEvent( eventPublisher.publish(new PersonsAddedEvent(
event == null ? Collections.emptyList() : event.getPersons())); event == null ? Collections.emptyList() : event.getPersons()));
} }
/** /**
* Publishes an autopsy event from the sleuthkit PersonUpdateEvent * Publishes an autopsy event from the sleuthkit PersonUpdateEvent
* indicating that persons have been updated. * indicating that persons have been updated.
* *
* @param event The sleuthkit event for the updating of persons. * @param event The sleuthkit event for the updating of persons.
*/ */
@Subscribe @Subscribe
public void publishPersonsChangedEvent(PersonsUpdateEvent event) { public void publishPersonsChangedEvent(PersonsUpdateEvent event) {
eventPublisher.publish(new PersonsChangedEvent( eventPublisher.publish(new PersonsChangedEvent(
event == null ? Collections.emptyList() : event.getPersons())); event == null ? Collections.emptyList() : event.getPersons()));
} }
/** /**
* Publishes an autopsy event from the sleuthkit PersonDeletedEvent * Publishes an autopsy event from the sleuthkit PersonDeletedEvent
* indicating that persons have been deleted. * indicating that persons have been deleted.
* *
* @param event The sleuthkit event for the deleting of persons. * @param event The sleuthkit event for the deleting of persons.
*/ */
@Subscribe @Subscribe
public void publishPersonsDeletedEvent(PersonsDeletionEvent event) { public void publishPersonsDeletedEvent(PersonsDeletionEvent event) {
eventPublisher.publish(new PersonsRemovedEvent( eventPublisher.publish(new PersonsRemovedEvent(
event == null ? Collections.emptyList() : event.getPersons())); event == null ? Collections.emptyList() : event.getPersons()));
@ -882,12 +875,12 @@ public class Case {
eventPublisher.publishLocally(new AutopsyEvent(Events.CURRENT_CASE.toString(), closedCase, null)); eventPublisher.publishLocally(new AutopsyEvent(Events.CURRENT_CASE.toString(), closedCase, null));
logger.log(Level.INFO, "Closing current case {0} ({1}) in {2}", new Object[]{closedCase.getDisplayName(), closedCase.getName(), closedCase.getCaseDirectory()}); //NON-NLS logger.log(Level.INFO, "Closing current case {0} ({1}) in {2}", new Object[]{closedCase.getDisplayName(), closedCase.getName(), closedCase.getCaseDirectory()}); //NON-NLS
closedCase.doCloseCaseAction(); closedCase.doCloseCaseAction();
currentCase = null;
logger.log(Level.INFO, "Closed current case {0} ({1}) in {2}", new Object[]{closedCase.getDisplayName(), closedCase.getName(), closedCase.getCaseDirectory()}); //NON-NLS logger.log(Level.INFO, "Closed current case {0} ({1}) in {2}", new Object[]{closedCase.getDisplayName(), closedCase.getName(), closedCase.getCaseDirectory()}); //NON-NLS
} catch (CaseActionException ex) { } catch (CaseActionException ex) {
logger.log(Level.SEVERE, String.format("Error closing current case %s (%s) in %s", closedCase.getDisplayName(), closedCase.getName(), closedCase.getCaseDirectory()), ex); //NON-NLS logger.log(Level.SEVERE, String.format("Error closing current case %s (%s) in %s", closedCase.getDisplayName(), closedCase.getName(), closedCase.getCaseDirectory()), ex); //NON-NLS
throw ex; throw ex;
} finally { } finally {
currentCase = null;
if (RuntimeProperties.runningWithGUI()) { if (RuntimeProperties.runningWithGUI()) {
updateGUIForCaseClosed(); updateGUIForCaseClosed();
} }
@ -1793,7 +1786,7 @@ public class Case {
public void notifyBlackBoardArtifactTagDeleted(BlackboardArtifactTag deletedTag) { public void notifyBlackBoardArtifactTagDeleted(BlackboardArtifactTag deletedTag) {
eventPublisher.publish(new BlackBoardArtifactTagDeletedEvent(deletedTag)); eventPublisher.publish(new BlackBoardArtifactTagDeletedEvent(deletedTag));
} }
public void notifyOsAccountAdded(OsAccount account) { public void notifyOsAccountAdded(OsAccount account) {
eventPublisher.publish(new OsAccountAddedEvent(account)); eventPublisher.publish(new OsAccountAddedEvent(account));
} }
@ -1801,13 +1794,14 @@ public class Case {
public void notifyOsAccountChanged(OsAccount account) { public void notifyOsAccountChanged(OsAccount account) {
eventPublisher.publish(new OsAccountChangedEvent(account)); eventPublisher.publish(new OsAccountChangedEvent(account));
} }
public void notifyOsAccountRemoved(Long osAccountObjectId) { public void notifyOsAccountRemoved(Long osAccountObjectId) {
eventPublisher.publish(new OsAccountRemovedEvent(osAccountObjectId)); eventPublisher.publish(new OsAccountRemovedEvent(osAccountObjectId));
} }
/** /**
* Notify via an autopsy event that a host has been added. * Notify via an autopsy event that a host has been added.
*
* @param host The host that has been added. * @param host The host that has been added.
*/ */
public void notifyHostAdded(Host host) { public void notifyHostAdded(Host host) {
@ -1816,22 +1810,25 @@ public class Case {
/** /**
* Notify via an autopsy event that a host has been changed. * Notify via an autopsy event that a host has been changed.
*
* @param newValue The host that has been updated. * @param newValue The host that has been updated.
*/ */
public void notifyHostChanged(Host newValue) { public void notifyHostChanged(Host newValue) {
eventPublisher.publish(new HostsChangedEvent(Collections.singletonList(newValue))); eventPublisher.publish(new HostsChangedEvent(Collections.singletonList(newValue)));
} }
/** /**
* Notify via an autopsy event that a host has been deleted. * Notify via an autopsy event that a host has been deleted.
*
* @param host The host that has been deleted. * @param host The host that has been deleted.
*/ */
public void notifyHostDeleted(Host host) { public void notifyHostDeleted(Host host) {
eventPublisher.publish(new HostsRemovedEvent(Collections.singletonList(host))); eventPublisher.publish(new HostsRemovedEvent(Collections.singletonList(host)));
} }
/** /**
* Notify via an autopsy event that a person has been added. * Notify via an autopsy event that a person has been added.
*
* @param person The person that has been added. * @param person The person that has been added.
*/ */
public void notifyPersonAdded(Person person) { public void notifyPersonAdded(Person person) {
@ -1840,20 +1837,22 @@ public class Case {
/** /**
* Notify via an autopsy event that a person has been changed. * Notify via an autopsy event that a person has been changed.
*
* @param newValue The person that has been updated. * @param newValue The person that has been updated.
*/ */
public void notifyPersonChanged(Person newValue) { public void notifyPersonChanged(Person newValue) {
eventPublisher.publish(new PersonsChangedEvent(Collections.singletonList(newValue))); eventPublisher.publish(new PersonsChangedEvent(Collections.singletonList(newValue)));
} }
/** /**
* Notify via an autopsy event that a person has been deleted. * Notify via an autopsy event that a person has been deleted.
*
* @param person The person that has been deleted. * @param person The person that has been deleted.
*/ */
public void notifyPersonDeleted(Person person) { public void notifyPersonDeleted(Person person) {
eventPublisher.publish(new PersonsRemovedEvent(Collections.singletonList(person))); eventPublisher.publish(new PersonsRemovedEvent(Collections.singletonList(person)));
} }
/** /**
* Adds a report to the case. * Adds a report to the case.
* *