Skip to content

Commit

Permalink
Replace 400 - Bad Request with 413 - Request entity too large error r…
Browse files Browse the repository at this point in the history
…esponse code for matching RS services #4488
  • Loading branch information
vrindanayak committed Apr 23, 2024
1 parent 7ede81c commit 8892267
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ private Response exportMatching(String exporterID, String aet,
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse(Response.Status.BAD_REQUEST, "Request entity too large");
return errResponse(Response.Status.REQUEST_ENTITY_TOO_LARGE,
"Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.");

ExportMatchingObjects exportMatchingObjects = new ExportMatchingObjects(
exporter, qrlevel, query, scheduledTime(), status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ Response ianMatching(String aet, String ianscp, String method, QueryRetrieveLeve
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

IANSCUMatchingObjects ianSCUMatchingObjects = new IANSCUMatchingObjects(ae, ianscp, query, status);
runInTx.execute(ianSCUMatchingObjects);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public Response applyRetentionPolicy() {
int queryMaxNumberOfResults = arcAE.queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

ExpireSeries es = new ExpireSeries(ae, query);
runInTx.execute(es);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.dcm4che3.conf.api.ConfigurationException;
import org.dcm4che3.data.*;
import org.dcm4che3.net.ApplicationEntity;
import org.dcm4che3.net.Device;
Expand Down Expand Up @@ -340,7 +339,8 @@ Response rejectMatching(String aet, String codeValue, String designator,
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

RejectMatchingObjects rejectMatchingObjects = new RejectMatchingObjects(
aet, rjNoteCode, qrlevel, query, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ Response updateMatching(String aet, String method, QueryRetrieveLevel2 qrlevel,
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

UpdateMatchingEntities updateMatchingObjects =
new UpdateMatchingEntities(aet, attrs, qrlevel, studyMgtCtx, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ public Response updateStudyAccessControlID(
int queryMaxNumberOfResults = qCtx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !qCtx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

UpdateStudyAccess updateStudyAccess = new UpdateStudyAccess(ae, query, accessControlID1);
runInTx.execute(updateStudyAccess);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public Response comparePatients() {
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

DiffPatientDemographics diffPatientDemographics = new DiffPatientDemographics(query, descriptor);
runInTx.execute(diffPatientDemographics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ Response storageCommitMatching(String aet, String stgcmtscp, String method, Quer
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
return errResponse("Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.",
Response.Status.REQUEST_ENTITY_TOO_LARGE);

StgCmtSCUMatchingObjects stgCmtSCUMatchingObjects = new StgCmtSCUMatchingObjects(
aet, stgcmtscp, qrlevel, query, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ Response verifyStorageOf(String aet,
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey()
&& query.fetchCount() > queryMaxNumberOfResults)
return errResponse(Response.Status.BAD_REQUEST, "Request entity too large");
return errResponse(Response.Status.REQUEST_ENTITY_TOO_LARGE,
"Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters.");

StgVerMatchingObjects stgVerMatchingObjects = new StgVerMatchingObjects(aet, qrlevel, query, status);
runInTx.execute(stgVerMatchingObjects);
Expand Down
9 changes: 9 additions & 0 deletions docs/swagger/paths/export.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@
"404": {
"description": "No such Archive AE Title or Exporter or Exporter configuration does not consist of IAN Destinations or Storage Commitment SCPs"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error."
}
Expand Down Expand Up @@ -491,6 +494,9 @@
"404": {
"description": "No such Archive AE Title or Exporter or Exporter configuration does not consist of IAN Destinations or Storage Commitment SCPs"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error."
}
Expand Down Expand Up @@ -818,6 +824,9 @@
"404": {
"description": "No such Archive AE Title or Exporter or Exporter configuration does not consist of IAN Destinations or Storage Commitment SCPs"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error."
}
Expand Down
9 changes: 9 additions & 0 deletions docs/swagger/paths/ian.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@
"404": {
"description": "No such Archive AE Title or Instance Availability Notification SCP AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -458,6 +461,9 @@
"404": {
"description": "No such Archive AE Title or Instance Availability Notification SCP AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -776,6 +782,9 @@
"404": {
"description": "No such Archive AE Title or Instance Availability Notification SCP AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down
18 changes: 18 additions & 0 deletions docs/swagger/paths/iocm.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
"409": {
"$ref": "../responses.json#/updateMatchingFailed"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -350,6 +353,9 @@
"409": {
"$ref": "../responses.json#/updateMatchingFailed"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -719,6 +725,9 @@
"404": {
"description": "No such Archive AE Title or Rejection Note"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -940,6 +949,9 @@
"404": {
"description": "No such Archive AE Title or Rejection Note"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -1276,6 +1288,9 @@
"404": {
"description": "No such Archive AE Title or Rejection Note"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -1717,6 +1732,9 @@
"404": {
"description": "No such Archive AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down
3 changes: 3 additions & 0 deletions docs/swagger/paths/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@
"404": {
"description": "No such Archive AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error."
}
Expand Down
6 changes: 3 additions & 3 deletions docs/swagger/paths/pam.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,12 @@
"204": {
"description": "No matching Patient found at Archive AE"
},
"400": {
"description": "Request entity too large"
},
"404": {
"description": "AE Title of Archive or PDQ Service not found"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down
9 changes: 9 additions & 0 deletions docs/swagger/paths/stgcmt.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@
"404": {
"description": "No such Archive AE Title or Storage Commitment SCP AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -556,6 +559,9 @@
"404": {
"description": "No such Archive AE Title or Storage Commitment SCP AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -874,6 +880,9 @@
"404": {
"description": "No such Archive AE Title or Storage Commitment SCP AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down
9 changes: 9 additions & 0 deletions docs/swagger/paths/stgver.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@
"404": {
"description": "No such Archive AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -505,6 +508,9 @@
"404": {
"description": "No such Archive AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down Expand Up @@ -823,6 +829,9 @@
"404": {
"description": "No such Archive AE Title"
},
"413": {
"description": "Request entity too large. Query count exceeds configured Query Max Number of Results, narrow down search using query filters."
},
"500": {
"description": "Internal Server Error"
}
Expand Down

0 comments on commit 8892267

Please sign in to comment.