diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/ibm/ServerWizard2/Launcher.java | 199 | ||||
-rw-r--r-- | src/com/ibm/ServerWizard2/LibraryFile.java | 41 | ||||
-rw-r--r-- | src/com/ibm/ServerWizard2/LibraryManager.java | 301 | ||||
-rw-r--r-- | src/com/ibm/ServerWizard2/MainDialog.java | 13 | ||||
-rw-r--r-- | src/com/ibm/ServerWizard2/ServerWizard2.java | 39 | ||||
-rw-r--r-- | src/com/ibm/ServerWizard2/SystemModel.java | 3 | ||||
-rw-r--r-- | src/com/ibm/ServerWizard2/TargetWizardController.java | 29 |
7 files changed, 280 insertions, 345 deletions
diff --git a/src/com/ibm/ServerWizard2/Launcher.java b/src/com/ibm/ServerWizard2/Launcher.java new file mode 100644 index 0000000..92d5016 --- /dev/null +++ b/src/com/ibm/ServerWizard2/Launcher.java @@ -0,0 +1,199 @@ +package com.ibm.ServerWizard2; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Vector; +import java.util.logging.ConsoleHandler; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; + +public class Launcher { + + public static String RELEASE_URL = "https://github.com/open-power/serverwiz/releases/download/"; + public static String JAR_NAME = "serverwiz2"; + public final static Logger LOGGER = Logger.getLogger(Launcher.class.getName()); + + public Launcher() { + + } + public static void main(String[] args) { + String version = "latest"; + boolean forceUpdate=false; + boolean forceLocal=false; + for (int i=0;i<args.length;i++) { + if (args[i].equals("-v")) { + if (i==args.length-1) { + System.out.println("Must provide a version if -v option is used"); + System.exit(3); + } + version=args[i+1]; + System.out.println("FORCE UPDATE:"+version); + forceUpdate=true; + } + if (args[i].equals("-d")) { + forceLocal=true; + } + } + //Setup logger + LOGGER.setLevel(Level.CONFIG); + LOGGER.setUseParentHandlers(false); + ConsoleHandler logConsole = new ConsoleHandler(); + logConsole.setLevel(Level.CONFIG); + LOGGER.addHandler(logConsole); + MyLogFormatter formatter = new MyLogFormatter(); + logConsole.setFormatter(formatter); + + try { + FileHandler logFile = new FileHandler("serverwiz2_launcher.%u.%g.log",20000,2,true); + LOGGER.addHandler(logFile); + logFile.setFormatter(formatter); + logFile.setLevel(Level.CONFIG); + } catch (IOException e) { + System.err.println("Unable to create logfile"); + System.exit(3); + } + LOGGER.config("======================================================================"); + LOGGER.config("Retreiving ServerWiz..."); + + String jarName = getArchFilename("serverwiz2"); + LOGGER.info("JarName = "+jarName); + GithubFile jar = new GithubFile("open-power/serverwiz/",version,jarName,GithubFile.FileTypes.JAR,LOGGER); + + String versionCurrent="NONE"; + + if (!jar.localFileExists()) { + if (forceLocal) { + JOptionPane.showMessageDialog(null, "Download is disabled and\n"+jar.getLocalPath()+" doesn't exist", + "Error", JOptionPane.ERROR_MESSAGE); + } + forceUpdate=true; + } + if (!forceUpdate && !forceLocal) { + //returns empty string if no update required, otherwise returns current version + versionCurrent=GithubFile.isTimeForUpdateCheck(LOGGER); + } + if (forceLocal) { + LOGGER.info("Downloading is disabled"); + versionCurrent=""; + } + boolean updated=false; + if (!versionCurrent.isEmpty()) { + LOGGER.info("Current jar version: "+versionCurrent); + try { + if (jar.update()) { + version=jar.getVersion(); + LOGGER.info("Latest version: "+version); + if (!version.equals(versionCurrent)) { + boolean doUpdate=true; + if (!versionCurrent.equals("NONE")) { + int selection=JOptionPane.showConfirmDialog(null, + "There is a newer verison of ServerWiz2 ("+version+"). Would like like to download?", + "Confirm Update", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if (selection==JOptionPane.NO_OPTION) { + doUpdate=false; + GithubFile.updateSuccess(LOGGER, versionCurrent); + } + } + if (doUpdate) { + jar.download(); + updated=true; + GithubFile.updateSuccess(LOGGER, version); + } + } else { + //versions are same + GithubFile.updateSuccess(LOGGER, versionCurrent); + } + } + } catch(Exception e) { + GithubFile.removeUpdateFile(false); + LOGGER.severe(e.getMessage()); + JOptionPane.showMessageDialog(null, e.toString(), "Error", JOptionPane.ERROR_MESSAGE); + System.exit(3); + } + } + Vector<String> commandLine = new Vector<String>(); + commandLine.add("java"); + commandLine.add("-jar"); + commandLine.add(jar.getLocalPath()); + + for (String arg : args) { + commandLine.add(arg); + } + if (updated) { + commandLine.add("-v"); + commandLine.add(version); + } + run(commandLine); + LOGGER.info("Exiting..."); + } + public static void run(Vector<String> commandLine) { + String commandLineStr=""; + for (String c : commandLine) { + commandLineStr=commandLineStr+c+" "; + } + LOGGER.info("Running: "+commandLineStr); + + try { + final ProcessBuilder builder = new ProcessBuilder(commandLine).redirectErrorStream(true); + final Process process = builder.start(); + + new Thread(new Runnable() { + public void run() { + InputStreamReader in = new InputStreamReader(process.getInputStream()); + BufferedReader inb = new BufferedReader(in); + String thisLine; + try { + while ((thisLine = inb.readLine()) != null) { + LOGGER.info(thisLine); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + }).start(); + + //final int exitValue = process.waitFor(); + } catch (Exception e) { + e.printStackTrace(); + } + } + public static String getWorkingDir() { + // gets working directory whether running as jar or from eclipse + File f = new File("").getAbsoluteFile(); + String workingDir = f.getAbsolutePath() + System.getProperty("file.separator"); + return workingDir; + } + public static String getArchFilename(String prefix) { + return prefix + "_" + getOSName() + getArchName() + ".jar"; + } + + private static String getOSName() { + String osNameProperty = System.getProperty("os.name"); + if (osNameProperty == null) { + throw new RuntimeException("os.name property is not set"); + } else { + osNameProperty = osNameProperty.toLowerCase(); + } + if (osNameProperty.contains("win")) { + return "win"; + } else if (osNameProperty.contains("linux") || osNameProperty.contains("nix")) + { + return "linux"; + } else { + throw new RuntimeException("Unknown OS name: " + osNameProperty); + } + } + + private static String getArchName() { + String osArch = System.getProperty("os.arch"); + if (osArch != null && osArch.contains("64")) { + return "64"; + } else { + return "32"; + } + } + } diff --git a/src/com/ibm/ServerWizard2/LibraryFile.java b/src/com/ibm/ServerWizard2/LibraryFile.java deleted file mode 100644 index 95f69b8..0000000 --- a/src/com/ibm/ServerWizard2/LibraryFile.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.ibm.ServerWizard2; - -import java.io.File; -import java.net.URL; - -public class LibraryFile { - - private URL remoteFile; - private File localFile; - private String filename; - private FileTypes type; - - public enum FileTypes { - ATTRIBUTE_TYPE_XML, TARGET_TYPE_XML, TARGET_INSTANCES_XML, SCRIPT - } - - public void init(String url, String workingDir, FileTypes type) throws Exception { - remoteFile = new URL(url); - File fi = new File(getRemotePath()); - filename = fi.getName(); - this.type = type; - String subdir = "xml"; - if (type==FileTypes.SCRIPT) { - subdir="scripts"; - } - localFile=new File(workingDir+subdir+System.getProperty("file.separator")+filename); - } - - public String getRemotePath() { - return remoteFile.toString(); - } - public String getLocalPath() { - return localFile.getPath(); - } - public String getFilename() { - return localFile.getName(); - } - public FileTypes getType() { - return type; - } -} diff --git a/src/com/ibm/ServerWizard2/LibraryManager.java b/src/com/ibm/ServerWizard2/LibraryManager.java index e1ea512..78e2c41 100644 --- a/src/com/ibm/ServerWizard2/LibraryManager.java +++ b/src/com/ibm/ServerWizard2/LibraryManager.java @@ -1,298 +1,71 @@ package com.ibm.ServerWizard2; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.net.URL; -import java.net.URLConnection; -import java.util.Calendar; -import java.util.Vector; - -import javax.swing.ProgressMonitorInputStream; - import org.eclipse.jface.dialogs.MessageDialog; public class LibraryManager { - public String xmlDirectory = ""; - public String scriptDirectory = ""; - private Vector<LibraryFile> files = new Vector<LibraryFile>(); - - public enum UpdateStatus { - FILE_NOT_LOCAL, REMOTE_FILE_NEWER, NO_UPDATE_NEEDED, UNABLE_TO_DOWNLOAD, UPDATE_REQUIRED, UPDATE_RECOMMENDED - } - - public static String getWorkingDir() { - // gets working directory whether running as jar or from eclipse - File f = new File("").getAbsoluteFile(); - String workingDir = f.getAbsolutePath() + System.getProperty("file.separator"); - return workingDir; - } + private String processScript = ""; + private String processDirectory = ""; + public static String REPO = "open-power/serverwiz/"; + GithubFile files[] = new GithubFile[7]; public void loadModel(SystemModel model) throws Exception { - for (LibraryFile libFile : files) { - if (libFile.getType() == LibraryFile.FileTypes.ATTRIBUTE_TYPE_XML) { + for (GithubFile libFile : files) { + if (libFile.getType() == GithubFile.FileTypes.ATTRIBUTE_TYPE_XML) { model.loadAttributes(new XmlHandler(), libFile.getLocalPath()); } - if (libFile.getType() == LibraryFile.FileTypes.TARGET_TYPE_XML) { + if (libFile.getType() == GithubFile.FileTypes.TARGET_TYPE_XML) { model.loadTargetTypes(new XmlHandler(), libFile.getLocalPath()); } - if (libFile.getType() == LibraryFile.FileTypes.TARGET_INSTANCES_XML) { + if (libFile.getType() == GithubFile.FileTypes.TARGET_INSTANCES_XML) { model.loadTargetInstances(libFile.getLocalPath()); } } } - public void init() { - String workingDir = LibraryManager.getWorkingDir(); - try { - //String hbUrl = "https://raw.githubusercontent.com/open-power/hostboot/master/src/usr/targeting/common/xmltohb/"; - String swUrl = "https://raw.githubusercontent.com/open-power/serverwiz/master/"; + public void init(String version) { + files[0] = new GithubFile(REPO,version, + "attribute_types.xml",GithubFile.FileTypes.ATTRIBUTE_TYPE_XML,ServerWizard2.LOGGER); - LibraryFile f1 = new LibraryFile(); - f1.init(swUrl + "xml/attribute_types.xml", workingDir, - LibraryFile.FileTypes.ATTRIBUTE_TYPE_XML); - files.add(f1); + files[1] = new GithubFile(REPO,version, + "attribute_types_hb.xml",GithubFile.FileTypes.ATTRIBUTE_TYPE_XML,ServerWizard2.LOGGER); - LibraryFile f2 = new LibraryFile(); - f2.init(swUrl + "xml/attribute_types_hb.xml", workingDir, - LibraryFile.FileTypes.ATTRIBUTE_TYPE_XML); - files.add(f2); + files[2] = new GithubFile(REPO,version, + "attribute_types_mrw.xml",GithubFile.FileTypes.ATTRIBUTE_TYPE_XML,ServerWizard2.LOGGER); - LibraryFile f3 = new LibraryFile(); - f3.init(swUrl + "xml/attribute_types_mrw.xml", workingDir, - LibraryFile.FileTypes.ATTRIBUTE_TYPE_XML); - files.add(f3); + files[3] = new GithubFile(REPO,version, + "target_types_mrw.xml",GithubFile.FileTypes.TARGET_TYPE_XML,ServerWizard2.LOGGER); - LibraryFile f4 = new LibraryFile(); - f4.init(swUrl + "xml/target_types_mrw.xml", workingDir, - LibraryFile.FileTypes.TARGET_TYPE_XML); - files.add(f4); + files[4] = new GithubFile(REPO,version, + "target_instances_v3.xml",GithubFile.FileTypes.TARGET_INSTANCES_XML,ServerWizard2.LOGGER); - LibraryFile f5 = new LibraryFile(); - f5.init(swUrl + "xml/target_instances_v3.xml", workingDir, - LibraryFile.FileTypes.TARGET_INSTANCES_XML); - files.add(f5); + files[5] = new GithubFile(REPO,version, + "processMrw.pl",GithubFile.FileTypes.SCRIPT,ServerWizard2.LOGGER); - LibraryFile f7 = new LibraryFile(); - f7.init(swUrl + "scripts/processMrw.pl", workingDir, LibraryFile.FileTypes.SCRIPT); - files.add(f7); - - LibraryFile f8 = new LibraryFile(); - f8.init(swUrl + "scripts/Targets.pm", workingDir, LibraryFile.FileTypes.SCRIPT); - files.add(f8); - - } catch (Exception e) { - ServerWizard2.LOGGER.severe(e.getMessage()); - e.printStackTrace(); - System.exit(3); - } - // create xml subdir if doesn't exist - File dir = new File(workingDir + "xml"); - if (!dir.exists()) { - try { - dir.mkdir(); - } catch (SecurityException se) { - System.err.println("Unable to create directory: " + workingDir + "xml"); - } - } - // create scripts subdir if doesn't exist - File sdir = new File(workingDir + "scripts"); - if (!sdir.exists()) { - try { - sdir.mkdir(); - } catch (SecurityException se) { - System.err.println("Unable to create directory: " + workingDir + "scripts"); - } - } + files[6] = new GithubFile(REPO,version, + "Targets.pm",GithubFile.FileTypes.SCRIPT,ServerWizard2.LOGGER); + processScript = files[5].getLocalPath(); + processDirectory = files[5].getLocalDirectory(); } - - public boolean doUpdateCheck() { - String workingDir = LibraryManager.getWorkingDir(); - String updateFilename = workingDir + "serverwiz2.update"; - File updateFile = new File(updateFilename); - - Long currentTime = Calendar.getInstance().getTimeInMillis(); - Boolean doUpdate = true; - - if (updateFile.exists()) { - // check last update - // update check done once per week - Long updateTime = (long) 0; - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(updateFile)); - String t = reader.readLine(); - updateTime = Long.parseLong(t); - } catch (Exception e) { - ServerWizard2.LOGGER.severe("Error reading " + updateFilename + "\n" - + e.getMessage()); - } finally { - try { - // Close the writer regardless of what happens... - reader.close(); - } catch (Exception e) { - } - } - ServerWizard2.LOGGER.info("Current Time: " + String.valueOf(currentTime) - + "; Update Time: " + String.valueOf(updateTime)); - - long msPerDay = 86400*1000; - if ((currentTime - updateTime) < msPerDay*3) { - ServerWizard2.LOGGER.info("Update Check Not Needed"); - doUpdate = false; - } - } - if (doUpdate) { - ServerWizard2.LOGGER.info("Update Check Needed"); - BufferedWriter writer = null; - try { - writer = new BufferedWriter(new FileWriter(updateFile)); - writer.write(String.valueOf(currentTime)); - } catch (Exception e) { - ServerWizard2.LOGGER.severe("Error writing " + updateFilename + "\n" - + e.getMessage()); - } finally { - try { - // Close the writer regardless of what happens... - writer.close(); - } catch (Exception e) { - } - } - } - return doUpdate; + public String getProcessingScript() { + return this.processScript; + } + public String getProcessingDirectory() { + return this.processDirectory; } + /* * check if files exist yes- files exist, check if github is newer if yes, * then ask user if wishes to update if no or can't download, then continue * no- files don't exist; download if can't download, then exit */ - public void update() { - // init(); - Boolean fileNotLocal = false; - Boolean remoteFileNewer = false; - Boolean doDownload = false; - for (LibraryFile libFile : files) { - UpdateStatus status = getUpdateStatus(libFile); - if (status == UpdateStatus.FILE_NOT_LOCAL) { - fileNotLocal = true; - } - if (status == UpdateStatus.REMOTE_FILE_NEWER) { - remoteFileNewer = true; - } - } - if (remoteFileNewer) { - doDownload = MessageDialog.openConfirm(null, "Confirm update", - "Library out of date. Do you wish to download latest library"); - } - // do download - if (fileNotLocal || doDownload) { - int fileNum = 0; - for (LibraryFile libFile : files) { - downloadXML(libFile, fileNum); - fileNum++; - } - } - } - - public UpdateStatus getUpdateStatus(LibraryFile f) { - ServerWizard2.LOGGER.info("Checking status: " + f.getRemotePath()); - - // Check local file size - File file = new File(f.getLocalPath()); - double localFileSize = 0; - if (file.exists()) { - localFileSize = file.length(); - } else { - return UpdateStatus.FILE_NOT_LOCAL; - } - UpdateStatus r = UpdateStatus.NO_UPDATE_NEEDED; - try { - URL u; - u = new URL(f.getRemotePath()); - URLConnection connection = u.openConnection(); - connection.setConnectTimeout(5000); - connection.connect(); - int remoteFileSize = connection.getContentLength(); - - if ((double) remoteFileSize == localFileSize) { - // no update needed - ServerWizard2.LOGGER.info("No update needed for " + f.getLocalPath() + "."); - r = UpdateStatus.NO_UPDATE_NEEDED; - } else { - // update needed - ServerWizard2.LOGGER.info("Update needed for " + f.getLocalPath() + "."); - r = UpdateStatus.REMOTE_FILE_NEWER; - } - connection.getInputStream().close(); - } catch (Exception e) { - // unable to download - ServerWizard2.LOGGER.info("Unable to connect to " + f.getFilename() - + ". Using local version."); - r = UpdateStatus.UNABLE_TO_DOWNLOAD; - } - return r; - } - - public void downloadXML(LibraryFile f, int fileNum) { - // Check local file size - File file = new File(f.getLocalPath()); - double localFileSize = 0; - if (file.exists()) { - localFileSize = file.length(); - } - ProgressMonitorInputStream pim = null; - try { - URL u; - u = new URL(f.getRemotePath()); - URLConnection connection = u.openConnection(); - connection.setConnectTimeout(5000); - connection.setReadTimeout(15000); - connection.connect(); - int remoteFileSize = connection.getContentLength(); - if ((double) remoteFileSize == localFileSize) { - ServerWizard2.LOGGER.info(f.getFilename() - + " - Not downloading, files are same size"); - } else { - ServerWizard2.LOGGER.info("Downloading: " + f.getRemotePath() + " (" - + remoteFileSize + ")"); - pim = new ProgressMonitorInputStream(null, "Downloading " + (fileNum + 1) + " of " - + files.size() + " library files: " + f.getFilename(), - connection.getInputStream()); - pim.getProgressMonitor().setMaximum(remoteFileSize); - pim.getProgressMonitor().setMillisToDecideToPopup(500); - Writer out = new BufferedWriter(new FileWriter(f.getLocalPath())); - int j; - while ((j = pim.read()) != -1) { - out.write((char) j); - } - out.close(); - } - connection.getInputStream().close(); - } catch (Exception e) { - if (pim != null) { - try { - pim.close(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - if (localFileSize == 0) { - ServerWizard2.LOGGER.severe("Unable to download " + f.getFilename() - + " and local version doesn't exist. Exiting..."); - MessageDialog.openError(null, "Unable to Download", - "Unable to download " + f.getFilename() - + " and local version doesn't exist. Exiting..."); - System.exit(3); - } else { - ServerWizard2.LOGGER.info("Unable to download " + f.getFilename() - + ". Using local version."); + public void update(String version) throws Exception { + if (!version.isEmpty()) { + ServerWizard2.LOGGER.info("Updating XML lib to version: "+version+"\n"); + for (GithubFile libFile : files) { + libFile.update(); + libFile.download(); } } } diff --git a/src/com/ibm/ServerWizard2/MainDialog.java b/src/com/ibm/ServerWizard2/MainDialog.java index 7234b20..30e30d8 100644 --- a/src/com/ibm/ServerWizard2/MainDialog.java +++ b/src/com/ibm/ServerWizard2/MainDialog.java @@ -462,18 +462,7 @@ public class MainDialog extends Dialog { btnForceUpdate.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - String workingDir = LibraryManager.getWorkingDir(); - String updateFilename = workingDir + "serverwiz2.update"; - File updateFile = new File(updateFilename); - if (updateFile.delete()) { - MessageDialog.openInformation(null, "Force Update", - "Update will occur upon restart..."); - ServerWizard2.LOGGER.info("Removing update file to force update upon restart."); - } else { - MessageDialog.openError(null, "Error", - "Unable to delete serverwiz2.update. Try deleting manually."); - ServerWizard2.LOGGER.severe("Unable to delete serverwiz2.update."); - } + GithubFile.removeUpdateFile(true); } }); diff --git a/src/com/ibm/ServerWizard2/ServerWizard2.java b/src/com/ibm/ServerWizard2/ServerWizard2.java index 136d3fc..a3e22b2 100644 --- a/src/com/ibm/ServerWizard2/ServerWizard2.java +++ b/src/com/ibm/ServerWizard2/ServerWizard2.java @@ -9,11 +9,36 @@ public class ServerWizard2 { /** * @param args */ - - public static final String VERSION = "2.1.0"; public final static Logger LOGGER = Logger.getLogger(ServerWizard2.class.getName()); - + public static void printUsage() { + System.out.println("Usage:"); + System.out.println(" -i [xml filename]"); + System.out.println(" -v [update to version]"); + System.out.println(" -h = print this usage"); + } public static void main(String[] args) { + String inputFilename=""; + String version=""; + for (int i=0;i<args.length;i++) { + if (args[i].equals("-i")) { + if (i==args.length-1) { + printUsage(); + System.exit(3); + } + inputFilename=args[i+1]; + } + if (args[i].equals("-v")) { + if (i==args.length-1) { + printUsage(); + System.exit(3); + } + version=args[i+1]; + } + if (args[i].equals("-h")) { + printUsage(); + System.exit(0); + } + } LOGGER.setLevel(Level.CONFIG); LOGGER.setUseParentHandlers(false); ConsoleHandler logConsole = new ConsoleHandler(); @@ -32,16 +57,16 @@ public class ServerWizard2 { System.exit(3); } LOGGER.config("======================================================================"); - LOGGER.config("ServerWiz2 Starting. VERSION: "+VERSION); + LOGGER.config("ServerWiz2 Starting..."); TargetWizardController tc = new TargetWizardController(); SystemModel systemModel = new SystemModel(); MainDialog view = new MainDialog(null); tc.setView(view); - tc.setModel(systemModel); + tc.setModel(systemModel,version); systemModel.addPropertyChangeListener(tc); view.setController(tc); - if (args.length>0) { - view.mrwFilename=args[0]; + if (!inputFilename.isEmpty()) { + view.mrwFilename=inputFilename; } view.open(); //d.dispose(); diff --git a/src/com/ibm/ServerWizard2/SystemModel.java b/src/com/ibm/ServerWizard2/SystemModel.java index d4c6cf4..0ad06d3 100644 --- a/src/com/ibm/ServerWizard2/SystemModel.java +++ b/src/com/ibm/ServerWizard2/SystemModel.java @@ -6,7 +6,6 @@ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -432,7 +431,6 @@ public class SystemModel { public void writeXML(String filename) throws Exception { Writer out = new BufferedWriter(new FileWriter(filename)); out.write("<targetInstances>\n"); - out.write("<version>" + ServerWizard2.VERSION + "</version>\n"); this.writeEnumeration(out); this.writeGlobalSettings(out); HashMap<String, Boolean> targetWritten = new HashMap<String, Boolean>(); @@ -552,6 +550,7 @@ public class SystemModel { } public void loadTargetInstances(String filename) throws Exception { + ServerWizard2.LOGGER.info("Loading Instances: " + filename); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setErrorHandler(new XmlHandler()); diff --git a/src/com/ibm/ServerWizard2/TargetWizardController.java b/src/com/ibm/ServerWizard2/TargetWizardController.java index 78afa9c..95edeff 100644 --- a/src/com/ibm/ServerWizard2/TargetWizardController.java +++ b/src/com/ibm/ServerWizard2/TargetWizardController.java @@ -26,26 +26,21 @@ import org.w3c.dom.NodeList; public class TargetWizardController implements PropertyChangeListener { SystemModel model; MainDialog view; + LibraryManager xmlLib = new LibraryManager(); + private String version=""; public TargetWizardController() { } public void init() { - LibraryManager xmlLib = new LibraryManager(); - xmlLib.init(); - if (xmlLib.doUpdateCheck()) { - xmlLib.update(); - } + xmlLib.init(version); try { + xmlLib.update(version); xmlLib.loadModel(model); this.initModel(); - } catch (Exception e) { - String btns[] = { "Close" }; - ServerWizard2.LOGGER.severe(e.getMessage()); - MessageDialog errDlg = new MessageDialog(view.getShell(), "Error", - null, e.getMessage(), MessageDialog.ERROR, btns, 0); - errDlg.open(); + ServerWizard2.LOGGER.severe(e.toString()); + MessageDialog.openError(null, "Error",e.toString()); e.printStackTrace(); System.exit(4); } @@ -124,8 +119,9 @@ public class TargetWizardController implements PropertyChangeListener { this.view = view; } - public void setModel(SystemModel model) { + public void setModel(SystemModel model,String version) { this.model = model; + this.version=version; } public Vector<String> getEnums(String e) { @@ -256,14 +252,11 @@ public class TargetWizardController implements PropertyChangeListener { return model.getBusTypes(); } public void runChecks(String filename) { - String includePath = LibraryManager.getWorkingDir()+"scripts"; - String script = LibraryManager.getWorkingDir()+"scripts"+System.getProperty("file.separator")+"processMrw.pl"; - String commandLine[] = { "perl", "-I", - includePath, - script, + xmlLib.getProcessingDirectory(), + xmlLib.getProcessingScript(), "-x", filename, "-f" @@ -273,8 +266,6 @@ public class TargetWizardController implements PropertyChangeListener { commandLineStr=commandLineStr+commandLine[i]+" "; } ServerWizard2.LOGGER.info("Running: "+commandLineStr); - String line; - String msg=""; try { final ProcessBuilder builder = new ProcessBuilder(commandLine).redirectErrorStream(true); |