Merge pull request #5883 from kellykelly3/1452-fix-TagsManager-getNotableTagDisplay

1452 - Fixed getNotableTagDisplayName
This commit is contained in:
Richard Cordovano 2020-05-13 10:33:28 -04:00 committed by GitHub
commit 9dde738f12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,6 +146,12 @@ public class TagsManager implements Closeable {
return tagDisplayNames; return tagDisplayNames;
} }
/**
* Gets the set of display names of notable (TskData.FileKnown.BAD) tag types.
* If a case is not open the list will only include only the user defined
* custom tags. Otherwise the list will include all notable tags.
* @return
*/
public static List<String> getNotableTagDisplayNames() { public static List<String> getNotableTagDisplayNames() {
List<String> tagDisplayNames = new ArrayList<>(); List<String> tagDisplayNames = new ArrayList<>();
for (TagNameDefinition tagDef : TagNameDefinition.getTagNameDefinitions()) { for (TagNameDefinition tagDef : TagNameDefinition.getTagNameDefinitions()) {
@ -153,6 +159,22 @@ public class TagsManager implements Closeable {
tagDisplayNames.add(tagDef.getDisplayName()); tagDisplayNames.add(tagDef.getDisplayName());
} }
} }
try {
TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager();
for (TagName tagName : tagsManager.getAllTagNames()) {
if(tagName.getKnownStatus() == TskData.FileKnown.BAD &&
!tagDisplayNames.contains(tagName.getDisplayName())) {
tagDisplayNames.add(tagName.getDisplayName());
}
}
} catch (NoCurrentCaseException ignored) {
/*
* No current case, nothing more to add to the set.
*/
} catch(TskCoreException ex) {
LOGGER.log(Level.SEVERE, "Failed to get list of TagNames from TagsManager.", ex);
}
return tagDisplayNames; return tagDisplayNames;
} }