From abb1ce465f87186f0955208f3efe1937aef234c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Lindo?= Date: Wed, 27 Nov 2024 16:53:30 +0000 Subject: [PATCH] enabled delete siarddk entry without deleting the siard file --- .../manager/SIARDPanel/SIARDManagerPage.java | 26 ++++++++----------- .../server/controller/SIARDController.java | 21 ++++++++------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java index 031e82e4b..a408d7de0 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java @@ -143,7 +143,8 @@ private void populateNavigationPanels() { if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_SERVER)) { DatabaseService.Util.call((Set databasePermissions) -> { ContextService.Util.call((Set authorizationGroups) -> { - permissionsNavigationPanel = PermissionsNavigationPanel.getInstance(database, databasePermissions, authorizationGroups); + permissionsNavigationPanel = PermissionsNavigationPanel.getInstance(database, databasePermissions, + authorizationGroups); if (permissionsNavigationPanel.hasPermissionsOrGroups()) { navigationPanels.add(permissionsNavigationPanel.build()); } @@ -207,21 +208,16 @@ private void setupFooterButtons() { if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_DESKTOP)) { message = messages.SIARDHomePageTextForDeleteAllFromDesktop(); } - if (database.getVersion().equals(ViewerConstants.SIARD_DK_1007) || database.getVersion().equals(ViewerConstants.SIARD_DK_128)) { - Dialogs.showInformationDialog(messages.SIARDHomePageDialogTitleForDelete(), - "SIARD deletion only supports SIARD version 2.1.", messages.basicActionUnderstood(), "btn btn-link"); - } else { - CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message, - messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px", - new DefaultAsyncCallback() { - @Override - public void onSuccess(Boolean result) { - if (result) { - deleteAll(); - } + CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message, + messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px", + new DefaultAsyncCallback() { + @Override + public void onSuccess(Boolean result) { + if (result) { + deleteAll(); } - }); - } + } + }); } else if (ViewerDatabaseStatus.INGESTING.equals(database.getStatus())) { Dialogs.showInformationDialog(messages.SIARDManagerPageInformationDialogTitle(), messages.SIARDManagerPageTextForWaitForFinishing(), messages.basicActionClose(), "btn btn-link"); diff --git a/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java b/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java index 6bc6048c8..3037572e1 100644 --- a/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java +++ b/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java @@ -886,17 +886,20 @@ public static boolean deleteAll(String databaseUUID) ViewerDatabase database = solrManager.retrieve(ViewerDatabase.class, databaseUUID); - if (ViewerFactory.getViewerConfiguration().getApplicationEnvironment() - .equals(ViewerConstants.APPLICATION_ENV_SERVER)) { - String siardPath = database.getPath(); - final boolean deleteSiard = !ViewerConfiguration.getInstance().getViewerConfigurationAsBoolean(false, - ViewerConfiguration.PROPERTY_DISABLE_SIARD_DELETION); - if (StringUtils.isNotBlank(siardPath) && Paths.get(siardPath).toFile().exists() && deleteSiard) { - deleteSIARDFileFromPath(siardPath, databaseUUID); + if (!database.getVersion().equals(ViewerConstants.SIARD_DK_1007) + && !database.getVersion().equals(ViewerConstants.SIARD_DK_128)) { + if (ViewerFactory.getViewerConfiguration().getApplicationEnvironment() + .equals(ViewerConstants.APPLICATION_ENV_SERVER)) { + String siardPath = database.getPath(); + final boolean deleteSiard = !ViewerConfiguration.getInstance().getViewerConfigurationAsBoolean(false, + ViewerConfiguration.PROPERTY_DISABLE_SIARD_DELETION); + if (StringUtils.isNotBlank(siardPath) && Paths.get(siardPath).toFile().exists() && deleteSiard) { + deleteSIARDFileFromPath(siardPath, databaseUUID); + } } - } - ViewerFactory.getConfigurationManager().deleteDatabaseFolder(databaseUUID); + ViewerFactory.getConfigurationManager().deleteDatabaseFolder(databaseUUID); + } String reportPath = database.getValidatorReportPath(); if (StringUtils.isNotBlank(reportPath) && Paths.get(reportPath).toFile().exists()) {