19 package org.sleuthkit.datamodel;
 
   21 import com.google.common.annotations.Beta;
 
   22 import java.util.ArrayList;
 
   23 import java.util.Collection;
 
   24 import java.util.Collections;
 
   25 import java.util.HashSet;
 
   26 import java.util.List;
 
   27 import java.util.Optional;
 
   29 import java.util.logging.Level;
 
   30 import java.util.logging.Logger;
 
   47         private final long objId;
 
   48         private final String name;
 
   49         private volatile Content parent;
 
   50         private volatile String uniquePath;
 
   53         private volatile boolean checkedHasChildren;
 
   54         private volatile int childrenCount;
 
   63                 checkedHasChildren = 
false;
 
   82                 if (uniquePath == null) {
 
   83                         String tempUniquePath = 
"";
 
   84                         if (!name.isEmpty()) {
 
   85                                 tempUniquePath = 
"/" + 
getName();
 
   89                         if (myParent != null) {
 
   94                         uniquePath = tempUniquePath;
 
  101                 if (checkedHasChildren == 
true) {
 
  106                 checkedHasChildren = 
true;
 
  113                 if (childrenCount != -1) {
 
  114                         return childrenCount;
 
  119                 hasChildren = childrenCount > 0;
 
  120                 checkedHasChildren = 
true;
 
  122                 return childrenCount;
 
  129                 if (parent == null) {
 
  131                         if (!parentIdOpt.isPresent()) {
 
  140         void setParent(
Content parent) {
 
  141                 this.parent = parent;
 
  154                 if (parentId == UNKNOWN_ID) {
 
  155                         ObjectInfo parentInfo = db.getParentInfo(
this);
 
  156                         if (parentInfo != null) {
 
  157                                 parentId = parentInfo.getId();
 
  161                 return parentId == UNKNOWN_ID
 
  163                                 : Optional.of(parentId);
 
  173         void setParentId(
long parentId) {
 
  192                 List<Content> children = 
new ArrayList<Content>();
 
  213                 List<Long> childrenIDs = 
new ArrayList<Long>();
 
  216                 childrenIDs.addAll(
getSleuthkitCase().getBlackboardArtifactChildrenIds(
this));
 
  225                 if (myParent == null) {
 
  240                 return getPool() != null;
 
  251         Volume getPoolVolume() throws TskCoreException {
 
  253                 if (myParent == null) {
 
  261                 if (myParent instanceof Volume) {
 
  263                         if (((Volume) myParent).isPoolContent()) {
 
  264                                 return (Volume) myParent;
 
  272                 return ((AbstractContent) myParent).getPoolVolume();
 
  282         Pool getPool() throws TskCoreException {
 
  284                 if (myParent == null) {
 
  288                 if (!(myParent instanceof AbstractContent)) {
 
  292                 if (myParent instanceof Pool) {
 
  293                         return (Pool) myParent;
 
  297                 return ((AbstractContent) myParent).getPool();
 
  314                 if (getClass() != obj.getClass()) {
 
  318                 if (this.objId != other.objId) {
 
  328                 } 
catch (TskCoreException ex) {
 
  329                         Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, null, ex);
 
  337                 int hash = 7 + (int) (this.objId ^ (this.objId >>> 32));
 
  340                 } 
catch (TskCoreException ex) {
 
  341                         Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, null, ex);
 
  354                 switch (artifactType.getCategory()) {
 
  357                         case ANALYSIS_RESULT: {
 
  362                                 throw new TskCoreException(String.format(
"Unknown category: %s for artifact type id: %d",
 
  363                                                 artifactType.getCategory().getName(), artifactTypeID));
 
  379                         throw new TskCoreException(String.format(
"Error adding analysis result to content with objId = %d.", objId), ex);
 
  386                 long dataSourceObjectId = dataSourceId;
 
  395                         throw new TskCoreException(String.format(
"Error adding analysis result to content with objId = %d.", objId), ex);
 
  415         @SuppressWarnings(
"deprecation")
 
  422         public ArrayList<BlackboardArtifact> 
getArtifacts(String artifactTypeName) 
throws TskCoreException {
 
  427         public ArrayList<BlackboardArtifact> 
getArtifacts(
int artifactTypeID) 
throws TskCoreException {
 
  429                         if (genInfoArtifact == null) 
 
  434                         ArrayList<BlackboardArtifact> list = 
new ArrayList<BlackboardArtifact>();
 
  436                         if (genInfoArtifact != null) {
 
  437                                 list.add(genInfoArtifact);
 
  456                 if (genInfoArtifact != null) {
 
  457                         return genInfoArtifact;
 
  463                 if (arts.isEmpty()) {
 
  470                         retArt = arts.get(0);
 
  472                 genInfoArtifact = retArt;
 
  478                 ArrayList<BlackboardAttribute> returnList = 
new ArrayList<BlackboardAttribute>();
 
  480                 if (genInfoArtifact == null) {
 
  482                         if (genInfoArtifact == null) {
 
  488                         if (attribute.getAttributeType().getTypeID() == attr_type.getTypeID()) {
 
  489                                 returnList.add(attribute);
 
  543                 Set<String> hashNames = 
new HashSet<String>();
 
  548                         if (attribute != null) {
 
  552                 return Collections.unmodifiableSet(hashNames);
 
  562                         return "AbstractContent [\t" + 
"objId " + String.format(
"%010d", objId) + 
"\t"  
  563                                         + 
"name " + name + 
"\t" + 
"parentId " + parentId + 
"\t"  
  564                                         + 
"\t" + 
"checkedHasChildren " + checkedHasChildren 
 
  565                                         + 
"\t" + 
"hasChildren " + hasChildren 
 
  566                                         + 
"\t" + 
"childrenCount " + childrenCount 
 
  567                                         + 
"uniquePath " + uniquePath + 
"]\t"; 
 
  571                                         return "AbstractContent [\t" + 
"objId " + String.format(
"%010d", objId) 
 
  572                                                         + 
"\t" + 
"name " + name 
 
  573                                                         + 
"\t" + 
"checkedHasChildren " + checkedHasChildren 
 
  574                                                         + 
"\t" + 
"hasChildren " + hasChildren 
 
  575                                                         + 
"\t" + 
"childrenCount " + childrenCount 
 
  579                                         return "AbstractContent [\t" + 
"objId "  
  580                                                         + String.format(
"%010d", objId) + 
"\t" + 
"name " + name 
 
  581                                                         + 
"\t" + 
"checkedHasChildren " + checkedHasChildren 
 
  582                                                         + 
"\t" + 
"hasChildren " + hasChildren 
 
  583                                                         + 
"\t" + 
"childrenCount " + childrenCount 
 
  585                                                         + 
"\t" + 
"parentId " + parentId + 
"]\t"; 
 
  587                         } 
catch (TskCoreException ex) {
 
  588                                 Logger.getLogger(AbstractContent.class.getName()).log(Level.SEVERE, 
"Could not find Parent", ex); 
 
  589                                 return "AbstractContent [\t" + 
"objId " + String.format(
"%010d", objId) + 
"\t"  
  590                                                 + 
"name " + name + 
"\t" + 
"parentId " + parentId + 
"\t"  
  591                                                 + 
"\t" + 
"checkedHasChildren " + checkedHasChildren 
 
  592                                                 + 
"\t" + 
"hasChildren " + hasChildren 
 
  593                                                 + 
"\t" + 
"childrenCount " + childrenCount 
 
  594                                                 + 
"uniquePath " + uniquePath + 
"]\t";  
 
long getBlackboardArtifactsCount(long objId)
 
static final Score SCORE_UNKNOWN
 
CaseDbTransaction beginTransaction()
 
List< Content > getChildren()
 
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()
 
AnalysisResult getAnalysisResult()
 
List< AnalysisResult > getAnalysisResults(long dataSourceObjId, Integer artifactTypeID)
 
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)
 
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)
 
Optional< Long > getParentId()
 
long getArtifactsCount(String artifactTypeName)
 
List< Long > getChildrenIds()
 
Score getAggregateScore(long objId)
 
ScoringManager getScoringManager()