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.Collections;
30 import java.util.List;
32 import java.util.logging.Level;
33 import java.util.logging.Logger;
40 static long ID_NOT_SET = -1;
41 private long objectId = ID_NOT_SET;
42 private final String pathAsString;
43 private final Path pathAsPath;
44 private final long createdTime;
45 private final String sourceModuleName;
46 private final String reportName;
51 private FileChannel fileChannel = null;
53 private static final Logger LOGGER = Logger.getLogger(
Report.class.
getName());
67 this.pathAsString = path;
68 if (path.startsWith(
"http")) {
69 this.pathAsPath = null;
72 this.pathAsPath = Paths.get(path);
75 this.createdTime = createdTime;
76 this.sourceModuleName = sourceModuleName;
77 this.reportName = reportName;
92 return (pathAsPath != null ? pathAsPath.toString() : pathAsString);
111 return this.sourceModuleName;
125 if (pathAsPath == null || Files.isDirectory(pathAsPath)) {
129 int totalBytesRead = 0;
130 ByteBuffer data = ByteBuffer.wrap(buf);
132 if (fileChannel == null) {
133 fileChannel = FileChannel.open(pathAsPath, READ);
135 fileChannel.position(offset);
138 bytesRead = fileChannel.read(data);
139 if (bytesRead != -1) {
140 totalBytesRead += bytesRead;
142 }
while (bytesRead != -1 && data.hasRemaining());
143 }
catch (IOException ex) {
144 LOGGER.log(Level.SEVERE,
"Failed to read report file.", ex);
147 return totalBytesRead;
153 if (fileChannel != null)
155 }
catch (IOException ex) {
156 LOGGER.log(Level.WARNING,
"Failed to close report file.", ex);
163 return (pathAsPath != null ? Files.size(pathAsPath) : 0);
164 }
catch (IOException ex) {
165 LOGGER.log(Level.SEVERE,
"Failed to get size of report.", ex);
174 return v.
visit(
this);
190 if (null == parent) {
199 return Collections.<
Content>emptyList();
214 if (parent == null) {
216 parentInfo = db.getParentInfo(
this);
217 if (parentInfo == null) {
228 return Collections.<Long>emptyList();
287 return Collections.<String>emptySet();
315 return v.
visit(
this);
long getBlackboardArtifactsCount(long objId)
List< Content > getChildren()
Set< String > getHashSetNames()
ArrayList< BlackboardArtifact > getBlackboardArtifacts(int artifactTypeID)
long getAllArtifactsCount()
long getArtifactsCount(int artifactTypeID)
long getArtifactsCount(String artifactTypeName)
Content getContentById(long id)
ArrayList< BlackboardAttribute > getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE attr_type)
List< Long > getChildrenIds()
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
ArrayList< BlackboardArtifact > getMatchingArtifacts(String whereClause)
BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type)
BlackboardArtifact newBlackboardArtifact(int artifactTypeID, long obj_id)
ArrayList< BlackboardArtifact > getArtifacts(String artifactTypeName)
BlackboardArtifact newArtifact(int artifactTypeID)
int read(byte[] buf, long offset, long len)
BlackboardArtifact.Type getArtifactType(String artTypeName)
BlackboardArtifact getGenInfoArtifact()
long getArtifactsCount(BlackboardArtifact.ARTIFACT_TYPE type)
String getSourceModuleName()
ArrayList< BlackboardArtifact > getAllArtifacts()
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
BlackboardArtifact getGenInfoArtifact(boolean create)