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

Paul Spencer pspencer at dmsolutions.ca
Mon Nov 9 13:55:12 EST 2009


I think Zak is working on a more generic solution here.  The code here  
should not have affected MapServer, it should only be invoked when the  
application definition is being loaded from a URL that starts with  
Library:// which indicates it is stored in a MapGuide repository.  The  
original issue that was being solved was how to automatically add  
commercial mapping APIs to an application - this required knowing if  
any of them are referenced in an Application Definition which required  
pre-requesting the ApplicationDefinition - which, when stored in a  
MapGuide repository issues an authentication challenge unless using a  
pre-established session - which is what this commit was about.

Zak is going to try refactoring this to work generically for MapServer  
and MapGuide by moving the code so that it runs at a slightly later  
time in initialization.

Cheers

Paul

On 2009-11-09, at 1:49 PM, Nolte, Tim wrote:

> 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
>
> _______________________________________________
> fusion-dev mailing list
> fusion-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-dev


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://research.dmsolutions.ca/



More information about the fusion-dev mailing list