Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cwms-data-api/src/main/java/cwms/cda/api/BasinController.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void getOne(@NotNull Context ctx, @NotNull String name) {

String units =
ctx.queryParamAsClass(UNIT, String.class).getOrDefault(UnitSystem.EN.value());
String office = ctx.queryParam(OFFICE);
String office = requiredParam(ctx, OFFICE);
String formatHeader = ctx.header(Header.ACCEPT);
ContentType contentType = Formats.parseHeader(formatHeader, Basin.class);
ctx.contentType(contentType.toString());
Expand Down Expand Up @@ -303,7 +303,7 @@ public void delete(@NotNull Context ctx, @NotNull String name) {
cwms.cda.data.dao.basin.BasinDao basinDao = new cwms.cda.data.dao.basin.BasinDao(dsl);
CwmsId basinId = new CwmsId.Builder()
.withName(name)
.withOfficeId(ctx.queryParam(OFFICE))
.withOfficeId(requiredParam(ctx, OFFICE))
.build();
basinDao.deleteBasin(basinId, deleteMethod.getRule());
StatusResponse re = new StatusResponse(basinId.getOfficeId(), "Deleted CWMS Basin", basinId.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public BinaryTimeSeriesValueController(MetricRegistry metrics) {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the owning office of "
+ "the Binary TimeSeries whose data is to be included in the response."),
@OpenApiParam(name = BLOB_ID, description = "Will be removed in a schema update. " +
"This is a placeholder for integration testing with schema 23.3.16", deprecated = true)
"This is a placeholder for integration testing with schema 23.3.16", deprecated = true,
required = true)
},
responses = {
@OpenApiResponse(status = STATUS_200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private Timer.Context markAndTime(String subject) {
@Override
public void getAll(Context ctx) {
String office = ctx.queryParam(OFFICE);
String projectId = ctx.queryParam(PROJECT_ID);
String projectId = requiredParam(ctx, PROJECT_ID);
try (Timer.Context ignored = markAndTime(GET_ALL)) {
DSLContext dsl = getDslContext(ctx);
EmbankmentDao dao = new EmbankmentDao(dsl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import cwms.cda.formatters.FormattingException;
import cwms.cda.formatters.UnsupportedFormatException;
import cwms.cda.helpers.DateUtils;
import cwms.cda.helpers.annotations.IgnoreRequiredQueryParamMismatch;
import io.javalin.apibuilder.CrudHandler;
import io.javalin.core.util.Header;
import io.javalin.http.Context;
Expand Down Expand Up @@ -378,6 +379,7 @@ public void getAll(@NotNull Context ctx) {
description = "Retrieves requested Location Level",
tags = TAG
)
@IgnoreRequiredQueryParamMismatch(parameterNames = {EFFECTIVE_DATE})
@Override
public void getOne(@NotNull Context ctx, @NotNull String levelId) {
String office = requiredParam(ctx, OFFICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ private Timer.Context markAndTime(String subject) {
+ " the assigned locations in the returned location groups. (default: false)"),
@OpenApiParam(name = LOCATION_CATEGORY_LIKE, description = "Posix <a href=\"regexp.html\">regular expression</a> "
+ "matching against the location category id"),
@OpenApiParam(name = CATEGORY_OFFICE_ID, required = true, description = "Specifies the "
@OpenApiParam(name = CATEGORY_OFFICE_ID, description = "Specifies the "
+ "owning office of the category the location group belongs to "
+ "whose data is to be included in the response."),
@OpenApiParam(name = LOCATION_OFFICE_ID, required = true, description = "Specifies the "
@OpenApiParam(name = LOCATION_OFFICE_ID, description = "Specifies the "
+ "owning office of the location assigned to the location group whose data is to be included in the response."),
},
responses = {
Expand All @@ -108,8 +108,8 @@ public void getAll(@NotNull Context ctx) {
DSLContext dsl = getDslContext(ctx);
LocationGroupDao cdm = new LocationGroupDao(dsl);

String groupOfficeId = requiredParam(ctx, OFFICE);
String categoryOfficeId = requiredParam(ctx, CATEGORY_OFFICE_ID);
String groupOfficeId = ctx.queryParam(OFFICE);
String categoryOfficeId = ctx.queryParam(CATEGORY_OFFICE_ID);
String locationOfficeId = ctx.queryParam(LOCATION_OFFICE_ID);

boolean includeAssigned = queryParamAsClass(ctx, new String[]{INCLUDE_ASSIGNED},
Expand Down Expand Up @@ -152,11 +152,12 @@ Boolean.class, false, metrics, name(LocationGroupController.class.getName(),
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the "
+ "owning office of the location group whose data is to be included "
+ "in the response."),
@OpenApiParam(name = GROUP_OFFICE_ID, required = true, description = "Specifies the "
+ "owning office of the location group whose data is to be included in the response."),
@OpenApiParam(name = CATEGORY_OFFICE_ID, required = true, description = "Specifies the "
@OpenApiParam(name = GROUP_OFFICE_ID, description = "Specifies the "
+ "owning office of the location group whose data is to be included in the response. "
+ "Required for GEO JSON format."),
@OpenApiParam(name = CATEGORY_OFFICE_ID, description = "Specifies the "
+ "owning office of the category the location group belongs to "
+ "whose data is to be included in the response."),
+ "whose data is to be included in the response. Required for GEO JSON format."),
@OpenApiParam(name = CATEGORY_ID, required = true, description = "Specifies"
+ " the category containing the location group whose data is to be "
+ "included in the response."),
Expand Down Expand Up @@ -325,8 +326,8 @@ public void delete(@NotNull Context ctx, @NotNull String groupId) {
DSLContext dsl = getDslContext(ctx);

LocationGroupDao dao = new LocationGroupDao(dsl);
String office = ctx.queryParam(OFFICE);
String categoryId = ctx.queryParam(CATEGORY_ID);
String office = requiredParam(ctx, OFFICE);
String categoryId = requiredParam(ctx, CATEGORY_ID);
boolean cascadeDelete = ctx.queryParamAsClass(CASCADE_DELETE, Boolean.class).getOrDefault(false);
dao.delete(categoryId, groupId, cascadeDelete, office);
ctx.status(HttpServletResponse.SC_NO_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ public void update(@NotNull Context ctx, @NotNull String locationId) {
},
queryParams = {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the office of the measurements to delete"),
@OpenApiParam(name = BEGIN, required = true, description = "The start of the time window to delete. " +
@OpenApiParam(name = BEGIN, description = "The start of the time window to delete. " +
TIME_FORMAT_DESC),
@OpenApiParam(name = END, required = true, description = "The end of the time window to delete." +
@OpenApiParam(name = END, description = "The end of the time window to delete." +
TIME_FORMAT_DESC),
@OpenApiParam(name = TIMEZONE, description = "This field specifies a default timezone "
+ "to be used if the format of the " + BEGIN + "and " + END
Expand Down
6 changes: 4 additions & 2 deletions cwms-data-api/src/main/java/cwms/cda/api/PoolController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static cwms.cda.api.Controllers.OFFICE;
import static cwms.cda.api.Controllers.PAGE;
import static cwms.cda.api.Controllers.PAGE_SIZE;
import static cwms.cda.api.Controllers.PARAMETER_ID;
import static cwms.cda.api.Controllers.POOL_ID;
import static cwms.cda.api.Controllers.PROJECT_ID;
import static cwms.cda.api.Controllers.RESULTS;
Expand All @@ -23,6 +24,7 @@
import static cwms.cda.api.Controllers.STATUS_501;
import static cwms.cda.api.Controllers.TOP_MASK;
import static cwms.cda.api.Controllers.queryParamAsClass;
import static cwms.cda.api.Controllers.requiredParam;
import static cwms.cda.data.dao.JooqDao.getDslContext;

import com.codahale.metrics.Histogram;
Expand Down Expand Up @@ -190,8 +192,8 @@ public void getOne(@NotNull Context ctx, @NotNull String poolId) {
PoolDao dao = new PoolDao(dsl);

// These are required
String office = ctx.queryParam(OFFICE);
String projectId = ctx.queryParam(PROJECT_ID);
String office = requiredParam(ctx, OFFICE);;
String projectId = requiredParam(ctx, PROJECT_ID);

// These are optional
String bottomMask =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ public void create(@NotNull Context ctx) {
@OpenApiParam(name = NAME, description = "The name of the project to be renamed"),
},
queryParams = {
@OpenApiParam(name = NAME, description = "The new name of the project"),
@OpenApiParam(name = OFFICE, description = "The office of the project to be renamed"),
@OpenApiParam(name = NAME, required = true, description = "The new name of the project"),
@OpenApiParam(name = OFFICE, required = true, description = "The office of the project to be renamed"),
},
requestBody = @OpenApiRequestBody(
content = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void create(Context ctx) {
queryParams = {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the "
+ "owning office of the specified level to be renamed"),
@OpenApiParam(name = SPECIFIED_LEVEL_ID, description = "The new specified level id.")
@OpenApiParam(name = SPECIFIED_LEVEL_ID, required = true, description = "The new specified level id.")
},
method = HttpMethod.PATCH,
tags = {TAG}
Expand All @@ -174,8 +174,8 @@ public void update(Context ctx, @NotNull String oldSpecifiedLevelId) {
DSLContext dsl = getDslContext(ctx);

SpecifiedLevelDao dao = getDao(dsl);
String newSpecifiedLevelId = ctx.queryParam(SPECIFIED_LEVEL_ID);
String office = ctx.queryParam(OFFICE);
String newSpecifiedLevelId = requiredParam(ctx, SPECIFIED_LEVEL_ID);
String office = requiredParam(ctx, OFFICE);
dao.update(oldSpecifiedLevelId, newSpecifiedLevelId, office);
ctx.status(HttpServletResponse.SC_NO_CONTENT);
}
Expand All @@ -201,7 +201,7 @@ public void delete(Context ctx, String specifiedLevelId) {
DSLContext dsl = getDslContext(ctx);

SpecifiedLevelDao dao = getDao(dsl);
String office = ctx.queryParam(OFFICE);
String office = requiredParam(ctx, OFFICE);
dao.delete(specifiedLevelId, office);
ctx.status(HttpServletResponse.SC_NO_CONTENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ public void getAll(Context ctx) {
@Override
public void getOne(@NotNull Context ctx, @NotNull String stdTextId) {
try (Timer.Context ignored = markAndTime(DELETE)) {
String office = ctx.queryParam(OFFICE);
if (office == null) {
throw new IllegalArgumentException(OFFICE + " is a required parameter");
}
String office = requiredParam(ctx, OFFICE);
DSLContext dsl = getDslContext(ctx);
StandardTextValue standardTextValue = getDao(dsl).retrieveStandardText(stdTextId, office);

Expand Down Expand Up @@ -204,12 +201,8 @@ public void update(@NotNull Context ctx, @NotNull String oldTextTimeSeriesId) {
@Override
public void delete(@NotNull Context ctx, @NotNull String stdTextId) {
try (Timer.Context ignored = markAndTime(DELETE)) {
String office = ctx.queryParam(OFFICE);
if (office == null) {
throw new IllegalArgumentException(OFFICE + " is a required parameter");
}
JooqDao.DeleteMethod deleteMethod = ctx.queryParamAsClass(METHOD, JooqDao.DeleteMethod.class)
.getOrThrow(e -> new IllegalArgumentException(METHOD + " is a required parameter"));
String office = requiredParam(ctx, OFFICE);
JooqDao.DeleteMethod deleteMethod = requiredParamAs(ctx, METHOD, JooqDao.DeleteMethod.class);
String deleteAction;
switch (deleteMethod) {
case DELETE_ALL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public TextTimeSeriesValueController(MetricRegistry metrics) {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the owning office of "
+ "the Text TimeSeries whose data is to be included in the response."),
@OpenApiParam(name = CLOB_ID, description = "Will be removed in a schema update. " +
"This is a placeholder for integration testing with schema 23.3.16", deprecated = true)
"This is a placeholder for integration testing with schema 23.3.16", deprecated = true,
required = true)
},
responses = {
@OpenApiResponse(status = STATUS_200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void handle(@NotNull Context ctx) {
? DateUtils.parseUserDate(end, timezone)
: ZonedDateTime.now(tz);

String office = requiredParam(ctx, OFFICE);
String office = ctx.queryParam(OFFICE);

FilteredTimeSeriesParameters ftsParams = FilteredTimeSeriesParameters.Builder.from(ctx)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private Timer.Context markAndTime(String subject) {
+ "timeseries assigned to the group(s) whose data is to be included in the response. If this "
+ "field is not specified, group information for all assigned TS offices shall be returned."),
@OpenApiParam(name = GROUP_OFFICE_ID, description = "Specifies the owning office of the "
+ "timeseries group", required = true),
+ "timeseries group"),
@OpenApiParam(name = INCLUDE_ASSIGNED, type = Boolean.class, description = "Include"
+ " the assigned timeseries in the returned timeseries groups. (default: true)"),
@OpenApiParam(name = TIMESERIES_CATEGORY_LIKE, description = "Posix <a href=\"regexp.html\">regular expression</a> "
Expand Down Expand Up @@ -163,15 +163,15 @@ Boolean.class, true, metrics, name(TimeSeriesGroupController.class.getName(),
+ "the timeseries group whose data is to be included in the response")
},
queryParams = {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the "
@OpenApiParam(name = OFFICE, description = "Specifies the "
+ "owning office of the timeseries assigned to the group whose data is to be included"
+ " in the response. This will limit the assigned timeseries returned to only those"
+ " assigned to the specified office."),
@OpenApiParam(name = CATEGORY_OFFICE_ID, description = "Specifies the owning office of the "
+ "timeseries group category", required = true),
+ "timeseries group category"),
@OpenApiParam(name = GROUP_OFFICE_ID, description = "Specifies the owning office of the "
+ "timeseries group", required = true),
@OpenApiParam(name = CATEGORY_ID, required = true, description = "Specifies"
+ "timeseries group"),
@OpenApiParam(name = CATEGORY_ID, description = "Specifies"
+ " the category containing the timeseries group whose data is to be "
+ "included in the response."),
},
Expand Down Expand Up @@ -337,8 +337,8 @@ public void delete(@NotNull Context ctx, @NotNull String groupId) {
DSLContext dsl = getDslContext(ctx);

TimeSeriesGroupDao dao = new TimeSeriesGroupDao(dsl);
String office = ctx.queryParam(OFFICE);
String categoryId = ctx.queryParam(CATEGORY_ID);
String office = requiredParam(ctx, OFFICE);
String categoryId = requiredParam(ctx, CATEGORY_ID);
dao.delete(categoryId, groupId, office);
ctx.status(HttpServletResponse.SC_NO_CONTENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void getOne(@NotNull Context ctx, @NotNull String timeseriesId) {
DSLContext dsl = getDslContext(ctx);

TimeSeriesIdentifierDescriptorDao dao = new TimeSeriesIdentifierDescriptorDao(dsl);
String office = ctx.queryParam(OFFICE);
String office = requiredParam(ctx, OFFICE);

String formatHeader = ctx.header(Header.ACCEPT);
if (Formats.DEFAULT.equals(formatHeader)) {
Expand Down Expand Up @@ -329,7 +329,7 @@ public void update(@NotNull Context ctx, @NotNull String name) {
@Override
public void delete(@NotNull Context ctx, @NotNull String timeseriesId) {

JooqDao.DeleteMethod method = ctx.queryParamAsClass(METHOD, JooqDao.DeleteMethod.class).get();
JooqDao.DeleteMethod method =requiredParamAs(ctx, METHOD, JooqDao.DeleteMethod.class);

String office = requiredParam(ctx, OFFICE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,22 @@

import static com.codahale.metrics.MetricRegistry.name;
import static cwms.cda.api.Controllers.*;
import static cwms.cda.api.Controllers.SINCE;
import static cwms.cda.data.dao.JooqDao.getDslContext;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.api.enums.UnitSystem;
import cwms.cda.data.dao.location.kind.TurbineDao;
import cwms.cda.data.dto.CwmsId;
import cwms.cda.data.dto.StatusResponse;
import cwms.cda.data.dto.location.kind.TurbineChange;
import cwms.cda.formatters.ContentType;
import cwms.cda.formatters.Formats;
import io.javalin.core.util.Header;
import cwms.cda.helpers.annotations.IgnoreRequiredQueryParamMismatch;
import io.javalin.http.Context;
import io.javalin.http.Handler;
import io.javalin.plugin.openapi.annotations.HttpMethod;
import io.javalin.plugin.openapi.annotations.OpenApi;
import io.javalin.plugin.openapi.annotations.OpenApiContent;
import io.javalin.plugin.openapi.annotations.OpenApiParam;
import io.javalin.plugin.openapi.annotations.OpenApiResponse;
import java.time.Instant;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;
Expand Down Expand Up @@ -99,6 +92,7 @@ private Timer.Context markAndTime(String subject) {
+ "inputs provided the project was not found.")
}
)
@IgnoreRequiredQueryParamMismatch(parameterNames = {TIMEZONE})
public void handle(@NotNull Context ctx) throws Exception {
String projectId = ctx.pathParam(NAME);
String office = ctx.pathParam(OFFICE);
Expand Down
Loading
Loading