Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 8 additions & 8 deletions cwms-data-api/src/main/java/cwms/cda/api/EntityController.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ public void create(@NotNull Context ctx) {
@OpenApiParam(name = ENTITY_ID, required = true, description = "Specifies the entity ID of the " +
" Entity to be updated. (e.g., NWS)")
},
queryParams = {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the owning office "+
" of the entity to be updated. (e.g., SPK)")
},
method = HttpMethod.PATCH,
tags = {TAG},
responses = {
Expand All @@ -185,9 +181,12 @@ public void update(@NotNull Context ctx, @NotNull String entityId) {
String formatHeader = ctx.req.getContentType();
ContentType contentType = Formats.parseHeader(formatHeader, Entity.class);
Entity entity = Formats.parseContent(contentType, ctx.bodyAsInputStream(), Entity.class);
if (entity.getId() == null || entity.getId().getOfficeId() == null || entity.getId().getName() == null) {
ctx.status(HttpServletResponse.SC_BAD_REQUEST);
ctx.result("Entity ID and Office ID must be provided in the request body.");
// Validate the office ID and entity ID are provided.
entity.validate();

if (!entityId.equalsIgnoreCase(entity.getId().getName())) {
ctx.status(HttpServletResponse.SC_NOT_FOUND);
ctx.result("Entity ID in path parameter must match the Entity ID in the request body.");
return;
}
EntityDao dao = new EntityDao(dsl);
Expand All @@ -196,7 +195,8 @@ public void update(@NotNull Context ctx, @NotNull String entityId) {
}
}

@OpenApi(

@OpenApi(
description = "Delete CWMS Entity.",
pathParams = {
@OpenApiParam(name = ENTITY_ID, required = true, description = "Specifies the entity ID " +
Expand Down
Loading
Loading