From ef5575be1b7e8122883773c799ddc522ed80c156 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 17 Jan 2012 21:09:46 -0500 Subject: Add json handler for GridInfo --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 15 +++++++++++++++ OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | 2 ++ 2 files changed, 17 insertions(+) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 645a77f..bfcddca 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -37,6 +37,7 @@ using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; +using OpenMetaverse.StructuredData; namespace OpenSim.Server.Handlers.Grid { @@ -142,5 +143,19 @@ namespace OpenSim.Server.Handlers.Grid return sb.ToString(); } + + public string JsonGetGridInfoMethod(string request, string path, string param, + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + + OSDMap map = new OSDMap(); + + foreach (string k in _info.Keys) + { + map[k] = OSD.FromString(_info[k].ToString()); + } + + return OSDParser.SerializeJsonString(map).ToString(); + } } } diff --git a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs index 8472d34..f9b5915 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs @@ -48,6 +48,8 @@ namespace OpenSim.Server.Handlers.Grid server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", handlers.RestGetGridInfoMethod)); + server.AddStreamHandler(new RestStreamHandler("GET", "/json_grid_info", + handlers.JsonGetGridInfoMethod)); server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); } -- cgit v1.1 From bf9ce4709faa22c23411ade380e77a699a29ce51 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 19 Jan 2012 13:48:31 -0500 Subject: Add fetching of SRV_HomeURI to "/json_grid_info" Make SRV_HomeURI available on the GridInfoService through the "/json_grid_info" URI. This i s mainly to service OSSL, but can be seen externally via the URI. --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index bfcddca..67472e3 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Grid public class GridInfoHandlers { private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + private IConfigSource m_Config; private Hashtable _info = new Hashtable(); /// @@ -60,6 +60,7 @@ namespace OpenSim.Server.Handlers.Grid /// public GridInfoHandlers(IConfigSource configSource) { + m_Config = configSource; loadGridInfo(configSource); } @@ -144,9 +145,38 @@ namespace OpenSim.Server.Handlers.Grid return sb.ToString(); } + /// + /// Get GridInfo in json format: Used bu the OSSL osGetGrid* + /// Adding the SRV_HomeIRI to the kvp returned for use in scripts + /// + /// + /// json string + /// + /// + /// Request. + /// + /// + /// /json_grid_info + /// + /// + /// Parameter. + /// + /// + /// Http request. + /// + /// + /// Http response. + /// public string JsonGetGridInfoMethod(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { + string HomeURI = String.Empty; + IConfig cfg = m_Config.Configs["LoginService"]; + + if (null != cfg) + { + HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); + } OSDMap map = new OSDMap(); @@ -155,6 +185,11 @@ namespace OpenSim.Server.Handlers.Grid map[k] = OSD.FromString(_info[k].ToString()); } + if (!String.IsNullOrEmpty(HomeURI)) + { + map["HomeURI"] = OSD.FromString(HomeURI); + } + return OSDParser.SerializeJsonString(map).ToString(); } } -- cgit v1.1 From edb2e4c5b3d5ed5d75edf1b6efbfd8bffe427e13 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 19 Jan 2012 13:55:53 -0500 Subject: Change URI to lowercase to match existing --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 67472e3..965a54e 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -187,7 +187,7 @@ namespace OpenSim.Server.Handlers.Grid if (!String.IsNullOrEmpty(HomeURI)) { - map["HomeURI"] = OSD.FromString(HomeURI); + map["home"] = OSD.FromString(HomeURI); } return OSDParser.SerializeJsonString(map).ToString(); -- cgit v1.1