@@ -55,7 +55,7 @@ private Timer.Context markAndTime(String subject) {
5555 },
5656 responses = {
5757 @ OpenApiResponse (status = STATUS_200 , content = {
58- @ OpenApiContent (isArray = true , from = Entity .class , type = Formats .JSONV2 )
58+ @ OpenApiContent (isArray = true , from = Entity .class , type = Formats .JSONV1 )
5959 })
6060 },
6161 tags = {TAG }
@@ -69,8 +69,14 @@ public void getAll(@NotNull Context ctx) {
6969 String officeId = ctx .queryParam (OFFICE );
7070 String entityId = ctx .queryParam (ENTITY_ID );
7171 String parentId = ctx .queryParam (PARENT_ENTITY_ID );
72- Boolean matchNullParents = ctx .queryParamAsClass (MATCH_NULL_PARENTS , Boolean .class )
73- .getOrDefault (true );
72+ Boolean matchNullParents ;
73+ if (parentId != null ) {
74+ matchNullParents = false ;
75+ } else {
76+ matchNullParents = ctx .queryParamAsClass (MATCH_NULL_PARENTS , Boolean .class )
77+ .getOrDefault (true );
78+ }
79+
7480 String categoryId = ctx .queryParam (CATEGORY_ID );
7581 String entityName = ctx .queryParam (LONG_NAME );
7682
@@ -100,7 +106,7 @@ public void getAll(@NotNull Context ctx) {
100106 },
101107 responses = {
102108 @ OpenApiResponse (status = STATUS_200 , content = {
103- @ OpenApiContent (from = Entity .class , type = Formats .JSONV2 )
109+ @ OpenApiContent (from = Entity .class , type = Formats .JSONV1 )
104110 })
105111 },
106112 tags = {TAG }
@@ -133,7 +139,7 @@ public void getOne(@NotNull Context ctx, @NotNull String entityId) {
133139 description = "Create CWMS Entity" ,
134140 requestBody = @ OpenApiRequestBody (
135141 content = {
136- @ OpenApiContent (from = Entity .class , type = Formats .JSONV2 )
142+ @ OpenApiContent (from = Entity .class , type = Formats .JSONV1 )
137143 },
138144 required = true ),
139145 responses = {
@@ -161,16 +167,12 @@ public void create(@NotNull Context ctx) {
161167 @ OpenApi (
162168 description = "Update an existing Entity." ,
163169 requestBody = @ OpenApiRequestBody (
164- content = {@ OpenApiContent (from = Entity .class , type = Formats .JSONV2 )},
170+ content = {@ OpenApiContent (from = Entity .class , type = Formats .JSONV1 )},
165171 required = true ),
166172 pathParams = {
167173 @ OpenApiParam (name = ENTITY_ID , required = true , description = "Specifies the entity ID of the " +
168174 " Entity to be updated. (e.g., NWS)" )
169175 },
170- queryParams = {
171- @ OpenApiParam (name = OFFICE , required = true , description = "Specifies the owning office " +
172- " of the entity to be updated. (e.g., SPK)" )
173- },
174176 method = HttpMethod .PATCH ,
175177 tags = {TAG },
176178 responses = {
@@ -185,9 +187,12 @@ public void update(@NotNull Context ctx, @NotNull String entityId) {
185187 String formatHeader = ctx .req .getContentType ();
186188 ContentType contentType = Formats .parseHeader (formatHeader , Entity .class );
187189 Entity entity = Formats .parseContent (contentType , ctx .bodyAsInputStream (), Entity .class );
188- if (entity .getId () == null || entity .getId ().getOfficeId () == null || entity .getId ().getName () == null ) {
189- ctx .status (HttpServletResponse .SC_BAD_REQUEST );
190- ctx .result ("Entity ID and Office ID must be provided in the request body." );
190+ // Validate the office ID and entity ID are provided.
191+ entity .validate ();
192+
193+ if (!entityId .equalsIgnoreCase (entity .getId ().getName ())) {
194+ ctx .status (HttpServletResponse .SC_NOT_FOUND );
195+ ctx .result ("Entity ID in path parameter must match the Entity ID in the request body." );
191196 return ;
192197 }
193198 EntityDao dao = new EntityDao (dsl );
@@ -196,7 +201,8 @@ public void update(@NotNull Context ctx, @NotNull String entityId) {
196201 }
197202 }
198203
199- @ OpenApi (
204+
205+ @ OpenApi (
200206 description = "Delete CWMS Entity." ,
201207 pathParams = {
202208 @ OpenApiParam (name = ENTITY_ID , required = true , description = "Specifies the entity ID " +
0 commit comments