public void parseBatchResult ( ClientResponse response ) throws IOException , ServiceException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( ) ; InputStream inputStream = response . getEntityInputStream ( ) ; ReaderWriter . writeTo ( inputStream , byteArrayOutputStream ) ; response . setEntityInputStream ( new ByteArrayInputStream ( byteArrayOutputStream . toByteArray ( ) ) ) ; JobInfo jobInfo ; List < DataSource > parts = parseParts ( response . getEntityInputStream ( ) , response . getHeaders ( ) . getFirst ( "Content-Type" ) ) ; if ( parts . size ( ) == 0 || parts . size ( ) > entityBatchOperations . size ( ) ) { throw new UniformInterfaceException ( String . format ( "Batch response from server does not contain the correct amount " + "of parts (expecting %d, received %d instead)" , parts . size ( ) , entityBatchOperations . size ( ) ) , response ) ; } for ( int i = 0 ; i < parts . size ( ) ; i ++ ) { DataSource ds = parts . get ( i ) ; EntityBatchOperation entityBatchOperation = entityBatchOperations . get ( i ) ; StatusLine status = StatusLine . create ( ds ) ; InternetHeaders headers = parseHeaders ( ds ) ; InputStream content = parseEntity ( ds ) ; if ( status . getStatus ( ) >= HTTP_ERROR ) { InBoundHeaders inBoundHeaders = new InBoundHeaders ( ) ; @ SuppressWarnings ( "unchecked" ) Enumeration < Header > e = headers . getAllHeaders ( ) ; while ( e . hasMoreElements ( ) ) { Header header = e . nextElement ( ) ; inBoundHeaders . putSingle ( header . getName ( ) , header . getValue ( ) ) ; } ClientResponse clientResponse = new ClientResponse ( status . getStatus ( ) , inBoundHeaders , content , null ) ; UniformInterfaceException uniformInterfaceException = new UniformInterfaceException ( clientResponse ) ; throw uniformInterfaceException ; } else if ( entityBatchOperation instanceof Job . CreateBatchOperation ) { try { jobInfo = oDataAtomUnmarshaller . unmarshalEntry ( content , JobInfo . class ) ; Job . CreateBatchOperation jobCreateBatchOperation = ( Job . CreateBatchOperation ) entityBatchOperation ; jobCreateBatchOperation . setJobInfo ( jobInfo ) ; } catch ( JAXBException e ) { throw new ServiceException ( e ) ; } } else if ( entityBatchOperation instanceof Task . CreateBatchOperation ) { try { oDataAtomUnmarshaller . unmarshalEntry ( content , TaskInfo . class ) ; } catch ( JAXBException e ) { throw new ServiceException ( e ) ; } } } }
Parses the batch result .