Mercurial > mxd2map
changeset 103:163d474165b0
Added check for ArcGISDesktop environment.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 14:04:03 +0200 |
parents | 3ca2ec55fb3b |
children | dca5f208500f 104af51a4717 |
files | ChangeLog src/java/de/intevation/mxd/ArcGISInitializer.java src/java/de/intevation/mxd/reader/MXDReader.java |
diffstat | 3 files changed, 44 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Jun 10 11:35:41 2011 +0200 +++ b/ChangeLog Fri Jun 10 14:04:03 2011 +0200 @@ -1,3 +1,11 @@ +2011-06-10 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/ArcGISInitializer.java: + Check for ArcGISDesktop environment and added logging. + + * src/java/de/intevation/mxd/reader/MXDReader.java: + Check the initializer return value. + 2011-06-10 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/writer/MapScriptWriter.java:
--- a/src/java/de/intevation/mxd/ArcGISInitializer.java Fri Jun 10 11:35:41 2011 +0200 +++ b/src/java/de/intevation/mxd/ArcGISInitializer.java Fri Jun 10 14:04:03 2011 +0200 @@ -1,6 +1,9 @@ package de.intevation.mxd; import java.io.IOException; +import java.io.File; + +import org.apache.log4j.Logger; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; @@ -15,6 +18,11 @@ public class ArcGISInitializer { /** + * The Logger. + */ + private static final Logger logger = Logger.getLogger(ArcGISInitializer.class); + + /** * Private member. */ private AoInitialize aoInit; @@ -26,17 +34,32 @@ */ public boolean initArcGIS () throws IOException { + logger.debug("initArcGIS()"); EngineInitializer.initializeEngine(); aoInit = new AoInitialize(); engineInstallDir = System.getenv("AGSENGINEJAVA"); + File installDir = new File(engineInstallDir); + if(!installDir.exists()) { + engineInstallDir = System.getenv("AGSDESKTOPJAVA"); + installDir = new File(engineInstallDir); + if(!installDir.exists()) { + logger.error("Could not find ArcGIS Environment. \n" + + "AGSENGINEJAVA or AGSDESKTOPJAVA not set."); + return false; + } + } + else { + return true; + } return true; } /** * Init ArcGIS License. */ - public void initArcGISLicenses() + public boolean initArcGISLicenses() throws IOException { + logger.debug("initArcGISLicenses()"); if(aoInit.isProductCodeAvailable (esriLicenseProductCode.esriLicenseProductCodeEngine) == esriLicenseStatus.esriLicenseAvailable) { @@ -50,11 +73,13 @@ (esriLicenseProductCode.esriLicenseProductCodeArcView); } else { - System.err.println("Engine Runtime or ArcView" + - " license not initialized."); - System.err.println("Exiting application."); - System.exit(-1); + logger.error("Engine Runtime or ArcView" + + " license not initialized.\n" + + "Please install an ArcGIS product and set the" + + " PATH-variable correctly."); + return false; } + return true; } /**
--- a/src/java/de/intevation/mxd/reader/MXDReader.java Fri Jun 10 11:35:41 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MXDReader.java Fri Jun 10 14:04:03 2011 +0200 @@ -55,8 +55,12 @@ public boolean init() throws IOException { logger.debug("init()"); - initializer.initArcGIS(); - initializer.initArcGISLicenses(); + if(!initializer.initArcGIS()) { + return false; + } + if(!initializer.initArcGISLicenses()) { + return false; + } return true; }