Coverage Report - com.aurea.maven.plugins.sonic.esb.AbstractESBMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractESBMojo
0%
0/34
0%
0/8
3.5
 
 1  
 package com.aurea.maven.plugins.sonic.esb;
 2  
 
 3  
 import java.io.File;
 4  
 import java.util.HashSet;
 5  
 import java.util.List;
 6  
 
 7  
 import org.codehaus.plexus.util.FileUtils;
 8  
 
 9  
 import com.aurea.maven.plugins.sonic.AbstractSonicMojo;
 10  
 import com.aurea.maven.plugins.sonic.utils.FileUtilities;
 11  
 import com.aurea.maven.plugins.sonic.utils.ProjectAnalyzer;
 12  
 import com.progress.sonic.utilities.esb.admin.XarAnalyzer;
 13  
 import com.sonicsw.deploy.IArtifact;
 14  
 
 15  0
 public abstract class AbstractESBMojo extends AbstractSonicMojo {
 16  
   
 17  
 
 18  
   /**
 19  
    * @parameter default-value="deploy/generated-src/xar"
 20  
    */
 21  0
   protected final File deployGenSrcDir     = null;
 22  
   
 23  
   /**
 24  
    * @parameter default-value="deploy/generated-src/test-xar"
 25  
    */
 26  0
   protected final File testDeployGenSrcDir = null;
 27  
   
 28  
   /**
 29  
    * the target directory for the generated testing processes with Stub references.
 30  
    * 
 31  
    * @parameter default-value="target/generated-test-sources/sonicesb"
 32  
    */
 33  
   protected File        targetGenTestSrcDir;
 34  
   
 35  
   /**
 36  
    * the target directory for the buggy workaround on the temp dir issue when analyzin xar files.
 37  
    * 
 38  
    * @parameter default-value="target/tmp/unzipdir"
 39  
    */
 40  
   protected File        xarUnzipDir;
 41  
   
 42  
   /**
 43  
    * @return list of processes found in the dependent artifacts
 44  
    */
 45  
   protected HashSet<String> getDependencyProcessNames() {
 46  
 
 47  0
     HashSet<String> hs = new HashSet<String>();
 48  
     
 49  
     // get a list of dependent .xar files
 50  0
     String[] xarFiles = FileUtilities.getFileList(getDependencyDirectory(), "**/*.xar", null);
 51  
     
 52  0
     for (String currXarFile : xarFiles) {
 53  0
       File currXarFullPath = new File(getDependencyDirectory(), currXarFile);
 54  0
       XarAnalyzer xa = new XarAnalyzer(currXarFullPath);
 55  0
       List<IArtifact> aa = xa.getAllArtifacts();
 56  
       
 57  0
       getLog().debug("    Searching xar: " + currXarFullPath.getAbsolutePath());
 58  0
       getLog().debug("    Found artifacts: " + aa);
 59  
       
 60  0
       for (IArtifact artifact : aa) {
 61  0
         getLog().debug("      getName: " + artifact.getName());
 62  0
         getLog().debug("      getPath: " + artifact.getPath());
 63  0
         getLog().debug("      getRootDirectory: " + artifact.getRootDirectory());
 64  0
         if ("Processes".equals(artifact.getRootDirectory())) {
 65  0
           hs.add(artifact.getName());
 66  
          // getLog().error("Found a Process: " + artifact.getName());
 67  
         }
 68  0
       }
 69  
     }
 70  
     
 71  0
     return hs;
 72  
   }
 73  
   
 74  
   /**
 75  
    * copies process source files from one location to another, replacing the .esbp extension with .xml in the process.
 76  
    * 
 77  
    * @param _srcDir
 78  
    *          source directory of the copy process. All sub-directories will be automatically included.
 79  
    * @param _targetDir
 80  
    *          target directory of the copy process. The directory structure will will flattened, so all process files
 81  
    *          will be located directly in this directory.
 82  
    */
 83  
   protected void copyProcessFilesReplacingEsbpWithXml(final String _srcDir, final String _targetDir) {
 84  
 
 85  0
     getLog().info("Copying process files from " + _srcDir + " to " + _targetDir);
 86  
     
 87  0
     new File(_targetDir, "ESB").mkdirs();
 88  0
     new File(_targetDir, "SonicFS").mkdirs();
 89  
     
 90  0
     getLog().debug("TBO: Directories Created: ESB + SonicFS");
 91  
     
 92  0
     getLog().debug("TBO: Source-Directory: " + _srcDir);
 93  
     
 94  0
     for (File processFile : ProjectAnalyzer.getProcessSourceFiles(_srcDir)) {
 95  0
       getLog().debug("TBO: ProcessFile: " + processFile);
 96  
       try {
 97  0
         getLog().info("  Found process file : " + processFile);
 98  0
         File processTargetFile = new File(_targetDir, "ESB/Processes/"
 99  
           + ProjectAnalyzer.getProcessNameFromFile(processFile) + ".xml");
 100  0
         processTargetFile.getParentFile().mkdirs();
 101  0
         FileUtils.copyFile(processFile, processTargetFile);
 102  0
       } catch (Exception e) {
 103  0
         getLog().warn("  Error copying process file :" + processFile + e.getMessage());
 104  0
       }
 105  
     }
 106  
     
 107  0
   }
 108  
 }