diff --git a/admin/query/src/main/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplication.java b/admin/query/src/main/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplication.java index 39bb0a9c5..2d62fa259 100644 --- a/admin/query/src/main/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplication.java +++ b/admin/query/src/main/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplication.java @@ -30,7 +30,7 @@ public class DeleteReplication extends BaseFunctionField { public static final String FIELD_NAME = "deleteReplication"; public static final String DESCRIPTION = - "Deletes a Replication. Optionally delete the data of the Replication. Deleting data will delete " + "Deletes a Replication and its history (statistics). Optionally delete the data of the Replication. Deleting data will delete " + "any local resources and metadata that were replicated by this Replication, but not any resources replicated to a remote Node."; public static final BooleanField RETURN_TYPE = new BooleanField(); diff --git a/admin/query/src/test/java/org/codice/ditto/replication/admin/query/ReplicationUtilsTest.java b/admin/query/src/test/java/org/codice/ditto/replication/admin/query/ReplicationUtilsTest.java index e1f14d5af..4459c7ed3 100644 --- a/admin/query/src/test/java/org/codice/ditto/replication/admin/query/ReplicationUtilsTest.java +++ b/admin/query/src/test/java/org/codice/ditto/replication/admin/query/ReplicationUtilsTest.java @@ -301,7 +301,7 @@ public void testMarkConfigDeleted() { when(configManager.get("id")).thenReturn(config); assertThat(utils.markConfigDeleted("id", true), is(true)); - assertThat(config.deleteData(), is(true)); + assertThat(config.shouldDeleteData(), is(true)); assertThat(config.isDeleted(), is(true)); assertThat(config.isSuspended(), is(true)); verify(replicator).cancelSyncRequest("id"); diff --git a/admin/query/src/test/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplicationTest.java b/admin/query/src/test/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplicationTest.java index b07a133b0..b39a60d91 100644 --- a/admin/query/src/test/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplicationTest.java +++ b/admin/query/src/test/java/org/codice/ditto/replication/admin/query/replications/persist/DeleteReplicationTest.java @@ -37,9 +37,9 @@ public class DeleteReplicationTest { private static final String ID = "abc123"; - DeleteReplication deleteReplication; + private DeleteReplication deleteReplication; - Map args; + private Map args; @Mock ReplicationUtils utils; diff --git a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleter.java b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleter.java index 7c4e1dfd1..d861038c8 100644 --- a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleter.java +++ b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleter.java @@ -37,8 +37,8 @@ /** * Periodically polls for available {@link ReplicatorConfig}s and deletes them based on the {@link - * ReplicatorConfig#isDeleted()} and {@link ReplicatorConfig#deleteData()} properties. A {@link - * ReplicatorConfig} marked as deleted always has its history deleted. + * ReplicatorConfig#isDeleted()} and {@link ReplicatorConfig#shouldDeleteData()} properties. A + * {@link ReplicatorConfig} marked as deleted always has its history deleted. */ public class ScheduledReplicatorDeleter { @@ -77,6 +77,8 @@ public ScheduledReplicatorDeleter( DEFAULT_PAGE_SIZE); } + @VisibleForTesting + @SuppressWarnings("squid:S00107" /* Only for testing */) ScheduledReplicatorDeleter( ReplicatorConfigManager replicatorConfigManager, ScheduledExecutorService scheduledExecutorService, @@ -105,7 +107,7 @@ public void destroy() { scheduledExecutorService.shutdownNow(); } - public void cleanup() { + void cleanup() { security.runAsAdmin( () -> { try { @@ -195,7 +197,7 @@ private void cleanupDeletedConfigs(List replicatorConfigs) { final String configId = config.getId(); final String configName = config.getName(); - if (config.deleteData()) { + if (config.shouldDeleteData()) { try { deleteMetacards(configId); } catch (PersistenceException e) { diff --git a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/data/ReplicatorConfigImpl.java b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/data/ReplicatorConfigImpl.java index 2f6ecf9e4..ed0d86238 100644 --- a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/data/ReplicatorConfigImpl.java +++ b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/data/ReplicatorConfigImpl.java @@ -96,7 +96,7 @@ public Map toMap() { result.put(DESCRIPTION_KEY, getDescription()); result.put(SUSPENDED_KEY, Boolean.toString(isSuspended())); result.put(DELETED_KEY, Boolean.toString(isDeleted())); - result.put(DELETE_DATA_KEY, Boolean.toString(deleteData())); + result.put(DELETE_DATA_KEY, Boolean.toString(shouldDeleteData())); return result; } @@ -206,7 +206,7 @@ public void setDeleted(boolean deleted) { } @Override - public boolean deleteData() { + public boolean shouldDeleteData() { return deleteData; } diff --git a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImpl.java b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImpl.java index c7bc22b4b..d6be31607 100644 --- a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImpl.java +++ b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImpl.java @@ -2,7 +2,6 @@ import java.util.stream.Stream; import javax.ws.rs.NotFoundException; -import org.codice.ditto.replication.api.ReplicationPersistenceException; import org.codice.ditto.replication.api.data.ReplicatorConfig; import org.codice.ditto.replication.api.impl.data.ReplicatorConfigImpl; import org.codice.ditto.replication.api.persistence.ReplicatorConfigManager; @@ -50,7 +49,7 @@ public void remove(String id) { public boolean exists(String id) { try { persistentStore.get(ReplicatorConfigImpl.class, id); - } catch (NotFoundException | ReplicationPersistenceException e) { + } catch (NotFoundException e) { return false; } return true; diff --git a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImpl.java b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImpl.java index 018613fd2..da3d1a298 100644 --- a/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImpl.java +++ b/replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImpl.java @@ -97,7 +97,7 @@ public void remove(String id) { public boolean exists(String id) { try { persistentStore.get(ReplicationSiteImpl.class, id); - } catch (NotFoundException | ReplicationPersistenceException e) { + } catch (NotFoundException e) { return false; } return true; diff --git a/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleterTest.java b/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleterTest.java index cbb56306c..cdb3298ff 100644 --- a/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleterTest.java +++ b/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/ScheduledReplicatorDeleterTest.java @@ -330,7 +330,7 @@ private ReplicatorConfig mockConfig( when(config.getId()).thenReturn(id); when(config.getName()).thenReturn(name); when(config.isDeleted()).thenReturn(isDeleted); - when(config.deleteData()).thenReturn(deleteData); + when(config.shouldDeleteData()).thenReturn(deleteData); return config; } diff --git a/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImplTest.java b/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImplTest.java index bda45780a..ba75544e5 100644 --- a/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImplTest.java +++ b/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/ReplicatorConfigManagerImplTest.java @@ -24,7 +24,6 @@ import java.util.stream.Stream; import javax.ws.rs.NotFoundException; -import org.codice.ditto.replication.api.ReplicationPersistenceException; import org.codice.ditto.replication.api.data.ReplicatorConfig; import org.codice.ditto.replication.api.impl.data.ReplicatorConfigImpl; import org.junit.Before; @@ -84,13 +83,6 @@ public void testExistsNotFound() { assertThat(manager.exists("id"), is(false)); } - @Test - public void testExistsErrorAccessingPersistenceStore() { - when(persistentStore.get(ReplicatorConfigImpl.class, "id")) - .thenThrow(ReplicationPersistenceException.class); - assertThat(manager.exists("id"), is(false)); - } - @Test public void testExistsConfigFound() { assertThat(manager.exists("id"), is(true)); diff --git a/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImplTest.java b/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImplTest.java index a04ef5daf..06142da3c 100644 --- a/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImplTest.java +++ b/replication-api-impl/src/test/java/org/codice/ditto/replication/api/impl/persistence/SiteManagerImplTest.java @@ -27,7 +27,6 @@ import javax.ws.rs.NotFoundException; import org.codice.ddf.configuration.SystemBaseUrl; import org.codice.ddf.configuration.SystemInfo; -import org.codice.ditto.replication.api.ReplicationPersistenceException; import org.codice.ditto.replication.api.data.ReplicationSite; import org.codice.ditto.replication.api.impl.data.ReplicationSiteImpl; import org.junit.Before; @@ -138,13 +137,6 @@ public void testExistsNotFound() { assertThat(siteManager.exists("id"), is(false)); } - @Test - public void testExistsErrorAccessingPersistenceStore() { - when(persistentStore.get(ReplicationSiteImpl.class, "id")) - .thenThrow(ReplicationPersistenceException.class); - assertThat(siteManager.exists("id"), is(false)); - } - @Test public void testExistsConfigFound() { assertThat(siteManager.exists("id"), is(true)); diff --git a/replication-api/src/main/java/org/codice/ditto/replication/api/data/ReplicatorConfig.java b/replication-api/src/main/java/org/codice/ditto/replication/api/data/ReplicatorConfig.java index 45179c258..ec34113e0 100644 --- a/replication-api/src/main/java/org/codice/ditto/replication/api/data/ReplicatorConfig.java +++ b/replication-api/src/main/java/org/codice/ditto/replication/api/data/ReplicatorConfig.java @@ -138,7 +138,7 @@ public interface ReplicatorConfig extends Persistable { void setSuspended(boolean suspended); /** - * See {@link #deleteData()}. + * See {@link #shouldDeleteData()}. * * @return whether or not this {@code ReplicatorConfig} should be considered as deleted */ @@ -147,7 +147,7 @@ public interface ReplicatorConfig extends Persistable { /** * Marks this {@code ReplicatorConfig} as deleted. * - * @param deleted + * @param deleted whether or not this {@code ReplicatorConfig} should be considered as deleted */ void setDeleted(boolean deleted); @@ -160,10 +160,10 @@ public interface ReplicatorConfig extends Persistable { * @return if {@code true}, delete the associated data replicated by this {@code * ReplicatorConfig}, otherwise retain the data. */ - boolean deleteData(); + boolean shouldDeleteData(); /** - * See {@link #deleteData()}. + * See {@link #shouldDeleteData()}. * * @param deleteData {@code true} if this {@code ReplicatorConfig}'s data should be deleted, * otherwise false diff --git a/replication-api/src/main/java/org/codice/ditto/replication/api/persistence/DataManager.java b/replication-api/src/main/java/org/codice/ditto/replication/api/persistence/DataManager.java index b6acc6675..3aac8dc5b 100644 --- a/replication-api/src/main/java/org/codice/ditto/replication/api/persistence/DataManager.java +++ b/replication-api/src/main/java/org/codice/ditto/replication/api/persistence/DataManager.java @@ -21,8 +21,9 @@ public interface DataManager { * * @param id The object id * @return the T object with the given id - * @throws ReplicationPersistenceException if an error occurs while trying to retrieve the object - * @throws NotFoundException if an object with the given id cannot be found + * @throws {@link org.codice.ditto.replication.api.ReplicationPersistenceException} if an error + * occurs while trying to retrieve the object + * @throws {@link javax.ws.rs.NotFoundException} if an object with the given id cannot be found * @throws IllegalStateException if multiple objects were found with the given id */ T get(String id); @@ -31,7 +32,8 @@ public interface DataManager { * Gets all the currently saved T objects * * @return Stream of all T objects - * @throws ReplicationPersistenceException if an error occurs while trying to retrieve the objects + * @throws {@link org.codice.ditto.replication.api.ReplicationPersistenceException} if an error + * occurs while trying to retrieve the objects */ Stream objects(); @@ -41,7 +43,8 @@ public interface DataManager { * method included in this interface. * * @param object The T object to save or update - * @throws ReplicationPersistenceException if an error occurs while trying to save the config + * @throws {@link org.codice.ditto.replication.api.ReplicationPersistenceException} if an error + * occurs while trying to save the config * @throws IllegalArgumentException if the T implementation is not one that can be saved */ void save(T object); @@ -50,14 +53,17 @@ public interface DataManager { * Deletes a T object with the given id * * @param id The id of the object to be removed - * @throws ReplicationPersistenceException if an error occurs while trying to delete the config - * @throws NotFoundException if an object with the given id cannot be found + * @throws {@link org.codice.ditto.replication.api.ReplicationPersistenceException} if an error + * occurs while trying to delete the config + * @throws {@link javax.ws.rs.NotFoundException} if an object with the given id cannot be found */ void remove(String id); /** * @param id unique id of the {@link Persistable} * @return {@code true} if the {@link Persistable} exists, otherwise {@code false}. + * @throws {@link org.codice.ditto.replication.api.ReplicationPersistenceException} if there is an + * error accessing storage */ boolean exists(String id); } diff --git a/ui/package.json b/ui/package.json index 73d7a214e..1091fc921 100644 --- a/ui/package.json +++ b/ui/package.json @@ -30,7 +30,7 @@ "graphql-tag": "2.10.0", "immutable": "3.8.2", "moment": "2.24.0", - "notistack": "0.5.0", + "notistack": "0.6.1", "prop-types": "15.6.2", "react": "16.8.3", "react-apollo": "2.3.3", @@ -76,7 +76,7 @@ "global": { "statements": 6, "branches": 6, - "lines": 7, + "lines": 6, "functions": 1 } }, diff --git a/ui/src/main/webapp/components/replications/ActionsMenu.js b/ui/src/main/webapp/components/replications/ActionsMenu.js index e3ad6dc46..51db5b473 100644 --- a/ui/src/main/webapp/components/replications/ActionsMenu.js +++ b/ui/src/main/webapp/components/replications/ActionsMenu.js @@ -30,7 +30,7 @@ import { import { allReplications } from './gql/queries' import { Mutation } from 'react-apollo' import Replications from './replications' -import { withSnackbar } from 'notistack' +import { withSnackbar, useSnackbar } from 'notistack' import Confirmable from '../common/Confirmable' const DeleteReplication = withSnackbar( @@ -119,8 +119,9 @@ const DeleteReplication = withSnackbar( ) DeleteReplication.displayName = 'DeleteReplication' -const SuspendReplication = withSnackbar(props => { - const { id, suspend, key, label, onClose, enqueueSnackbar, name } = props +const SuspendReplication = props => { + const { id, suspend, key, label, onClose, name } = props + const { enqueueSnackbar } = useSnackbar() return ( @@ -167,11 +168,11 @@ const SuspendReplication = withSnackbar(props => { )} ) -}) -SuspendReplication.displayName = 'SuspendReplication' +} -const CancelReplication = withSnackbar(props => { - const { id, onClose, name, enqueueSnackbar } = props +const CancelReplication = props => { + const { id, onClose, name } = props + const { enqueueSnackbar } = useSnackbar() return ( @@ -218,8 +219,7 @@ const CancelReplication = withSnackbar(props => { )} ) -}) -CancelReplication.displayName = 'CancelReplication' +} const ActionsMenu = function(props) { const { menuId, anchorEl = null, onClose, replication } = props diff --git a/ui/yarn.lock b/ui/yarn.lock index 98a3b1b5f..6c49e0b17 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -5406,10 +5406,10 @@ normalize-scroll-left@^0.1.2: resolved "https://registry.yarnpkg.com/normalize-scroll-left/-/normalize-scroll-left-0.1.2.tgz#6b79691ba79eb5fb107fa5edfbdc06b55caee2aa" integrity sha512-F9YMRls0zCF6BFIE2YnXDRpHPpfd91nOIaNdDgrx5YMoPLo8Wqj+6jNXHQsYBavJeXP4ww8HCt0xQAKc5qk2Fg== -notistack@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/notistack/-/notistack-0.5.0.tgz#4fece949c973cad6d1d4a9d34da8024ef3158b5e" - integrity sha512-DYAix/jnN/Qv/AHwgbNFcQ2d6HjeQ8duEge6OJr5rn0pmxUutQjuGpZ+3dJ/4FBJtfRbnv0BX59ZtHrn2tE+Jw== +notistack@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/notistack/-/notistack-0.6.1.tgz#d29a7b85deb67ed144e5427438280961615c7b1b" + integrity sha512-tuXmw/0TBmdeHqRjWQwf9Jh298OMEwi18mrnTwxV4IfkxO0n2AplTj/WM9D9kV7aEmMjHTcHixRzllZUou1mAw== dependencies: classnames "^2.2.6" prop-types "^15.6.2"