| 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 | |
|
| 20 | |
|
| 21 | 0 | protected final File deployGenSrcDir = null; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | 0 | protected final File testDeployGenSrcDir = null; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
protected File targetGenTestSrcDir; |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
protected File xarUnzipDir; |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
protected HashSet<String> getDependencyProcessNames() { |
| 46 | |
|
| 47 | 0 | HashSet<String> hs = new HashSet<String>(); |
| 48 | |
|
| 49 | |
|
| 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 | |
|
| 67 | |
} |
| 68 | 0 | } |
| 69 | |
} |
| 70 | |
|
| 71 | 0 | return hs; |
| 72 | |
} |
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 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 | |
} |