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;
41 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
67 static final ExecutorService backgroundTasksPool;
73 @NbBundle.Messages({
"AbstractContentNode.nodescription=no description",
74 "AbstractContentNode.valueLoading=value loading"})
75 protected static final String
NO_DESCR = Bundle.AbstractContentNode_nodescription();
76 protected static final String
VALUE_LOADING = Bundle.AbstractContentNode_valueLoading();
84 enum NodeSpecificEvents {
85 TRANSLATION_AVAILABLE,
92 backgroundTasksPool = Executors.newFixedThreadPool(MAX_POOL_SIZE,
93 new ThreadFactoryBuilder().setNameFormat(
"content-node-background-task-%d").build());
101 AbstractContentNode(T content) {
102 this(content, Lookups.singleton(content));
111 AbstractContentNode(T content, Lookup lookup) {
112 super(Children.create(
new ContentChildren(content),
false), lookup);
113 this.content = content;
115 super.setName(
"content_" + Long.toString(content.getId()));
134 return super.getName();
159 if (!c.hasChildren()) {
162 }
catch (TskCoreException ex) {
164 logger.log(Level.SEVERE,
"Error checking if the node has children, for content: " + c, ex);
168 String query =
"SELECT COUNT(obj_id) AS count FROM "
169 +
" ( SELECT obj_id FROM tsk_objects WHERE par_obj_id = " + c.getId() +
" AND type = "
170 + TskData.ObjectType.ARTIFACT.getObjectType()
171 +
" INTERSECT SELECT artifact_obj_id FROM blackboard_artifacts WHERE obj_id = " + c.getId()
172 +
" AND (artifact_type_id = " + ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
173 +
" OR artifact_type_id = " + ARTIFACT_TYPE.TSK_MESSAGE.getTypeID() +
") "
174 +
" UNION SELECT obj_id FROM tsk_objects WHERE par_obj_id = " + c.getId()
175 +
" AND type = " + TskData.ObjectType.ABSTRACTFILE.getObjectType() +
") AS OBJECT_IDS";
178 ResultSet resultSet = dbQuery.getResultSet();
179 if (resultSet.next()) {
180 return (0 < resultSet.getInt(
"count"));
183 logger.log(Level.SEVERE,
"Error checking if the node has children, for content: " + c, ex);
196 boolean hasChildren =
false;
198 if (content != null) {
200 hasChildren = content.hasChildren();
201 }
catch (TskCoreException ex) {
202 logger.log(Level.SEVERE,
"Error checking if the node has children, for content: " + content, ex);
216 List<Long> childrenIds = null;
218 if (content != null) {
220 childrenIds = content.getChildrenIds();
221 }
catch (TskCoreException ex) {
222 logger.log(Level.SEVERE,
"Error getting children ids, for content: " + content, ex);
236 List<Content> children = null;
238 if (content != null) {
240 children = content.getChildren();
241 }
catch (TskCoreException ex) {
242 logger.log(Level.SEVERE,
"Error getting children, for content: " + content, ex);
258 int childrenCount = -1;
260 if (content != null) {
262 childrenCount = content.getChildrenCount();
263 }
catch (TskCoreException ex) {
264 logger.log(Level.SEVERE,
"Error checking node content children count, for content: " + content, ex);
268 return childrenCount;
283 public int read(byte[] buf,
long offset,
long len)
throws TskException {
284 return content.read(buf, offset, len);
303 Sheet visibleSheet = this.getSheet();
304 Sheet.Set visibleSheetSet = visibleSheet.get(Sheet.PROPERTIES);
305 Property<?>[] visibleProps = visibleSheetSet.getProperties();
307 for (
int i = 0; i < visibleProps.length; i++) {
308 if (visibleProps[i].
getName().equals(newProp.getName())) {
309 visibleProps[i] = newProp;
313 visibleSheetSet.put(visibleProps);
314 visibleSheet.put(visibleSheetSet);
316 this.setSheet(visibleSheet);
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()
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
abstract Pair< DataResultViewerTable.Score, String > getScorePropertyAndDescription(List< Tag > tags)