mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
remove obsolete and unused ContentStreams
This commit is contained in:
parent
2b4bb33798
commit
abf21f58ee
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Autopsy Forensic Browser
|
|
||||||
*
|
|
||||||
* Copyright 2011-2016 Basis Technology Corp.
|
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.sleuthkit.autopsy.keywordsearch;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
import org.openide.util.NbBundle;
|
|
||||||
import org.apache.solr.common.util.ContentStream;
|
|
||||||
import org.sleuthkit.datamodel.AbstractContent;
|
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper over InputStream that implements ContentStream to feed to Solr.
|
|
||||||
*/
|
|
||||||
class AbstractFileStringContentStream implements ContentStream {
|
|
||||||
//input
|
|
||||||
|
|
||||||
private final AbstractFile content;
|
|
||||||
private final Charset charset;
|
|
||||||
//converted
|
|
||||||
private final InputStream stream;
|
|
||||||
|
|
||||||
public AbstractFileStringContentStream(AbstractFile content, Charset charset, InputStream inputStream) {
|
|
||||||
this.content = content;
|
|
||||||
this.charset = charset;
|
|
||||||
this.stream = inputStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbstractContent getSourceContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentType() {
|
|
||||||
return "text/plain;charset=" + charset.name(); //NON-NLS
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return content.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Reader getReader() throws IOException {
|
|
||||||
return new InputStreamReader(stream);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getSize() {
|
|
||||||
//return convertedLength;
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
NbBundle.getMessage(this.getClass(), "AbstractFileStringContentStream.getSize.exception.msg"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSourceInfo() {
|
|
||||||
return NbBundle.getMessage(this.getClass(), "AbstractFileStringContentStream.getSrcInfo.text", content.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getStream() throws IOException {
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
super.finalize();
|
|
||||||
|
|
||||||
stream.close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -108,6 +108,7 @@ public class ArtifactExtractor extends TextExtractor<Void, BlackboardArtifact> {
|
|||||||
switch (attribute.getValueType()) {
|
switch (attribute.getValueType()) {
|
||||||
case DATETIME:
|
case DATETIME:
|
||||||
artifactContents.append(ContentUtils.getStringTime(attribute.getValueLong(), dataSource));
|
artifactContents.append(ContentUtils.getStringTime(attribute.getValueLong(), dataSource));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
artifactContents.append(attribute.getDisplayString());
|
artifactContents.append(attribute.getDisplayString());
|
||||||
}
|
}
|
||||||
@ -136,15 +137,7 @@ public class ArtifactExtractor extends TextExtractor<Void, BlackboardArtifact> {
|
|||||||
return source.getArtifactID();
|
return source.getArtifactID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
ContentStream getContentStream(byte[] encodedBytes, int length, BlackboardArtifact source) {
|
|
||||||
return new ByteArtifactStream(encodedBytes, length, source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
ContentStream getNullStream(BlackboardArtifact source) {
|
|
||||||
return new Ingester.NullArtifactStream(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getName(BlackboardArtifact source) {
|
String getName(BlackboardArtifact source) {
|
||||||
|
@ -115,15 +115,6 @@ abstract class FileTextExtractor<AppendixProvider> extends TextExtractor<Appendi
|
|||||||
return source.getId();
|
return source.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
ContentStream getContentStream(byte[] encodedBytes, int length, AbstractFile source) {
|
|
||||||
return new ByteContentStream(encodedBytes, length, source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
ContentStream getNullStream(AbstractFile source) {
|
|
||||||
return new Ingester.NullContentStream(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getName(AbstractFile source) {
|
String getName(AbstractFile source) {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.keywordsearch;
|
package org.sleuthkit.autopsy.keywordsearch;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
@ -28,13 +27,11 @@ import java.util.Map;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.apache.solr.client.solrj.SolrServerException;
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.apache.solr.common.util.ContentStream;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.coreutils.TextUtil;
|
import org.sleuthkit.autopsy.coreutils.TextUtil;
|
||||||
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
||||||
import org.sleuthkit.datamodel.AbstractContent;
|
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
@ -266,7 +263,6 @@ class Ingester {
|
|||||||
String chunkId = Server.getChunkIdString(sourceID, numChunks + 1);
|
String chunkId = Server.getChunkIdString(sourceID, numChunks + 1);
|
||||||
fields.put(Server.Schema.ID.toString(), chunkId);
|
fields.put(Server.Schema.ID.toString(), chunkId);
|
||||||
try {
|
try {
|
||||||
ContentStream bcs = extractor.getContentStream(encodedBytes, encodedBytes.length, source);
|
|
||||||
try {
|
try {
|
||||||
indexChunk(encodedBytes, sourceName, fields, encodedBytes.length);
|
indexChunk(encodedBytes, sourceName, fields, encodedBytes.length);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -413,92 +409,6 @@ class Ingester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ContentStream associated with FsContent, but forced with no content
|
|
||||||
*/
|
|
||||||
static class NullContentStream implements ContentStream {
|
|
||||||
|
|
||||||
AbstractContent aContent;
|
|
||||||
|
|
||||||
NullContentStream(AbstractContent aContent) {
|
|
||||||
this.aContent = aContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return aContent.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSourceInfo() {
|
|
||||||
return NbBundle.getMessage(this.getClass(), "Ingester.NullContentStream.getSrcInfo.text", aContent.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getSize() {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getStream() throws IOException {
|
|
||||||
return new ByteArrayInputStream(new byte[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Reader getReader() throws IOException {
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
NbBundle.getMessage(this.getClass(), "Ingester.NullContentStream.getReader"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ContentStream associated with Artifact, but forced with no content
|
|
||||||
*/
|
|
||||||
static class NullArtifactStream implements ContentStream {
|
|
||||||
|
|
||||||
BlackboardArtifact aContent;
|
|
||||||
|
|
||||||
NullArtifactStream(BlackboardArtifact aContent) {
|
|
||||||
this.aContent = aContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return aContent.getDisplayName() + "_" + aContent.getArtifactID();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NbBundle.Messages("Ingester.NullArtifactStream.getSrcInfo.text=File:{0})\n")
|
|
||||||
@Override
|
|
||||||
public String getSourceInfo() {
|
|
||||||
return Bundle.Ingester_NullArtifactStream_getSrcInfo_text(aContent.getArtifactID());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getSize() {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getStream() throws IOException {
|
|
||||||
return new ByteArrayInputStream(new byte[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Reader getReader() throws IOException {
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
NbBundle.getMessage(this.getClass(), "Ingester.NullContentStream.getReader"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that there was an error with the specific ingest operation, but
|
* Indicates that there was an error with the specific ingest operation, but
|
||||||
|
@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.keywordsearch;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import org.apache.solr.common.util.ContentStream;
|
|
||||||
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
||||||
|
|
||||||
abstract class TextExtractor<AppendixProvider, TextSource extends SleuthkitVisitableItem> {
|
abstract class TextExtractor<AppendixProvider, TextSource extends SleuthkitVisitableItem> {
|
||||||
@ -41,7 +40,5 @@ abstract class TextExtractor<AppendixProvider, TextSource extends SleuthkitVisit
|
|||||||
|
|
||||||
abstract long getID(TextSource source);
|
abstract long getID(TextSource source);
|
||||||
|
|
||||||
abstract ContentStream getContentStream(byte[] encodedBytes, int length, TextSource source);
|
|
||||||
abstract String getName(TextSource source);
|
abstract String getName(TextSource source);
|
||||||
abstract ContentStream getNullStream(TextSource source);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user