mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-05 08:46:20 +00:00
comments and minor cleanup
This commit is contained in:
@@ -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<BlackboardArtifactTag> {
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<BlackboardArtifactTag> {
|
||||
@@ -35,11 +35,20 @@ public class BlackBoardArtifactTagDeletedEvent extends TagDeletedEvent<Blackboar
|
||||
super(Case.Events.BLACKBOARD_ARTIFACT_TAG_DELETED.toString(), new DeletedBlackboardArtifactTagInfo(deletedTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*
|
||||
* @return the DeletedBlackboardArtifactTagInfo for the deleted tag
|
||||
*/
|
||||
@Override
|
||||
public DeletedBlackboardArtifactTagInfo getDeletedTagInfo() {
|
||||
return (DeletedBlackboardArtifactTagInfo) getOldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension of {@link DeletedTagInfo} for BlackBoardArtifactTags that
|
||||
* includes artifact related info.
|
||||
*/
|
||||
@Immutable
|
||||
public static class DeletedBlackboardArtifactTagInfo extends DeletedTagInfo<BlackboardArtifactTag> implements Serializable {
|
||||
|
||||
@@ -55,6 +64,7 @@ public class BlackBoardArtifactTagDeletedEvent extends TagDeletedEvent<Blackboar
|
||||
contentID = deletedTag.getContent().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentID() {
|
||||
return contentID;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,15 @@ public class ContentTagAddedEvent extends TagAddedEvent<ContentTag> {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,20 @@ public class ContentTagDeletedEvent extends TagDeletedEvent<ContentTag> {
|
||||
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<ContentTag> implements Serializable {
|
||||
|
||||
@@ -57,6 +66,7 @@ public class ContentTagDeletedEvent extends TagDeletedEvent<ContentTag> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentID() {
|
||||
return contentID;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,15 @@ abstract class TagAddedEvent<T extends Tag> 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<T extends Tag> 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<T extends Tag> 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<T extends Tag> 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<T extends Tag> 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;
|
||||
}
|
||||
|
||||
@@ -36,13 +36,24 @@ abstract class TagDeletedEvent<T extends Tag> 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<T> 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 <T> the subtype of Tag, BlackBoardArtifactTag or ContentTag
|
||||
*/
|
||||
@Immutable
|
||||
abstract static class DeletedTagInfo<T extends Tag> implements Serializable {
|
||||
|
||||
@@ -58,6 +69,8 @@ abstract class TagDeletedEvent<T extends Tag> extends AutopsyEvent {
|
||||
name = deletedTag.getName();
|
||||
}
|
||||
|
||||
abstract public long getContentID();
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user