[fusion-dev] RE: [fusion-commits] r1966 - trunk/lib

Nolte, Tim Tim.Nolte at ipcswirelessinc.com
Mon Nov 9 13:49:08 EST 2009


FYI, this bug fix breaks in MapServer installs. I see that it has been
hard-coded to 'layers/MapGuide/php/CreateSession.php' which isn't valid
for MapServer. Seems like somehow we need a more generic way for
creating the session. I'm not familiar with how MapGuide works with
sessions but for the most part we are looking at PHP sessions which
should be pretty standard. What are the thoughts here?

- Tim

----
Timothy J Nolte - tnolte at ilpcs.com
Network Planning Engineer

iPCS Wireless, Inc.
4717 Broadmoor Ave, Suite G
Kentwood, MI 49512

Office: 616-656-5163
PCS:    616-706-2438
Fax:    616-554-6484
Web: www.ipcswirelessinc.com
-----Original Message-----
From: fusion-commits-bounces at lists.osgeo.org
[mailto:fusion-commits-bounces at lists.osgeo.org] On Behalf Of
svn_fusion at osgeo.org
Sent: Sunday, November 08, 2009 10:16 PM
To: fusion-commits at lists.osgeo.org
Subject: [fusion-commits] r1966 - trunk/lib

Author: liuar
Date: 2009-11-08 22:15:36 -0500 (Sun, 08 Nov 2009)
New Revision: 1966

Modified:
   trunk/lib/fusion.js
Log:
Fixed http://trac.osgeo.org/fusion/ticket/300
pre-create a session to avoid the unauthorized dialog, which is a defect
of safari and chrome. 

Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js	2009-11-06 16:05:28 UTC (rev 1965)
+++ trunk/lib/fusion.js	2009-11-09 03:15:36 UTC (rev 1966)
@@ -227,7 +227,8 @@
         initialize : function(options) {
             options = options || {};
             var sessionIdParam = this.getQueryParam('Session');
-            this.sessionId = sessionIdParam || (options.sessionId ||
null);
+			// Override the pre-created sessionId by user
specified sessionId(if exist)
+			this.sessionId = sessionIdParam ||
options.sessionId || this.sessionId;
         
             if (options.applicationDefinitionURL) {
                 this.applicationDefinitionURL =
options.applicationDefinitionURL;            
@@ -252,11 +253,11 @@
             this.sScriptLang = "";
 
             /*
-                     * if the application has been loaded from the same
host as
-                     * fusion is installed in, then technically we
don't need to
-                     * use the redirect script because we conform to
the 
-                     * Same Origin Policy for XmlHttpRequest to work.
-                     */
+			 * if the application has been loaded from the
same host as
+			 * fusion is installed in, then technically we
don't need to
+			 * use the redirect script because we conform to
the 
+			 * Same Origin Policy for XmlHttpRequest to
work.
+			 */
             var test =
window.location.protocol+'//'+window.location.host;
             var configUrl = 'config.json';
             //if (this.fusionURL.indexOf(test,0) == 0) {
@@ -1147,7 +1148,7 @@
     
         var fusionURL = r + Fusion.getFusionURL() + configUrl; 
     
-        var xhr = new XMLHttpRequest(); 
+        var xhr = getXmlHttpRequest(); 
         xhr.open("GET", fusionURL, false); 
         xhr.send(null); 
     
@@ -1174,7 +1175,7 @@
         } 
         Fusion.configuration.mapguide.mapAgentUrl = s +
'mapagent/mapagent.fcgi'; 
         return Fusion.configuration.mapguide.mapAgentUrl; 
-    } 
+    }
     
     var addElement = function(element) { 
         if (!element) { 
@@ -1188,29 +1189,50 @@
         } 
     
         document.writeln('<script src="' + src + '"><\/script>'); 
-    } 
+    }
 
-	if(navigator.userAgent.indexOf("MSIE")>0 ||
navigator.userAgent.indexOf("Firefox")>0){
-		var appDefUrl =
Fusion.getQueryParam('ApplicationDefinition'); 
-		if(appDefUrl){
-			
-			var xhr = new XMLHttpRequest(); 
-			var mapAgentUrl = getAgentUrl(); 
-			xhr.open("GET", mapAgentUrl +
"?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGu
ide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml", false); 
-			xhr.send(null); 
-			var appDefXML = xhr.responseXML.documentElement;

-			
-			if(appDefXML){
-				var googleElement =
appDefXML.getElementsByTagName("GoogleScript")[0]; 
-				var yahooElement =
appDefXML.getElementsByTagName("YahooScript")[0]; 
-				var veElement =
appDefXML.getElementsByTagName("VirtualEarthScript")[0]; 
+	var getXmlHttpRequest = function(){	
+        try { return new XMLHttpRequest(); }
+		catch (e) { try { return new
ActiveXObject('Msxml2.XMLHTTP'); } 
+		catch (e) { try { return new
ActiveXObject('Microsoft.XMLHTTP'); }
+		catch (e) { return  null; }}}
+	}
+	
+	/**
+	 * Function: createSessionId
+	 *
+	 * Pre-create a session to avoid the 401 Unauthorized dialog
+	 *
+	 */
+	var createSessionId = function(){
+		var xhr = getXmlHttpRequest();
+		xhr.open("GET",
Fusion.fusionURL+"layers/MapGuide/php/CreateSession.php",false);
+		xhr.send(null); 
+		var o;
+		eval('o='+xhr.responseText);
+		Fusion.sessionId = o.sessionId;
+	}
+	
+	createSessionId();	
+	var appDefUrl = Fusion.getQueryParam('ApplicationDefinition'); 
+	if(appDefUrl){
+		var xhr = new getXmlHttpRequest(); 
+		var mapAgentUrl = getAgentUrl(); 
+		xhr.open("GET", mapAgentUrl +
"?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGu
ide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml&SESSION="+
Fusion.sessionId, false); 
+		xhr.send(null); 
+		var appDefXML = xhr.responseXML.documentElement; 
+		
+		if(appDefXML){
+			var googleElement =
appDefXML.getElementsByTagName("GoogleScript")[0]; 
+			var yahooElement =
appDefXML.getElementsByTagName("YahooScript")[0]; 
+			var veElement =
appDefXML.getElementsByTagName("VirtualEarthScript")[0]; 
 
-				addElement(googleElement); 
-				addElement(yahooElement); 
-				addElement(veElement);
-			}
+			addElement(googleElement); 
+			addElement(yahooElement); 
+			addElement(veElement);
 		}
 	}
+	
     
 })();
 

_______________________________________________
fusion-commits mailing list
fusion-commits at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fusion-commits



More information about the fusion-dev mailing list