Skip to content

Commit

Permalink
Merge pull request #95 from NASA-PDS/pds-api-127
Browse files Browse the repository at this point in the history
pds api 127: improved error messaging
  • Loading branch information
tloubrieu-jpl authored Mar 1, 2022
2 parents 7e50de3 + 54d02ca commit 13df0ce
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private ResponseEntity<Object> getBundlesCollectionsEntity(String lidvid, int st
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down Expand Up @@ -202,7 +202,7 @@ public ResponseEntity<Object> productsOfABundle(String lidvid, @Valid Integer st
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected ResponseEntity<Object> getProductsOfACollectionResponseEntity(String l
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (LidVidNotFoundException e)
{
Expand Down Expand Up @@ -222,7 +222,7 @@ public ResponseEntity<Object> bundlesContainingCollection(String lidvid, @Valid
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected ResponseEntity<Object> getProductsResponseEntity(String q, String keyw
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ protected ResponseEntity<Object> getAllProductsResponseEntity(String identifier,
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down Expand Up @@ -182,7 +182,7 @@ protected ResponseEntity<Object> getLatestProductResponseEntity(String lidvid)
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ResponseEntity<Object> bundlesContainingProduct(String lidvid, @Valid Int
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down Expand Up @@ -149,7 +149,7 @@ public ResponseEntity<Object> collectionsContainingProduct(String lidvid, @Valid
catch (ApplicationTypeException e)
{
log.error("Application type not implemented", e);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_ACCEPTABLE);
}
catch (IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ private List<String> add_output_needs (List<String> given) throws ApplicationTyp
}
else
{
log.warn("Could not find a matach for application type: " + String.valueOf(this.format));
log.warn(" Known types: " + String.valueOf(this.formatters.keySet().size()));
for (String key : this.formatters.keySet()) log.warn(" key: " + String.valueOf(key));
throw new ApplicationTypeException("The given application type, " + String.valueOf(this.format) + ", is not known by RquestAndResponseContext.");
String known = String.join(", ", this.formatters.keySet());
log.warn("The Accept header value " + String.valueOf(this.format) + " is not supported, supported values are " + known);
throw new ApplicationTypeException("The Accept header value " + String.valueOf(this.format) + " is not supported, supported values are " + known);
}

/* if the URL contains fields, then make sure the minimum was included too OR there is maximum set. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class JsonErrorMessageSerializer extends AbstractHttpMessageConverter<Err
public JsonErrorMessageSerializer()
{ super(MediaType.APPLICATION_JSON,
new MediaType("application","kvp+json"),
new MediaType("application", "pds4+json")); }
new MediaType("application", "pds4+json"),
MediaType.ALL); }

@Override
protected boolean supports(Class<?> clazz) { return ErrorMessage.class.isAssignableFrom(clazz); }
Expand Down

0 comments on commit 13df0ce

Please sign in to comment.