[mapguide-users] Modify layout with anonymous user

euskalmap ziburudebian at free.fr
Wed Jul 8 06:15:05 EDT 2009


Hi,
Thanks very much.
All is ok; we can close this post.
bye

Kenneth Skovhede, GEOGRAF A/S wrote:
> 
> When you redirect, you must use the tempLayoutId variable:
> 
> String ag_NewUrl = "/mapguide/mapviewerajax/?WEBLAYOUT=" +
> Server.UrlEncode(tempLayoutId) + "&SESSION=" + 
> Server.UrlEncode(ag_sessionId);
> 
> 
> Otherwise you will still use the non-modified version.
> 
> Regards, Kenneth Skovhede, GEOGRAF A/S
> 
> 
> 
> euskalmap skrev:
>> Hi kenneth,
>>
>> Thanks a lot for you code; i try it but it do not run (
>> http://patxi.mayol.free.fr/public/ag_default_maestro.aspx here is my code
>> )
>> : the mapdefinition of layout is not change !
>> have you an idea ?
>>
>>
>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>   
>>> Something like this would do it with MaestroAPI (untested):
>>>
>>>             MaestroAPI.ServerConnectionI con; //Needs initialization
>>>
>>>             //Read the current resources
>>>             MaestroAPI.WebLayout layout =
>>> con.GetWebLayout("???.WebLayout");
>>>             MaestroAPI.MapDefinition map = 
>>> con.GetMapDefinition(layout.Map.ResourceId);
>>>
>>>             //Create the temp layer
>>>             MaestroAPI.MapLayerType layer = new 
>>> OSGeo.MapGuide.MaestroAPI.MapLayerType();
>>>             layer.ResourceId = "???.LayerDefinition";
>>>             layer.Name = "Temporary layer";
>>>
>>>             //Add it to the map
>>>             map.Layers.Add(layer);
>>>
>>>             //Generate a session based temporary id (will become 
>>> Session:<sessionid>//Random Map Identifier.MapDefinition)
>>>             string tempMapId = new MaestroAPI.ResourceIdentifier("Random 
>>> Map Identifier", MaestroAPI.ResourceTypes.MapDefinition, con.SessionID);
>>>            
>>>             //Save the modified map in the session repo
>>>             con.SaveResourceAs(map, tempMapId);
>>>
>>>             //Modify the layout to point at the temp map
>>>             layout.Map.ResourceId = tempMapId;
>>>
>>>             //Generate a session based temporary id, and save the 
>>> modified layout (will become Session:<sessionid>//Random WebLayot 
>>> Identifier.WebLayout)
>>>             string tempLayoutId = new 
>>> MaestroAPI.ResourceIdentifier("Random WebLayout Identifier", 
>>> MaestroAPI.ResourceTypes.WebLayout, con.SessionID);
>>>             con.SaveResourceAs(layout, tempLayoutId);
>>>
>>>             //Open the viewer with the modified weblayout, that uses the 
>>> modified map
>>>             Response.Redirect("/mapguide/mapviewerajax/?session=" + 
>>> Server.UrlEncode(con.SessionID) + "&layout=" + 
>>> Server.UrlEncode(tempLayoutId));
>>>
>>> You can rewrite the property access with the corresponding xml changes,
>>> and the GetResource/SaveResource with the corresponding function calls 
>>> to the
>>> MapGuide API, if you don't want to use Maestro.
>>>
>>> Instead of the "Random ... Identifier" strings, you should use 
>>> Guid.NewGuid().ToString().
>>>
>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>
>>>
>>>
>>> euskalmap skrev:
>>>     
>>>> Hi,
>>>> thanks for your information but how do you make toYou have to create a
>>>> temporary WebLayout AND a temporary MapDefinition and then make the
>>>> temporary WebLayout point to the temporary MapDefinition.
>>>> Have you an example of code?
>>>> Thnaks
>>>>
>>>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>>>   
>>>>       
>>>>> If you save to "Library://" the data will be modified permanently.
>>>>> Normally the "Anonymous" user is not allowed to save to "Library://".
>>>>>
>>>>> If you save to "Session:<sessionid>//" the changes will only be
>>>>> visible
>>>>> to
>>>>> the current user. You must take care not to mix sessionid's.
>>>>>
>>>>> I think you are trying to use the WebLayout from Library, that will
>>>>> not 
>>>>> work.
>>>>> You have to create a temporary WebLayout AND a temporary
>>>>> MapDefinition.
>>>>>
>>>>> Then make the temporary WebLayout point to the temporary
>>>>> MapDefinition.
>>>>> (I think your code does this)
>>>>> Then save both WebLayout and MapDefinition in "Session:<sessionid>//".
>>>>> When you redirect, you should point to the temporary WebLayout.
>>>>> As you pass in the sessionId, the viewer should be able to read it 
>>>>> correctly.
>>>>>
>>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> euskalmap skrev:
>>>>>     
>>>>>         
>>>>>> Hi,
>>>>>> I refresh my post! If you have an idea !!!
>>>>>>
>>>>>> Sorry, I wanted to say that my c# code change the mapdefinitin in the
>>>>>> layout
>>>>>> for the current session;
>>>>>> if i use administrator user, it seems to me that my repositories is
>>>>>> modified
>>>>>> in maestro, no and i will not ?
>>>>>> For (Sample 1) my code is 
>>>>>> http://patxi.mayol.free.fr/ag_default3.aspx
>>>>>> here 
>>>>>> For (Sample 2) my xml file is 
>>>>>> http://patxi.mayol.free.fr/test_after.xml
>>>>>> here 
>>>>>> Thanks 
>>>>>>
>>>>>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>>>>>   
>>>>>>       
>>>>>>           
>>>>>>> You mention "layout resource", but the message states a
>>>>>>> MapDefinition
>>>>>>> is 
>>>>>>> saved?
>>>>>>> Anonymous can only save to the same session, only Administrator can
>>>>>>> save 
>>>>>>> across
>>>>>>> sessions.
>>>>>>>
>>>>>>> As for the parse error, your document is likely invalid.
>>>>>>>
>>>>>>> For (Sample 1), can you post the related code?
>>>>>>> For (Sample 2), can you post a binary copy of the document you are 
>>>>>>> trying to save?
>>>>>>>
>>>>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> euskalmap skrev:
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>>>> Hi,
>>>>>>>> I modify, by c# script, the name of the layout resource; i use the
>>>>>>>> MgUserInformation function with Anonymous user without password. 
>>>>>>>> sample1 : In mapguide administrator this user have no role => so
>>>>>>>> when
>>>>>>>> i
>>>>>>>> load
>>>>>>>> the page i have this message : 
>>>>>>>> Permission denied to resource:
>>>>>>>> Session:98d50e40-ffff-ffff-8000-0016d44491c1_en_7F0000010AFC0AFB0AFA//Map_40312.MapDefinition 
>>>>>>>> sample 2 : if i add the role Adminstrator and Map Author of the
>>>>>>>> Anonymous
>>>>>>>> user, i have this message :
>>>>>>>> An exception occurred in DB XML component. Error: XML Indexer:
>>>>>>>> Fatal
>>>>>>>> Parse
>>>>>>>> error in document at line, 1, char 1. Parser message: Invalid
>>>>>>>> document
>>>>>>>> structure 
>>>>>>>>
>>>>>>>> I understand anything ! Have you an idea ?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>   
>>>>>>>>       
>>>>>>>>           
>>>>>>>>               
>>>>>>> _______________________________________________
>>>>>>> mapguide-users mailing list
>>>>>>> mapguide-users at lists.osgeo.org
>>>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>>>
>>>>>>>
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>>   
>>>>>>       
>>>>>>           
>>>>> _______________________________________________
>>>>> mapguide-users mailing list
>>>>> mapguide-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>
>>>>>
>>>>>     
>>>>>         
>>>>   
>>>>       
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>>     
>>
>>   
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Modify-layout-with-anonymous-user-tp3092823p3224656.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list