mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Add deep copying of auto ingest monitor snapshots
This commit is contained in:
parent
5973fc39ee
commit
2abb755703
@ -148,6 +148,37 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
this.stageDetails = this.getProcessingStageDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructs an automated ingest job.
|
||||
*
|
||||
* @param job The job to be copied.
|
||||
*/
|
||||
AutoIngestJob(AutoIngestJob job) {
|
||||
/*
|
||||
* Version 0 fields.
|
||||
*/
|
||||
this.manifest = job.getManifest(); // Manifest is immutable.
|
||||
this.nodeName = job.getProcessingHostName();
|
||||
this.caseDirectoryPath = job.getCaseDirectoryPath().toString();
|
||||
this.priority = job.getPriority();
|
||||
this.stage = job.getProcessingStage();
|
||||
this.stageStartDate = job.getProcessingStageStartDate();
|
||||
this.dataSourceProcessor = job.getDataSourceProcessor();
|
||||
this.ingestJob = job.getIngestJob();
|
||||
this.cancelled = job.isCanceled();
|
||||
this.completed = job.isCompleted();
|
||||
this.completedDate = new Date(job.getCompletedDate().getTime());
|
||||
this.errorsOccurred = job.getErrorsOccurred();
|
||||
|
||||
/*
|
||||
* Version 1 fields.
|
||||
*/
|
||||
this.version = job.getVersion();
|
||||
this.processingStatus = job.getProcessingStatus();
|
||||
this.numberOfCrashes = job.getNumberOfCrashes();
|
||||
this.stageDetails = job.getProcessingStageDetails(); // StageDetails is immutable.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the job manifest.
|
||||
*
|
||||
@ -292,6 +323,13 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
this.dataSourceProcessor = dataSourceProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data source processor for the job.
|
||||
*/
|
||||
private DataSourceProcessor getDataSourceProcessor() {
|
||||
return this.dataSourceProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ingest job for the auto ingest job. Used for obtaining
|
||||
* processing stage details, cancelling the currently running data source
|
||||
@ -498,6 +536,15 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
return -this.getManifest().getDateFileCreated().compareTo(otherJob.getManifest().getDateFileCreated());
|
||||
}
|
||||
|
||||
/**
|
||||
* gest the version number of the job data.
|
||||
*
|
||||
* @return The version number.
|
||||
*/
|
||||
private int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator that supports doing a descending sort of jobs based on job
|
||||
* completion date.
|
||||
|
@ -142,7 +142,7 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
jobsSnapshot.removePendingJob(event.getJob());
|
||||
jobsSnapshot.addOrReplaceRunningJob(event.getJob());
|
||||
setChanged();
|
||||
notifyObservers(jobsSnapshot);
|
||||
notifyObservers(jobsSnapshot.deepCopy());
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
jobsSnapshot.removePendingJob(job);
|
||||
jobsSnapshot.addOrReplaceRunningJob(job);
|
||||
setChanged();
|
||||
notifyObservers(jobsSnapshot);
|
||||
notifyObservers(jobsSnapshot.deepCopy());
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
jobsSnapshot.removeRunningJob(job);
|
||||
jobsSnapshot.addOrReplaceCompletedJob(job);
|
||||
setChanged();
|
||||
notifyObservers(jobsSnapshot);
|
||||
notifyObservers(jobsSnapshot.deepCopy());
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
*/
|
||||
JobsSnapshot getJobsSnapshot() {
|
||||
synchronized (jobsLock) {
|
||||
return jobsSnapshot;
|
||||
return jobsSnapshot.deepCopy();
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
}).start();
|
||||
|
||||
}
|
||||
return jobsSnapshot;
|
||||
return jobsSnapshot.deepCopy();
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
synchronized (jobsLock) {
|
||||
jobsSnapshot = queryCoordinationService();
|
||||
setChanged();
|
||||
notifyObservers(jobsSnapshot);
|
||||
notifyObservers(jobsSnapshot.deepCopy());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -468,6 +468,25 @@ public final class AutoIngestMonitor extends Observable implements PropertyChang
|
||||
jobSet.add(job);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a deep copy of a jobs snapshot.
|
||||
*
|
||||
* @return The deep copy.
|
||||
*/
|
||||
private JobsSnapshot deepCopy() {
|
||||
JobsSnapshot copy = new JobsSnapshot();
|
||||
this.pendingJobs.forEach((job) -> {
|
||||
this.addOrReplacePendingJob(new AutoIngestJob(job));
|
||||
});
|
||||
this.runningJobs.forEach((job) -> {
|
||||
this.addOrReplacePendingJob(new AutoIngestJob(job));
|
||||
});
|
||||
this.completedJobs.forEach((job) -> {
|
||||
this.addOrReplacePendingJob(new AutoIngestJob(job));
|
||||
});
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user