19 package org.sleuthkit.datamodel;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.HashSet;
25 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
45 private final long objId;
46 private final String name;
47 private volatile Content parent;
48 private volatile String uniquePath;
51 private volatile boolean checkedHasChildren;
52 private volatile int childrenCount;
61 checkedHasChildren =
false;
80 if (uniquePath == null) {
81 String tempUniquePath =
"";
82 if (!name.isEmpty()) {
83 tempUniquePath =
"/" +
getName();
87 if (myParent != null) {
92 uniquePath = tempUniquePath;
99 if (checkedHasChildren ==
true) {
104 checkedHasChildren =
true;
111 if (childrenCount != -1) {
112 return childrenCount;
117 hasChildren = childrenCount > 0;
118 checkedHasChildren =
true;
120 return childrenCount;
127 if (parent == null) {
128 ObjectInfo parentInfo;
129 parentInfo = db.getParentInfo(
this);
130 if (parentInfo == null) {
139 void setParent(
Content parent) {
140 this.parent = parent;
150 void setParentId(
long parentId) {
169 List<Content> children =
new ArrayList<Content>();
190 List<Long> childrenIDs =
new ArrayList<Long>();
193 childrenIDs.addAll(
getSleuthkitCase().getBlackboardArtifactChildrenIds(
this));
202 if (myParent == null) {
217 return getPool() != null;
228 Volume getPoolVolume() throws TskCoreException {
230 if (myParent == null) {
238 if (myParent instanceof Volume) {
240 if (((Volume) myParent).isPoolContent()) {
241 return (Volume) myParent;
249 return ((AbstractContent) myParent).getPoolVolume();
259 Pool getPool() throws TskCoreException {
261 if (myParent == null) {
265 if (!(myParent instanceof AbstractContent)) {
269 if (myParent instanceof Pool) {
270 return (Pool) myParent;
274 return ((AbstractContent) myParent).getPool();
291 if (getClass() != obj.getClass()) {
295 if (this.objId != other.objId) {
305 }
catch (TskCoreException ex) {
306 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, null, ex);
314 int hash = 7 + (int) (this.objId ^ (this.objId >>> 32));
317 }
catch (TskCoreException ex) {
318 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, null, ex);
331 switch (artifactType.getCategory()) {
334 case ANALYSIS_RESULT: {
339 throw new TskCoreException(String.format(
"Unknown category: %s for artifact type id: %d",
340 artifactType.getCategory().getName(), artifactTypeID));
356 throw new TskCoreException(String.format(
"Error adding analysis result to content with objId = %d.", objId), ex);
363 long dataSourceObjectId = dataSourceId;
372 throw new TskCoreException(String.format(
"Error adding analysis result to content with objId = %d.", objId), ex);
380 if (osAccountId != null) {
381 try (CaseDbConnection connection = db.getConnection()) {
392 if (osAccountId != null) {
393 try (CaseDbConnection connection = db.getConnection()) {
406 @SuppressWarnings(
"deprecation")
413 public ArrayList<BlackboardArtifact>
getArtifacts(String artifactTypeName)
throws TskCoreException {
418 public ArrayList<BlackboardArtifact>
getArtifacts(
int artifactTypeID)
throws TskCoreException {
420 if (genInfoArtifact == null)
425 ArrayList<BlackboardArtifact> list =
new ArrayList<BlackboardArtifact>();
427 if (genInfoArtifact != null) {
428 list.add(genInfoArtifact);
447 if (genInfoArtifact != null) {
448 return genInfoArtifact;
454 if (arts.isEmpty()) {
461 retArt = arts.get(0);
463 genInfoArtifact = retArt;
469 ArrayList<BlackboardAttribute> returnList =
new ArrayList<BlackboardAttribute>();
471 if (genInfoArtifact == null) {
473 if (genInfoArtifact == null) {
479 if (attribute.getAttributeType().getTypeID() == attr_type.getTypeID()) {
480 returnList.add(attribute);
534 Set<String> hashNames =
new HashSet<String>();
539 if (attribute != null) {
543 return Collections.unmodifiableSet(hashNames);
553 return "AbstractContent [\t" +
"objId " + String.format(
"%010d", objId) +
"\t"
554 +
"name " + name +
"\t" +
"parentId " + parentId +
"\t"
555 +
"\t" +
"checkedHasChildren " + checkedHasChildren
556 +
"\t" +
"hasChildren " + hasChildren
557 +
"\t" +
"childrenCount " + childrenCount
558 +
"uniquePath " + uniquePath +
"]\t";
562 return "AbstractContent [\t" +
"objId " + String.format(
"%010d", objId)
563 +
"\t" +
"name " + name
564 +
"\t" +
"checkedHasChildren " + checkedHasChildren
565 +
"\t" +
"hasChildren " + hasChildren
566 +
"\t" +
"childrenCount " + childrenCount
570 return "AbstractContent [\t" +
"objId "
571 + String.format(
"%010d", objId) +
"\t" +
"name " + name
572 +
"\t" +
"checkedHasChildren " + checkedHasChildren
573 +
"\t" +
"hasChildren " + hasChildren
574 +
"\t" +
"childrenCount " + childrenCount
576 +
"\t" +
"parentId " + parentId +
"]\t";
578 }
catch (TskCoreException ex) {
579 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE,
"Could not find Parent", ex);
580 return "AbstractContent [\t" +
"objId " + String.format(
"%010d", objId) +
"\t"
581 +
"name " + name +
"\t" +
"parentId " + parentId +
"\t"
582 +
"\t" +
"checkedHasChildren " + checkedHasChildren
583 +
"\t" +
"hasChildren " + hasChildren
584 +
"\t" +
"childrenCount " + childrenCount
585 +
"uniquePath " + uniquePath +
"]\t";
long getBlackboardArtifactsCount(long objId)
static final Score SCORE_UNKNOWN
CaseDbTransaction beginTransaction()
List< Content > getChildren()
void newOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccountInstance.OsAccountInstanceType instanceType)
ArrayList< BlackboardArtifact > getBlackboardArtifacts(int artifactTypeID)
Blackboard getBlackboard()
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, long sourceObjId, Long dataSourceObjId, Collection< BlackboardAttribute > attributes, Long osAccountId)
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList)
List< AnalysisResult > getAnalysisResults(BlackboardArtifact.Type artifactType)
Content getContentById(long id)
ArrayList< BlackboardArtifact > getAllArtifacts()
List< AnalysisResult > getAnalysisResults(long sourceObjId)
AnalysisResult getAnalysisResult()
String toString(boolean preserveState)
ArrayList< BlackboardArtifact > getMatchingArtifacts(String whereClause)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList, Long osAccountId, long dataSourceId)
List< AnalysisResult > getAllAnalysisResults()
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList)
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList, long dataSourceId)
BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type)
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
BlackboardArtifact getGenInfoArtifact()
AbstractContent(SleuthkitCase db, long obj_id, String name)
SleuthkitCase getSleuthkitCase()
boolean equals(Object obj)
BlackboardArtifact.Type getArtifactType(String artTypeName)
long getArtifactsCount(ARTIFACT_TYPE type)
long getAllArtifactsCount()
List< BlackboardAttribute > getAttributes()
List< DataArtifact > getAllDataArtifacts()
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, long objId, Long dataSourceObjId, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList)
BlackboardArtifact newArtifact(int artifactTypeID)
OsAccountManager getOsAccountManager()
Set< String > getHashSetNames()
long getArtifactsCount(int artifactTypeID)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList, Long osAccountId)
Score getAggregateScore()
ArrayList< BlackboardArtifact > getArtifacts(String artifactTypeName)
static final long UNKNOWN_ID
BlackboardArtifact getGenInfoArtifact(boolean create)
ArrayList< BlackboardAttribute > getGenInfoAttributes(ATTRIBUTE_TYPE attr_type)
long getArtifactsCount(String artifactTypeName)
List< Long > getChildrenIds()
Score getAggregateScore(long objId)
ScoringManager getScoringManager()