19 package org.sleuthkit.autopsy.datamodel;
21 import com.google.common.util.concurrent.ThreadFactoryBuilder;
22 import java.sql.ResultSet;
23 import java.sql.SQLException;
24 import java.util.List;
25 import java.util.concurrent.ExecutorService;
26 import java.util.concurrent.Executors;
27 import java.util.logging.Level;
28 import org.apache.commons.lang3.tuple.Pair;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Sheet;
32 import org.openide.util.lookup.Lookups;
33 import org.openide.util.Lookup;
34 import org.openide.util.NbBundle;
35 import org.openide.util.NbBundle.Messages;
43 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
70 static final ExecutorService backgroundTasksPool;
76 @NbBundle.Messages({
"AbstractContentNode.nodescription=no description",
77 "AbstractContentNode.valueLoading=value loading"})
78 protected static final String
NO_DESCR = Bundle.AbstractContentNode_nodescription();
79 protected static final String
VALUE_LOADING = Bundle.AbstractContentNode_valueLoading();
87 enum NodeSpecificEvents {
88 TRANSLATION_AVAILABLE,
95 backgroundTasksPool = Executors.newFixedThreadPool(MAX_POOL_SIZE,
96 new ThreadFactoryBuilder().setNameFormat(
"content-node-background-task-%d").build());
104 AbstractContentNode(T content) {
105 this(
content, Lookups.singleton(content));
114 AbstractContentNode(T content, Lookup lookup) {
115 super(Children.create(
new ContentChildren(content),
true), lookup);
118 super.setName(
"content_" + Long.toString(content.getId()));
137 return super.getName();
162 if (!c.hasChildren()) {
165 }
catch (TskCoreException ex) {
167 logger.log(Level.SEVERE,
"Error checking if the node has children, for content: " + c, ex);
171 String query =
"SELECT COUNT(obj_id) AS count FROM "
172 +
" ( SELECT obj_id FROM tsk_objects WHERE par_obj_id = " + c.getId() +
" AND type = "
173 + TskData.ObjectType.ARTIFACT.getObjectType()
174 +
" INTERSECT SELECT artifact_obj_id FROM blackboard_artifacts WHERE obj_id = " + c.getId()
175 +
" AND (artifact_type_id = " + ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
176 +
" OR artifact_type_id = " + ARTIFACT_TYPE.TSK_MESSAGE.getTypeID() +
") "
177 +
" UNION SELECT obj_id FROM tsk_objects WHERE par_obj_id = " + c.getId()
178 +
" AND type = " + TskData.ObjectType.ABSTRACTFILE.getObjectType() +
") AS OBJECT_IDS";
181 ResultSet resultSet = dbQuery.getResultSet();
182 if (resultSet.next()) {
183 return (0 < resultSet.getInt(
"count"));
186 logger.log(Level.SEVERE,
"Error checking if the node has children, for content: " + c, ex);
199 boolean hasChildren =
false;
201 if (content != null) {
203 hasChildren = content.hasChildren();
204 }
catch (TskCoreException ex) {
205 logger.log(Level.SEVERE,
"Error checking if the node has children, for content: " + content, ex);
219 List<Long> childrenIds = null;
221 if (content != null) {
223 childrenIds = content.getChildrenIds();
224 }
catch (TskCoreException ex) {
225 logger.log(Level.SEVERE,
"Error getting children ids, for content: " + content, ex);
239 List<Content> children = null;
241 if (content != null) {
243 children = content.getChildren();
244 }
catch (TskCoreException ex) {
245 logger.log(Level.SEVERE,
"Error getting children, for content: " + content, ex);
261 int childrenCount = -1;
263 if (content != null) {
265 childrenCount = content.getChildrenCount();
266 }
catch (TskCoreException ex) {
267 logger.log(Level.SEVERE,
"Error checking node content children count, for content: " + content, ex);
271 return childrenCount;
286 public int read(byte[] buf,
long offset,
long len)
throws TskException {
287 return content.read(buf, offset, len);
306 Sheet visibleSheet = this.getSheet();
307 Sheet.Set visibleSheetSet = visibleSheet.get(Sheet.PROPERTIES);
308 Property<?>[] visibleProps = visibleSheetSet.getProperties();
310 for (
int i = 0; i < visibleProps.length; i++) {
311 if (visibleProps[i].
getName().equals(newProp.getName())) {
312 visibleProps[i] = newProp;
316 visibleSheetSet.put(visibleProps);
317 visibleSheet.put(visibleSheetSet);
319 this.setSheet(visibleSheet);
346 "# {0} - significanceDisplayName",
347 "AbstractContentNode_getScorePropertyAndDescription_description=Has an {0} analysis result score"
350 Score score = Score.SCORE_UNKNOWN;
352 score = this.content.getAggregateScore();
353 }
catch (TskCoreException ex) {
354 logger.log(Level.WARNING,
"Unable to get aggregate score for content with id: " +
this.content.getId(), ex);
357 String significanceDisplay = score.getSignificance().getDisplayName();
358 String description = Bundle.AbstractContentNode_getScorePropertyAndDescription_description(significanceDisplay);
359 return Pair.of(score, description);
synchronized void updateSheet(NodeProperty<?>...newProps)
int read(byte[] buf, long offset, long len)
static final String VALUE_LOADING
abstract DataResultViewerTable.HasCommentStatus getCommentProperty(List< Tag > tags, CorrelationAttributeInstance attribute)
static final Integer MAX_POOL_SIZE
List< Content > getContentChildren()
static final Logger logger
void setName(String name)
int getContentChildrenCount()
boolean hasContentChildren()
abstract CorrelationAttributeInstance getCorrelationAttributeInstance()
abstract Pair< Long, String > getCountPropertyAndDescription(Type attributeType, String attributeValue, String defaultDescription)
boolean hasVisibleContentChildren()
Pair< Score, String > getScorePropertyAndDescription(List< Tag > tags)
SleuthkitCase getSleuthkitCase()
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
abstract List< Tag > getAllTagsFromDatabase()
List< Long > getContentChildrenIds()
static boolean contentHasVisibleContentChildren(Content c)
static final String NO_DESCR