Merge remote-tracking branch 'upstream/timeline-event-mgr' into 1091-update-filters

# Conflicts:
#	Core/src/org/sleuthkit/autopsy/timeline/events/EventAddedEvent.java
This commit is contained in:
millmanorama 2018-11-15 13:01:59 +01:00
commit aedd2bd526
2 changed files with 72 additions and 20 deletions

View File

@ -18,22 +18,76 @@
*/ */
package org.sleuthkit.autopsy.timeline.events; package org.sleuthkit.autopsy.timeline.events;
import java.io.Serializable;
import java.util.logging.Level;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.timeline.TimelineEvent;
/** /**
* * An AutopsyEvent broadcast when a TimelineEvent is added to the case.
*/ */
public class EventAddedEvent extends AutopsyEvent { public class EventAddedEvent extends AutopsyEvent implements Serializable {
private final long addedEventID;
public long getAddedEventID() { private static final long serialVersionUID = 1L;
return addedEventID; private static final Logger logger = Logger.getLogger(EventAddedEvent.class.getName());
}
private transient TimelineEvent addedEvent;
public EventAddedEvent(org.sleuthkit.datamodel.TimelineManager.EventAddedEvent event) { public EventAddedEvent(org.sleuthkit.datamodel.TimelineManager.EventAddedEvent event) {
super(Case.Events.EVENT_ADDED.name(), null, event.getEvent()); super(Case.Events.EVENT_ADDED.name(), null, event.getAddedEvent().getEventID());
addedEventID = event.getEvent().getEventID(); addedEvent = event.getAddedEvent();
}
/**
* Gets the TimelineEvent that was added.
*
* @return The TimelineEvent or null if there is an error retrieving the
* TimelineEvent.
*/
@Override
public TimelineEvent getNewValue() {
/**
* The addedEvent field is set in the constructor, but it is transient
* so it will become null when the event is serialized for publication
* over a network. Doing a lazy load of the TimelineEvent object
* bypasses the issues related to the serialization and de-serialization
* of TimelineEvent objects and may also save database round trips from
* other nodes since subscribers to this event are often not interested
* in the event data.
*/
if (null != addedEvent) {
return addedEvent;
}
try {
Long addedEventID = (Long) super.getNewValue();
addedEvent = Case.getCurrentCaseThrows().getSleuthkitCase().getTimelineManager().getEventById(addedEventID);
return addedEvent;
} catch (NoCurrentCaseException | TskCoreException ex) {
logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS
return null;
}
}
/**
* Gets the TimelineEvent that was added.
*
* @return The TimelineEvent or null if there is an error retrieving the
* TimelineEvent.
*/
public TimelineEvent getAddedEvent() {
return getNewValue();
}
/**
* Gets the Id of the event that was added.
*
* @return The Id of the event that was added.
*/
public long getAddedEventID() {
return (long) super.getNewValue();
} }
} }

View File

@ -18,12 +18,10 @@
*/ */
package org.sleuthkit.autopsy.timeline.utils; package org.sleuthkit.autopsy.timeline.utils;
import com.google.common.net.MediaType; import com.google.common.collect.ImmutableSet;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.datamodel.TimelineManager; import org.sleuthkit.datamodel.TimelineManager;
import org.sleuthkit.datamodel.timeline.TimelineFilter.FileTypeFilter; import org.sleuthkit.datamodel.timeline.TimelineFilter.FileTypeFilter;
@ -34,16 +32,16 @@ import org.sleuthkit.datamodel.timeline.TimelineFilter.FileTypesFilter;
*/ */
public final class FilterUtils { public final class FilterUtils {
private static final Set<MediaType> MEDIA_MIME_TYPES = Stream.of( private static final Set<String> MEDIA_MIME_TYPES = ImmutableSet.of(
"image/*",//NON-NLS "image/*",//NON-NLS
"video/*",//NON-NLS "video/*",//NON-NLS
"audio/*",//NON-NLS "audio/*",//NON-NLS
"application/vnd.ms-asf", //NON-NLS "application/vnd.ms-asf", //NON-NLS
"application/vnd.rn-realmedia", //NON-NLS "application/vnd.rn-realmedia", //NON-NLS
"application/x-shockwave-flash" //NON-NLS "application/x-shockwave-flash" //NON-NLS
).map(MediaType::parse).collect(Collectors.toSet()); );
private static final Set<MediaType> EXECUTABLE_MIME_TYPES = Stream.of( private static final Set<String> EXECUTABLE_MIME_TYPES = ImmutableSet.of(
"application/x-bat",//NON-NLS "application/x-bat",//NON-NLS
"application/x-dosexec",//NON-NLS "application/x-dosexec",//NON-NLS
"application/vnd.microsoft.portable-executable",//NON-NLS "application/vnd.microsoft.portable-executable",//NON-NLS
@ -55,9 +53,9 @@ public final class FilterUtils {
"application/x-winexe",//NON-NLS "application/x-winexe",//NON-NLS
"application/msdos-windows",//NON-NLS "application/msdos-windows",//NON-NLS
"application/x-msdos-program"//NON-NLS "application/x-msdos-program"//NON-NLS
).map(MediaType::parse).collect(Collectors.toSet()); );
private static final Set<MediaType> DOCUMENT_MIME_TYPES = Stream.of( private static final Set<String> DOCUMENT_MIME_TYPES =ImmutableSet.of(
"text/*", //NON-NLS "text/*", //NON-NLS
"application/rtf", //NON-NLS "application/rtf", //NON-NLS
"application/pdf", //NON-NLS "application/pdf", //NON-NLS
@ -75,9 +73,9 @@ public final class FilterUtils {
"application/vnd.oasis.opendocument.presentation", //NON-NLS "application/vnd.oasis.opendocument.presentation", //NON-NLS
"application/vnd.oasis.opendocument.spreadsheet", //NON-NLS "application/vnd.oasis.opendocument.spreadsheet", //NON-NLS
"application/vnd.oasis.opendocument.text" //NON-NLS "application/vnd.oasis.opendocument.text" //NON-NLS
).map(MediaType::parse).collect(Collectors.toSet()); );
private static final Set<MediaType> NON_OTHER_MIME_TYPES = new HashSet<>(); private static final Set<String> NON_OTHER_MIME_TYPES = new HashSet<>();
static { static {
NON_OTHER_MIME_TYPES.addAll(MEDIA_MIME_TYPES); NON_OTHER_MIME_TYPES.addAll(MEDIA_MIME_TYPES);
@ -116,7 +114,7 @@ public final class FilterUtils {
*/ */
private static class InverseFileTypeFilter extends FileTypeFilter { private static class InverseFileTypeFilter extends FileTypeFilter {
InverseFileTypeFilter(String displayName, Collection<MediaType> mediaTypes) { InverseFileTypeFilter(String displayName, Collection<String> mediaTypes) {
super(displayName, mediaTypes); super(displayName, mediaTypes);
} }