@ SuppressWarnings ( "unchecked" ) protected < T extends Resource > T unmarshalReference ( HttpResponse response , String format ) { T resource = null ; OperationOutcome error = null ; byte [ ] cnt = log ( response ) ; if ( cnt != null ) { try { resource = ( T ) getParser ( format ) . parse ( cnt ) ; if ( resource instanceof OperationOutcome && hasError ( ( OperationOutcome ) resource ) ) { error = ( OperationOutcome ) resource ; } } catch ( IOException ioe ) { throw new EFhirClientException ( "Error reading Http Response: " + ioe . getMessage ( ) , ioe ) ; } catch ( Exception e ) { throw new EFhirClientException ( "Error parsing response message: " + e . getMessage ( ) , e ) ; } } if ( error != null ) { throw new EFhirClientException ( "Error from server: " + ResourceUtilities . getErrorDescription ( error ) , error ) ; } return resource ; }
Unmarshals a resource from the response stream .