/*
 */
package org.datadryad.rest.converters;

import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import org.datadryad.rest.models.Manuscript;
import org.datadryad.rest.legacymodels.LegacyManuscript;

/**
 *
 * @author Dan Leehr <dan.leehr@nescent.org>
 */
public class ManuscriptToLegacyXMLConverter {

    public static void main(String args[]) {
        Manuscript manuscript = new Manuscript();
        manuscript.configureTestValues();
        convertToInternalXML(manuscript, System.out);
    }

    static void convertToInternalXML(Manuscript manuscript, OutputStream outputStream) {
        JAXBContext context = null;
        try {
            LegacyManuscript legacyManuscript = new LegacyManuscript(manuscript);
            context = JAXBContext.newInstance(LegacyManuscript.class);
            Marshaller marshaller = context.createMarshaller();
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            marshaller.marshal(legacyManuscript, outputStream);
        } catch (JAXBException ex) {
            System.err.println("Error converting manuscript to internal XML:" + ex);
        }
    }

}

@@ -579,24 +579,42 @@
 stValues();%0A
+        try %7B%0A    
         conv
@@ -663,14 +663,153 @@
     
-%7D%0A%0A
    
+ %7D catch (JAXBException ex) %7B%0A            System.err.println(%22Error converting manuscript to internal XML:%22 + ex);%0A        %7D%0A    %7D%0A%0A    public
  sta
@@ -892,57 +892,28 @@
 am) 
-%7B%0A        JAXBContext context = null;%0A        try
+throws JAXBException
  %7B%0A 
@@ -919,20 +919,16 @@
         
-  
-  
 LegacyMa
@@ -993,27 +993,35 @@
 t);%0A        
-   
+JAXBContext
  context = J
@@ -1076,20 +1076,16 @@
         
-    
 Marshall
@@ -1128,36 +1128,32 @@
 ller();%0A        
-   
- 
 marshaller.setPr
@@ -1227,28 +1227,24 @@
 E);%0A        
-    
 marshaller.m
@@ -1291,141 +1291,8 @@
     
-    %7D catch (JAXBException ex) %7B%0A            System.err.println(%22Error converting manuscript to internal XML:%22 + ex);%0A        %7D%0A    %7D%0A
+%7D
 %0A%7D%0A

change convertToInternalXML to public