Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FileIngestTask.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-2021 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest;
20 
21 import java.util.Objects;
23 import org.sleuthkit.datamodel.AbstractFile;
24 import org.sleuthkit.datamodel.TskCoreException;
25 
30 final class FileIngestTask extends IngestTask {
31 
32  private final long fileId;
33  private AbstractFile file;
34 
43  FileIngestTask(IngestJobExecutor ingestJobPipeline, AbstractFile file) {
44  super(file.getName(), ingestJobPipeline);
45  this.file = file;
46  fileId = file.getId();
47  }
48 
59  FileIngestTask(IngestJobExecutor ingestJobPipeline, long fileId) {
60  super("", ingestJobPipeline);
61  this.fileId = fileId;
62  }
63 
69  long getFileId() {
70  return fileId;
71  }
72 
81  synchronized AbstractFile getFile() throws TskCoreException {
82  if (file == null) {
83  file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(fileId);
84  if (file != null) {
85  setContentName(file.getName());
86  }
87  }
88  return file;
89  }
90 
91  @Override
92  void execute(long threadId) {
93  super.setThreadId(threadId);
94  getIngestJobExecutor().execute(this);
95  }
96 
97  @Override
98  public boolean equals(Object obj) {
99  if (obj == null) {
100  return false;
101  }
102  if (getClass() != obj.getClass()) {
103  return false;
104  }
105  FileIngestTask other = (FileIngestTask) obj;
106  IngestJobExecutor thisPipeline = getIngestJobExecutor();
107  IngestJobExecutor otherPipeline = other.getIngestJobExecutor();
108  if (thisPipeline != otherPipeline && (thisPipeline == null || !thisPipeline.equals(otherPipeline))) {
109  return false;
110  }
111  return (getFileId() == other.getFileId());
112  }
113 
114  @Override
115  public int hashCode() {
116  int hash = 5;
117  hash = 47 * hash + Objects.hashCode(getIngestJobExecutor());
118  hash = 47 * hash + Objects.hashCode(getFileId());
119  return hash;
120  }
121 
122 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.