Coverage Report - liquibase.dbdoc.ChangeLogWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
ChangeLogWriter
0%
0/14
0%
0/2
2
 
 1  
 package liquibase.dbdoc;
 2  
 
 3  
 import liquibase.resource.ResourceAccessor;
 4  
 import liquibase.util.StreamUtil;
 5  
 
 6  
 import java.io.File;
 7  
 import java.io.FileOutputStream;
 8  
 import java.io.IOException;
 9  
 import java.io.InputStream;
 10  
 
 11  
 public class ChangeLogWriter {
 12  
     protected File outputDir;
 13  
     private ResourceAccessor resourceAccessor;
 14  
 
 15  0
     public ChangeLogWriter(ResourceAccessor resourceAccessor, File rootOutputDir) {
 16  0
         this.outputDir = new File(rootOutputDir, "changelogs");
 17  0
         this.resourceAccessor = resourceAccessor;
 18  0
     }
 19  
 
 20  
     public void writeChangeLog(String changeLog, String physicalFilePath) throws IOException {
 21  0
         InputStream stylesheet = resourceAccessor.getResourceAsStream(physicalFilePath);
 22  0
         if (stylesheet == null) {
 23  0
             throw new IOException("Can not find " + changeLog);
 24  
         }
 25  
 
 26  
         // File file = outputDir;
 27  
         // String[] splitPath = (changeLog.getFilePath() + ".xml").split("/");
 28  
         // for (int i =0; i < splitPath.length; i++) {
 29  
         // String pathPart = splitPath[i];
 30  
         // file = new File(file, pathPart);
 31  
         // if (i < splitPath.length - 1) {
 32  
         // file.mkdirs();
 33  
         // }
 34  
         // }
 35  
 
 36  0
         File xmlFile = new File(outputDir, changeLog + ".xml");
 37  0
         xmlFile.getParentFile().mkdirs();
 38  
 
 39  0
         FileOutputStream changeLogStream = new FileOutputStream(xmlFile, false);
 40  
         try {
 41  0
             StreamUtil.copy(stylesheet, changeLogStream);
 42  
         } finally {
 43  0
             changeLogStream.close();
 44  0
         }
 45  
 
 46  0
     }
 47  
 
 48  
 }