changeset 198:6db0677a6450

Merged with Stephans commits.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 20 Jul 2011 18:01:32 +0200
parents cdbf2f2dca35 (diff) 123ebb293f3a (current diff)
children 877be7484245
files ChangeLog
diffstat 2 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jul 20 17:02:50 2011 +0200
+++ b/ChangeLog	Wed Jul 20 18:01:32 2011 +0200
@@ -1,3 +1,16 @@
+2011-07-20  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/writer/MapScriptWriter.java:
+	  Check for database connectio user parameter for SDE connections.
+	  Set default "sde" if attribute is missing.
+
+2011-07-20  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/writer/MapScriptWriter.java:
+	  If a SDE datasource and a join table is used, check if the join
+	  table contains a "." to verify there could be a database schema.
+	  If no "." is found, abort writing the mapfile.
+
 2011-07-20  Stephan Holl  <stephan.holl@intevation.de>
 
 	* website/.htaccess,
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Jul 20 17:02:50 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Jul 20 18:01:32 2011 +0200
@@ -111,13 +111,15 @@
         //Write the map attributes.
         writeMap();
         //Write the layers.
-        writeLayer();
+	boolean ret = writeLayer();
         //Save the map.
-        mapObj cloneMap = map.cloneMap();
-
-        cloneMap.save(mapFilename);
-        logger.info("Mapfile created: " + mapFilename);
-        return true;
+	if (ret) {
+            mapObj cloneMap = map.cloneMap();
+            cloneMap.save(mapFilename);
+            logger.info("Mapfile created: " + mapFilename);
+            return true;
+	}
+	return false;
     }
 
     /**
@@ -180,7 +182,7 @@
     /**
      * Create layer objects and set the attributes.
      */
-    private void writeLayer() {
+    private boolean writeLayer() {
         logger.debug("writeLayer()");
         Element mapNode = (Element)XMLUtils.xpath(
             root,
@@ -266,10 +268,16 @@
                 layer.setConnectionType(
                 MS_CONNECTION_TYPE.MS_PLUGIN.swigValue(),
                 MS_BINDIR + "/ms/plugins/msplugin_sde_93.dll");
+		String database_auth = layerElement.getAttribute("database");
+		if (database_auth.equals("") || database_auth == null) {
+		    logger.warn("Could not set the database connection user." +
+				" Setting to \"sde\" as default.");
+		    database_auth = "sde";
+		}
                 layer.setConnection(
                 layerElement.getAttribute("server") + "," +
                     "port:" + layerElement.getAttribute("instance") + "," +
-                layerElement.getAttribute("database") + "," +
+                database_auth + "," +
                 layerElement.getAttribute("user") + ",<PASSWORD>");
                 layer.setData(
                     layerElement.getAttribute("data_source") +
@@ -278,6 +286,13 @@
                 layer.setProcessing("CLOSE_CONNECTION=defer");
                 layer.setProcessing("ATTRIBUTE_QUALIFIED=TRUE");
                 if(layerElement.hasAttribute("join_table")) {
+		    String join = layerElement.getAttribute("join_table");
+		    if (join.indexOf(".") <= 0) {
+		    	logger.warn ("Incomplete join table in layer " +
+				     layerElement.getAttribute("name") +
+				     ". Aborting.");
+			return false;
+		    }
                     layer.setProcessing(
                         "JOINTABLE=" +
                     layerElement.getAttribute("join_table"));
@@ -318,6 +333,7 @@
             //Write classes.
             writeClass(layer, layerElement);
         }
+	return true;
     }
 
     /**
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)