diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index f18c600942..0274dd7c23 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -84,8 +84,10 @@ import org.sleuthkit.autopsy.casemodule.events.DataSourceAddedEvent; import org.sleuthkit.autopsy.casemodule.events.DataSourceDeletedEvent; import org.sleuthkit.autopsy.casemodule.events.DataSourceNameChangedEvent; 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.HostsDeletedEvent; +import org.sleuthkit.autopsy.casemodule.events.HostsRemovedFromPersonEvent; import org.sleuthkit.autopsy.casemodule.events.OsAccountsAddedEvent; import org.sleuthkit.autopsy.casemodule.events.OsAccountsUpdatedEvent; import org.sleuthkit.autopsy.casemodule.events.OsAccountsDeletedEvent; @@ -586,6 +588,17 @@ public class Case { public void publishPersonsDeletedEvent(TskEvent.PersonsDeletedTskEvent event) { 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())); + } + } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsAddedToPersonEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsAddedToPersonEvent.java index 8b1b9da8a3..a7937330d2 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsAddedToPersonEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsAddedToPersonEvent.java @@ -18,22 +18,28 @@ */ package org.sleuthkit.autopsy.casemodule.events; -import java.util.Collections; import java.util.List; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Person; /** - * - * @author rcordovano + * Application events published when one or more hosts have been added to a + * person. */ public final class HostsAddedToPersonEvent extends PersonHostsEvent { - + 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 hosts) { super(Case.Events.HOSTS_ADDED_TO_PERSON.toString(), person, hosts); } - + } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsRemovedFromPersonEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsRemovedFromPersonEvent.java index eaf200368d..df84e0bbaa 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsRemovedFromPersonEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/HostsRemovedFromPersonEvent.java @@ -1,7 +1,20 @@ /* - * 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. + * Autopsy Forensic Browser + * + * Copyright 2021 Basis Technology Corp. + * Contact: carrier sleuthkit 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; @@ -11,15 +24,22 @@ import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Person; /** - * - * @author rcordovano + * Application events published when one or more hosts have been removed from a + * person. */ -public class HostsRemovedFromPersonEvent extends PersonHostsEvent { - +public class HostsRemovedFromPersonEvent extends PersonHostsEvent { + 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 hosts) { super(Case.Events.HOSTS_REMOVED_FROM_PERSON.toString(), person, hosts); } - -} \ No newline at end of file + +} diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/PersonHostsEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/PersonHostsEvent.java index f1426e38e4..edf0f8b65d 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/PersonHostsEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/PersonHostsEvent.java @@ -15,37 +15,41 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; /** - * - * @author rcordovano + * An abstract super class for person and host association change events. */ public abstract class PersonHostsEvent extends TskDataModelChangedEvent { - + private static final long serialVersionUID = 1L; - + /** - * - * @param eventName - * @param person - * @param hosts + * Constructs the abstract super class part of a person and host association + * change event. + * + * @param eventName The name of the Case.Events enum value for the event + * type. + * @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 hosts) { super(eventName, Collections.singletonList(person), Person::getPersonId, hosts, Host::getHostId); } - + /** - * - * @return + * Gets the person. + * + * @return The person. */ - Person getPerson() { + public Person getPerson() { return getOldValue().get(0); } - + /** - * - * @return + * Gets the hosts. + * + * @return The hosts. */ - List getHosts() { - return getNewValue(); + public List getHosts() { + return getNewValue(); } @Override @@ -58,8 +62,8 @@ public abstract class PersonHostsEvent extends TskDataModelChangedEvent getNewValueObjects(SleuthkitCase caseDb, List ids) throws TskCoreException { List hosts = new ArrayList<>(); @@ -70,6 +74,6 @@ public abstract class PersonHostsEvent extends TskDataModelChangedEvent