protected Bundle unmarshalFeed ( HttpResponse response , String format ) { Bundle feed = null ; byte [ ] cnt = log ( response ) ; String contentType = response . getHeaders ( "Content-Type" ) [ 0 ] . getValue ( ) ; OperationOutcome error = null ; try { if ( cnt != null ) { if ( contentType . contains ( ResourceFormat . RESOURCE_XML . getHeader ( ) ) || contentType . contains ( "text/xml+fhir" ) ) { Resource rf = getParser ( format ) . parse ( cnt ) ; if ( rf instanceof Bundle ) feed = ( Bundle ) rf ; else if ( rf instanceof OperationOutcome && hasError ( ( OperationOutcome ) rf ) ) { error = ( OperationOutcome ) rf ; } else { throw new EFhirClientException ( "Error reading server response: a resource was returned instead" ) ; } } } } catch ( IOException ioe ) { throw new EFhirClientException ( "Error reading Http Response" , ioe ) ; } catch ( Exception e ) { throw new EFhirClientException ( "Error parsing response message" , e ) ; } if ( error != null ) { throw new EFhirClientException ( "Error from server: " + ResourceUtilities . getErrorDescription ( error ) , error ) ; } return feed ; }
Unmarshals Bundle from response stream .