mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-09 06:39:33 +00:00
Introduce IngestJobStartResult
This commit is contained in:
parent
09cf29ebcf
commit
fa16e9e38c
77
Core/src/org/sleuthkit/autopsy/ingest/IngestJobStartResult.java
Executable file
77
Core/src/org/sleuthkit/autopsy/ingest/IngestJobStartResult.java
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2013-2015 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.ingest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class IngestJobStartResult {
|
||||||
|
|
||||||
|
private IngestJob job; // may be null
|
||||||
|
private IngestManagerException startupException; // may be null
|
||||||
|
private List<IngestModuleError> moduleErrors; // may be empty
|
||||||
|
|
||||||
|
public IngestJobStartResult() {
|
||||||
|
job = null;
|
||||||
|
startupException = null;
|
||||||
|
moduleErrors = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the job
|
||||||
|
*/
|
||||||
|
public IngestJob getJob() {
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param job the job to set
|
||||||
|
*/
|
||||||
|
public void setJob(IngestJob job) {
|
||||||
|
this.job = job;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the startupException
|
||||||
|
*/
|
||||||
|
public IngestManagerException getStartupException() {
|
||||||
|
return startupException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startupException the startupException to set
|
||||||
|
*/
|
||||||
|
public void setStartupException(IngestManagerException startupException) {
|
||||||
|
this.startupException = startupException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the moduleErrors
|
||||||
|
*/
|
||||||
|
public List<IngestModuleError> getModuleErrors() {
|
||||||
|
return moduleErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param moduleErrors the moduleErrors to set
|
||||||
|
*/
|
||||||
|
public void setModuleErrors(List<IngestModuleError> moduleErrors) {
|
||||||
|
this.moduleErrors = moduleErrors;
|
||||||
|
}
|
||||||
|
}
|
@ -66,7 +66,6 @@ import org.sleuthkit.datamodel.Content;
|
|||||||
* data sources by ingest modules.
|
* data sources by ingest modules.
|
||||||
*/
|
*/
|
||||||
@NbBundle.Messages({
|
@NbBundle.Messages({
|
||||||
"IngestAborted=Ingest Aborted.",
|
|
||||||
"# {0} - error message", "IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList=\nErrors: \n{0}",
|
"# {0} - error message", "IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList=\nErrors: \n{0}",
|
||||||
"IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution=Please disable the failed modules or fix the errors and then restart ingest \nby right clicking on the data source and selecting Run Ingest Modules.",
|
"IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution=Please disable the failed modules or fix the errors and then restart ingest \nby right clicking on the data source and selecting Run Ingest Modules.",
|
||||||
"IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg=Unable to start up one or more ingest modules, ingest job cancelled.",
|
"IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg=Unable to start up one or more ingest modules, ingest job cancelled.",
|
||||||
@ -496,23 +495,19 @@ public class IngestManager {
|
|||||||
*
|
*
|
||||||
* @param dataSources The data sources to process.
|
* @param dataSources The data sources to process.
|
||||||
* @param settings The settings for the ingest job.
|
* @param settings The settings for the ingest job.
|
||||||
* @param errors Out parameter. This is a list of errors encountered.
|
|
||||||
*
|
*
|
||||||
* @return The ingest job that was started on success or null on failure.
|
* @return The IngestJobStartResult describing the results of attempting to
|
||||||
|
* start the ingest job.
|
||||||
*/
|
*/
|
||||||
public synchronized IngestJob beginIngestJob(Collection<Content> dataSources, IngestJobSettings settings, List<IngestModuleError> errors) {
|
public synchronized IngestJobStartResult beginIngestJob(Collection<Content> dataSources, IngestJobSettings settings) {
|
||||||
|
IngestJobStartResult ingestJobStartResult = new IngestJobStartResult();
|
||||||
if (this.jobCreationIsEnabled) {
|
if (this.jobCreationIsEnabled) {
|
||||||
IngestJob job = new IngestJob(dataSources, settings, RuntimeProperties.coreComponentsAreActive());
|
IngestJob job = new IngestJob(dataSources, settings, RuntimeProperties.coreComponentsAreActive());
|
||||||
if (job.hasIngestPipeline()) {
|
if (job.hasIngestPipeline()) {
|
||||||
errors.addAll(this.startIngestJob(job)); // capture any errors
|
ingestJobStartResult = this.startIngestJob(job); // Start job
|
||||||
if (errors.isEmpty()) {
|
|
||||||
return job;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return ingestJobStartResult;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -527,8 +522,7 @@ public class IngestManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public synchronized IngestJob startIngestJob(Collection<Content> dataSources, IngestJobSettings settings) {
|
public synchronized IngestJob startIngestJob(Collection<Content> dataSources, IngestJobSettings settings) {
|
||||||
List<IngestModuleError> ignored = new ArrayList<>();
|
return beginIngestJob(dataSources, settings).getJob();
|
||||||
return beginIngestJob(dataSources, settings, ignored);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -536,9 +530,12 @@ public class IngestManager {
|
|||||||
*
|
*
|
||||||
* @param job The ingest job to start.
|
* @param job The ingest job to start.
|
||||||
*
|
*
|
||||||
* @return A list of errors, empty if the job was successfully started
|
* @return The IngestJobStartResult describing the results of attempting to
|
||||||
|
* start the ingest job.
|
||||||
*/
|
*/
|
||||||
private List<IngestModuleError> startIngestJob(IngestJob job) {
|
private IngestJobStartResult startIngestJob(IngestJob job) {
|
||||||
|
IngestJobStartResult ingestJobStartResult = new IngestJobStartResult();
|
||||||
|
ingestJobStartResult.setJob(job);
|
||||||
if (this.jobCreationIsEnabled) {
|
if (this.jobCreationIsEnabled) {
|
||||||
// multi-user cases must have multi-user database service running
|
// multi-user cases must have multi-user database service running
|
||||||
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
|
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
|
||||||
@ -558,10 +555,12 @@ public class IngestManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// abort ingest
|
// abort ingest
|
||||||
return Collections.<IngestModuleError>emptyList();
|
ingestJobStartResult.setStartupException(new IngestManagerException("Ingest aborted.", new Exception("Remote database is down"))); // KDM
|
||||||
|
return ingestJobStartResult;
|
||||||
}
|
}
|
||||||
} catch (ServicesMonitor.ServicesMonitorException ignore) {
|
} catch (ServicesMonitor.ServicesMonitorException ex) {
|
||||||
return Collections.<IngestModuleError>emptyList();
|
ingestJobStartResult.setStartupException(new IngestManagerException("Ingest aborted.", ex));
|
||||||
|
return ingestJobStartResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,15 +571,15 @@ public class IngestManager {
|
|||||||
synchronized (jobsById) {
|
synchronized (jobsById) {
|
||||||
jobsById.put(job.getId(), job);
|
jobsById.put(job.getId(), job);
|
||||||
}
|
}
|
||||||
List<IngestModuleError> errors = job.start();
|
ingestJobStartResult.setModuleErrors(job.start());
|
||||||
if (errors.isEmpty()) {
|
if (ingestJobStartResult.getModuleErrors().isEmpty()) {
|
||||||
this.fireIngestJobStarted(job.getId());
|
this.fireIngestJobStarted(job.getId());
|
||||||
IngestManager.logger.log(Level.INFO, "Ingest job {0} started", job.getId()); //NON-NLS
|
IngestManager.logger.log(Level.INFO, "Ingest job {0} started", job.getId()); //NON-NLS
|
||||||
} else {
|
} else {
|
||||||
synchronized (jobsById) {
|
synchronized (jobsById) {
|
||||||
this.jobsById.remove(job.getId());
|
this.jobsById.remove(job.getId());
|
||||||
}
|
}
|
||||||
for (IngestModuleError error : errors) {
|
for (IngestModuleError error : ingestJobStartResult.getModuleErrors()) {
|
||||||
logger.log(Level.SEVERE, String.format("Error starting %s ingest module for job %d", error.getModuleDisplayName(), job.getId()), error.getModuleError()); //NON-NLS
|
logger.log(Level.SEVERE, String.format("Error starting %s ingest module for job %d", error.getModuleDisplayName(), job.getId()), error.getModuleError()); //NON-NLS
|
||||||
}
|
}
|
||||||
IngestManager.logger.log(Level.SEVERE, "Ingest job {0} could not be started", job.getId()); //NON-NLS
|
IngestManager.logger.log(Level.SEVERE, "Ingest job {0} could not be started", job.getId()); //NON-NLS
|
||||||
@ -589,7 +588,7 @@ public class IngestManager {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
StringBuilder moduleStartUpErrors = new StringBuilder();
|
StringBuilder moduleStartUpErrors = new StringBuilder();
|
||||||
for (IngestModuleError error : errors) {
|
for (IngestModuleError error : ingestJobStartResult.getModuleErrors()) {
|
||||||
String moduleName = error.getModuleDisplayName();
|
String moduleName = error.getModuleDisplayName();
|
||||||
moduleStartUpErrors.append(moduleName);
|
moduleStartUpErrors.append(moduleName);
|
||||||
moduleStartUpErrors.append(": ");
|
moduleStartUpErrors.append(": ");
|
||||||
@ -608,9 +607,9 @@ public class IngestManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors;
|
|
||||||
}
|
}
|
||||||
return Collections.<IngestModuleError>emptyList();
|
return ingestJobStartResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void finishIngestJob(IngestJob job) {
|
synchronized void finishIngestJob(IngestJob job) {
|
||||||
|
42
Core/src/org/sleuthkit/autopsy/ingest/IngestManagerException.java
Executable file
42
Core/src/org/sleuthkit/autopsy/ingest/IngestManagerException.java
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 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.ingest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encapsulates an exception thrown by an ingest module during an operation such
|
||||||
|
* as startup or shut down with an exception object for the error that occurred.
|
||||||
|
*/
|
||||||
|
public final class IngestManagerException {
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
private final Throwable cause;
|
||||||
|
|
||||||
|
IngestManagerException(String message, Throwable cause) {
|
||||||
|
this.message = message;
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Throwable getCause() {
|
||||||
|
return this.cause;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user