19 package org.sleuthkit.datamodel;
21 import java.io.IOException;
22 import java.nio.ByteBuffer;
23 import java.nio.channels.FileChannel;
24 import java.nio.file.Files;
25 import java.nio.file.Path;
26 import java.nio.file.Paths;
27 import static java.nio.file.StandardOpenOption.READ;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.Collections;
31 import java.util.List;
33 import java.util.logging.Level;
34 import java.util.logging.Logger;
44 static long ID_NOT_SET = -1;
45 private long objectId = ID_NOT_SET;
46 private final String pathAsString;
47 private final Path pathAsPath;
48 private final long createdTime;
49 private final String sourceModuleName;
50 private final String reportName;
55 private FileChannel fileChannel = null;
57 private static final Logger LOGGER = Logger.getLogger(
Report.class.
getName());
71 this.pathAsString = path;
72 if (path.startsWith(
"http")) {
73 this.pathAsPath = null;
75 this.pathAsPath = Paths.get(path);
78 this.createdTime = createdTime;
79 this.sourceModuleName = sourceModuleName;
80 this.reportName = reportName;
95 return (pathAsPath != null ? pathAsPath.toString() : pathAsString);
114 return this.sourceModuleName;
128 if (pathAsPath == null || Files.isDirectory(pathAsPath)) {
132 int totalBytesRead = 0;
133 ByteBuffer data = ByteBuffer.wrap(buf);
135 if (fileChannel == null) {
136 fileChannel = FileChannel.open(pathAsPath, READ);
138 fileChannel.position(offset);
141 bytesRead = fileChannel.read(data);
142 if (bytesRead != -1) {
143 totalBytesRead += bytesRead;
145 }
while (bytesRead != -1 && data.hasRemaining());
146 }
catch (IOException ex) {
147 LOGGER.log(Level.SEVERE,
"Failed to read report file.", ex);
150 return totalBytesRead;
156 if (fileChannel != null) {
159 }
catch (IOException ex) {
160 LOGGER.log(Level.WARNING,
"Failed to close report file.", ex);
167 return (pathAsPath != null ? Files.size(pathAsPath) : 0);
168 }
catch (IOException ex) {
169 LOGGER.log(Level.SEVERE,
"Failed to get size of report.", ex);
178 return v.
visit(
this);
194 if (null == parent) {
203 return Collections.<
Content>emptyList();
218 if (parent == null) {
220 parentInfo = db.getParentInfo(
this);
221 if (parentInfo == null) {
232 return Collections.<Long>emptyList();
242 long fileObjId =
getId();
248 null, null, null, Collections.emptyList())
249 .getAnalysisResult();
251 throw new TskCoreException(
"Unable to get analysis result for keword hit.", ex);
313 @SuppressWarnings(
"deprecation")
367 return db.
getBlackboard().getDataArtifactsBySource(objectId);
382 return Collections.<String>emptySet();
410 return v.
visit(
this);
long getBlackboardArtifactsCount(long objId)
static final Score SCORE_UNKNOWN
List< Content > getChildren()
CaseDbTransaction beginTransaction()
List< DataArtifact > getAllDataArtifacts()
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList)
Set< String > getHashSetNames()
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList)
ArrayList< BlackboardArtifact > getBlackboardArtifacts(int artifactTypeID)
Blackboard getBlackboard()
long getAllArtifactsCount()
List< AnalysisResult > getAnalysisResults(BlackboardArtifact.Type artifactType)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList, Long osAccountId, long dataSourceId)
long getArtifactsCount(int artifactTypeID)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, long sourceObjId, Long dataSourceObjId, Collection< BlackboardAttribute > attributes, Long osAccountId)
long getArtifactsCount(String artifactTypeName)
List< AnalysisResult > getAllAnalysisResults()
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList, Long osAccountId)
Content getContentById(long id)
ArrayList< BlackboardAttribute > getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE attr_type)
List< Long > getChildrenIds()
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
List< AnalysisResult > getAnalysisResults(long dataSourceObjId, Integer artifactTypeID)
Score getAggregateScore()
ArrayList< BlackboardArtifact > getMatchingArtifacts(String whereClause)
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(String artifactTypeName)
BlackboardArtifact.Type getArtifactType(String artTypeName)
BlackboardArtifact newArtifact(int artifactTypeID)
int read(byte[] buf, long offset, long len)
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, long objId, Long dataSourceObjId, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList)
BlackboardArtifact getGenInfoArtifact()
long getArtifactsCount(BlackboardArtifact.ARTIFACT_TYPE type)
String getSourceModuleName()
ArrayList< BlackboardArtifact > getAllArtifacts()
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
Score getAggregateScore(long objId)
ScoringManager getScoringManager()
BlackboardArtifact getGenInfoArtifact(boolean create)