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 { class AddDrawableFilesTask extends BulkDrawableFilesTask {
private final ImageGalleryController controller;
private final DrawableDB taskDB;
AddDrawableFilesTask(long dataSourceObjId, ImageGalleryController controller) { AddDrawableFilesTask(long dataSourceObjId, ImageGalleryController controller) {
super(dataSourceObjId, controller); super(dataSourceObjId, controller);
this.controller = controller;
this.taskDB = controller.getDrawablesDatabase();
taskDB.buildFileMetaDataCache(); taskDB.buildFileMetaDataCache();
} }

View File

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

View File

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

View File

@ -30,7 +30,7 @@ import org.sleuthkit.autopsy.casemodule.Case;
* gallery. * gallery.
*/ */
@NbBundle.Messages({"ImageGalleryModule.moduleName=Image Gallery"}) @NbBundle.Messages({"ImageGalleryModule.moduleName=Image Gallery"})
public class ImageGalleryModule { public final class ImageGalleryModule {
private static final String MODULE_NAME = Bundle.ImageGalleryModule_moduleName(); 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.all=All",
"ImageGalleryTopComponent.chooseDataSourceDialog.titleText=Image Gallery",}) "ImageGalleryTopComponent.chooseDataSourceDialog.titleText=Image Gallery",})
private void openForCurrentCase() throws TskCoreException { private void openForCurrentCase() throws TskCoreException {
Case currentCase = Case.getCurrentCase();
ImageGalleryController controllerForCase = ImageGalleryController.getController(currentCase);
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

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

View File

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