5959import org .pwss .service .NoteService ;
6060import org .pwss .service .ScanService ;
6161import org .pwss .service .ScanSummaryService ;
62- import org .pwss .utils .AppTheme ;
63- import org .pwss .utils . ConversionUtils ;
64- import org .pwss .utils . ErrorUtils ;
65- import org .pwss .utils . LiveFeedUtils ;
66- import org .pwss .utils . MonitoredDirectoryUtils ;
67- import org .pwss .utils . OSUtils ;
68- import org .pwss .utils . ReportUtils ;
69- import org .pwss .utils .StringConstants ;
62+ import org .pwss .util .AppTheme ;
63+ import org .pwss .util . ConversionUtil ;
64+ import org .pwss .util . ErrorUtil ;
65+ import org .pwss .util . LiveFeedUtil ;
66+ import org .pwss .util . MonitoredDirectoryUtil ;
67+ import org .pwss .util . OSUtil ;
68+ import org .pwss .util . ReportUtil ;
69+ import org .pwss .util .StringConstants ;
7070import org .pwss .view .popup_menu .MonitoredDirectoryPopupFactory ;
7171import org .pwss .view .popup_menu .listener .MonitoredDirectoryPopupListenerImpl ;
7272import org .pwss .view .screen .HomeScreen ;
7676import static org .pwss .app_settings .AppConfig .MAX_HASH_EXTRACTION_FILE_SIZE ;
7777import static org .pwss .app_settings .AppConfig .USE_SPLASH_SCREEN ;
7878
79- // TODO: NEEDS REFACTORING - VERY LARGE CLASS
8079public final class HomeController extends BaseController <HomeScreen > {
8180
8281 /**
@@ -250,7 +249,8 @@ void fetchDataAndRefreshView() {
250249 try {
251250 // Fetch all monitored directories for display in the monitored directories
252251 // table
253- allMonitoredDirectories = monitoredDirectoryService .getAllDirectories ();
252+ allMonitoredDirectories = MonitoredDirectoryUtil
253+ .filterMonitoredDirectoriesOnConfirmedPath (monitoredDirectoryService .getAllDirectories ());
254254
255255 // Only fetch diffs if there are active monitored directories present
256256 final long activeDirCount = allMonitoredDirectories .stream ().filter (MonitoredDirectory ::isActive ).count ();
@@ -371,7 +371,7 @@ public void mouseClicked(MouseEvent e) {
371371 DiffTableModel model = (DiffTableModel ) screen .getDiffTable ().getModel ();
372372 Optional <Diff > diff = model .getDiffAt (modelRow );
373373
374- diff .ifPresent (d -> screen .getDiffDetails ().setText (ReportUtils .formatDiff (d )));
374+ diff .ifPresent (d -> screen .getDiffDetails ().setText (ReportUtil .formatDiff (d )));
375375 } else {
376376 screen .getDiffDetails ().setText ("" );
377377 }
@@ -395,7 +395,7 @@ public void mouseClicked(MouseEvent e) {
395395 int selectedRow = screen .getFileScanSummaryTable ().getSelectedRow ();
396396 if (selectedRow >= 0 && selectedRow < fileSummaries .size ()) {
397397 ScanSummary selectedSummary = fileSummaries .get (selectedRow );
398- screen .getScanSummaryDetails ().setText (ReportUtils .formatSummary (selectedSummary ));
398+ screen .getScanSummaryDetails ().setText (ReportUtil .formatSummary (selectedSummary ));
399399 } else {
400400 screen .getScanSummaryDetails ().setText ("" );
401401 }
@@ -426,12 +426,12 @@ public void mouseClicked(MouseEvent e) {
426426 screen .getMaxHashExtractionFileSizeSlider ().addChangeListener (l -> {
427427 long valueMegabytes = screen .getMaxHashExtractionFileSizeSlider ().getValue ();
428428 log .debug ("Setting max hash extraction file size to {} MB" , valueMegabytes );
429- long valueBytes = ConversionUtils .megabytesToBytes (valueMegabytes );
429+ long valueBytes = ConversionUtil .megabytesToBytes (valueMegabytes );
430430
431431 // Set App config value to size in bytes
432432 if (AppConfig .setMaxHashExtractionFileSize (valueBytes )) {
433433 screen .getMaxHashExtractionFileSizeValueLabel ().setText (valueMegabytes + " MB" );
434- maxFileSizeForHashExtraction = ConversionUtils .megabytesToBytes (valueMegabytes );
434+ maxFileSizeForHashExtraction = ConversionUtil .megabytesToBytes (valueMegabytes );
435435 } else {
436436 log .error ("Failed to update max hash extraction file size in app config." );
437437 }
@@ -452,7 +452,7 @@ public void mouseClicked(MouseEvent e) {
452452 // If unchecked set the size to the current slider value
453453 long sliderValueMegabytes = screen .getMaxHashExtractionFileSizeSlider ().getValue ();
454454 log .debug ("Setting max hash extraction file size to {} MB" , sliderValueMegabytes );
455- long sliderValueBytes = ConversionUtils .megabytesToBytes (sliderValueMegabytes );
455+ long sliderValueBytes = ConversionUtil .megabytesToBytes (sliderValueMegabytes );
456456 if (AppConfig .setMaxHashExtractionFileSize (sliderValueBytes )) {
457457 maxFileSizeForHashExtraction = sliderValueBytes ;
458458 screen .getMaxHashExtractionFileSizeValueLabel ().setText (sliderValueMegabytes + " MB" );
@@ -469,7 +469,7 @@ protected void refreshView() {
469469 // Update UI components based on the current state
470470 screen .getScanButton ().setText (scanRunning ? StringConstants .SCAN_STOP : StringConstants .SCAN_FULL );
471471
472- String notifications = MonitoredDirectoryUtils
472+ String notifications = MonitoredDirectoryUtil
473473 .getMonitoredDirectoryNotificationMessage (allMonitoredDirectories );
474474 boolean hasNotifications = !notifications .isEmpty ();
475475
@@ -515,7 +515,7 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
515515 if (!dir .baselineEstablished ()) {
516516 setForeground (Color .YELLOW );
517517 setToolTipText (StringConstants .TOOLTIP_BASELINE_NOT_ESTABLISHED );
518- } else if (MonitoredDirectoryUtils .isScanOlderThanAWeek (dir )) {
518+ } else if (MonitoredDirectoryUtil .isScanOlderThanAWeek (dir )) {
519519 setForeground (Color .ORANGE );
520520 setToolTipText (StringConstants .TOOLTIP_OLD_SCAN );
521521 } else {
@@ -543,7 +543,7 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
543543 diff .ifPresent (d -> {
544544 int choice = screen .showOptionDialog (
545545 JOptionPane .WARNING_MESSAGE ,
546- OSUtils .getQuarantineWarningMessage (),
546+ OSUtil .getQuarantineWarningMessage (),
547547 new String [] { StringConstants .GENERIC_YES , StringConstants .GENERIC_NO },
548548 StringConstants .GENERIC_NO );
549549 if (choice == 0 ) {
@@ -607,7 +607,7 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
607607 screen .getMaxHashExtractionFileSizeSlider ().setEnabled (true );
608608
609609 final int maxSliderValueMegabytes = Math
610- .toIntExact (ConversionUtils .bytesToMegabytes (maxFileSizeForHashExtraction ));
610+ .toIntExact (ConversionUtil .bytesToMegabytes (maxFileSizeForHashExtraction ));
611611 screen .getMaxHashExtractionFileSizeSlider ().setValue (maxSliderValueMegabytes );
612612 screen .getMaxHashExtractionFileSizeValueLabel ().setText (maxSliderValueMegabytes + " MB" );
613613 } else {
@@ -691,7 +691,7 @@ public void performStartScan(boolean singleDirectory) {
691691 log .debug (StringConstants .SCAN_START_ERROR , e );
692692 log .error (StringConstants .SCAN_START_ERROR + " {}" , e .getMessage ());
693693 SwingUtilities .invokeLater (() -> screen
694- .showError (ErrorUtils .formatErrorMessage (StringConstants .SCAN_START_ERROR , e .getMessage ())));
694+ .showError (ErrorUtil .formatErrorMessage (StringConstants .SCAN_START_ERROR , e .getMessage ())));
695695 }
696696 }
697697
@@ -830,12 +830,12 @@ private void startPollingScanLiveFeed(boolean singleDirectory, List<MonitoredDir
830830 LiveFeedResponse liveFeed = scanService .getLiveFeed ();
831831
832832 String currentLiveFeedText = screen .getLiveFeedText ().getText ();
833- String newEntry = LiveFeedUtils .formatLiveFeedEntry (liveFeed .livefeed ());
833+ String newEntry = LiveFeedUtil .formatLiveFeedEntry (liveFeed .livefeed ());
834834 String updatedLiveFeedText = currentLiveFeedText + newEntry ;
835835 screen .getLiveFeedText ().setText (updatedLiveFeedText );
836836
837837 // Update the total difference count based on new warnings
838- totalDiffCount .addAndGet (LiveFeedUtils .countWarnings (liveFeed .livefeed ()));
838+ totalDiffCount .addAndGet (LiveFeedUtil .countWarnings (liveFeed .livefeed ()));
839839 screen .getLiveFeedDiffCount ().setText (StringConstants .SCAN_DIFFS_PREFIX + totalDiffCount );
840840
841841 // Update scanRunning state and refresh the UI if necessary
@@ -849,7 +849,7 @@ private void startPollingScanLiveFeed(boolean singleDirectory, List<MonitoredDir
849849
850850 liveFeed = scanService .getLiveFeed ();
851851
852- totalDiffCount .getAndAdd (LiveFeedUtils .countWarnings (liveFeed .livefeed ()));
852+ totalDiffCount .getAndAdd (LiveFeedUtil .countWarnings (liveFeed .livefeed ()));
853853 screen .getLiveFeedDiffCount ().setText (StringConstants .SCAN_DIFFS_PREFIX + totalDiffCount );
854854
855855 onFinishScan (true , singleDirectory );
0 commit comments