From 92cdf795ce6c74dc405a4a0798ea013deb1739cc Mon Sep 17 00:00:00 2001 From: Ryan Miles Date: Mon, 5 Oct 2026 09:07:14 -0700 Subject: [PATCH 1/4] Switching FAIL_IF_EXISTS to OVERRIDE_PROTECTION, adding backwards compatability and note. --- .../location/kind/GateChangeCreateController.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java b/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java index c9c92b09f1..34797b9bcd 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java @@ -20,10 +20,6 @@ package cwms.cda.api.location.kind; -import static cwms.cda.api.Controllers.CREATE; -import static cwms.cda.api.Controllers.FAIL_IF_EXISTS; -import static cwms.cda.api.Controllers.STATUS_201; - import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Timer; import cwms.cda.api.BaseHandler; @@ -44,6 +40,7 @@ import javax.servlet.http.HttpServletResponse; import org.jetbrains.annotations.NotNull; import org.jooq.DSLContext; +import static cwms.cda.api.Controllers.*; public class GateChangeCreateController extends BaseHandler { @@ -60,8 +57,10 @@ public GateChangeCreateController(MetricRegistry metrics) { }, required = true), queryParams = { - @OpenApiParam(name = FAIL_IF_EXISTS, type = Boolean.class, - description = "Create will fail if provided Gate Changes already exist. Default: true") + @OpenApiParam(name = OVERRIDE_PROTECTION, type = Boolean.class, + description = "Create will fail if provided Gate Changes already exist." + + " Previously known as " + FAIL_IF_EXISTS + "." + + " Default: true") }, description = "Create CWMS Gate Changes", method = HttpMethod.POST, @@ -72,7 +71,7 @@ public GateChangeCreateController(MetricRegistry metrics) { ) @Override public void handle(@NotNull Context context) throws Exception { - boolean failIfExists = context.queryParamAsClass(FAIL_IF_EXISTS, Boolean.class).getOrDefault(true); + boolean overrideProtection = queryParamAsClass(context, new String[] { OVERRIDE_PROTECTION, FAIL_IF_EXISTS }, Boolean.class, true); String formatHeader = context.header(Header.ACCEPT) != null ? context.header(Header.ACCEPT) : Formats.JSONV1; ContentType contentType = Formats.parseHeader(formatHeader, GateChange.class); List changes = Formats.parseContentList(contentType, context.body(), GateChange.class); @@ -83,7 +82,7 @@ public void handle(@NotNull Context context) throws Exception { try (Timer.Context ignored = markAndTime(CREATE)) { DSLContext dsl = JooqDao.getDslContext(context); OutletDao dao = new OutletDao(dsl); - dao.storeOperationalChanges(changes, failIfExists); + dao.storeOperationalChanges(changes, overrideProtection); context.status(HttpServletResponse.SC_CREATED); } } From 27cb82a2a683fe126fa7a46058d09eeac649cd2a Mon Sep 17 00:00:00 2001 From: Ryan Miles Date: Mon, 5 Oct 2026 12:06:36 -0700 Subject: [PATCH 2/4] Updating unit tests to use OVERRIDE_PROTECTION --- .../cda/api/location/kind/GateChangeControllerTestIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cwms-data-api/src/test/java/cwms/cda/api/location/kind/GateChangeControllerTestIT.java b/cwms-data-api/src/test/java/cwms/cda/api/location/kind/GateChangeControllerTestIT.java index 65262fa313..15359bf360 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/location/kind/GateChangeControllerTestIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/location/kind/GateChangeControllerTestIT.java @@ -163,7 +163,7 @@ void test_changes_crud() { .contentType(Formats.JSONV1) .body(json) .header(AUTH_HEADER, USER.toHeaderValue()) - .queryParam(FAIL_IF_EXISTS, "false") + .queryParam(OVERRIDE_PROTECTION, "false") .when() .redirects().follow(true) .redirects().max(3) @@ -212,7 +212,7 @@ void test_changes_crud() { .contentType(Formats.JSONV1) .body(json) .header(AUTH_HEADER, USER.toHeaderValue()) - .queryParam(FAIL_IF_EXISTS, "false") + .queryParam(OVERRIDE_PROTECTION, "false") .when() .redirects().follow(true) .redirects().max(3) @@ -320,7 +320,7 @@ void test_changes_create_from_file() throws Exception { .contentType(Formats.JSONV1) .body(json) .header(AUTH_HEADER, USER.toHeaderValue()) - .queryParam(FAIL_IF_EXISTS, false) + .queryParam(OVERRIDE_PROTECTION, false) .when() .redirects().follow(true) .redirects().max(3) From 34b746ee094d53ae92cf2ef35b0cb15ab89ea115 Mon Sep 17 00:00:00 2001 From: Ryan Miles Date: Mon, 5 Oct 2026 12:26:46 -0700 Subject: [PATCH 3/4] Adding documentation for FAIL_IF_EXISTS and making sure it's deprecated --- .../cda/api/location/kind/GateChangeCreateController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java b/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java index 34797b9bcd..058074a6bd 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java @@ -59,8 +59,10 @@ public GateChangeCreateController(MetricRegistry metrics) { queryParams = { @OpenApiParam(name = OVERRIDE_PROTECTION, type = Boolean.class, description = "Create will fail if provided Gate Changes already exist." + - " Previously known as " + FAIL_IF_EXISTS + "." + - " Default: true") + " Default: true"), + @OpenApiParam(name = FAIL_IF_EXISTS, type = Boolean.class, + description = "Create will fail if provided Gate Changes already exist." + + " Deprecated, use " + OVERRIDE_PROTECTION) }, description = "Create CWMS Gate Changes", method = HttpMethod.POST, From 60f5c633daaed3979a136748c00cf803a8f0feb7 Mon Sep 17 00:00:00 2001 From: Ryan Miles Date: Tue, 6 Oct 2026 15:29:49 -0700 Subject: [PATCH 4/4] Updated documentation for OVERRIDE_PROTECTION and FAIL_IF_EXISTS and added deprecated flag for FAIL_IF_EXISTS. --- .../api/location/kind/GateChangeCreateController.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java b/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java index 058074a6bd..05f1329652 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/location/kind/GateChangeCreateController.java @@ -58,11 +58,12 @@ public GateChangeCreateController(MetricRegistry metrics) { required = true), queryParams = { @OpenApiParam(name = OVERRIDE_PROTECTION, type = Boolean.class, - description = "Create will fail if provided Gate Changes already exist." + - " Default: true"), - @OpenApiParam(name = FAIL_IF_EXISTS, type = Boolean.class, - description = "Create will fail if provided Gate Changes already exist." + - " Deprecated, use " + OVERRIDE_PROTECTION) + description = "A flag ('True'/'False') specifying whether to delete protected data. " + + "Default is True"), + @OpenApiParam(name = FAIL_IF_EXISTS, type = Boolean.class, deprecated = true, + description = "A flag ('True'/'False') specifying whether to delete protected data. " + + "Default is True" + + " Deprecated, use " + OVERRIDE_PROTECTION) }, description = "Create CWMS Gate Changes", method = HttpMethod.POST,