From f2ff6d5186420ed4bbf7379ad6dc92f46b7907a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 20:31:46 +0000 Subject: Move asset commands from AssetService to AssetServerConnector so that we can harmonise the same commands on the simulator side. No functional change. --- .../Server/Handlers/Asset/AssetServerConnector.cs | 127 ++++++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index df571fa..9960228 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -26,7 +26,11 @@ */ using System; +using System.IO; using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; @@ -67,6 +71,127 @@ namespace OpenSim.Server.Handlers.Asset server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "show digest", + "show digest ", + "Show asset digest", + HandleShowDigest); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "delete asset", + "delete asset ", + "Delete asset from database", + HandleDeleteAsset); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "dump asset", + "dump asset ", + "Dump asset to a file", + "The filename is the same as the ID given.", + HandleDumpAsset); + } + + void HandleDeleteAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: delete asset "); + return; + } + + AssetBase asset = m_AssetService.Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + m_AssetService.Delete(args[2]); + + //MainConsole.Instance.Output("Asset deleted"); + // TODO: Implement this + + MainConsole.Instance.Output("Asset deletion not supported by database"); + } + + void HandleDumpAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Usage is dump asset "); + return; + } + + UUID assetId; + string rawAssetId = args[2]; + + if (!UUID.TryParse(rawAssetId, out assetId)) + { + MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); + return; + } + + AssetBase asset = m_AssetService.Get(assetId.ToString()); + if (asset == null) + { + MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); + return; + } + + string fileName = rawAssetId; + + using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) + { + using (BinaryWriter bw = new BinaryWriter(fs)) + { + bw.Write(asset.Data); + } + } + + MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); + } + + void HandleShowDigest(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: show digest "); + return; + } + + AssetBase asset = m_AssetService.Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + int i; + + MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); + MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); + MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); + MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); + MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); + + for (i = 0 ; i < 5 ; i++) + { + int off = i * 16; + if (asset.Data.Length <= off) + break; + int len = 16; + if (asset.Data.Length < off + len) + len = asset.Data.Length - off; + + byte[] line = new byte[len]; + Array.Copy(asset.Data, off, line, 0, len); + + string text = BitConverter.ToString(line); + MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + } } } -} +} \ No newline at end of file -- cgit v1.1 From 5b160f5b7b2abf41e518e3974098b1bc82268c2a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 20:56:29 +0000 Subject: Rename 'show digest' console command to 'show asset' --- OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 9960228..61718f1 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -157,7 +157,7 @@ namespace OpenSim.Server.Handlers.Asset { if (args.Length < 3) { - MainConsole.Instance.Output("Syntax: show digest "); + MainConsole.Instance.Output("Syntax: show asset "); return; } -- cgit v1.1 From f06acc0a854980fd66426103892742580e057974 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 21:05:10 +0000 Subject: Add size and temporary information to "show asset" command --- OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 61718f1..5dcb33b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -175,6 +175,8 @@ namespace OpenSim.Server.Handlers.Asset MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); + MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length); + MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no"); MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); for (i = 0 ; i < 5 ; i++) -- cgit v1.1 From da0fc3c8f572adba69e52e1d7f528946ab1f6f23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 21:11:32 +0000 Subject: Make "show asset" command available simulator side. Actually make the service command be "show asset" instead of "show digest" this time. Last time I accidnetally just changed the usage message. --- OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 5dcb33b..9b80245 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -73,10 +73,10 @@ namespace OpenSim.Server.Handlers.Asset server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); MainConsole.Instance.Commands.AddCommand("kfs", false, - "show digest", - "show digest ", - "Show asset digest", - HandleShowDigest); + "show asset", + "show asset ", + "Show asset information", + HandleShowAsset); MainConsole.Instance.Commands.AddCommand("kfs", false, "delete asset", @@ -153,7 +153,7 @@ namespace OpenSim.Server.Handlers.Asset MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); } - void HandleShowDigest(string module, string[] args) + void HandleShowAsset(string module, string[] args) { if (args.Length < 3) { -- cgit v1.1 From e13a17cc0c8514bc673d5ba39c86d23451278389 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 16 Jan 2012 02:19:19 +0100 Subject: Allow retrival of multiple user records in one operation, analog to presence --- .../Handlers/GridUser/GridUserServerPostHandler.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 4c0d52e..bf21255 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.GridUser return SetPosition(request); case "getgriduserinfo": return GetGridUserInfo(request); + case "getgriduserinfos": + return GetGridUserInfos(request); } m_log.DebugFormat("[GRID USER HANDLER]: unknown method request: {0}", method); } @@ -193,6 +195,46 @@ namespace OpenSim.Server.Handlers.GridUser } + byte[] GetGridUserInfos(Dictionary request) + { + + string[] userIDs; + + if (!request.ContainsKey("AgentIDs")) + { + m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos called without required uuids argument"); + return FailureResult(); + } + + if (!(request["AgentIDs"] is List)) + { + m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos input argument was of unexpected type {0}", request["uuids"].GetType().ToString()); + return FailureResult(); + } + + userIDs = ((List)request["AgentIDs"]).ToArray(); + + GridUserInfo[] pinfos = m_GridUserService.GetGridUserInfo(userIDs); + + Dictionary result = new Dictionary(); + if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridUserInfo pinfo in pinfos) + { + Dictionary rinfoDict = pinfo.ToKeyValuePairs(); + result["griduser" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + } + private bool UnpackArgs(Dictionary request, out string user, out UUID region, out Vector3 position, out Vector3 lookAt) { user = string.Empty; -- cgit v1.1 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 From 2d0412d366c1c243cc3abfe753f21d59b4c55473 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Jan 2012 22:35:55 +0000 Subject: Make errors reported by OpenSim when it halts because it can't find certain config sections or files a bit more user friendly. --- OpenSim/Server/Base/ServicesServerBase.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index aeba35f..a6f4e47 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -126,11 +126,10 @@ namespace OpenSim.Server.Base m_Config = new IniConfigSource(iniFile); } } - catch (Exception) + catch (Exception e) { - System.Console.WriteLine("Error reading from config source {0}", - iniFile); - Thread.CurrentThread.Abort(); + System.Console.WriteLine("Error reading from config source. {0}", e.Message); + Environment.Exit(1); } // Merge the configuration from the command line into the -- cgit v1.1