7553 data model event changes

This commit is contained in:
Richard Cordovano 2021-05-04 15:07:51 -04:00
parent 0ee586196f
commit 92cba46d6d
4 changed files with 80 additions and 37 deletions

View File

@ -84,8 +84,10 @@ import org.sleuthkit.autopsy.casemodule.events.DataSourceAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.DataSourceDeletedEvent; import org.sleuthkit.autopsy.casemodule.events.DataSourceDeletedEvent;
import org.sleuthkit.autopsy.casemodule.events.DataSourceNameChangedEvent; import org.sleuthkit.autopsy.casemodule.events.DataSourceNameChangedEvent;
import org.sleuthkit.autopsy.casemodule.events.HostsAddedEvent; import org.sleuthkit.autopsy.casemodule.events.HostsAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.HostsAddedToPersonEvent;
import org.sleuthkit.autopsy.casemodule.events.HostsUpdatedEvent; import org.sleuthkit.autopsy.casemodule.events.HostsUpdatedEvent;
import org.sleuthkit.autopsy.casemodule.events.HostsDeletedEvent; import org.sleuthkit.autopsy.casemodule.events.HostsDeletedEvent;
import org.sleuthkit.autopsy.casemodule.events.HostsRemovedFromPersonEvent;
import org.sleuthkit.autopsy.casemodule.events.OsAccountsAddedEvent; import org.sleuthkit.autopsy.casemodule.events.OsAccountsAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.OsAccountsUpdatedEvent; import org.sleuthkit.autopsy.casemodule.events.OsAccountsUpdatedEvent;
import org.sleuthkit.autopsy.casemodule.events.OsAccountsDeletedEvent; import org.sleuthkit.autopsy.casemodule.events.OsAccountsDeletedEvent;
@ -586,6 +588,17 @@ public class Case {
public void publishPersonsDeletedEvent(TskEvent.PersonsDeletedTskEvent event) { public void publishPersonsDeletedEvent(TskEvent.PersonsDeletedTskEvent event) {
eventPublisher.publish(new PersonsDeletedEvent(event.getPersonIds())); eventPublisher.publish(new PersonsDeletedEvent(event.getPersonIds()));
} }
@Subscribe
public void publishHostsAddedToPersonEvent(TskEvent.HostsAddedToPersonTskEvent event) {
eventPublisher.publish(new HostsAddedToPersonEvent(event.getPerson(), event.getHosts()));
}
@Subscribe
public void publisHostsRemovedFromPersonEvent(TskEvent.HostsRemovedFromPersonTskEvent event) {
eventPublisher.publish(new HostsRemovedFromPersonEvent(event.getPerson(), event.getHosts()));
}
} }
/** /**

View File

@ -18,20 +18,26 @@
*/ */
package org.sleuthkit.autopsy.casemodule.events; package org.sleuthkit.autopsy.casemodule.events;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Host;
import org.sleuthkit.datamodel.Person; import org.sleuthkit.datamodel.Person;
/** /**
* * Application events published when one or more hosts have been added to a
* @author rcordovano * person.
*/ */
public final class HostsAddedToPersonEvent extends PersonHostsEvent { public final class HostsAddedToPersonEvent extends PersonHostsEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Constructs an application event published when one or more hosts have
* been added to a person.
*
* @param person The person.
* @param hosts The hosts.
*/
HostsAddedToPersonEvent(Person person, List<Host> hosts) { HostsAddedToPersonEvent(Person person, List<Host> hosts) {
super(Case.Events.HOSTS_ADDED_TO_PERSON.toString(), person, hosts); super(Case.Events.HOSTS_ADDED_TO_PERSON.toString(), person, hosts);
} }

View File

@ -1,7 +1,20 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * Autopsy Forensic Browser
* To change this template file, choose Tools | Templates *
* and open the template in the editor. * Copyright 2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.sleuthkit.autopsy.casemodule.events; package org.sleuthkit.autopsy.casemodule.events;
@ -11,13 +24,20 @@ import org.sleuthkit.datamodel.Host;
import org.sleuthkit.datamodel.Person; import org.sleuthkit.datamodel.Person;
/** /**
* * Application events published when one or more hosts have been removed from a
* @author rcordovano * person.
*/ */
public class HostsRemovedFromPersonEvent extends PersonHostsEvent { public class HostsRemovedFromPersonEvent extends PersonHostsEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Constructs an application event published when one or more hosts have
* been removed from a person.
*
* @param person The person.
* @param hosts The hosts.
*/
HostsRemovedFromPersonEvent(Person person, List<Host> hosts) { HostsRemovedFromPersonEvent(Person person, List<Host> hosts) {
super(Case.Events.HOSTS_REMOVED_FROM_PERSON.toString(), person, hosts); super(Case.Events.HOSTS_REMOVED_FROM_PERSON.toString(), person, hosts);
} }

View File

@ -15,36 +15,40 @@ import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
/** /**
* * An abstract super class for person and host association change events.
* @author rcordovano
*/ */
public abstract class PersonHostsEvent extends TskDataModelChangedEvent<Person, Host> { public abstract class PersonHostsEvent extends TskDataModelChangedEvent<Person, Host> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Constructs the abstract super class part of a person and host association
* change event.
* *
* @param eventName * @param eventName The name of the Case.Events enum value for the event
* @param person * type.
* @param hosts * @param person The person that is the subject of the event.
* @param hosts The hosts that are the subject of the event.
*/ */
PersonHostsEvent(String eventName, Person person, List<Host> hosts) { PersonHostsEvent(String eventName, Person person, List<Host> hosts) {
super(eventName, Collections.singletonList(person), Person::getPersonId, hosts, Host::getHostId); super(eventName, Collections.singletonList(person), Person::getPersonId, hosts, Host::getHostId);
} }
/** /**
* Gets the person.
* *
* @return * @return The person.
*/ */
Person getPerson() { public Person getPerson() {
return getOldValue().get(0); return getOldValue().get(0);
} }
/** /**
* Gets the hosts.
* *
* @return * @return The hosts.
*/ */
List<Host> getHosts() { public List<Host> getHosts() {
return getNewValue(); return getNewValue();
} }