Skip to content

Commit

Permalink
#1032 : RESTful services: return "404 Not Found" instead "503 Service…
Browse files Browse the repository at this point in the history
… Unavailable" if referenced Archive AE is not configured
  • Loading branch information
vrindanayak committed Oct 17, 2017
1 parent 86d2ea5 commit def6eef
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected void execute() {
ApplicationEntity ae = getApplicationEntity(arcDev.getRejectExpiredStudiesAETitle());
if (ae == null || !ae.isInstalled()) {
LOG.warn("No such Application Entity: " + arcDev.getRejectExpiredStudiesAETitle(),
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
}
RejectionNote rn = getRejectionNote(arcDev.getRejectionNotes());
if (rn == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private ApplicationEntity getApplicationEntity() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
return ae;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,15 @@ public class EchoRS {
private HttpServletRequest request;

private ApplicationEntity getApplicationEntity() {
ApplicationEntity ae = device.getApplicationEntity(aet);
ApplicationEntity ae = device.getApplicationEntity(aet, true);
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
return ae;
}

private ApplicationEntity getRemoteApplicationEntity() throws ConfigurationException {
ApplicationEntity ae = device.getApplicationEntity(aet, true);
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
try {
return conf.findApplicationEntity(remoteAET);
} catch (ConfigurationNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private ApplicationEntity getApplicationEntity() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
return ae;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private ApplicationEntity getApplicationEntity() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
return ae;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private ApplicationEntity getApplicationEntity() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
return ae;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private Response export(String studyUID, String seriesUID, String objectUID, Str
LOG.info("Process POST {} from {}@{}", request.getRequestURI(), request.getRemoteUser(), request.getRemoteHost());
ApplicationEntity ae = device.getApplicationEntity(aet, true);
if (ae == null || !ae.isInstalled())
return errResponse(Response.Status.SERVICE_UNAVAILABLE, "No such Application Entity: " + aet);
return errResponse(Response.Status.NOT_FOUND, "No such Application Entity: " + aet);

boolean bOnlyIAN = Boolean.parseBoolean(onlyIAN);
boolean bOnlyStgCmt = Boolean.parseBoolean(onlyStgCmt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private ArchiveAEExtension getArchiveAE() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(getResponse(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE));
Response.Status.NOT_FOUND));
ArchiveAEExtension arcAE = ae.getAEExtension(ArchiveAEExtension.class);
if (request.getAttribute(ORG_KEYCLOAK_KEYCLOAK_SECURITY_CONTEXT) != null)
if(!authenticatedUser(arcAE.getAcceptedUserRoles()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private ArchiveAEExtension getArchiveAE() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(getResponse(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE));
Response.Status.NOT_FOUND));
ArchiveAEExtension arcAE = ae.getAEExtension(ArchiveAEExtension.class);
if (request.getAttribute(ORG_KEYCLOAK_KEYCLOAK_SECURITY_CONTEXT) != null)
if(!authenticatedUser(arcAE.getAcceptedUserRoles()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ private ApplicationEntity getApplicationEntity() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
return ae;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private ApplicationEntity getApplicationEntity() {
ApplicationEntity ae = device.getApplicationEntity(aet, true);
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(getResponse(
"No such Application Entity: " + aet, Response.Status.SERVICE_UNAVAILABLE));
"No such Application Entity: " + aet, Response.Status.NOT_FOUND));
return ae;
}

Expand Down
44 changes: 0 additions & 44 deletions dcm4chee-arc-ui2/src/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3559,50 +3559,6 @@
}
}
},
"/aets/{aet}/rs/mwlitems/{studyUID}/{spsID}/move": {
"delete": {
"tags": [
"IOCM-RS",
"MWL-RS"
],
"summary": "Delete Scheduled Procedure Step",
"operationId": "DeleteSPS",
"parameters": [
{
"name": "aet",
"in": "path",
"description": "Archive AE Title",
"required": true,
"type": "string"
},
{
"name": "studyUID",
"in": "path",
"description": "Unique Identifier of the Study",
"required": true,
"type": "string"
},
{
"name": "spsID",
"in": "path",
"description": "Identifier of the Scheduled Procedure Step",
"required": true,
"type": "string"
}
],
"responses": {
"204": {
"description": "successful operation"
},
"404": {
"description": "no such SPS"
},
"default": {
"description": "unexpected error"
}
}
}
},
"/aets/{aet}/rs/studies": {
"post": {
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private void checkAET() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
}

private enum Output {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private void checkAET() {
if (ae == null || !ae.isInstalled())
throw new WebApplicationException(
"No such Application Entity: " + aet,
Response.Status.SERVICE_UNAVAILABLE);
Response.Status.NOT_FOUND);
}

private StreamingOutput entityOf(RetrieveContext ctx, InstanceLocations inst, ObjectType objectType,
Expand Down

0 comments on commit def6eef

Please sign in to comment.