private void serialize ( final String resource , final long nodeId , final Long revision , final boolean doNodeId , final OutputStream output , final boolean wrapResult ) { if ( mDatabase . existsResource ( resource ) ) { ISession session = null ; try { session = mDatabase . getSession ( new SessionConfiguration ( resource , StandardSettings . KEY ) ) ; if ( wrapResult ) { output . write ( BEGINRESULT ) ; final XMLSerializerProperties props = new XMLSerializerProperties ( ) ; final XMLSerializerBuilder builder = new XMLSerializerBuilder ( session , nodeId , output , props ) ; builder . setREST ( doNodeId ) ; builder . setID ( doNodeId ) ; builder . setDeclaration ( false ) ; final XMLSerializer serializer = builder . build ( ) ; serializer . call ( ) ; output . write ( ENDRESULT ) ; } else { final XMLSerializerProperties props = new XMLSerializerProperties ( ) ; final XMLSerializerBuilder builder = new XMLSerializerBuilder ( session , nodeId , output , props ) ; builder . setREST ( doNodeId ) ; builder . setID ( doNodeId ) ; builder . setDeclaration ( false ) ; final XMLSerializer serializer = builder . build ( ) ; serializer . call ( ) ; } } catch ( final TTException ttExcep ) { throw new JaxRxException ( ttExcep ) ; } catch ( final IOException ioExcep ) { throw new JaxRxException ( ioExcep ) ; } catch ( final Exception globExcep ) { if ( globExcep instanceof JaxRxException ) { // NOPMD due // to // different // exception // types throw ( JaxRxException ) globExcep ; } else { throw new JaxRxException ( globExcep ) ; } } finally { try { WorkerHelper . closeRTX ( null , session ) ; } catch ( final TTException exce ) { throw new JaxRxException ( exce ) ; } } } else { throw new JaxRxException ( 404 , "Resource does not exist" ) ; } }
This method serializes requested resource