mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
better handling of exceptions in event bus eventhandlers
This commit is contained in:
parent
8c2f6d274a
commit
ed2fcdf80e
@ -35,8 +35,6 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
|||||||
import org.sleuthkit.autopsy.events.ContentTagAddedEvent;
|
import org.sleuthkit.autopsy.events.ContentTagAddedEvent;
|
||||||
import org.sleuthkit.autopsy.events.ContentTagDeletedEvent;
|
import org.sleuthkit.autopsy.events.ContentTagDeletedEvent;
|
||||||
import org.sleuthkit.autopsy.imagegallery.ImageGalleryController;
|
import org.sleuthkit.autopsy.imagegallery.ImageGalleryController;
|
||||||
import org.sleuthkit.autopsy.imagegallery.datamodel.Category;
|
|
||||||
import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableDB;
|
|
||||||
import org.sleuthkit.datamodel.ContentTag;
|
import org.sleuthkit.datamodel.ContentTag;
|
||||||
import org.sleuthkit.datamodel.TagName;
|
import org.sleuthkit.datamodel.TagName;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
@ -18,19 +18,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.imagegallery.datamodel;
|
package org.sleuthkit.autopsy.imagegallery.datamodel;
|
||||||
|
|
||||||
|
import com.google.common.eventbus.AsyncEventBus;
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||||
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
|
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.events.ContentTagAddedEvent;
|
import org.sleuthkit.autopsy.events.ContentTagAddedEvent;
|
||||||
import org.sleuthkit.autopsy.events.ContentTagDeletedEvent;
|
import org.sleuthkit.autopsy.events.ContentTagDeletedEvent;
|
||||||
import org.sleuthkit.autopsy.imagegallery.datamodel.Category;
|
|
||||||
import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableFile;
|
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.ContentTag;
|
import org.sleuthkit.datamodel.ContentTag;
|
||||||
import org.sleuthkit.datamodel.TagName;
|
import org.sleuthkit.datamodel.TagName;
|
||||||
@ -42,13 +43,20 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
*/
|
*/
|
||||||
public class DrawableTagsManager {
|
public class DrawableTagsManager {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(DrawableTagsManager.class.getName());
|
||||||
|
|
||||||
private static final String FOLLOW_UP = "Follow Up";
|
private static final String FOLLOW_UP = "Follow Up";
|
||||||
|
|
||||||
final private Object autopsyTagsManagerLock = new Object();
|
final private Object autopsyTagsManagerLock = new Object();
|
||||||
private TagsManager autopsyTagsManager;
|
private TagsManager autopsyTagsManager;
|
||||||
|
|
||||||
/** Used to distribute {@link TagsChangeEvent}s */
|
/** Used to distribute {@link TagsChangeEvent}s */
|
||||||
private final EventBus tagsEventBus = new EventBus("Tags Event Bus");
|
private final EventBus tagsEventBus = new AsyncEventBus(
|
||||||
|
Executors.newSingleThreadExecutor(
|
||||||
|
new BasicThreadFactory.Builder().namingPattern("Tags Event Bus").uncaughtExceptionHandler((Thread t, Throwable e) -> {
|
||||||
|
LOGGER.log(Level.SEVERE, "uncaught exception in event bus handler", e);
|
||||||
|
}).build()
|
||||||
|
));
|
||||||
|
|
||||||
/** The tag name corresponding to the "built-in" tag "Follow Up" */
|
/** The tag name corresponding to the "built-in" tag "Follow Up" */
|
||||||
private TagName followUpTagName;
|
private TagName followUpTagName;
|
||||||
@ -130,7 +138,7 @@ public class DrawableTagsManager {
|
|||||||
.filter(CategoryManager::isCategoryTagName)
|
.filter(CategoryManager::isCategoryTagName)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
} catch (TskCoreException | IllegalStateException ex) {
|
} catch (TskCoreException | IllegalStateException ex) {
|
||||||
Logger.getLogger(DrawableTagsManager.class.getName()).log(Level.WARNING, "couldn't access case", ex);
|
LOGGER.log(Level.WARNING, "couldn't access case", ex);
|
||||||
}
|
}
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
@ -166,7 +174,7 @@ public class DrawableTagsManager {
|
|||||||
throw new TskCoreException("tagame exists but wasn't found", ex);
|
throw new TskCoreException("tagame exists but wasn't found", ex);
|
||||||
}
|
}
|
||||||
} catch (IllegalStateException ex) {
|
} catch (IllegalStateException ex) {
|
||||||
Logger.getLogger(DrawableTagsManager.class.getName()).log(Level.SEVERE, "Case was closed out from underneath", ex);
|
LOGGER.log(Level.SEVERE, "Case was closed out from underneath", ex);
|
||||||
throw new TskCoreException("Case was closed out from underneath", ex);
|
throw new TskCoreException("Case was closed out from underneath", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,15 +551,16 @@ public class GroupManager {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void handleTagAdded(ContentTagAddedEvent evt) {
|
public void handleTagAdded(ContentTagAddedEvent evt) {
|
||||||
GroupKey<?> groupKey = null;
|
GroupKey<?> groupKey = null;
|
||||||
if (groupBy == DrawableAttribute.TAGS) {
|
if (groupBy == DrawableAttribute.CATEGORY && CategoryManager.isCategoryTagName(evt.getTag().getName())) {
|
||||||
groupKey = new GroupKey<TagName>(DrawableAttribute.TAGS, evt.getTag().getName());
|
|
||||||
} else if (groupBy == DrawableAttribute.CATEGORY) {
|
|
||||||
groupKey = new GroupKey<Category>(DrawableAttribute.CATEGORY, CategoryManager.categoryFromTagName(evt.getTag().getName()));
|
groupKey = new GroupKey<Category>(DrawableAttribute.CATEGORY, CategoryManager.categoryFromTagName(evt.getTag().getName()));
|
||||||
|
} else if (groupBy == DrawableAttribute.TAGS && CategoryManager.isNotCategoryTagName(evt.getTag().getName())) {
|
||||||
|
groupKey = new GroupKey<TagName>(DrawableAttribute.TAGS, evt.getTag().getName());
|
||||||
|
}
|
||||||
|
if (groupKey != null) {
|
||||||
|
final long fileID = evt.getTag().getContent().getId();
|
||||||
|
DrawableGroup g = getGroupForKey(groupKey);
|
||||||
|
addFileToGroup(g, groupKey, fileID);
|
||||||
}
|
}
|
||||||
final long fileID = evt.getTag().getContent().getId();
|
|
||||||
DrawableGroup g = getGroupForKey(groupKey);
|
|
||||||
addFileToGroup(g, groupKey, fileID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("AssignmentToMethodParameter")
|
@SuppressWarnings("AssignmentToMethodParameter")
|
||||||
@ -618,9 +619,11 @@ public class GroupManager {
|
|||||||
} else if (groupBy == DrawableAttribute.TAGS && CategoryManager.isNotCategoryTagName(evt.getTag().getName())) {
|
} else if (groupBy == DrawableAttribute.TAGS && CategoryManager.isNotCategoryTagName(evt.getTag().getName())) {
|
||||||
groupKey = new GroupKey<TagName>(DrawableAttribute.TAGS, evt.getTag().getName());
|
groupKey = new GroupKey<TagName>(DrawableAttribute.TAGS, evt.getTag().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupKey != null) {
|
if (groupKey != null) {
|
||||||
final long fileID = evt.getTag().getContent().getId();
|
final long fileID = evt.getTag().getContent().getId();
|
||||||
DrawableGroup g = removeFromGroup(groupKey, fileID);
|
DrawableGroup g = removeFromGroup(groupKey, fileID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user