catch IllegalStateException from Case.getCurrentCase() in TagsManager methods

This commit is contained in:
jmillman 2015-06-24 10:29:03 -04:00
parent f9f1c7db94
commit 8808496f83
2 changed files with 25 additions and 5 deletions

View File

@ -14,4 +14,8 @@ FileManager.addLocalDirInt2.exception.closed.msg=Attempted to use FileManager af
TagsManager.addContentTag.exception.beginByteOffsetOOR.msg=beginByteOffset \= {0} out of content size range (0 - {1}) TagsManager.addContentTag.exception.beginByteOffsetOOR.msg=beginByteOffset \= {0} out of content size range (0 - {1})
TagsManager.addContentTag.exception.endByteOffsetOOR.msg=endByteOffset \= {0} out of content size range (0 - {1}) TagsManager.addContentTag.exception.endByteOffsetOOR.msg=endByteOffset \= {0} out of content size range (0 - {1})
TagsManager.addContentTag.exception.endLTbegin.msg=endByteOffset < beginByteOffset TagsManager.addContentTag.exception.endLTbegin.msg=endByteOffset < beginByteOffset
TagsManager.predefTagNames.bookmark.text=Bookmark TagsManager.predefTagNames.bookmark.text=Bookmark
TagsManager.addContentTag.noCaseWarning=Failed to add publish new content tag event. There is no case open.
TagsManager.deleteContentTag.noCaseWarning=Failed to add publish content tag deleted event. There is no case open.
TagsManager.addBlackboardArtifactTag.noCaseWarning=Failed to add publish new blackboard artifact tag event. There is no case open.
TagsManager.deleteBlackboardArtifactTag.noCaseWarning=Failed to add publish blackboard artifact tag deleted event. There is no case open.

View File

@ -248,7 +248,11 @@ public class TagsManager implements Closeable {
} }
} }
final ContentTag newContentTag = tskCase.addContentTag(content, tagName, comment, beginByteOffset, endByteOffset); final ContentTag newContentTag = tskCase.addContentTag(content, tagName, comment, beginByteOffset, endByteOffset);
Case.getCurrentCase().notifyContentTagAdded(newContentTag); try {
Case.getCurrentCase().notifyContentTagAdded(newContentTag);
} catch (IllegalArgumentException ex) {
Logger.getLogger(TagsManager.class.getName()).log(Level.WARNING, NbBundle.getMessage(TagsManager.class, "TagsManager.addContentTag.noCaseWarning"));
}
return newContentTag; return newContentTag;
} }
@ -266,7 +270,11 @@ public class TagsManager implements Closeable {
} }
tskCase.deleteContentTag(tag); tskCase.deleteContentTag(tag);
Case.getCurrentCase().notifyContentTagDeleted(tag); try {
Case.getCurrentCase().notifyContentTagDeleted(tag);
} catch (IllegalArgumentException e) {
Logger.getLogger(TagsManager.class.getName()).log(Level.WARNING, NbBundle.getMessage(TagsManager.class, "TagsManager.deleteContentTag.noCaseWarning"));
}
} }
/** /**
@ -375,7 +383,11 @@ public class TagsManager implements Closeable {
} }
BlackboardArtifactTag addBlackboardArtifactTag = tskCase.addBlackboardArtifactTag(artifact, tagName, comment); BlackboardArtifactTag addBlackboardArtifactTag = tskCase.addBlackboardArtifactTag(artifact, tagName, comment);
Case.getCurrentCase().notifyBlackBoardArtifactTagAdded(addBlackboardArtifactTag); try {
Case.getCurrentCase().notifyBlackBoardArtifactTagAdded(addBlackboardArtifactTag);
} catch (IllegalArgumentException e) {
Logger.getLogger(TagsManager.class.getName()).log(Level.WARNING, NbBundle.getMessage(TagsManager.class, "TagsManager.addBlackboardArtifactTag.noCaseWarning"));
}
return addBlackboardArtifactTag; return addBlackboardArtifactTag;
} }
@ -393,7 +405,11 @@ public class TagsManager implements Closeable {
} }
tskCase.deleteBlackboardArtifactTag(tag); tskCase.deleteBlackboardArtifactTag(tag);
Case.getCurrentCase().notifyBlackBoardArtifactTagDeleted(tag); try {
Case.getCurrentCase().notifyBlackBoardArtifactTagDeleted(tag);
} catch (IllegalArgumentException e) {
Logger.getLogger(TagsManager.class.getName()).log(Level.WARNING, NbBundle.getMessage(TagsManager.class, "TagsManager.deleteBlackboardArtifactTag.noCaseWarning"));
}
} }
/** /**