[
https://issues.apache.org/jira/browse/FC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shawn McKinney resolved FC-279.
-------------------------------
Resolution: Fixed
> Fix RestUtils error mapping for HTTP errors
> -------------------------------------------
>
> Key: FC-279
> URL: https://issues.apache.org/jira/browse/FC-279
> Project: FORTRESS
> Issue Type: Bug
> Affects Versions: 2.0.4
> Reporter: Shawn McKinney
> Assignee: Shawn McKinney
> Priority: Major
> Fix For: 3.0.0-RC1
>
>
> The problem:
> Currently when the URL for Fortress Rest isn't set right, in RestUtils, 404
> error gets masked, as the response is attempted to be parsed.
> Fix the error handing to properly catch http errors and map to appropriate
> exception.
> There's a bit more to this. That is currently Fortress Rest maps application
> defined errors, e.g. read and authentication failures to HTTP error codes, in
> addition to the application status codes.
> The rationale, so certain RESTful clients, i.e. the new Fortress UI don't
> have to crack the message when errors happen.
> Impedance mismatch between generic HTTP errors and application defined errors
> notwithstanding, there needs to be a way to differentiate between generic
> HTTP errors, i.e. thrown by Tomcat, and application defined HTTP errors,
> thrown by the Fortress Rest processor.
> ***
> The solution, is to examine the response, in addition to the error code, to
> determine if generic HTTP errors should be thrown, or if normal processing
> should resume.
> {{ case HTTP_404_NOT_FOUND:}}
> {{ szResponse = IOUtils.toString( response.getEntity().getContent(), "UTF-8"
> );}}
> {{ // Crack the response and see if it can be parsed as a valid Fortress
> Response object or generic HTTP:}}
> {{ if( StringUtils.isNotEmpty( szResponse ) &&
> szResponse.contains(VALID_RESPONSE) )}}
> {{ {}}
> {{ LOG.debug( "HTTP: 404: post uri=[{}], function=[{}], response=[{}]",
> uri, function, szResponse );}}
> {{ }}}
> {{ else}}
> {{ {}}
> {{ error = generateErrorMessage( uri, function, "HTTP Error:" +
> response.getStatusLine().getStatusCode());}}
> {{ LOG.error( error );}}
> {{ throw new RestException( GlobalErrIds.REST_NOT_FOUND_ERR, error );}}
> {{ }}}
> {{ break;}}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]