public static String getDeployment ( DeploymentType deployment , boolean indent ) throws IOException { try { if ( m_jc == null || m_schema == null ) { throw new RuntimeException ( "Error schema validation." ) ; } Marshaller marshaller = m_jc . createMarshaller ( ) ; marshaller . setSchema ( m_schema ) ; marshaller . setProperty ( Marshaller . JAXB_FORMATTED_OUTPUT , Boolean . valueOf ( indent ) ) ; StringWriter sw = new StringWriter ( ) ; marshaller . marshal ( new JAXBElement <> ( new QName ( "" , "deployment" ) , DeploymentType . class , deployment ) , sw ) ; return sw . toString ( ) ; } catch ( JAXBException e ) { // Convert some linked exceptions to more friendly errors. if ( e . getLinkedException ( ) instanceof java . io . FileNotFoundException ) { hostLog . error ( e . getLinkedException ( ) . getMessage ( ) ) ; return null ; } else if ( e . getLinkedException ( ) instanceof org . xml . sax . SAXParseException ) { hostLog . error ( "Error schema validating deployment.xml file. " + e . getLinkedException ( ) . getMessage ( ) ) ; return null ; } else { throw new RuntimeException ( e ) ; } } }
Given the deployment object generate the XML