mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 16:36:15 +00:00
Improve lazy load for for casemodule/services/TagsManager
This commit is contained in:
parent
331ef9f869
commit
3ece1f852a
@ -69,9 +69,7 @@ public class TagsManager implements Closeable {
|
|||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
public synchronized List<TagName> getAllTagNames() throws TskCoreException {
|
public synchronized List<TagName> getAllTagNames() throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getAllTagNames();
|
return caseDb.getAllTagNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +83,7 @@ public class TagsManager implements Closeable {
|
|||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
public synchronized List<TagName> getTagNamesInUse() throws TskCoreException {
|
public synchronized List<TagName> getTagNamesInUse() throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getTagNamesInUse();
|
return caseDb.getTagNamesInUse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +95,7 @@ public class TagsManager implements Closeable {
|
|||||||
* @return True or false.
|
* @return True or false.
|
||||||
*/
|
*/
|
||||||
public synchronized boolean tagNameExists(String tagDisplayName) {
|
public synchronized boolean tagNameExists(String tagDisplayName) {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return uniqueTagNames.containsKey(tagDisplayName);
|
return uniqueTagNames.containsKey(tagDisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +150,7 @@ public class TagsManager implements Closeable {
|
|||||||
* to the case database.
|
* to the case database.
|
||||||
*/
|
*/
|
||||||
public synchronized TagName addTagName(String displayName, String description, TagName.HTML_COLOR color) throws TagNameAlreadyExistsException, TskCoreException {
|
public synchronized TagName addTagName(String displayName, String description, TagName.HTML_COLOR color) throws TagNameAlreadyExistsException, TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uniqueTagNames.containsKey(displayName)) {
|
if (uniqueTagNames.containsKey(displayName)) {
|
||||||
throw new TagNameAlreadyExistsException();
|
throw new TagNameAlreadyExistsException();
|
||||||
}
|
}
|
||||||
@ -226,9 +217,7 @@ public class TagsManager implements Closeable {
|
|||||||
* the case database.
|
* the case database.
|
||||||
*/
|
*/
|
||||||
public synchronized ContentTag addContentTag(Content content, TagName tagName, String comment, long beginByteOffset, long endByteOffset) throws IllegalArgumentException, TskCoreException {
|
public synchronized ContentTag addContentTag(Content content, TagName tagName, String comment, long beginByteOffset, long endByteOffset) throws IllegalArgumentException, TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (beginByteOffset >= 0 && endByteOffset >= 1) {
|
if (beginByteOffset >= 0 && endByteOffset >= 1) {
|
||||||
if (beginByteOffset > content.getSize() - 1) {
|
if (beginByteOffset > content.getSize() - 1) {
|
||||||
@ -267,9 +256,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized void deleteContentTag(ContentTag tag) throws TskCoreException {
|
public synchronized void deleteContentTag(ContentTag tag) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
caseDb.deleteContentTag(tag);
|
caseDb.deleteContentTag(tag);
|
||||||
try {
|
try {
|
||||||
@ -288,9 +275,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public List<ContentTag> getAllContentTags() throws TskCoreException {
|
public List<ContentTag> getAllContentTags() throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getAllContentTags();
|
return caseDb.getAllContentTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,9 +290,7 @@ public class TagsManager implements Closeable {
|
|||||||
* the case database.
|
* the case database.
|
||||||
*/
|
*/
|
||||||
public synchronized long getContentTagsCountByTagName(TagName tagName) throws TskCoreException {
|
public synchronized long getContentTagsCountByTagName(TagName tagName) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getContentTagsCountByTagName(tagName);
|
return caseDb.getContentTagsCountByTagName(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,11 +305,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized ContentTag getContentTagByTagID(long tagID) throws TskCoreException {
|
public synchronized ContentTag getContentTagByTagID(long tagID) throws TskCoreException {
|
||||||
// @@@ This is a work around to be removed when database access on the EDT is correctly synchronized.
|
lazyLoadExistingTagNames();
|
||||||
if (!tagNamesInitialized) {
|
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
return caseDb.getContentTagByID(tagID);
|
return caseDb.getContentTagByID(tagID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,11 +321,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized List<ContentTag> getContentTagsByTagName(TagName tagName) throws TskCoreException {
|
public synchronized List<ContentTag> getContentTagsByTagName(TagName tagName) throws TskCoreException {
|
||||||
// @@@ This is a work around to be removed when database access on the EDT is correctly synchronized.
|
lazyLoadExistingTagNames();
|
||||||
if (!tagNamesInitialized) {
|
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
return caseDb.getContentTagsByTagName(tagName);
|
return caseDb.getContentTagsByTagName(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,11 +337,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized List<ContentTag> getContentTagsByContent(Content content) throws TskCoreException {
|
public synchronized List<ContentTag> getContentTagsByContent(Content content) throws TskCoreException {
|
||||||
// @@@ This is a work around to be removed when database access on the EDT is correctly synchronized.
|
lazyLoadExistingTagNames();
|
||||||
if (!tagNamesInitialized) {
|
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
return caseDb.getContentTagsByContent(content);
|
return caseDb.getContentTagsByContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,9 +371,7 @@ public class TagsManager implements Closeable {
|
|||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
public synchronized BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName, String comment) throws TskCoreException {
|
public synchronized BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName, String comment) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
BlackboardArtifactTag addBlackboardArtifactTag = caseDb.addBlackboardArtifactTag(artifact, tagName, comment);
|
BlackboardArtifactTag addBlackboardArtifactTag = caseDb.addBlackboardArtifactTag(artifact, tagName, comment);
|
||||||
try {
|
try {
|
||||||
Case.getCurrentCase().notifyBlackBoardArtifactTagAdded(addBlackboardArtifactTag);
|
Case.getCurrentCase().notifyBlackBoardArtifactTagAdded(addBlackboardArtifactTag);
|
||||||
@ -421,9 +390,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException {
|
public synchronized void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
caseDb.deleteBlackboardArtifactTag(tag);
|
caseDb.deleteBlackboardArtifactTag(tag);
|
||||||
try {
|
try {
|
||||||
Case.getCurrentCase().notifyBlackBoardArtifactTagDeleted(tag);
|
Case.getCurrentCase().notifyBlackBoardArtifactTagDeleted(tag);
|
||||||
@ -441,9 +408,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public List<BlackboardArtifactTag> getAllBlackboardArtifactTags() throws TskCoreException {
|
public List<BlackboardArtifactTag> getAllBlackboardArtifactTags() throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getAllBlackboardArtifactTags();
|
return caseDb.getAllBlackboardArtifactTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,9 +424,7 @@ public class TagsManager implements Closeable {
|
|||||||
* the case database.
|
* the case database.
|
||||||
*/
|
*/
|
||||||
public synchronized long getBlackboardArtifactTagsCountByTagName(TagName tagName) throws TskCoreException {
|
public synchronized long getBlackboardArtifactTagsCountByTagName(TagName tagName) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getBlackboardArtifactTagsCountByTagName(tagName);
|
return caseDb.getBlackboardArtifactTagsCountByTagName(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,9 +439,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized BlackboardArtifactTag getBlackboardArtifactTagByTagID(long tagID) throws TskCoreException {
|
public synchronized BlackboardArtifactTag getBlackboardArtifactTagByTagID(long tagID) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getBlackboardArtifactTagByID(tagID);
|
return caseDb.getBlackboardArtifactTagByID(tagID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,9 +455,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized List<BlackboardArtifactTag> getBlackboardArtifactTagsByTagName(TagName tagName) throws TskCoreException {
|
public synchronized List<BlackboardArtifactTag> getBlackboardArtifactTagsByTagName(TagName tagName) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getBlackboardArtifactTagsByTagName(tagName);
|
return caseDb.getBlackboardArtifactTagsByTagName(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,9 +471,7 @@ public class TagsManager implements Closeable {
|
|||||||
* case database.
|
* case database.
|
||||||
*/
|
*/
|
||||||
public synchronized List<BlackboardArtifactTag> getBlackboardArtifactTagsByArtifact(BlackboardArtifact artifact) throws TskCoreException {
|
public synchronized List<BlackboardArtifactTag> getBlackboardArtifactTagsByArtifact(BlackboardArtifact artifact) throws TskCoreException {
|
||||||
if (!tagNamesInitialized) {
|
lazyLoadExistingTagNames();
|
||||||
getExistingTagNames();
|
|
||||||
}
|
|
||||||
return caseDb.getBlackboardArtifactTagsByArtifact(artifact);
|
return caseDb.getBlackboardArtifactTagsByArtifact(artifact);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,22 +484,24 @@ public class TagsManager implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates the tag names collection with the existing tag names from all
|
* Populates the tag names collection and the tag names table in the case
|
||||||
* sources.
|
* database with the existing tag names from all sources.
|
||||||
*/
|
*/
|
||||||
private void getExistingTagNames() {
|
private void lazyLoadExistingTagNames() {
|
||||||
getTagNamesFromCurrentCase();
|
if (!tagNamesInitialized) {
|
||||||
getTagNamesFromTagsSettings();
|
addTagNamesFromCurrentCase();
|
||||||
getPredefinedTagNames();
|
addTagNamesFromTagsSettings();
|
||||||
saveTagNamesToTagsSettings();
|
addPredefinedTagNames();
|
||||||
tagNamesInitialized = true;
|
saveTagNamesToTagsSettings();
|
||||||
|
tagNamesInitialized = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds any tag names that are in the case database to the tag names
|
* Adds any tag names that are in the case database to the tag names
|
||||||
* collection.
|
* collection.
|
||||||
*/
|
*/
|
||||||
private void getTagNamesFromCurrentCase() {
|
private void addTagNamesFromCurrentCase() {
|
||||||
try {
|
try {
|
||||||
List<TagName> currentTagNames = caseDb.getAllTagNames();
|
List<TagName> currentTagNames = caseDb.getAllTagNames();
|
||||||
for (TagName tagName : currentTagNames) {
|
for (TagName tagName : currentTagNames) {
|
||||||
@ -555,10 +514,10 @@ public class TagsManager implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds any tag names that are in the properties file to the tag names
|
* Adds any tag names that are in the properties file to the tag names
|
||||||
* collection. The properties file is used to make it possible to use tag
|
* collection and to the case database. The properties file is used to make
|
||||||
* names across cases.
|
* it possible to use tag names across cases.
|
||||||
*/
|
*/
|
||||||
private void getTagNamesFromTagsSettings() {
|
private void addTagNamesFromTagsSettings() {
|
||||||
String setting = ModuleSettings.getConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY);
|
String setting = ModuleSettings.getConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY);
|
||||||
if (null != setting && !setting.isEmpty()) {
|
if (null != setting && !setting.isEmpty()) {
|
||||||
// Read the tag name setting and break it into tag name tuples.
|
// Read the tag name setting and break it into tag name tuples.
|
||||||
@ -583,7 +542,7 @@ public class TagsManager implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Adds the standard tag names to the tag names collection.
|
* Adds the standard tag names to the tag names collection.
|
||||||
*/
|
*/
|
||||||
private void getPredefinedTagNames() {
|
private void addPredefinedTagNames() {
|
||||||
if (!uniqueTagNames.containsKey(NbBundle.getMessage(this.getClass(), "TagsManager.predefTagNames.bookmark.text"))) {
|
if (!uniqueTagNames.containsKey(NbBundle.getMessage(this.getClass(), "TagsManager.predefTagNames.bookmark.text"))) {
|
||||||
try {
|
try {
|
||||||
TagName tagName = caseDb.addTagName(
|
TagName tagName = caseDb.addTagName(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user