From 62259e2d6b7dee6da268dddd81f57e536b2ada32 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 30 Jun 2015 12:43:52 -0400 Subject: [PATCH] comments and minor cleanup --- .../BlackBoardArtifactTagAddedEvent.java | 16 ++++++--- .../BlackBoardArtifactTagDeletedEvent.java | 12 ++++++- .../autopsy/events/ContentTagAddedEvent.java | 12 +++++-- .../events/ContentTagDeletedEvent.java | 10 ++++++ .../autopsy/events/TagAddedEvent.java | 34 ++++++++++++++++--- .../autopsy/events/TagDeletedEvent.java | 17 ++++++++-- 6 files changed, 86 insertions(+), 15 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagAddedEvent.java b/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagAddedEvent.java index 0528bd9a7d..f6dad50cfe 100644 --- a/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagAddedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagAddedEvent.java @@ -24,21 +24,27 @@ import org.sleuthkit.datamodel.BlackboardArtifactTag; import org.sleuthkit.datamodel.TskCoreException; /** - * + * Event sent when a black board artifact tag is added. */ @Immutable public class BlackBoardArtifactTagAddedEvent extends TagAddedEvent { private static final long serialVersionUID = 1L; - private final long tagID; public BlackBoardArtifactTagAddedEvent(BlackboardArtifactTag newTag) { super(Case.Events.BLACKBOARD_ARTIFACT_TAG_ADDED.toString(), newTag); - tagID = newTag.getId(); } + /** + * get the BlackboardArtifactTag that was added by its id + * + * @return BlackboardArtifactTag that was added + * + * @throws IllegalStateException + * @throws TskCoreException + */ @Override - BlackboardArtifactTag getTagByID(long id) throws IllegalStateException, TskCoreException { - return Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagByTagID(tagID); + BlackboardArtifactTag getTagByID() throws IllegalStateException, TskCoreException { + return Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagByTagID(getTagID()); } } diff --git a/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagDeletedEvent.java b/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagDeletedEvent.java index 3e8a853d0f..31f2196dc4 100644 --- a/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagDeletedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/events/BlackBoardArtifactTagDeletedEvent.java @@ -24,7 +24,7 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.datamodel.BlackboardArtifactTag; /** - * + * Event that is fired when a black board artifact tag is deleted. */ @Immutable public class BlackBoardArtifactTagDeletedEvent extends TagDeletedEvent { @@ -35,11 +35,20 @@ public class BlackBoardArtifactTagDeletedEvent extends TagDeletedEvent implements Serializable { @@ -55,6 +64,7 @@ public class BlackBoardArtifactTagDeletedEvent extends TagDeletedEvent { super(Case.Events.CONTENT_TAG_ADDED.toString(), newTag); } - ContentTag getTagByID(long id) throws IllegalStateException, TskCoreException { - return Case.getCurrentCase().getServices().getTagsManager().getContentTagByTagID(id); + /** + * get the ContentTag that was added by its id + * + * @return ContentTag that was added + * + * @throws IllegalStateException + * @throws TskCoreException + */ + ContentTag getTagByID() throws IllegalStateException, TskCoreException { + return Case.getCurrentCase().getServices().getTagsManager().getContentTagByTagID(getTagID()); } } diff --git a/Core/src/org/sleuthkit/autopsy/events/ContentTagDeletedEvent.java b/Core/src/org/sleuthkit/autopsy/events/ContentTagDeletedEvent.java index 92fa070f35..3ffc9ccbbf 100644 --- a/Core/src/org/sleuthkit/autopsy/events/ContentTagDeletedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/events/ContentTagDeletedEvent.java @@ -35,11 +35,20 @@ public class ContentTagDeletedEvent extends TagDeletedEvent { super(Case.Events.CONTENT_TAG_DELETED.toString(), new DeletedContentTagInfo(deletedTag)); } + /** + * {@inheritDoc } + * + * @return the DeletedContentTagInfo for the deleted tag + */ @Override public DeletedContentTagInfo getDeletedTagInfo() { return (DeletedContentTagInfo) getOldValue(); } + /** + * Extension of {@link DeletedTagInfo} for BlackBoardArtifactTags that + * includes byte offset related info. + */ @Immutable public static class DeletedContentTagInfo extends DeletedTagInfo implements Serializable { @@ -57,6 +66,7 @@ public class ContentTagDeletedEvent extends TagDeletedEvent { } + @Override public long getContentID() { return contentID; } diff --git a/Core/src/org/sleuthkit/autopsy/events/TagAddedEvent.java b/Core/src/org/sleuthkit/autopsy/events/TagAddedEvent.java index 830b2f7d32..fed9c7a661 100644 --- a/Core/src/org/sleuthkit/autopsy/events/TagAddedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/events/TagAddedEvent.java @@ -31,7 +31,15 @@ abstract class TagAddedEvent extends AutopsyEvent { private static final long serialVersionUID = 1L; private static final Logger LOGGER = Logger.getLogger(TagAddedEvent.class.getName()); + /** + * The tag that was added. This will be lost during serialization and + * re-loaded from the database in getNewValue() + */ private transient T tag; + /** + * The id of the tag that was added. This will bu used to re-load the + * transient tag from the database. + */ private final Long tagID; TagAddedEvent(String propertyName, T addedTag) { @@ -40,6 +48,11 @@ abstract class TagAddedEvent extends AutopsyEvent { tagID = addedTag.getId(); } + /** + * get the id of the Tag that was added + * + * @return the id of the Tag that was added + */ Long getTagID() { return tagID; } @@ -56,10 +69,10 @@ abstract class TagAddedEvent extends AutopsyEvent { @Override public T getNewValue() { /** - * The dataSource field is set in the constructor, but it is transient + * The tag 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 Content object bypasses the - * issues related to the serialization and de-serialization of Content + * over a network. Doing a lazy load of the Tag object bypasses the + * issues related to the serialization and de-serialization of Tag * objects and may also save database round trips from other nodes since * subscribers to this event are often not interested in the event data. */ @@ -67,7 +80,7 @@ abstract class TagAddedEvent extends AutopsyEvent { return tag; } try { - tag = getTagByID(tagID); + tag = getTagByID(); return tag; } catch (IllegalStateException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error doing lazy load for remote event", ex); @@ -75,5 +88,16 @@ abstract class TagAddedEvent extends AutopsyEvent { } } - abstract T getTagByID(long id) throws IllegalStateException, TskCoreException; + /** + * implementors should override this to lookup the appropriate kind of tag + * (Content/BlackBoardArtifact) during the lazy load of the transient tag + * field + * + * + * @return the Tag based on the saved tag id + * + * @throws IllegalStateException + * @throws TskCoreException + */ + abstract T getTagByID() throws IllegalStateException, TskCoreException; } diff --git a/Core/src/org/sleuthkit/autopsy/events/TagDeletedEvent.java b/Core/src/org/sleuthkit/autopsy/events/TagDeletedEvent.java index a058ede3d1..2bf4bd363d 100644 --- a/Core/src/org/sleuthkit/autopsy/events/TagDeletedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/events/TagDeletedEvent.java @@ -36,13 +36,24 @@ abstract class TagDeletedEvent extends AutopsyEvent { } /** - * get info about the Tag that was deleted + * get info about the Tag that was deleted. * - * @return the Tag + * Since we don't serialize the deleted tag, and we can't look it up by id + * after it is deleted, we send this info to represent it. + * + * @return info about the Tag that was deleted. */ @SuppressWarnings("unchecked") abstract public DeletedTagInfo getDeletedTagInfo(); + /** + * Base Class for info about a deleted tag. This is sent as the old value in + * the event, since we are not serializing the Tag it self, and we can't + * look it up by id, like we do for added tags, because it doesn't exist + * in the db any more. + * + * @param the subtype of Tag, BlackBoardArtifactTag or ContentTag + */ @Immutable abstract static class DeletedTagInfo implements Serializable { @@ -58,6 +69,8 @@ abstract class TagDeletedEvent extends AutopsyEvent { name = deletedTag.getName(); } + abstract public long getContentID(); + public String getComment() { return comment; }