Additional Codacy fixes for Image Gallery code

This commit is contained in:
Richard Cordovano 2019-06-18 13:52:27 -04:00
parent 3238cab113
commit 41f29d66ed
7 changed files with 22 additions and 24 deletions

View File

@ -33,8 +33,13 @@ import org.sleuthkit.datamodel.TskData;
*/
class AddDrawableFilesTask extends BulkDrawableFilesTask {
private final ImageGalleryController controller;
private final DrawableDB taskDB;
AddDrawableFilesTask(long dataSourceObjId, ImageGalleryController controller) {
super(dataSourceObjId, controller);
this.controller = controller;
this.taskDB = controller.getDrawablesDatabase();
taskDB.buildFileMetaDataCache();
}

View File

@ -46,14 +46,11 @@ abstract class BulkDrawableFilesTask extends DrawableDbTask {
private static final String MIMETYPE_CLAUSE = "(mime_type LIKE '" //NON-NLS
+ String.join("' OR mime_type LIKE '", FileTypeUtils.getAllSupportedMimeTypes()) //NON-NLS
+ "') ";
private final String DRAWABLE_QUERY;
private final String DATASOURCE_CLAUSE;
protected final ImageGalleryController controller;
protected final DrawableDB taskDB;
protected final SleuthkitCase tskCase;
protected final long dataSourceObjId;
private ProgressHandle progressHandle;
private boolean taskCompletionStatus;
private final String drawableQuery;
private final ImageGalleryController controller;
private final DrawableDB taskDB;
private final SleuthkitCase tskCase;
private final long dataSourceObjId;
//NON-NLS
BulkDrawableFilesTask(long dataSourceObjId, ImageGalleryController controller) {
@ -61,8 +58,8 @@ abstract class BulkDrawableFilesTask extends DrawableDbTask {
this.taskDB = controller.getDrawablesDatabase();
this.tskCase = controller.getCaseDatabase();
this.dataSourceObjId = dataSourceObjId;
DATASOURCE_CLAUSE = " (data_source_obj_id = " + dataSourceObjId + ") ";
DRAWABLE_QUERY = DATASOURCE_CLAUSE + " AND ( meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + ")" + " AND ( " + MIMETYPE_CLAUSE //NON-NLS
drawableQuery = " (data_source_obj_id = " + dataSourceObjId + ") "
+ " AND ( meta_type = " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + ")" + " AND ( " + MIMETYPE_CLAUSE //NON-NLS
+ " OR mime_type LIKE 'video/%' OR mime_type LIKE 'image/%' )" //NON-NLS
+ " ORDER BY parent_path ";
}
@ -82,7 +79,7 @@ abstract class BulkDrawableFilesTask extends DrawableDbTask {
* @throws TskCoreException
*/
List<AbstractFile> getFiles() throws TskCoreException {
return tskCase.findAllFilesWhere(DRAWABLE_QUERY);
return tskCase.findAllFilesWhere(drawableQuery);
}
@Override
@ -90,7 +87,7 @@ abstract class BulkDrawableFilesTask extends DrawableDbTask {
"BulkDrawableFilesTask.populatingDb.status=populating analyzed image/video database"
})
public void run() {
progressHandle = getInitialProgressHandle();
ProgressHandle progressHandle = getInitialProgressHandle();
progressHandle.start();
updateMessage(Bundle.BulkDrawableFilesTask_populatingDb_status() + " (Data Source " + dataSourceObjId + ")");
DrawableDB.DrawableTransaction drawableDbTransaction = null;

View File

@ -28,7 +28,7 @@ import org.openide.util.Cancellable;
import org.openide.util.NbBundle;
/**
* Abstract base class for task to be done on
* An abstract base class for drawables database tasks.
*/
@NbBundle.Messages({
"DrawableDbTask.InnerTask.progress.name=progress",
@ -40,9 +40,6 @@ public abstract class DrawableDbTask implements Runnable, Cancellable {
private final SimpleDoubleProperty progress = new SimpleDoubleProperty(this, Bundle.DrawableDbTask_InnerTask_progress_name());
private final SimpleStringProperty message = new SimpleStringProperty(this, Bundle.DrawableDbTask_InnerTask_message_name());
protected DrawableDbTask() {
}
public double getProgress() {
return progress.get();
}
@ -89,4 +86,3 @@ public abstract class DrawableDbTask implements Runnable, Cancellable {
return getState() == Worker.State.CANCELLED;
}
}

View File

@ -30,7 +30,7 @@ import org.sleuthkit.autopsy.casemodule.Case;
* gallery.
*/
@NbBundle.Messages({"ImageGalleryModule.moduleName=Image Gallery"})
public class ImageGalleryModule {
public final class ImageGalleryModule {
private static final String MODULE_NAME = Bundle.ImageGalleryModule_moduleName();

View File

@ -251,8 +251,6 @@ public final class ImageGalleryTopComponent extends TopComponent implements Expl
"ImageGalleryTopComponent.chooseDataSourceDialog.all=All",
"ImageGalleryTopComponent.chooseDataSourceDialog.titleText=Image Gallery",})
private void openForCurrentCase() throws TskCoreException {
Case currentCase = Case.getCurrentCase();
ImageGalleryController controllerForCase = ImageGalleryController.getController(currentCase);
Platform.runLater(new Runnable() {
@Override
public void run() {

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-2018 Basis Technology Corp.
* Copyright 2015-2019 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -37,7 +37,6 @@ import org.controlsfx.control.action.Action;
import org.controlsfx.control.action.ActionUtils;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.actions.GetTagNameAndCommentDialog;
import org.sleuthkit.autopsy.actions.GetTagNameDialog;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;

View File

@ -53,7 +53,7 @@ import org.sleuthkit.datamodel.TagName;
import org.sleuthkit.datamodel.TskCoreException;
/**
*
* An action that associates a drawable file with a Project Vic category.
*/
@NbBundle.Messages({"CategorizeAction.displayName=Categorize"})
public class CategorizeAction extends Action {
@ -111,6 +111,9 @@ public class CategorizeAction extends Action {
}
}
/**
* A task that associates a drawable file with a Project Vic category.
*/
@NbBundle.Messages({
"# {0} - fileID number",
"CategorizeDrawableFileTask.errorUnable.msg=Unable to categorize {0}.",