1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.common.impex.schema;
17  
18  import java.io.Writer;
19  
20  import javax.xml.bind.JAXBContext;
21  import javax.xml.bind.JAXBException;
22  import javax.xml.bind.Marshaller;
23  
24  import org.kuali.common.impex.model.Schema;
25  
26  public class DefaultExportSchemaService implements ExportSchemaService {
27  
28  	@Override
29  	public void exportSchema(Schema schema, Writer writer) {
30  		try {
31  			JAXBContext context = JAXBContext.newInstance(Schema.class);
32  			Marshaller marshaller = context.createMarshaller();
33  			marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
34  			marshaller.marshal(schema, writer);
35  		} catch (JAXBException e) {
36  			throw new IllegalStateException("Could not persist given schema", e);
37  		}
38  	}
39  
40  }