From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001
From: David Walter Seikel
Date: Thu, 3 Nov 2016 21:44:39 +1000
Subject: Initial update to OpenSim 0.8.2.1 source code.
---
OpenSim/Services/AssetService/AssetService.cs | 51 +-
.../AssetService/Properties/AssemblyInfo.cs | 4 +-
OpenSim/Services/AssetService/XAssetService.cs | 77 ++-
OpenSim/Services/AssetService/XAssetServiceBase.cs | 47 +-
.../Properties/AssemblyInfo.cs | 4 +-
.../Properties/AssemblyInfo.cs | 4 +-
.../AvatarService/Properties/AssemblyInfo.cs | 4 +-
OpenSim/Services/Base/Properties/AssemblyInfo.cs | 4 +-
OpenSim/Services/Base/ServiceBase.cs | 13 +-
.../AgentPreferences/AgentPreferencesConnector.cs | 230 +++++++
.../Connectors/Asset/AssetServicesConnector.cs | 118 ++--
.../Connectors/Asset/HGAssetServiceConnector.cs | 104 +--
.../AuthenticationServicesConnector.cs | 14 +-
.../AuthorizationServicesConnector.cs | 3 +-
.../Connectors/Avatar/AvatarServicesConnector.cs | 17 +-
.../Services/Connectors/BaseServiceConnector.cs | 33 +
.../Connectors/Estate/EstateDataConnector.cs | 338 ++++++++++
.../Freeswitch/RemoteFreeswitchConnector.cs | 2 +-
.../Connectors/Friends/FriendsServicesConnector.cs | 12 +-
.../Connectors/Grid/GridServicesConnector.cs | 121 +++-
.../GridUser/GridUserServicesConnector.cs | 17 +-
.../Hypergrid/GatekeeperServiceConnector.cs | 99 ++-
.../Hypergrid/HGFriendsServicesConnector.cs | 2 +-
.../Connectors/Hypergrid/HeloServicesConnector.cs | 57 +-
.../Hypergrid/UserAgentServiceConnector.cs | 591 +++++------------
.../InstantMessageServiceConnector.cs | 1 +
.../Inventory/XInventoryServicesConnector.cs | 405 ++++++++----
.../Connectors/Land/LandServicesConnector.cs | 4 +-
.../MapImage/MapImageServicesConnector.cs | 83 ++-
.../Neighbour/NeighbourServicesConnector.cs | 72 +-
.../Presence/PresenceServicesConnector.cs | 26 +-
.../Services/Connectors/Properties/AssemblyInfo.cs | 4 +-
.../SimianGrid/SimianActivityDetector.cs | 4 +-
.../SimianGrid/SimianAssetServiceConnector.cs | 526 ++++++++++-----
.../SimianAuthenticationServiceConnector.cs | 12 +-
.../SimianGrid/SimianAvatarServiceConnector.cs | 8 +-
.../SimianGrid/SimianExternalCapsModule.cs | 180 +++++
.../SimianGrid/SimianFriendsServiceConnector.cs | 8 +-
.../Services/Connectors/SimianGrid/SimianGrid.cs | 118 +++-
.../SimianGrid/SimianGridMaptileModule.cs | 118 ++--
.../SimianGrid/SimianGridServiceConnector.cs | 49 +-
.../SimianGrid/SimianInventoryServiceConnector.cs | 119 ++--
.../SimianGrid/SimianPresenceServiceConnector.cs | 212 +++---
.../Connectors/SimianGrid/SimianProfiles.cs | 8 +-
.../SimianUserAccountServiceConnector.cs | 13 +-
.../Connectors/Simulation/EstateDataService.cs | 139 ----
.../Connectors/Simulation/SimulationDataService.cs | 182 ------
.../Simulation/SimulationServiceConnector.cs | 165 +++--
.../UserAccounts/UserAccountServicesConnector.cs | 57 +-
.../Services/EstateService/EstateDataService.cs | 136 ++++
OpenSim/Services/FSAssetService/FSAssetService.cs | 723 +++++++++++++++++++++
.../FreeswitchService/Properties/AssemblyInfo.cs | 4 +-
.../Services/Friends/Properties/AssemblyInfo.cs | 4 +-
OpenSim/Services/GridService/GridService.cs | 415 +++++++++---
OpenSim/Services/GridService/HypergridLinker.cs | 236 +++++--
.../GridService/Properties/AssemblyInfo.cs | 4 +-
.../Services/HypergridService/GatekeeperService.cs | 121 +++-
.../Services/HypergridService/HGAssetService.cs | 34 +-
.../Services/HypergridService/HGFSAssetService.cs | 189 ++++++
.../Services/HypergridService/HGFriendsService.cs | 3 +-
.../HypergridService/HGInstantMessageService.cs | 19 +-
.../HypergridService/HGInventoryService.cs | 27 +-
.../HypergridService/HGSuitcaseInventoryService.cs | 258 ++++----
.../HypergridService/Properties/AssemblyInfo.cs | 4 +-
.../Services/HypergridService/UserAccountCache.cs | 7 +-
.../Services/HypergridService/UserAgentService.cs | 259 +++++---
.../HypergridService/UserAgentServiceBase.cs | 84 +++
.../Interfaces/IAgentPreferencesService.cs | 115 ++++
OpenSim/Services/Interfaces/IAssetService.cs | 9 +-
OpenSim/Services/Interfaces/IAvatarService.cs | 46 +-
.../Services/Interfaces/IBakedTextureService.cs | 38 ++
OpenSim/Services/Interfaces/IBansService.cs | 48 ++
OpenSim/Services/Interfaces/IEstateDataService.cs | 115 ++++
OpenSim/Services/Interfaces/IGridService.cs | 286 +++++---
OpenSim/Services/Interfaces/IHypergridServices.cs | 66 +-
OpenSim/Services/Interfaces/IInventoryService.cs | 36 +-
OpenSim/Services/Interfaces/IMapImageService.cs | 1 +
OpenSim/Services/Interfaces/IOfflineIMService.cs | 7 +
OpenSim/Services/Interfaces/ISimulationService.cs | 39 +-
OpenSim/Services/Interfaces/IUserAccountService.cs | 2 +
OpenSim/Services/Interfaces/IUserManagement.cs | 97 +++
.../Services/Interfaces/IUserProfilesService.cs | 80 +++
OpenSim/Services/Interfaces/OpenProfileClient.cs | 134 ++++
.../Services/Interfaces/Properties/AssemblyInfo.cs | 4 +-
.../Services/InventoryService/LibraryService.cs | 1 +
.../InventoryService/Properties/AssemblyInfo.cs | 4 +-
.../Services/InventoryService/XInventoryService.cs | 172 ++---
OpenSim/Services/LLLoginService/LLLoginResponse.cs | 83 ++-
OpenSim/Services/LLLoginService/LLLoginService.cs | 166 +++--
.../LLLoginService/Properties/AssemblyInfo.cs | 4 +-
.../Services/MapImageService/MapImageService.cs | 110 +++-
.../MapImageService/Properties/AssemblyInfo.cs | 4 +-
.../Services/PresenceService/PresenceService.cs | 87 ++-
.../PresenceService/Properties/AssemblyInfo.cs | 4 +-
.../SimulationService/SimulationDataService.cs | 191 ++++++
.../UserAccountService/AgentPreferencesService.cs | 82 +++
.../AgentPreferencesServiceBase.cs | 73 +++
.../Services/UserAccountService/GridUserService.cs | 127 +++-
.../UserAccountService/GridUserServiceBase.cs | 10 +-
.../UserAccountService/Properties/AssemblyInfo.cs | 4 +-
.../UserAccountService/UserAccountService.cs | 56 +-
.../UserProfilesService/UserProfilesService.cs | 263 ++++++++
.../UserProfilesService/UserProfilesServiceBase.cs | 87 +++
103 files changed, 7171 insertions(+), 2486 deletions(-)
create mode 100644 OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
create mode 100644 OpenSim/Services/Connectors/BaseServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
create mode 100644 OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
delete mode 100644 OpenSim/Services/Connectors/Simulation/EstateDataService.cs
delete mode 100644 OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
create mode 100644 OpenSim/Services/EstateService/EstateDataService.cs
create mode 100644 OpenSim/Services/FSAssetService/FSAssetService.cs
create mode 100644 OpenSim/Services/HypergridService/HGFSAssetService.cs
create mode 100644 OpenSim/Services/HypergridService/UserAgentServiceBase.cs
create mode 100644 OpenSim/Services/Interfaces/IAgentPreferencesService.cs
create mode 100644 OpenSim/Services/Interfaces/IBakedTextureService.cs
create mode 100644 OpenSim/Services/Interfaces/IBansService.cs
create mode 100644 OpenSim/Services/Interfaces/IEstateDataService.cs
create mode 100644 OpenSim/Services/Interfaces/IUserManagement.cs
create mode 100644 OpenSim/Services/Interfaces/IUserProfilesService.cs
create mode 100644 OpenSim/Services/Interfaces/OpenProfileClient.cs
create mode 100644 OpenSim/Services/SimulationService/SimulationDataService.cs
create mode 100644 OpenSim/Services/UserAccountService/AgentPreferencesService.cs
create mode 100644 OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs
create mode 100644 OpenSim/Services/UserProfilesService/UserProfilesService.cs
create mode 100644 OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs
(limited to 'OpenSim/Services')
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index e7eb6fe..0aefa16 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -123,53 +123,54 @@ namespace OpenSim.Services.AssetService
public virtual AssetMetadata GetMetadata(string id)
{
// m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id);
-
- UUID assetID;
- if (!UUID.TryParse(id, out assetID))
- return null;
+ AssetBase asset = Get(id);
- AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null)
return asset.Metadata;
-
- return null;
+ else
+ return null;
}
public virtual byte[] GetData(string id)
{
// m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id);
-
- UUID assetID;
- if (!UUID.TryParse(id, out assetID))
- return null;
+ AssetBase asset = Get(id);
- AssetBase asset = m_Database.GetAsset(assetID);
- return asset.Data;
+ if (asset != null)
+ return asset.Data;
+ else
+ return null;
}
public virtual bool Get(string id, Object sender, AssetRetrieved handler)
{
//m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
-
- UUID assetID;
- if (!UUID.TryParse(id, out assetID))
- return false;
-
- AssetBase asset = m_Database.GetAsset(assetID);
-
- //m_log.DebugFormat("[AssetService]: Got asset {0}", asset);
-
- handler(id, sender, asset);
+ handler(id, sender, Get(id));
return true;
}
+ public virtual bool[] AssetsExist(string[] ids)
+ {
+ try
+ {
+ UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
+ return m_Database.AssetsExist(uuid);
+ }
+ catch (Exception e)
+ {
+ m_log.Error("[ASSET SERVICE]: Exception getting assets ", e);
+ return new bool[ids.Length];
+ }
+ }
+
public virtual string Store(AssetBase asset)
{
- if (!m_Database.ExistsAsset(asset.FullID))
+ bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0];
+ if (!exists)
{
// m_log.DebugFormat(
// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
@@ -200,4 +201,4 @@ namespace OpenSim.Services.AssetService
return m_Database.Delete(id);
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
index 1509400..63654a6 100644
--- a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs
index a1d10ed..b1e5184 100644
--- a/OpenSim/Services/AssetService/XAssetService.cs
+++ b/OpenSim/Services/AssetService/XAssetService.cs
@@ -39,16 +39,18 @@ using OpenMetaverse;
namespace OpenSim.Services.AssetService
{
///
- /// This will be developed into a de-duplicating asset service.
- /// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it.
+ /// A de-duplicating asset service.
///
+ [Obsolete]
public class XAssetService : XAssetServiceBase, IAssetService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected static XAssetService m_RootInstance;
- public XAssetService(IConfigSource config) : base(config)
+ public XAssetService(IConfigSource config) : this(config, "AssetService") {}
+
+ public XAssetService(IConfigSource config, string configName) : base(config, configName)
{
if (m_RootInstance == null)
{
@@ -56,22 +58,21 @@ namespace OpenSim.Services.AssetService
if (m_AssetLoader != null)
{
- IConfig assetConfig = config.Configs["AssetService"];
+ IConfig assetConfig = config.Configs[configName];
if (assetConfig == null)
throw new Exception("No AssetService configuration");
- string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
- String.Empty);
+ string loaderArgs = assetConfig.GetString("AssetLoaderArgs", String.Empty);
bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
- if (assetLoaderEnabled)
+ if (assetLoaderEnabled && !HasChainedAssetService)
{
m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
m_AssetLoader.ForEachDefaultXmlAsset(
loaderArgs,
- delegate(AssetBase a)
+ a =>
{
AssetBase existingAsset = Get(a.ID);
// AssetMetadata existingMetadata = GetMetadata(a.ID);
@@ -85,6 +86,7 @@ namespace OpenSim.Services.AssetService
}
m_log.Debug("[XASSET SERVICE]: Local asset service enabled");
+ m_log.Error("[XASSET SERVICE]: THIS ASSET SERVICE HAS BEEN MARKED OBSOLETE. PLEASE USE FSAssetService");
}
}
}
@@ -103,7 +105,23 @@ namespace OpenSim.Services.AssetService
try
{
- return m_Database.GetAsset(assetID);
+ AssetBase asset = m_Database.GetAsset(assetID);
+
+ if (asset != null)
+ {
+ return asset;
+ }
+ else if (HasChainedAssetService)
+ {
+ asset = m_ChainedAssetService.Get(id);
+
+ if (asset != null)
+ MigrateFromChainedService(asset);
+
+ return asset;
+ }
+
+ return null;
}
catch (Exception e)
{
@@ -120,30 +138,25 @@ namespace OpenSim.Services.AssetService
public virtual AssetMetadata GetMetadata(string id)
{
// m_log.DebugFormat("[XASSET SERVICE]: Get asset metadata for {0}", id);
-
- UUID assetID;
- if (!UUID.TryParse(id, out assetID))
- return null;
+ AssetBase asset = Get(id);
- AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null)
return asset.Metadata;
-
- return null;
+ else
+ return null;
}
public virtual byte[] GetData(string id)
{
// m_log.DebugFormat("[XASSET SERVICE]: Get asset data for {0}", id);
- UUID assetID;
+ AssetBase asset = Get(id);
- if (!UUID.TryParse(id, out assetID))
+ if (asset != null)
+ return asset.Data;
+ else
return null;
-
- AssetBase asset = m_Database.GetAsset(assetID);
- return asset.Data;
}
public virtual bool Get(string id, Object sender, AssetRetrieved handler)
@@ -155,7 +168,7 @@ namespace OpenSim.Services.AssetService
if (!UUID.TryParse(id, out assetID))
return false;
- AssetBase asset = m_Database.GetAsset(assetID);
+ AssetBase asset = Get(id);
//m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
@@ -164,9 +177,16 @@ namespace OpenSim.Services.AssetService
return true;
}
+ public virtual bool[] AssetsExist(string[] ids)
+ {
+ UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
+ return m_Database.AssetsExist(uuid);
+ }
+
public virtual string Store(AssetBase asset)
{
- if (!m_Database.ExistsAsset(asset.FullID))
+ bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0];
+ if (!exists)
{
// m_log.DebugFormat(
// "[XASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
@@ -194,7 +214,16 @@ namespace OpenSim.Services.AssetService
if (!UUID.TryParse(id, out assetID))
return false;
+ if (HasChainedAssetService)
+ m_ChainedAssetService.Delete(id);
+
return m_Database.Delete(id);
}
+
+ private void MigrateFromChainedService(AssetBase asset)
+ {
+ Store(asset);
+ m_ChainedAssetService.Delete(asset.ID);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Services/AssetService/XAssetServiceBase.cs b/OpenSim/Services/AssetService/XAssetServiceBase.cs
index 0c5c2c3..c118c9d 100644
--- a/OpenSim/Services/AssetService/XAssetServiceBase.cs
+++ b/OpenSim/Services/AssetService/XAssetServiceBase.cs
@@ -27,9 +27,11 @@
using System;
using System.Reflection;
+using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Data;
+using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Base;
@@ -37,10 +39,15 @@ namespace OpenSim.Services.AssetService
{
public class XAssetServiceBase : ServiceBase
{
- protected IXAssetDataPlugin m_Database = null;
- protected IAssetLoader m_AssetLoader = null;
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public XAssetServiceBase(IConfigSource config) : base(config)
+ protected IXAssetDataPlugin m_Database;
+ protected IAssetLoader m_AssetLoader;
+ protected IAssetService m_ChainedAssetService;
+
+ protected bool HasChainedAssetService { get { return m_ChainedAssetService != null; } }
+
+ public XAssetServiceBase(IConfigSource config, string configName) : base(config)
{
string dllName = String.Empty;
string connString = String.Empty;
@@ -48,7 +55,7 @@ namespace OpenSim.Services.AssetService
//
// Try reading the [AssetService] section first, if it exists
//
- IConfig assetConfig = config.Configs["AssetService"];
+ IConfig assetConfig = config.Configs[configName];
if (assetConfig != null)
{
dllName = assetConfig.GetString("StorageProvider", dllName);
@@ -77,17 +84,35 @@ namespace OpenSim.Services.AssetService
if (m_Database == null)
throw new Exception("Could not find a storage interface in the given module");
- m_Database.Initialise(connString);
+ string chainedAssetServiceDesignator = assetConfig.GetString("ChainedServiceModule", null);
+
+ if (chainedAssetServiceDesignator != null)
+ {
+ m_log.InfoFormat(
+ "[XASSET SERVICE BASE]: Loading chained asset service from {0}", chainedAssetServiceDesignator);
- string loaderName = assetConfig.GetString("DefaultAssetLoader",
- String.Empty);
+ Object[] args = new Object[] { config, configName };
+ m_ChainedAssetService = ServerUtils.LoadPlugin(chainedAssetServiceDesignator, args);
- if (loaderName != String.Empty)
+ if (!HasChainedAssetService)
+ throw new Exception(
+ String.Format("Failed to load ChainedAssetService from {0}", chainedAssetServiceDesignator));
+ }
+
+ m_Database.Initialise(connString);
+
+ if (HasChainedAssetService)
{
- m_AssetLoader = LoadPlugin(loaderName);
+ string loaderName = assetConfig.GetString("DefaultAssetLoader",
+ String.Empty);
+
+ if (loaderName != String.Empty)
+ {
+ m_AssetLoader = LoadPlugin(loaderName);
- if (m_AssetLoader == null)
- throw new Exception("Asset loader could not be loaded");
+ if (m_AssetLoader == null)
+ throw new Exception("Asset loader could not be loaded");
+ }
}
}
}
diff --git a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
index 0eb2ba7..f25accc 100644
--- a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
index 6d6b11e..47d47ab 100644
--- a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
index 0944149..a233d8a 100644
--- a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/Base/Properties/AssemblyInfo.cs b/OpenSim/Services/Base/Properties/AssemblyInfo.cs
index 306b699..b113c42 100644
--- a/OpenSim/Services/Base/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Base/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs
index ef30cba..a7eb2be 100644
--- a/OpenSim/Services/Base/ServiceBase.cs
+++ b/OpenSim/Services/Base/ServiceBase.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Reflection;
using log4net;
using Nini.Config;
@@ -45,9 +46,15 @@ namespace OpenSim.Services.Base
public T LoadPlugin(string dllName, Object[] args) where T:class
{
- string[] parts = dllName.Split(new char[] {':'});
+ // The path:type separator : is unfortunate because it collides
+ // with Windows paths like C:\...
+ // When the path provided includes the drive, this fails.
+ // Hence the root/noroot thing going on here.
+ string pathRoot = Path.GetPathRoot(dllName);
+ string noRoot = dllName.Substring(pathRoot.Length);
+ string[] parts = noRoot.Split(new char[] {':'});
- dllName = parts[0];
+ dllName = pathRoot + parts[0];
string className = String.Empty;
@@ -79,7 +86,7 @@ namespace OpenSim.Services.Base
continue;
Type typeInterface =
- pluginType.GetInterface(interfaceName, true);
+ pluginType.GetInterface(interfaceName);
if (typeInterface != null)
{
T plug = (T)Activator.CreateInstance(pluginType,
diff --git a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
new file mode 100644
index 0000000..1dbc0c8
--- /dev/null
+++ b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.ServiceAuth;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
+using OpenSim.Server.Base;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors
+{
+ public class AgentPreferencesServicesConnector : BaseServiceConnector, IAgentPreferencesService
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+
+ public AgentPreferencesServicesConnector()
+ {
+ }
+
+ public AgentPreferencesServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public AgentPreferencesServicesConnector(IConfigSource source)
+ : base(source, "AgentPreferencesService")
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig gridConfig = source.Configs["AgentPreferencesService"];
+ if (gridConfig == null)
+ {
+ m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini");
+ throw new Exception("Agent Preferences connector init error");
+ }
+
+ string serviceURI = gridConfig.GetString("AgentPreferencesServerURI", String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[AGENT PREFERENCES CONNECTOR]: No Server URI named in section AgentPreferences");
+ throw new Exception("Agent Preferences connector init error");
+ }
+ m_ServerURI = serviceURI;
+
+ base.Initialise(source, "AgentPreferencesService");
+ }
+
+ #region IAgentPreferencesService
+
+ public AgentPrefs GetAgentPreferences(UUID principalID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ string reply = string.Empty;
+ string uri = String.Concat(m_ServerURI, "/agentprefs");
+
+ sendData["METHOD"] = "getagentprefs";
+ sendData["UserID"] = principalID;
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);
+
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
+ if (String.IsNullOrEmpty(reply))
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null or empty reply");
+ return null;
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
+ }
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+ if (replyData != null)
+ {
+ if (replyData.ContainsKey("result") &&
+ (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received Failure response");
+ return null;
+ }
+ }
+ else
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null response");
+ return null;
+ }
+ AgentPrefs prefs = new AgentPrefs(replyData);
+ return prefs;
+ }
+
+ public bool StoreAgentPreferences(AgentPrefs data)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["METHOD"] = "setagentprefs";
+
+ sendData["PrincipalID"] = data.PrincipalID.ToString();
+ sendData["AccessPrefs"] = data.AccessPrefs;
+ sendData["HoverHeight"] = data.HoverHeight.ToString();
+ sendData["Language"] = data.Language;
+ sendData["LanguageIsPublic"] = data.LanguageIsPublic.ToString();
+ sendData["PermEveryone"] = data.PermEveryone.ToString();
+ sendData["PermGroup"] = data.PermGroup.ToString();
+ sendData["PermNextOwner"] = data.PermNextOwner.ToString();
+
+ string uri = String.Concat(m_ServerURI, "/agentprefs");
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);
+
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("result"))
+ {
+ if (replyData["result"].ToString().ToLower() == "success")
+ return true;
+ else
+ return false;
+ }
+ else
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences reply data does not contain result field");
+ }
+
+ }
+ else
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply");
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
+ }
+
+ return false;
+ }
+
+ public string GetLang(UUID principalID)
+ {
+ Dictionary sendData = new Dictionary();
+ string reply = string.Empty;
+
+ sendData["METHOD"] = "getagentlang";
+ sendData["UserID"] = principalID.ToString();
+
+ string uri = String.Concat(m_ServerURI, "/agentprefs");
+ string reqString = ServerUtils.BuildQueryString(sendData);
+
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
+ if (String.IsNullOrEmpty(reply))
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received null or empty reply");
+ return "en-us"; // I guess? Gotta return somethin'!
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
+ }
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+ if (replyData != null)
+ {
+ if (replyData.ContainsKey("result") &&
+ (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received Failure response");
+ return "en-us";
+ }
+ if (replyData.ContainsKey("Language"))
+ return replyData["Language"].ToString();
+ }
+ else
+ {
+ m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received null response");
+
+ }
+ return "en-us";
+ }
+
+ #endregion IAgentPreferencesService
+ }
+}
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index 2b2f11f..bd43552 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -33,13 +33,12 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
-using OpenSim.Framework.Communications;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class AssetServicesConnector : IAssetService
+ public class AssetServicesConnector : BaseServiceConnector, IAssetService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -55,6 +54,11 @@ namespace OpenSim.Services.Connectors
// Maps: Asset ID -> Handlers which will be called when the asset has been loaded
private Dictionary m_AssetHandlers = new Dictionary();
+ public int MaxAssetRequestConcurrency
+ {
+ get { return m_maxAssetRequestConcurrency; }
+ set { m_maxAssetRequestConcurrency = value; }
+ }
public AssetServicesConnector()
{
@@ -66,6 +70,7 @@ namespace OpenSim.Services.Connectors
}
public AssetServicesConnector(IConfigSource source)
+ : base(source, "AssetService")
{
Initialise(source);
}
@@ -112,8 +117,16 @@ namespace OpenSim.Services.Connectors
if (asset == null)
{
- asset = SynchronousRestObjectRequester.
- MakeRequest("GET", uri, 0, m_maxAssetRequestConcurrency);
+ // XXX: Commented out for now since this has either never been properly operational or not for some time
+ // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option.
+ // Wasn't noticed before because timeout wasn't actually used.
+ // Not attempting concurrency setting for now as this omission was discovered in release candidate
+ // phase for OpenSimulator 0.8. Need to revisit afterwards.
+// asset
+// = SynchronousRestObjectRequester.MakeRequest(
+// "GET", uri, 0, m_maxAssetRequestConcurrency);
+
+ asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth);
if (m_Cache != null)
m_Cache.Cache(asset);
@@ -143,8 +156,7 @@ namespace OpenSim.Services.Connectors
string uri = m_ServerURI + "/assets/" + id + "/metadata";
- AssetMetadata asset = SynchronousRestObjectRequester.
- MakeRequest("GET", uri, 0);
+ AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth);
return asset;
}
@@ -158,27 +170,29 @@ namespace OpenSim.Services.Connectors
return fullAsset.Data;
}
- RestClient rc = new RestClient(m_ServerURI);
- rc.AddResourcePath("assets");
- rc.AddResourcePath(id);
- rc.AddResourcePath("data");
+ using (RestClient rc = new RestClient(m_ServerURI))
+ {
+ rc.AddResourcePath("assets");
+ rc.AddResourcePath(id);
+ rc.AddResourcePath("data");
- rc.RequestMethod = "GET";
+ rc.RequestMethod = "GET";
- Stream s = rc.Request();
+ Stream s = rc.Request(m_Auth);
- if (s == null)
- return null;
+ if (s == null)
+ return null;
- if (s.Length > 0)
- {
- byte[] ret = new byte[s.Length];
- s.Read(ret, 0, (int)s.Length);
+ if (s.Length > 0)
+ {
+ byte[] ret = new byte[s.Length];
+ s.Read(ret, 0, (int)s.Length);
- return ret;
- }
+ return ret;
+ }
- return null;
+ return null;
+ }
}
public bool Get(string id, Object sender, AssetRetrieved handler)
@@ -216,7 +230,7 @@ namespace OpenSim.Services.Connectors
AsynchronousRestObjectRequester.MakeRequest("GET", uri, 0,
delegate(AssetBase a)
{
- if (m_Cache != null)
+ if (a != null && m_Cache != null)
m_Cache.Cache(a);
AssetRetrievedEx handlers;
@@ -226,7 +240,7 @@ namespace OpenSim.Services.Connectors
m_AssetHandlers.Remove(id);
}
handlers.Invoke(a);
- }, m_maxAssetRequestConcurrency);
+ }, m_maxAssetRequestConcurrency, m_Auth);
success = true;
}
@@ -249,9 +263,30 @@ namespace OpenSim.Services.Connectors
return true;
}
+ public virtual bool[] AssetsExist(string[] ids)
+ {
+ string uri = m_ServerURI + "/get_assets_exist";
+
+ bool[] exist = null;
+ try
+ {
+ exist = SynchronousRestObjectRequester.MakeRequest("POST", uri, ids, m_Auth);
+ }
+ catch (Exception)
+ {
+ // This is most likely to happen because the server doesn't support this function,
+ // so just silently return "doesn't exist" for all the assets.
+ }
+
+ if (exist == null)
+ exist = new bool[ids.Length];
+
+ return exist;
+ }
+
public string Store(AssetBase asset)
{
- if (asset.Temporary || asset.Local)
+ if (asset.Local)
{
if (m_Cache != null)
m_Cache.Cache(asset);
@@ -261,27 +296,32 @@ namespace OpenSim.Services.Connectors
string uri = m_ServerURI + "/assets/";
- string newID = string.Empty;
+ string newID;
try
{
- newID = SynchronousRestObjectRequester.
- MakeRequest("POST", uri, asset);
+ newID = SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth);
}
catch (Exception e)
{
- m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message);
+ m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e);
+ return string.Empty;
}
- if (newID != String.Empty)
+ // TEMPORARY: SRAS returns 'null' when it's asked to store existing assets
+ if (newID == null)
{
- // Placing this here, so that this work with old asset servers that don't send any reply back
- // SynchronousRestObjectRequester returns somethins that is not an empty string
- if (newID != null)
- asset.ID = newID;
-
- if (m_Cache != null)
- m_Cache.Cache(asset);
+ m_log.DebugFormat("[ASSET CONNECTOR]: Storing of asset {0} returned null; assuming the asset already exists", asset.ID);
+ return asset.ID;
}
+
+ if (string.IsNullOrEmpty(newID))
+ return string.Empty;
+
+ asset.ID = newID;
+
+ if (m_Cache != null)
+ m_Cache.Cache(asset);
+
return newID;
}
@@ -305,8 +345,7 @@ namespace OpenSim.Services.Connectors
string uri = m_ServerURI + "/assets/" + id;
- if (SynchronousRestObjectRequester.
- MakeRequest("POST", uri, asset))
+ if (SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth))
{
if (m_Cache != null)
m_Cache.Cache(asset);
@@ -320,8 +359,7 @@ namespace OpenSim.Services.Connectors
{
string uri = m_ServerURI + "/assets/" + id;
- if (SynchronousRestObjectRequester.
- MakeRequest("DELETE", uri, 0))
+ if (SynchronousRestObjectRequester.MakeRequest("DELETE", uri, 0, m_Auth))
{
if (m_Cache != null)
m_Cache.Expire(id);
diff --git a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
index c395178..3710c86 100644
--- a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Hypergrid;
using OpenSim.Services.Connectors.SimianGrid;
+using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
@@ -83,39 +84,6 @@ namespace OpenSim.Services.Connectors
}
}
- private bool StringToUrlAndAssetID(string id, out string url, out string assetID)
- {
- url = String.Empty;
- assetID = String.Empty;
-
- Uri assetUri;
-
- if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
- assetUri.Scheme == Uri.UriSchemeHttp)
- {
- // Simian
- if (assetUri.Query != string.Empty)
- {
- NameValueCollection qscoll = HttpUtility.ParseQueryString(assetUri.Query);
- assetID = qscoll["id"];
- if (assetID != null)
- url = id.Replace(assetID, ""); // Malformed again, as simian expects
- else
- url = id; // !!! best effort
- }
- else // robust
- {
- url = "http://" + assetUri.Authority;
- assetID = assetUri.LocalPath.Trim(new char[] { '/' });
- }
-
- return true;
- }
-
- m_log.DebugFormat("[HG ASSET SERVICE]: Malformed URL {0}", id);
- return false;
- }
-
private IAssetService GetConnector(string url)
{
IAssetService connector = null;
@@ -149,7 +117,7 @@ namespace OpenSim.Services.Connectors
string url = string.Empty;
string assetID = string.Empty;
- if (StringToUrlAndAssetID(id, out url, out assetID))
+ if (Util.ParseForeignAssetID(id, out url, out assetID))
{
IAssetService connector = GetConnector(url);
return connector.Get(assetID);
@@ -163,7 +131,7 @@ namespace OpenSim.Services.Connectors
string url = string.Empty;
string assetID = string.Empty;
- if (StringToUrlAndAssetID(id, out url, out assetID))
+ if (Util.ParseForeignAssetID(id, out url, out assetID))
{
IAssetService connector = GetConnector(url);
return connector.GetCached(assetID);
@@ -177,7 +145,7 @@ namespace OpenSim.Services.Connectors
string url = string.Empty;
string assetID = string.Empty;
- if (StringToUrlAndAssetID(id, out url, out assetID))
+ if (Util.ParseForeignAssetID(id, out url, out assetID))
{
IAssetService connector = GetConnector(url);
return connector.GetMetadata(assetID);
@@ -196,7 +164,7 @@ namespace OpenSim.Services.Connectors
string url = string.Empty;
string assetID = string.Empty;
- if (StringToUrlAndAssetID(id, out url, out assetID))
+ if (Util.ParseForeignAssetID(id, out url, out assetID))
{
IAssetService connector = GetConnector(url);
return connector.Get(assetID, sender, handler);
@@ -205,12 +173,72 @@ namespace OpenSim.Services.Connectors
return false;
}
+
+ private struct AssetAndIndex
+ {
+ public UUID assetID;
+ public int index;
+
+ public AssetAndIndex(UUID assetID, int index)
+ {
+ this.assetID = assetID;
+ this.index = index;
+ }
+ }
+
+ public virtual bool[] AssetsExist(string[] ids)
+ {
+ // This method is a bit complicated because it works even if the assets belong to different
+ // servers; that requires sending separate requests to each server.
+
+ // Group the assets by the server they belong to
+
+ var url2assets = new Dictionary>();
+
+ for (int i = 0; i < ids.Length; i++)
+ {
+ string url = string.Empty;
+ string assetID = string.Empty;
+
+ if (Util.ParseForeignAssetID(ids[i], out url, out assetID))
+ {
+ if (!url2assets.ContainsKey(url))
+ url2assets.Add(url, new List());
+ url2assets[url].Add(new AssetAndIndex(UUID.Parse(assetID), i));
+ }
+ }
+
+ // Query each of the servers in turn
+
+ bool[] exist = new bool[ids.Length];
+
+ foreach (string url in url2assets.Keys)
+ {
+ IAssetService connector = GetConnector(url);
+ lock (EndPointLock(connector))
+ {
+ List curAssets = url2assets[url];
+ string[] assetIDs = curAssets.ConvertAll(a => a.assetID.ToString()).ToArray();
+ bool[] curExist = connector.AssetsExist(assetIDs);
+
+ int i = 0;
+ foreach (AssetAndIndex ai in curAssets)
+ {
+ exist[ai.index] = curExist[i];
+ ++i;
+ }
+ }
+ }
+
+ return exist;
+ }
+
public string Store(AssetBase asset)
{
string url = string.Empty;
string assetID = string.Empty;
- if (StringToUrlAndAssetID(asset.ID, out url, out assetID))
+ if (Util.ParseForeignAssetID(asset.ID, out url, out assetID))
{
IAssetService connector = GetConnector(url);
// Restore the assetID to a simple UUID
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
index 2b77154..c8a4912 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
@@ -32,14 +32,14 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class AuthenticationServicesConnector : IAuthenticationService
+ public class AuthenticationServicesConnector : BaseServiceConnector, IAuthenticationService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -57,6 +57,7 @@ namespace OpenSim.Services.Connectors
}
public AuthenticationServicesConnector(IConfigSource source)
+ : base(source, "AuthenticationService")
{
Initialise(source);
}
@@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors
throw new Exception("Authentication connector init error");
}
m_ServerURI = serviceURI;
+
+ base.Initialise(source, "AuthenticationService");
}
public string Authenticate(UUID principalID, string password, int lifetime)
@@ -92,7 +95,7 @@ namespace OpenSim.Services.Connectors
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/auth/plain",
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
Dictionary replyData = ServerUtils.ParseXmlResponse(
reply);
@@ -105,6 +108,7 @@ namespace OpenSim.Services.Connectors
public bool Verify(UUID principalID, string token, int lifetime)
{
+// m_log.Error("[XXX]: Verify");
Dictionary sendData = new Dictionary();
sendData["LIFETIME"] = lifetime.ToString();
sendData["PRINCIPAL"] = principalID.ToString();
@@ -114,7 +118,7 @@ namespace OpenSim.Services.Connectors
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/auth/plain",
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
Dictionary replyData = ServerUtils.ParseXmlResponse(
reply);
@@ -135,7 +139,7 @@ namespace OpenSim.Services.Connectors
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/auth/plain",
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
Dictionary replyData = ServerUtils.ParseXmlResponse(
reply);
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
index 35b7109..d2da85f 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
@@ -32,7 +32,6 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
@@ -105,7 +104,7 @@ namespace OpenSim.Services.Connectors
catch (Exception e)
{
m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message);
- message = "";
+ message = e.Message;
return m_ResponseOnFailure;
}
if (response == null)
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
index ddfca57..3f44efa 100644
--- a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
@@ -32,7 +32,7 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
@@ -41,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class AvatarServicesConnector : IAvatarService
+ public class AvatarServicesConnector : BaseServiceConnector, IAvatarService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -59,6 +59,7 @@ namespace OpenSim.Services.Connectors
}
public AvatarServicesConnector(IConfigSource source)
+ : base(source, "AvatarService")
{
Initialise(source);
}
@@ -81,6 +82,8 @@ namespace OpenSim.Services.Connectors
throw new Exception("Avatar connector init error");
}
m_ServerURI = serviceURI;
+
+ base.Initialise(source, "AvatarService");
}
@@ -114,7 +117,7 @@ namespace OpenSim.Services.Connectors
// m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
try
{
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply");
@@ -162,7 +165,7 @@ namespace OpenSim.Services.Connectors
//m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
try
{
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -207,7 +210,7 @@ namespace OpenSim.Services.Connectors
// m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
try
{
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -250,7 +253,7 @@ namespace OpenSim.Services.Connectors
// m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
try
{
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -293,7 +296,7 @@ namespace OpenSim.Services.Connectors
// m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
try
{
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
diff --git a/OpenSim/Services/Connectors/BaseServiceConnector.cs b/OpenSim/Services/Connectors/BaseServiceConnector.cs
new file mode 100644
index 0000000..98cd489
--- /dev/null
+++ b/OpenSim/Services/Connectors/BaseServiceConnector.cs
@@ -0,0 +1,33 @@
+using System;
+using OpenSim.Framework;
+using OpenSim.Framework.ServiceAuth;
+
+using Nini.Config;
+
+namespace OpenSim.Services.Connectors
+{
+ public class BaseServiceConnector
+ {
+ protected IServiceAuth m_Auth;
+
+ public BaseServiceConnector() { }
+
+ public BaseServiceConnector(IConfigSource config, string section)
+ {
+ Initialise(config, section);
+ }
+
+ public void Initialise(IConfigSource config, string section)
+ {
+ string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", section }, "None");
+
+ switch (authType)
+ {
+ case "BasicHttpAuthentication":
+ m_Auth = new BasicHttpAuthentication(config, section);
+ break;
+ }
+
+ }
+ }
+}
diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
new file mode 100644
index 0000000..6412bcd
--- /dev/null
+++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Reflection;
+
+using log4net;
+
+using OpenMetaverse;
+using Nini.Config;
+
+using OpenSim.Framework;
+using OpenSim.Framework.ServiceAuth;
+using OpenSim.Services.Connectors;
+using OpenSim.Services.Interfaces;
+using OpenSim.Server.Base;
+
+namespace OpenSim.Services.Connectors
+{
+ public class EstateDataRemoteConnector : BaseServiceConnector, IEstateDataService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+ private ExpiringCache> m_EstateCache = new ExpiringCache>();
+ private const int EXPIRATION = 5 * 60; // 5 minutes in secs
+
+ public EstateDataRemoteConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig gridConfig = source.Configs["EstateService"];
+ if (gridConfig == null)
+ {
+ m_log.Error("[ESTATE CONNECTOR]: EstateService missing from OpenSim.ini");
+ throw new Exception("Estate connector init error");
+ }
+
+ string serviceURI = gridConfig.GetString("EstateServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[ESTATE CONNECTOR]: No Server URI named in section EstateService");
+ throw new Exception("Estate connector init error");
+ }
+ m_ServerURI = serviceURI;
+
+ base.Initialise(source, "EstateService");
+ }
+
+ #region IEstateDataService
+
+ public List LoadEstateSettingsAll()
+ {
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/estates";
+
+ reply = MakeRequest("GET", uri, string.Empty);
+ if (String.IsNullOrEmpty(reply))
+ return new List();
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ List estates = new List();
+ if (replyData != null && replyData.Count > 0)
+ {
+ m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettingsAll returned {0} elements", replyData.Count);
+ Dictionary.ValueCollection estateData = replyData.Values;
+ foreach (object r in estateData)
+ {
+ if (r is Dictionary)
+ {
+ EstateSettings es = new EstateSettings((Dictionary)r);
+ estates.Add(es);
+ }
+ }
+ m_EstateCache.AddOrUpdate("estates", estates, EXPIRATION);
+ }
+ else
+ m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettingsAll from {0} received null or zero response", uri);
+
+ return estates;
+
+ }
+
+ public List GetEstatesAll()
+ {
+ List eids = new List();
+ // If we don't have them, load them from the server
+ List estates = null;
+ if (!m_EstateCache.TryGetValue("estates", out estates))
+ LoadEstateSettingsAll();
+
+ foreach (EstateSettings es in estates)
+ eids.Add((int)es.EstateID);
+
+ return eids;
+ }
+
+ public List GetEstates(string search)
+ {
+ // If we don't have them, load them from the server
+ List estates = null;
+ if (!m_EstateCache.TryGetValue("estates", out estates))
+ LoadEstateSettingsAll();
+
+ List eids = new List();
+ foreach (EstateSettings es in estates)
+ if (es.EstateName == search)
+ eids.Add((int)es.EstateID);
+
+ return eids;
+ }
+
+ public List GetEstatesByOwner(UUID ownerID)
+ {
+ // If we don't have them, load them from the server
+ List estates = null;
+ if (!m_EstateCache.TryGetValue("estates", out estates))
+ LoadEstateSettingsAll();
+
+ List eids = new List();
+ foreach (EstateSettings es in estates)
+ if (es.EstateOwner == ownerID)
+ eids.Add((int)es.EstateID);
+
+ return eids;
+ }
+
+ public List GetRegions(int estateID)
+ {
+ string reply = string.Empty;
+ // /estates/regions/?eid=int
+ string uri = m_ServerURI + "/estates/regions/?eid=" + estateID.ToString();
+
+ reply = MakeRequest("GET", uri, string.Empty);
+ if (String.IsNullOrEmpty(reply))
+ return new List();
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ List regions = new List();
+ if (replyData != null && replyData.Count > 0)
+ {
+ m_log.DebugFormat("[ESTATE CONNECTOR]: GetRegions for estate {0} returned {1} elements", estateID, replyData.Count);
+ Dictionary.ValueCollection data = replyData.Values;
+ foreach (object r in data)
+ {
+ UUID uuid = UUID.Zero;
+ if (UUID.TryParse(r.ToString(), out uuid))
+ regions.Add(uuid);
+ }
+ }
+ else
+ m_log.DebugFormat("[ESTATE CONNECTOR]: GetRegions from {0} received null or zero response", uri);
+
+ return regions;
+ }
+
+ public EstateSettings LoadEstateSettings(UUID regionID, bool create)
+ {
+ string reply = string.Empty;
+ // /estates/estate/?region=uuid&create=[t|f]
+ string uri = m_ServerURI + string.Format("/estates/estate/?region={0}&create={1}", regionID, create);
+
+ reply = MakeRequest("GET", uri, string.Empty);
+ if (String.IsNullOrEmpty(reply))
+ return null;
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null && replyData.Count > 0)
+ {
+ m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings({0}) returned {1} elements", regionID, replyData.Count);
+ EstateSettings es = new EstateSettings(replyData);
+ return es;
+ }
+ else
+ m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings(regionID) from {0} received null or zero response", uri);
+
+ return null;
+ }
+
+ public EstateSettings LoadEstateSettings(int estateID)
+ {
+ string reply = string.Empty;
+ // /estates/estate/?eid=int
+ string uri = m_ServerURI + string.Format("/estates/estate/?eid={0}", estateID);
+
+ reply = MakeRequest("GET", uri, string.Empty);
+ if (String.IsNullOrEmpty(reply))
+ return null;
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null && replyData.Count > 0)
+ {
+ m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings({0}) returned {1} elements", estateID, replyData.Count);
+ EstateSettings es = new EstateSettings(replyData);
+ return es;
+ }
+ else
+ m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings(estateID) from {0} received null or zero response", uri);
+
+ return null;
+ }
+
+ ///
+ /// Forbidden operation
+ ///
+ ///
+ public EstateSettings CreateNewEstate()
+ {
+ // No can do
+ return null;
+ }
+
+ public void StoreEstateSettings(EstateSettings es)
+ {
+ // /estates/estate/
+ string uri = m_ServerURI + ("/estates/estate");
+
+ Dictionary formdata = es.ToMap();
+ formdata["OP"] = "STORE";
+
+ PostRequest(uri, formdata);
+ }
+
+ public bool LinkRegion(UUID regionID, int estateID)
+ {
+ // /estates/estate/?eid=int®ion=uuid
+ string uri = m_ServerURI + String.Format("/estates/estate/?eid={0}®ion={1}", estateID, regionID);
+
+ Dictionary formdata = new Dictionary();
+ formdata["OP"] = "LINK";
+ return PostRequest(uri, formdata);
+ }
+
+ private bool PostRequest(string uri, Dictionary sendData)
+ {
+ string reqString = ServerUtils.BuildQueryString(sendData);
+
+ string reply = MakeRequest("POST", uri, reqString);
+ if (String.IsNullOrEmpty(reply))
+ return false;
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ bool result = false;
+ if (replyData != null && replyData.Count > 0)
+ {
+ if (replyData.ContainsKey("Result"))
+ {
+ if (Boolean.TryParse(replyData["Result"].ToString(), out result))
+ m_log.DebugFormat("[ESTATE CONNECTOR]: PostRequest {0} returned {1}", uri, result);
+ }
+ }
+ else
+ m_log.DebugFormat("[ESTATE CONNECTOR]: PostRequest {0} received null or zero response", uri);
+
+ return result;
+ }
+
+ ///
+ /// Forbidden operation
+ ///
+ ///
+ public bool DeleteEstate(int estateID)
+ {
+ return false;
+ }
+
+ #endregion
+
+ private string MakeRequest(string verb, string uri, string formdata)
+ {
+ string reply = string.Empty;
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest(verb, uri, formdata, m_Auth);
+ }
+ catch (WebException e)
+ {
+ using (HttpWebResponse hwr = (HttpWebResponse)e.Response)
+ {
+ if (hwr != null)
+ {
+ if (hwr.StatusCode == HttpStatusCode.NotFound)
+ m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri));
+ if (hwr.StatusCode == HttpStatusCode.Unauthorized)
+ m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri));
+ }
+ else
+ m_log.Error(string.Format(
+ "[ESTATE CONNECTOR]: WebException for {0} {1} {2} ",
+ verb, uri, formdata, e));
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[ESTATE CONNECTOR]: Exception when contacting estate server at {0}: {1}", uri, e.Message);
+ }
+
+ return reply;
+ }
+ }
+}
diff --git a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
index d688299..20dc1cc 100644
--- a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
+++ b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
@@ -32,7 +32,7 @@ using System.Collections;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
index b1dd84e..b7702a8 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+using OpenSim.Framework.ServiceAuth;
+
using OpenSim.Services.Interfaces;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Services.Connectors.Friends
{
- public class FriendsServicesConnector : IFriendsService
+ public class FriendsServicesConnector : BaseServiceConnector, IFriendsService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors.Friends
throw new Exception("Friends connector init error");
}
m_ServerURI = serviceURI;
+ base.Initialise(source, "FriendsService");
}
@@ -112,7 +114,7 @@ namespace OpenSim.Services.Connectors.Friends
try
{
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -168,7 +170,7 @@ namespace OpenSim.Services.Connectors.Friends
string uri = m_ServerURI + "/friends";
try
{
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
@@ -223,7 +225,7 @@ namespace OpenSim.Services.Connectors.Friends
string uri = m_ServerURI + "/friends";
try
{
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index 34ed0d7..596f867 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class GridServicesConnector : IGridService
+ public class GridServicesConnector : BaseServiceConnector, IGridService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors
throw new Exception("Grid connector init error");
}
m_ServerURI = serviceURI;
+
+ base.Initialise(source, "GridService");
}
@@ -102,7 +105,7 @@ namespace OpenSim.Services.Connectors
// m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
try
{
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -158,7 +161,7 @@ namespace OpenSim.Services.Connectors
try
{
string reply
- = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
if (reply != string.Empty)
{
@@ -195,7 +198,7 @@ namespace OpenSim.Services.Connectors
try
{
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
}
catch (Exception e)
{
@@ -238,7 +241,7 @@ namespace OpenSim.Services.Connectors
string uri = m_ServerURI + "/grid";
try
{
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
@@ -285,7 +288,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
@@ -330,7 +333,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
@@ -374,7 +377,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
@@ -428,7 +431,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
@@ -479,7 +482,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
@@ -515,6 +518,57 @@ namespace OpenSim.Services.Connectors
return rinfos;
}
+ public List GetDefaultHypergridRegions(UUID scopeID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+
+ sendData["METHOD"] = "get_default_hypergrid_regions";
+
+ List rinfos = new List();
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ ServerUtils.BuildQueryString(sendData), m_Auth);
+
+ //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return rinfos;
+ }
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null)
+ {
+ Dictionary.ValueCollection rinfosList = replyData.Values;
+ foreach (object r in rinfosList)
+ {
+ if (r is Dictionary)
+ {
+ GridRegion rinfo = new GridRegion((Dictionary)r);
+ rinfos.Add(rinfo);
+ }
+ }
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions {0} received null response",
+ scopeID);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions received null reply");
+
+ return rinfos;
+ }
+
public List GetFallbackRegions(UUID scopeID, int x, int y)
{
Dictionary sendData = new Dictionary();
@@ -532,7 +586,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
@@ -583,7 +637,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
@@ -634,7 +688,7 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), m_Auth);
}
catch (Exception e)
{
@@ -665,6 +719,45 @@ namespace OpenSim.Services.Connectors
return flags;
}
+ public Dictionary GetExtraFeatures()
+ {
+ Dictionary sendData = new Dictionary();
+ Dictionary extraFeatures = new Dictionary();
+
+ sendData["METHOD"] = "get_grid_extra_features";
+
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ ServerUtils.BuildQueryString(sendData), m_Auth);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: GetExtraFeatures - Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return extraFeatures;
+ }
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData != null) && replyData.Count > 0)
+ {
+ foreach (string key in replyData.Keys)
+ {
+ extraFeatures[key] = replyData[key].ToString();
+ }
+ }
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetExtraServiceURLs received null reply");
+
+ return extraFeatures;
+ }
#endregion
}
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
index 94bda82..b5ca1ad 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class GridUserServicesConnector : IGridUserService
+ public class GridUserServicesConnector : BaseServiceConnector, IGridUserService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors
throw new Exception("GridUser connector init error");
}
m_ServerURI = serviceURI;
+ base.Initialise(source, "GridUserService");
}
@@ -162,7 +164,8 @@ namespace OpenSim.Services.Connectors
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -198,7 +201,8 @@ namespace OpenSim.Services.Connectors
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -214,7 +218,7 @@ namespace OpenSim.Services.Connectors
}
else
- m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply");
+ m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply");
}
catch (Exception e)
{
@@ -243,7 +247,8 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply");
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 5bcff48..b1663ee 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -53,7 +53,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
private IAssetService m_AssetService;
- public GatekeeperServiceConnector() : base()
+ public GatekeeperServiceConnector()
+ : base()
{
}
@@ -123,11 +124,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
realHandle = Convert.ToUInt64((string)hash["handle"]);
//m_log.Debug(">> HERE, realHandle: " + realHandle);
}
- if (hash["region_image"] != null) {
+ if (hash["region_image"] != null)
+ {
imageURL = (string)hash["region_image"];
//m_log.Debug(">> HERE, imageURL: " + imageURL);
}
- if (hash["external_name"] != null) {
+ if (hash["external_name"] != null)
+ {
externalName = (string)hash["external_name"];
//m_log.Debug(">> HERE, externalName: " + externalName);
}
@@ -178,7 +181,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
//m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
imageData = OpenJPEG.EncodeFromImage(bitmap, true);
}
-
+
AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
// !!! for now
@@ -199,10 +202,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
return mapTile;
}
- public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID)
+ public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, UUID agentID, string agentHomeURI, out string message)
{
Hashtable hash = new Hashtable();
hash["region_uuid"] = regionID.ToString();
+ if (agentID != UUID.Zero)
+ {
+ hash["agent_id"] = agentID.ToString();
+ if (agentHomeURI != null)
+ hash["agent_home_uri"] = agentHomeURI;
+ }
IList paramList = new ArrayList();
paramList.Add(hash);
@@ -216,12 +225,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
}
catch (Exception e)
{
+ message = "Error contacting grid.";
m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message);
return null;
}
if (response.IsFault)
{
+ message = "Error contacting grid.";
m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString);
return null;
}
@@ -233,6 +244,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
{
bool success = false;
Boolean.TryParse((string)hash["result"], out success);
+
+ if (hash["message"] != null)
+ message = (string)hash["message"];
+ else if (success)
+ message = null;
+ else
+ message = "The teleport destination could not be found."; // probably the dest grid is old and doesn't send 'message', but the most common problem is that the region is unavailable
+
if (success)
{
GridRegion region = new GridRegion();
@@ -252,12 +271,25 @@ namespace OpenSim.Services.Connectors.Hypergrid
region.RegionLocY = n;
//m_log.Debug(">> HERE, y: " + region.RegionLocY);
}
+ if (hash["size_x"] != null)
+ {
+ Int32.TryParse((string)hash["size_x"], out n);
+ region.RegionSizeX = n;
+ //m_log.Debug(">> HERE, x: " + region.RegionLocX);
+ }
+ if (hash["size_y"] != null)
+ {
+ Int32.TryParse((string)hash["size_y"], out n);
+ region.RegionSizeY = n;
+ //m_log.Debug(">> HERE, y: " + region.RegionLocY);
+ }
if (hash["region_name"] != null)
{
region.RegionName = (string)hash["region_name"];
//m_log.Debug(">> HERE, region_name: " + region.RegionName);
}
- if (hash["hostname"] != null) {
+ if (hash["hostname"] != null)
+ {
region.ExternalHostName = (string)hash["hostname"];
//m_log.Debug(">> HERE, hostname: " + region.ExternalHostName);
}
@@ -275,10 +307,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
//m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint);
}
-
+
if (hash["server_uri"] != null)
{
- region.ServerURI = (string) hash["server_uri"];
+ region.ServerURI = (string)hash["server_uri"];
//m_log.Debug(">> HERE, server_uri: " + region.ServerURI);
}
@@ -289,61 +321,12 @@ namespace OpenSim.Services.Connectors.Hypergrid
}
catch (Exception e)
{
+ message = "Error parsing response from grid.";
m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace);
return null;
}
return null;
}
-
- public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
- {
- // m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");
-
- myipaddress = String.Empty;
- reason = String.Empty;
-
- if (destination == null)
- {
- m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
- return false;
- }
-
- string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
-
- try
- {
- OSDMap args = aCircuit.PackAgentCircuitData();
-
- args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
- args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
- args["destination_name"] = OSD.FromString(destination.RegionName);
- args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
- args["teleport_flags"] = OSD.FromString(flags.ToString());
-
- OSDMap result = WebUtil.PostToService(uri, args, 80000);
- if (result["Success"].AsBoolean())
- {
- OSDMap unpacked = (OSDMap)result["_Result"];
-
- if (unpacked != null)
- {
- reason = unpacked["reason"].AsString();
- myipaddress = unpacked["your_ip"].AsString();
- return unpacked["success"].AsBoolean();
- }
- }
-
- reason = result["Message"] != null ? result["Message"].AsString() : "error";
- return false;
- }
- catch (Exception e)
- {
- m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
- reason = e.Message;
- }
-
- return false;
- }
}
}
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
index e984a54..622d4e1 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
@@ -277,7 +277,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- ServerUtils.BuildQueryString(sendData));
+ ServerUtils.BuildQueryString(sendData), 15);
}
catch (Exception e)
{
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
index 5c50936..b5e6d69 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
@@ -47,16 +47,22 @@ namespace OpenSim.Services.Connectors
public HeloServicesConnector(string serverURI)
{
- if (!serverURI.EndsWith("="))
- m_ServerURI = serverURI.TrimEnd('/') + "/helo/";
- else
+ try
{
- // Simian sends malformed urls like this:
- // http://valley.virtualportland.org/simtest/Grid/?id=
- //
- try
+ Uri uri;
+
+ if (!serverURI.EndsWith("="))
+ {
+ // Let's check if this is a valid URI, because it may not be
+ uri = new Uri(serverURI);
+ m_ServerURI = serverURI.TrimEnd('/') + "/helo/";
+ }
+ else
{
- Uri uri = new Uri(serverURI + "xxx");
+ // Simian sends malformed urls like this:
+ // http://valley.virtualportland.org/simtest/Grid/?id=
+ //
+ uri = new Uri(serverURI + "xxx");
if (uri.Query == string.Empty)
m_ServerURI = serverURI.TrimEnd('/') + "/helo/";
else
@@ -66,26 +72,34 @@ namespace OpenSim.Services.Connectors
m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/";
}
}
- catch (UriFormatException)
- {
- m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI);
- }
+
+ }
+ catch (UriFormatException)
+ {
+ m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI);
}
}
-
public virtual string Helo()
{
- HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
- // Eventually we need to switch to HEAD
- /* req.Method = "HEAD"; */
+ if (String.IsNullOrEmpty(m_ServerURI))
+ {
+ m_log.WarnFormat("[HELO SERVICE]: Unable to invoke HELO due to empty URL");
+ return String.Empty;
+ }
try
{
- WebResponse response = req.GetResponse();
- if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
- return string.Empty;
- return response.Headers.Get("X-Handlers-Provided");
+ HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
+ // Eventually we need to switch to HEAD
+ /* req.Method = "HEAD"; */
+
+ using (WebResponse response = req.GetResponse())
+ {
+ if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
+ return string.Empty;
+ return response.Headers.Get("X-Handlers-Provided");
+ }
}
catch (Exception e)
{
@@ -95,6 +109,5 @@ namespace OpenSim.Services.Connectors
// fail
return string.Empty;
}
-
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 2f263ae..8abd046 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -44,13 +44,15 @@ using Nini.Config;
namespace OpenSim.Services.Connectors.Hypergrid
{
- public class UserAgentServiceConnector : IUserAgentService
+ public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
- string m_ServerURL;
+ private string m_ServerURLHost;
+ private string m_ServerURL;
+ private GridRegion m_Gatekeeper;
public UserAgentServiceConnector(string url) : this(url, true)
{
@@ -58,7 +60,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
public UserAgentServiceConnector(string url, bool dnsLookup)
{
- m_ServerURL = url;
+ m_ServerURL = m_ServerURLHost = url;
if (dnsLookup)
{
@@ -74,10 +76,11 @@ namespace OpenSim.Services.Connectors.Hypergrid
}
catch (Exception e)
{
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message);
+ m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", url, e.Message);
}
}
- m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
+
+ //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
}
public UserAgentServiceConnector(IConfigSource config)
@@ -97,16 +100,23 @@ namespace OpenSim.Services.Connectors.Hypergrid
m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService");
throw new Exception("UserAgent connector init error");
}
- m_ServerURL = serviceURI;
+
+ m_ServerURL = m_ServerURLHost = serviceURI;
if (!m_ServerURL.EndsWith("/"))
m_ServerURL += "/";
- m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
+ //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0}", m_ServerURL);
}
+ protected override string AgentPath()
+ {
+ return "homeagent/";
+ }
- // The Login service calls this interface with a non-null [client] ipaddress
- public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason)
+ // The Login service calls this interface with fromLogin=true
+ // Sims call it with fromLogin=false
+ // Either way, this is verified by the handler
+ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
{
reason = String.Empty;
@@ -117,151 +127,34 @@ namespace OpenSim.Services.Connectors.Hypergrid
return false;
}
- string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/";
-
- Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri);
-
- HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
- AgentCreateRequest.Method = "POST";
- AgentCreateRequest.ContentType = "application/json";
- AgentCreateRequest.Timeout = 10000;
- //AgentCreateRequest.KeepAlive = false;
- //AgentCreateRequest.Headers.Add("Authorization", authKey);
-
- // Fill it in
- OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
-
- string strBuffer = "";
- byte[] buffer = new byte[1];
- try
- {
- strBuffer = OSDParser.SerializeJsonString(args);
- Encoding str = Util.UTF8;
- buffer = str.GetBytes(strBuffer);
-
- }
- catch (Exception e)
- {
- m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
- // ignore. buffer will be empty, caller should check.
- }
-
- Stream os = null;
- try
- { // send the Post
- AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
- os = AgentCreateRequest.GetRequestStream();
- os.Write(buffer, 0, strBuffer.Length); //Send it
- m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
- uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
- }
- //catch (WebException ex)
- catch
- {
- //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
- reason = "cannot contact remote region";
- return false;
- }
- finally
- {
- if (os != null)
- os.Close();
- }
-
- // Let's wait for the response
- //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
+ GridRegion home = new GridRegion();
+ home.ServerURI = m_ServerURL;
+ home.RegionID = destination.RegionID;
+ home.RegionLocX = destination.RegionLocX;
+ home.RegionLocY = destination.RegionLocY;
- WebResponse webResponse = null;
- StreamReader sr = null;
- try
- {
- webResponse = AgentCreateRequest.GetResponse();
- if (webResponse == null)
- {
- m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
- }
- else
- {
+ m_Gatekeeper = gatekeeper;
- sr = new StreamReader(webResponse.GetResponseStream());
- string response = sr.ReadToEnd().Trim();
- m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
-
- if (!String.IsNullOrEmpty(response))
- {
- try
- {
- // we assume we got an OSDMap back
- OSDMap r = Util.GetOSDMap(response);
- bool success = r["success"].AsBoolean();
- reason = r["reason"].AsString();
- return success;
- }
- catch (NullReferenceException e)
- {
- m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
-
- // check for old style response
- if (response.ToLower().StartsWith("true"))
- return true;
-
- return false;
- }
- }
- }
- }
- catch (WebException ex)
- {
- m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
- reason = "Destination did not reply";
- return false;
- }
- finally
- {
- if (sr != null)
- sr.Close();
- }
-
- return true;
+ Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
+ uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
+ return CreateAgent(source, home, aCircuit, flags, out reason);
}
// The simulators call this interface
- public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
+ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
{
- return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason);
+ return LoginAgentToGrid(source, aCircuit, gatekeeper, destination, false, out reason);
}
- protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
+ protected override void PackData(OSDMap args, GridRegion source, AgentCircuitData aCircuit, GridRegion destination, uint flags)
{
- OSDMap args = null;
- try
- {
- args = aCircuit.PackAgentCircuitData();
- }
- catch (Exception e)
- {
- m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
- }
-
- // Add the input arguments
- args["gatekeeper_serveruri"] = OSD.FromString(gatekeeper.ServerURI);
- args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName);
- args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString());
- args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
- args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
- args["destination_name"] = OSD.FromString(destination.RegionName);
- args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
+ base.PackData(args, source, aCircuit, destination, flags);
+ args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
+ args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
+ args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
-
- // 10/3/2010
- // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here.
- // This need cleaning elsewhere...
- //if (ipaddress != null)
- // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString());
-
- return args;
}
public void SetClientToken(UUID sessionID, string token)
@@ -269,96 +162,111 @@ namespace OpenSim.Services.Connectors.Hypergrid
// no-op
}
- public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
+ private Hashtable CallServer(string methodName, Hashtable hash)
{
- position = Vector3.UnitY; lookAt = Vector3.UnitY;
-
- Hashtable hash = new Hashtable();
- hash["userID"] = userID.ToString();
-
IList paramList = new ArrayList();
paramList.Add(hash);
- XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
+ XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
+
+ // Send and get reply
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
- catch (Exception)
+ catch (Exception e)
{
- return null;
+ m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURLHost, e.Message);
+ throw;
}
if (response.IsFault)
{
- return null;
+ throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURLHost, response.FaultString));
}
hash = (Hashtable)response.Value;
- //foreach (Object o in hash)
- // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
- try
+
+ if (hash == null)
{
- bool success = false;
- Boolean.TryParse((string)hash["result"], out success);
- if (success)
- {
- GridRegion region = new GridRegion();
+ throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURLHost));
+ }
- UUID.TryParse((string)hash["uuid"], out region.RegionID);
- //m_log.Debug(">> HERE, uuid: " + region.RegionID);
- int n = 0;
- if (hash["x"] != null)
- {
- Int32.TryParse((string)hash["x"], out n);
- region.RegionLocX = n;
- //m_log.Debug(">> HERE, x: " + region.RegionLocX);
- }
- if (hash["y"] != null)
- {
- Int32.TryParse((string)hash["y"], out n);
- region.RegionLocY = n;
- //m_log.Debug(">> HERE, y: " + region.RegionLocY);
- }
- if (hash["region_name"] != null)
- {
- region.RegionName = (string)hash["region_name"];
- //m_log.Debug(">> HERE, name: " + region.RegionName);
- }
- if (hash["hostname"] != null)
- region.ExternalHostName = (string)hash["hostname"];
- if (hash["http_port"] != null)
- {
- uint p = 0;
- UInt32.TryParse((string)hash["http_port"], out p);
- region.HttpPort = p;
- }
- if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
- region.ServerURI = (string)hash["server_uri"];
+ return hash;
+ }
- if (hash["internal_port"] != null)
- {
- int p = 0;
- Int32.TryParse((string)hash["internal_port"], out p);
- region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
- }
- if (hash["position"] != null)
- Vector3.TryParse((string)hash["position"], out position);
- if (hash["lookAt"] != null)
- Vector3.TryParse((string)hash["lookAt"], out lookAt);
+ public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
+ {
+ position = Vector3.UnitY; lookAt = Vector3.UnitY;
- // Successful return
- return region;
- }
+ Hashtable hash = new Hashtable();
+ hash["userID"] = userID.ToString();
+
+ hash = CallServer("get_home_region", hash);
+
+ bool success;
+ if (!Boolean.TryParse((string)hash["result"], out success) || !success)
+ return null;
+
+ GridRegion region = new GridRegion();
+ UUID.TryParse((string)hash["uuid"], out region.RegionID);
+ //m_log.Debug(">> HERE, uuid: " + region.RegionID);
+ int n = 0;
+ if (hash["x"] != null)
+ {
+ Int32.TryParse((string)hash["x"], out n);
+ region.RegionLocX = n;
+ //m_log.Debug(">> HERE, x: " + region.RegionLocX);
}
- catch (Exception)
+ if (hash["y"] != null)
{
- return null;
+ Int32.TryParse((string)hash["y"], out n);
+ region.RegionLocY = n;
+ //m_log.Debug(">> HERE, y: " + region.RegionLocY);
+ }
+ if (hash["size_x"] != null)
+ {
+ Int32.TryParse((string)hash["size_x"], out n);
+ region.RegionSizeX = n;
+ //m_log.Debug(">> HERE, x: " + region.RegionLocX);
}
+ if (hash["size_y"] != null)
+ {
+ Int32.TryParse((string)hash["size_y"], out n);
+ region.RegionSizeY = n;
+ //m_log.Debug(">> HERE, y: " + region.RegionLocY);
+ }
+ if (hash["region_name"] != null)
+ {
+ region.RegionName = (string)hash["region_name"];
+ //m_log.Debug(">> HERE, name: " + region.RegionName);
+ }
+ if (hash["hostname"] != null)
+ region.ExternalHostName = (string)hash["hostname"];
+ if (hash["http_port"] != null)
+ {
+ uint p = 0;
+ UInt32.TryParse((string)hash["http_port"], out p);
+ region.HttpPort = p;
+ }
+ if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
+ region.ServerURI = (string)hash["server_uri"];
- return null;
+ if (hash["internal_port"] != null)
+ {
+ int p = 0;
+ Int32.TryParse((string)hash["internal_port"], out p);
+ region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
+ }
+ if (hash["position"] != null)
+ Vector3.TryParse((string)hash["position"], out position);
+ if (hash["lookAt"] != null)
+ Vector3.TryParse((string)hash["lookAt"], out lookAt);
+
+ // Successful return
+ return region;
}
public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
@@ -445,14 +353,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
}
catch
{
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURL);
+ m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURLHost);
// reason = "Exception: " + e.Message;
return friendsOnline;
}
if (response.IsFault)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURL, response.FaultString);
+ m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURLHost, response.FaultString);
// reason = "XMLRPC Fault";
return friendsOnline;
}
@@ -464,7 +372,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
{
if (hash == null)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
+ m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
// reason = "Internal error 1";
return friendsOnline;
}
@@ -517,14 +425,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
}
catch
{
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURL);
+ m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURLHost);
// reason = "Exception: " + e.Message;
return online;
}
if (response.IsFault)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURL, response.FaultString);
+ m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURLHost, response.FaultString);
// reason = "XMLRPC Fault";
return online;
}
@@ -536,7 +444,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
{
if (hash == null)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
+ m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
// reason = "Internal error 1";
return online;
}
@@ -567,51 +475,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString();
- IList paramList = new ArrayList();
- paramList.Add(hash);
-
- XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList);
+ hash = CallServer("get_user_info", hash);
Dictionary info = new Dictionary();
- XmlRpcResponse response = null;
- try
- {
- response = request.Send(m_ServerURL, 10000);
- }
- catch
- {
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL);
- return info;
- }
- if (response.IsFault)
+ foreach (object key in hash.Keys)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
- return info;
- }
-
- hash = (Hashtable)response.Value;
- try
- {
- if (hash == null)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
- return info;
- }
-
- // Here is the actual response
- foreach (object key in hash.Keys)
+ if (hash[key] != null)
{
- if (hash[key] != null)
- {
- info.Add(key.ToString(), hash[key]);
- }
+ info.Add(key.ToString(), hash[key]);
}
}
- catch
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
- }
return info;
}
@@ -621,60 +495,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString();
- IList paramList = new ArrayList();
- paramList.Add(hash);
-
- XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList);
-// string reason = string.Empty;
-
- // Send and get reply
- Dictionary serverURLs = new Dictionary();
- XmlRpcResponse response = null;
- try
- {
- response = request.Send(m_ServerURL, 10000);
- }
- catch
- {
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL);
-// reason = "Exception: " + e.Message;
- return serverURLs;
- }
-
- if (response.IsFault)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
-// reason = "XMLRPC Fault";
- return serverURLs;
- }
-
- hash = (Hashtable)response.Value;
- //foreach (Object o in hash)
- // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
- try
+ hash = CallServer("get_server_urls", hash);
+
+ Dictionary serverURLs = new Dictionary();
+ foreach (object key in hash.Keys)
{
- if (hash == null)
+ if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
-// reason = "Internal error 1";
- return serverURLs;
+ string serverType = key.ToString().Substring(4); // remove "SRV_"
+ serverURLs.Add(serverType, hash[key].ToString());
}
-
- // Here is the actual response
- foreach (object key in hash.Keys)
- {
- if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
- {
- string serverType = key.ToString().Substring(4); // remove "SRV_"
- serverURLs.Add(serverType, hash[key].ToString());
- }
- }
-
- }
- catch
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
-// reason = "Exception: " + e.Message;
}
return serverURLs;
@@ -685,55 +515,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString();
- IList paramList = new ArrayList();
- paramList.Add(hash);
+ hash = CallServer("locate_user", hash);
- XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
-// string reason = string.Empty;
-
- // Send and get reply
string url = string.Empty;
- XmlRpcResponse response = null;
- try
- {
- response = request.Send(m_ServerURL, 10000);
- }
- catch
- {
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL);
-// reason = "Exception: " + e.Message;
- return url;
- }
- if (response.IsFault)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString);
-// reason = "XMLRPC Fault";
- return url;
- }
-
- hash = (Hashtable)response.Value;
- //foreach (Object o in hash)
- // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
- try
- {
- if (hash == null)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
-// reason = "Internal error 1";
- return url;
- }
-
- // Here's the actual response
- if (hash.ContainsKey("URL"))
- url = hash["URL"].ToString();
-
- }
- catch
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
-// reason = "Exception: " + e.Message;
- }
+ // Here's the actual response
+ if (hash.ContainsKey("URL"))
+ url = hash["URL"].ToString();
return url;
}
@@ -744,55 +532,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
hash["userID"] = userID.ToString();
hash["targetUserID"] = targetUserID.ToString();
- IList paramList = new ArrayList();
- paramList.Add(hash);
-
- XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
-// string reason = string.Empty;
+ hash = CallServer("get_uui", hash);
- // Send and get reply
string uui = string.Empty;
- XmlRpcResponse response = null;
- try
- {
- response = request.Send(m_ServerURL, 10000);
- }
- catch
- {
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL);
-// reason = "Exception: " + e.Message;
- return uui;
- }
-
- if (response.IsFault)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString);
-// reason = "XMLRPC Fault";
- return uui;
- }
-
- hash = (Hashtable)response.Value;
- //foreach (Object o in hash)
- // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
- try
- {
- if (hash == null)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
-// reason = "Internal error 1";
- return uui;
- }
- // Here's the actual response
- if (hash.ContainsKey("UUI"))
- uui = hash["UUI"].ToString();
-
- }
- catch
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response.");
-// reason = "Exception: " + e.Message;
- }
+ // Here's the actual response
+ if (hash.ContainsKey("UUI"))
+ uui = hash["UUI"].ToString();
return uui;
}
@@ -803,54 +549,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
hash["first"] = first;
hash["last"] = last;
- IList paramList = new ArrayList();
- paramList.Add(hash);
+ hash = CallServer("get_uuid", hash);
- XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList);
- // string reason = string.Empty;
-
- // Send and get reply
- UUID uuid = UUID.Zero;
- XmlRpcResponse response = null;
- try
- {
- response = request.Send(m_ServerURL, 10000);
- }
- catch
+ if (!hash.ContainsKey("UUID"))
{
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL);
- // reason = "Exception: " + e.Message;
- return uuid;
+ throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURLHost));
}
- if (response.IsFault)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString);
- // reason = "XMLRPC Fault";
- return uuid;
- }
-
- hash = (Hashtable)response.Value;
- //foreach (Object o in hash)
- // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
- try
- {
- if (hash == null)
- {
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
- // reason = "Internal error 1";
- return uuid;
- }
-
- // Here's the actual response
- if (hash.ContainsKey("UUID"))
- UUID.TryParse(hash["UUID"].ToString(), out uuid);
-
- }
- catch
+ UUID uuid;
+ if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response.");
- // reason = "Exception: " + e.Message;
+ throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURLHost, hash["UUID"].ToString()));
}
return uuid;
@@ -858,7 +567,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
private bool GetBoolResponse(XmlRpcRequest request, out string reason)
{
- //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL);
+ //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURLHost);
XmlRpcResponse response = null;
try
{
@@ -866,14 +575,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
}
catch (Exception e)
{
- m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURL);
+ m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURLHost);
reason = "Exception: " + e.Message;
return false;
}
if (response.IsFault)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURL, response.FaultString);
+ m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURLHost, response.FaultString);
reason = "XMLRPC Fault";
return false;
}
@@ -885,7 +594,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
{
if (hash == null)
{
- m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
+ m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
reason = "Internal error 1";
return false;
}
@@ -896,7 +605,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
else
{
reason = "Internal error 2";
- m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURL);
+ m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURLHost);
}
return success;
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
index dbce9f6..e19c23d 100644
--- a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
+++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
@@ -123,6 +123,7 @@ namespace OpenSim.Services.Connectors.InstantMessage
gim["position_z"] = msg.Position.Z.ToString();
gim["region_id"] = msg.RegionID.ToString();
gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None);
+ gim["region_id"] = new UUID(msg.RegionID).ToString();
return gim;
}
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index 44f5e01..7cecd93 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -33,22 +33,37 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
-using OpenSim.Framework.Communications;
+
+using OpenSim.Framework.Monitoring;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class XInventoryServicesConnector : IInventoryService
+ public class XInventoryServicesConnector : BaseServiceConnector, IInventoryService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// Number of requests made to the remote inventory service.
+ ///
+ public int RequestsMade { get; private set; }
+
private string m_ServerURI = String.Empty;
- private object m_Lock = new object();
+ ///
+ /// Timeout for remote requests.
+ ///
+ ///
+ /// In this case, -1 is default timeout (100 seconds), not infinite.
+ ///
+ private int m_requestTimeoutSecs = -1;
+
+ private const double CACHE_EXPIRATION_SECONDS = 20.0;
+ private static ExpiringCache m_ItemCache = new ExpiringCache();
public XInventoryServicesConnector()
{
@@ -60,20 +75,21 @@ namespace OpenSim.Services.Connectors
}
public XInventoryServicesConnector(IConfigSource source)
+ : base(source, "InventoryService")
{
Initialise(source);
}
public virtual void Initialise(IConfigSource source)
{
- IConfig assetConfig = source.Configs["InventoryService"];
- if (assetConfig == null)
+ IConfig config = source.Configs["InventoryService"];
+ if (config == null)
{
m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
throw new Exception("Inventory connector init error");
}
- string serviceURI = assetConfig.GetString("InventoryServerURI",
+ string serviceURI = config.GetString("InventoryServerURI",
String.Empty);
if (serviceURI == String.Empty)
@@ -82,6 +98,45 @@ namespace OpenSim.Services.Connectors
throw new Exception("Inventory connector init error");
}
m_ServerURI = serviceURI;
+
+ m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs);
+
+ StatsManager.RegisterStat(
+ new Stat(
+ "RequestsMade",
+ "Requests made",
+ "Number of requests made to the remove inventory service",
+ "requests",
+ "inventory",
+ serviceURI,
+ StatType.Pull,
+ MeasuresOfInterest.AverageChangeOverTime,
+ s => s.Value = RequestsMade,
+ StatVerbosity.Debug));
+ }
+
+ private bool CheckReturn(Dictionary ret)
+ {
+ if (ret == null)
+ return false;
+
+ if (ret.Count == 0)
+ return false;
+
+ if (ret.ContainsKey("RESULT"))
+ {
+ if (ret["RESULT"] is string)
+ {
+ bool result;
+
+ if (bool.TryParse((string)ret["RESULT"], out result))
+ return result;
+
+ return false;
+ }
+ }
+
+ return true;
}
public bool CreateUserInventory(UUID principalID)
@@ -91,12 +146,7 @@ namespace OpenSim.Services.Connectors
{ "PRINCIPAL", principalID.ToString() }
});
- if (ret == null)
- return false;
- if (ret.Count == 0)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public List GetInventorySkeleton(UUID principalID)
@@ -106,9 +156,7 @@ namespace OpenSim.Services.Connectors
{ "PRINCIPAL", principalID.ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
Dictionary folders = (Dictionary)ret["FOLDERS"];
@@ -135,15 +183,13 @@ namespace OpenSim.Services.Connectors
{ "PRINCIPAL", principalID.ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
return BuildFolder((Dictionary)ret["folder"]);
}
- public InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
+ public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
{
Dictionary ret = MakeRequest("GETFOLDERFORTYPE",
new Dictionary {
@@ -151,9 +197,7 @@ namespace OpenSim.Services.Connectors
{ "TYPE", ((int)type).ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
return BuildFolder((Dictionary)ret["folder"]);
@@ -164,7 +208,7 @@ namespace OpenSim.Services.Connectors
InventoryCollection inventory = new InventoryCollection();
inventory.Folders = new List();
inventory.Items = new List();
- inventory.UserID = principalID;
+ inventory.OwnerID = principalID;
try
{
@@ -174,20 +218,20 @@ namespace OpenSim.Services.Connectors
{ "FOLDER", folderID.ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
- Dictionary folders =
- (Dictionary)ret["FOLDERS"];
- Dictionary items =
- (Dictionary)ret["ITEMS"];
-
- foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
- inventory.Folders.Add(BuildFolder((Dictionary)o));
- foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
- inventory.Items.Add(BuildItem((Dictionary)o));
+ Dictionary folders = ret.ContainsKey("FOLDERS") ?
+ (Dictionary)ret["FOLDERS"] : null;
+ Dictionary items = ret.ContainsKey("ITEMS") ?
+ (Dictionary)ret["ITEMS"] : null;
+
+ if (folders != null)
+ foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
+ inventory.Folders.Add(BuildFolder((Dictionary)o));
+ if (items != null)
+ foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
+ inventory.Items.Add(BuildItem((Dictionary)o));
}
catch (Exception e)
{
@@ -196,6 +240,87 @@ namespace OpenSim.Services.Connectors
return inventory;
}
+
+ public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
+ {
+ InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length];
+ // m_log.DebugFormat("[XXX]: In GetMultipleFoldersContent {0}", String.Join(",", folderIDs));
+ try
+ {
+ Dictionary resultSet = MakeRequest("GETMULTIPLEFOLDERSCONTENT",
+ new Dictionary {
+ { "PRINCIPAL", principalID.ToString() },
+ { "FOLDERS", String.Join(",", folderIDs) },
+ { "COUNT", folderIDs.Length.ToString() }
+ });
+
+ if (!CheckReturn(resultSet))
+ return null;
+
+ int i = 0;
+ foreach (KeyValuePair kvp in resultSet)
+ {
+ InventoryCollection inventory = new InventoryCollection();
+ if (kvp.Key.StartsWith("F_"))
+ {
+ UUID fid = UUID.Zero;
+ if (UUID.TryParse(kvp.Key.Substring(2), out fid) && fid == folderIDs[i])
+ {
+ inventory.Folders = new List();
+ inventory.Items = new List();
+
+ Dictionary ret = (Dictionary)kvp.Value;
+
+ if (ret.ContainsKey("FID"))
+ {
+ if (!UUID.TryParse(ret["FID"].ToString(), out inventory.FolderID))
+ m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", ret["FID"].ToString());
+ }
+ else
+ m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response");
+
+ inventory.Version = -1;
+ if (ret.ContainsKey("VERSION"))
+ Int32.TryParse(ret["VERSION"].ToString(), out inventory.Version);
+ if (ret.ContainsKey("OWNER"))
+ UUID.TryParse(ret["OWNER"].ToString(), out inventory.OwnerID);
+
+ //m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID);
+
+ Dictionary folders =
+ (Dictionary)ret["FOLDERS"];
+ Dictionary items =
+ (Dictionary)ret["ITEMS"];
+
+ foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
+ {
+ inventory.Folders.Add(BuildFolder((Dictionary)o));
+ }
+ foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
+ {
+ inventory.Items.Add(BuildItem((Dictionary)o));
+ }
+
+ inventoryArr[i] = inventory;
+ }
+ else
+ {
+ m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Folder id does not match. Expected {0} got {1}",
+ folderIDs[i], fid);
+ m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: {0} {1}", String.Join(",", folderIDs), String.Join(",", resultSet.Keys));
+ }
+
+ i += 1;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleFoldersContent: {0}", e.Message);
+ }
+
+ return inventoryArr;
+ }
public List GetFolderItems(UUID principalID, UUID folderID)
{
@@ -205,9 +330,7 @@ namespace OpenSim.Services.Connectors
{ "FOLDER", folderID.ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
Dictionary items = (Dictionary)ret["ITEMS"];
@@ -230,10 +353,7 @@ namespace OpenSim.Services.Connectors
{ "ID", folder.ID.ToString() }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool UpdateFolder(InventoryFolderBase folder)
@@ -248,10 +368,7 @@ namespace OpenSim.Services.Connectors
{ "ID", folder.ID.ToString() }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool MoveFolder(InventoryFolderBase folder)
@@ -263,10 +380,7 @@ namespace OpenSim.Services.Connectors
{ "PRINCIPAL", folder.Owner.ToString() }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool DeleteFolders(UUID principalID, List folderIDs)
@@ -282,10 +396,7 @@ namespace OpenSim.Services.Connectors
{ "FOLDERS", slist }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool PurgeFolder(InventoryFolderBase folder)
@@ -295,17 +406,18 @@ namespace OpenSim.Services.Connectors
{ "ID", folder.ID.ToString() }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool AddItem(InventoryItemBase item)
{
+ if (item.Description == null)
+ item.Description = String.Empty;
if (item.CreatorData == null)
item.CreatorData = String.Empty;
- Dictionary ret = MakeRequest("ADDITEM",
+ if (item.CreatorId == null)
+ item.CreatorId = String.Empty;
+ Dictionary ret = MakeRequest("ADDITEM",
new Dictionary {
{ "AssetID", item.AssetID.ToString() },
{ "AssetType", item.AssetType.ToString() },
@@ -330,10 +442,7 @@ namespace OpenSim.Services.Connectors
{ "CreationDate", item.CreationDate.ToString() }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool UpdateItem(InventoryItemBase item)
@@ -365,10 +474,13 @@ namespace OpenSim.Services.Connectors
{ "CreationDate", item.CreationDate.ToString() }
});
- if (ret == null)
- return false;
+ bool result = CheckReturn(ret);
+ if (result)
+ {
+ m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS);
+ }
- return bool.Parse(ret["RESULT"].ToString());
+ return result;
}
public bool MoveItems(UUID principalID, List items)
@@ -389,10 +501,7 @@ namespace OpenSim.Services.Connectors
{ "DESTLIST", destlist }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public bool DeleteItems(UUID principalID, List itemIDs)
@@ -408,14 +517,17 @@ namespace OpenSim.Services.Connectors
{ "ITEMS", slist }
});
- if (ret == null)
- return false;
-
- return bool.Parse(ret["RESULT"].ToString());
+ return CheckReturn(ret);
}
public InventoryItemBase GetItem(InventoryItemBase item)
{
+ InventoryItemBase retrieved = null;
+ if (m_ItemCache.TryGetValue(item.ID, out retrieved))
+ {
+ return retrieved;
+ }
+
try
{
Dictionary ret = MakeRequest("GETITEM",
@@ -423,19 +535,81 @@ namespace OpenSim.Services.Connectors
{ "ID", item.ID.ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
- return BuildItem((Dictionary)ret["item"]);
+ retrieved = BuildItem((Dictionary)ret["item"]);
}
catch (Exception e)
{
m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e);
}
- return null;
+ m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS);
+
+ return retrieved;
+ }
+
+ public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
+ {
+ //m_log.DebugFormat("[XXX]: In GetMultipleItems {0}", String.Join(",", itemIDs));
+
+ InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length];
+ // Try to get them from the cache
+ List pending = new List();
+ InventoryItemBase item = null;
+ int i = 0;
+ foreach (UUID id in itemIDs)
+ {
+ if (m_ItemCache.TryGetValue(id, out item))
+ itemArr[i++] = item;
+ else
+ pending.Add(id);
+ }
+
+ if (pending.Count == 0) // we're done, everything was in the cache
+ return itemArr;
+
+ try
+ {
+ Dictionary resultSet = MakeRequest("GETMULTIPLEITEMS",
+ new Dictionary {
+ { "PRINCIPAL", principalID.ToString() },
+ { "ITEMS", String.Join(",", pending.ToArray()) },
+ { "COUNT", pending.Count.ToString() }
+ });
+
+ if (!CheckReturn(resultSet))
+ {
+ if (i == 0)
+ return null;
+ else
+ return itemArr;
+ }
+
+ // carry over index i where we left above
+ foreach (KeyValuePair kvp in resultSet)
+ {
+ InventoryCollection inventory = new InventoryCollection();
+ if (kvp.Key.StartsWith("item_"))
+ {
+ if (kvp.Value is Dictionary)
+ {
+ item = BuildItem((Dictionary)kvp.Value);
+ m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS);
+ itemArr[i++] = item;
+ }
+ else
+ itemArr[i++] = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleItems: {0}", e.Message);
+ }
+
+ return itemArr;
}
public InventoryFolderBase GetFolder(InventoryFolderBase folder)
@@ -447,9 +621,7 @@ namespace OpenSim.Services.Connectors
{ "ID", folder.ID.ToString() }
});
- if (ret == null)
- return null;
- if (ret.Count == 0)
+ if (!CheckReturn(ret))
return null;
return BuildFolder((Dictionary)ret["folder"]);
@@ -469,7 +641,7 @@ namespace OpenSim.Services.Connectors
{ "PRINCIPAL", principalID.ToString() }
});
- if (ret == null)
+ if (!CheckReturn(ret))
return null;
List items = new List();
@@ -488,51 +660,22 @@ namespace OpenSim.Services.Connectors
{ "ASSET", assetID.ToString() }
});
+ // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int
if (ret == null)
return 0;
- return int.Parse(ret["RESULT"].ToString());
- }
-
- public InventoryCollection GetUserInventory(UUID principalID)
- {
- InventoryCollection inventory = new InventoryCollection();
- inventory.Folders = new List();
- inventory.Items = new List();
- inventory.UserID = principalID;
-
- try
+ if (ret.ContainsKey("RESULT"))
{
- Dictionary ret = MakeRequest("GETUSERINVENTORY",
- new Dictionary {
- { "PRINCIPAL", principalID.ToString() }
- });
-
- if (ret == null)
- return null;
- if (ret.Count == 0)
- return null;
-
- Dictionary folders =
- (Dictionary)ret["FOLDERS"];
- Dictionary items =
- (Dictionary)ret["ITEMS"];
+ if (ret["RESULT"] is string)
+ {
+ int intResult;
- foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
- inventory.Folders.Add(BuildFolder((Dictionary)o));
- foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
- inventory.Items.Add(BuildItem((Dictionary)o));
+ if (int.TryParse ((string)ret["RESULT"], out intResult))
+ return intResult;
+ }
}
- catch (Exception e)
- {
- m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetUserInventory: ", e);
- }
-
- return inventory;
- }
- public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback)
- {
+ return 0;
}
public bool HasInventoryForUser(UUID principalID)
@@ -545,13 +688,19 @@ namespace OpenSim.Services.Connectors
private Dictionary MakeRequest(string method,
Dictionary sendData)
{
- sendData["METHOD"] = method;
+ // Add "METHOD" as the first key in the dictionary. This ensures that it will be
+ // visible even when using partial logging ("debug http all 5").
+ Dictionary temp = sendData;
+ sendData = new Dictionary{ { "METHOD", method } };
+ foreach (KeyValuePair kvp in temp)
+ sendData.Add(kvp.Key, kvp.Value);
+
+ RequestsMade++;
- string reply = string.Empty;
- lock (m_Lock)
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- m_ServerURI + "/xinventory",
- ServerUtils.BuildQueryString(sendData));
+ string reply
+ = SynchronousRestFormsRequester.MakeRequest(
+ "POST", m_ServerURI + "/xinventory",
+ ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth);
Dictionary replyData = ServerUtils.ParseXmlResponse(
reply);
@@ -619,4 +768,4 @@ namespace OpenSim.Services.Connectors
return item;
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 30a73a4..034c42e 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -33,7 +33,7 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using Nwc.XmlRpc;
@@ -78,7 +78,7 @@ namespace OpenSim.Services.Connectors
try
{
uint xpos = 0, ypos = 0;
- Utils.LongToUInts(regionHandle, out xpos, out ypos);
+ Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos);
GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos);
if (info != null) // just to be sure
{
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index 30bfb70..c91ed84 100644
--- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
+++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
@@ -35,7 +35,8 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
-using OpenSim.Framework.Communications;
+
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
@@ -43,7 +44,7 @@ using OpenMetaverse.StructuredData;
namespace OpenSim.Services.Connectors
{
- public class MapImageServicesConnector : IMapImageService
+ public class MapImageServicesConnector : BaseServiceConnector, IMapImageService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -84,26 +85,26 @@ namespace OpenSim.Services.Connectors
}
m_ServerURI = serviceURI;
m_ServerURI = serviceURI.TrimEnd('/');
+ base.Initialise(source, "MapImageService");
}
- public bool AddMapTile(int x, int y, byte[] jpgData, out string reason)
+ public bool RemoveMapTile(int x, int y, out string reason)
{
reason = string.Empty;
int tickstart = Util.EnvironmentTickCount();
Dictionary sendData = new Dictionary();
sendData["X"] = x.ToString();
sendData["Y"] = y.ToString();
- sendData["TYPE"] = "image/jpeg";
- sendData["DATA"] = Convert.ToBase64String(jpgData);
string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/map";
+ string uri = m_ServerURI + "/removemap";
try
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors
}
else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
{
- m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
+ m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString());
reason = replyData["Message"].ToString();
return false;
}
@@ -142,6 +143,72 @@ namespace OpenSim.Services.Connectors
{
// This just dumps a warning for any operation that takes more than 100 ms
int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
+ m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff);
+ }
+
+ return false;
+ }
+
+ public bool AddMapTile(int x, int y, byte[] jpgData, out string reason)
+ {
+ reason = string.Empty;
+ int tickstart = Util.EnvironmentTickCount();
+ Dictionary sendData = new Dictionary();
+ sendData["X"] = x.ToString();
+ sendData["Y"] = y.ToString();
+ sendData["TYPE"] = "image/jpeg";
+ sendData["DATA"] = Convert.ToBase64String(jpgData);
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/map";
+
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ reqString,
+ m_Auth);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
+ {
+ return true;
+ }
+ else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
+ {
+ reason = string.Format("Map post to {0} failed: {1}", uri, replyData["Message"].ToString());
+ m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
+
+ return false;
+ }
+ else if (!replyData.ContainsKey("Result"))
+ {
+ reason = string.Format("Reply data from {0} does not contain result field", uri);
+ m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
+ }
+ else
+ {
+ reason = string.Format("Unexpected result {0} from {1}" + replyData["Result"].ToString(), uri);
+ m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
+ }
+ }
+ else
+ {
+ reason = string.Format("Map post received null reply from {0}", uri);
+ m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
+ }
+ }
+ catch (Exception e)
+ {
+ reason = string.Format("Exception when posting to map server at {0}: {1}", uri, e.Message);
+ m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
+ }
+ finally
+ {
+ // This just dumps a warning for any operation that takes more than 100 ms
+ int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile uploaded in {0}ms", tickdiff);
}
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 7429293..925364a 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -35,7 +35,7 @@ using System.Reflection;
using System.Text;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@@ -69,7 +69,7 @@ namespace OpenSim.Services.Connectors
public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
uint x = 0, y = 0;
- Utils.LongToUInts(regionHandle, out x, out y);
+ Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
GridRegion regInfo = m_GridService.GetRegionByPosition(thisRegion.ScopeID, (int)x, (int)y);
if ((regInfo != null) &&
// Don't remote-call this instance; that's a startup hickup
@@ -97,9 +97,9 @@ namespace OpenSim.Services.Connectors
}
catch (Exception e)
{
- m_log.WarnFormat(
- "[NEIGHBOUR SERVICE CONNCTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3}{4}",
- uri, thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
+ m_log.Warn(string.Format(
+ "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3} ",
+ uri, thisRegion.RegionName, region.RegionName, e.Message), e);
return false;
}
@@ -116,9 +116,9 @@ namespace OpenSim.Services.Connectors
}
catch (Exception e)
{
- m_log.WarnFormat(
- "[NEIGHBOUR SERVICE CONNCTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2}{3}",
- thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
+ m_log.Warn(string.Format(
+ "[NEIGHBOUR SERVICES CONNECTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2} ",
+ thisRegion.RegionName, region.RegionName, e.Message), e);
return false;
}
@@ -136,9 +136,9 @@ namespace OpenSim.Services.Connectors
}
catch (Exception e)
{
- m_log.WarnFormat(
- "[NEIGHBOUR SERVICE CONNCTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2}{3}",
- thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
+ m_log.Warn(string.Format(
+ "[NEIGHBOUR SERVICES CONNECTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2} ",
+ thisRegion.RegionName, region.RegionName, e.Message), e);
return false;
}
@@ -153,53 +153,53 @@ namespace OpenSim.Services.Connectors
}
catch (Exception e)
{
- m_log.WarnFormat(
- "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}",
- thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
+ m_log.Warn(string.Format(
+ "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1} (uri {2}). Exception {3} ",
+ thisRegion.RegionName, region.RegionName, uri, e.Message), e);
return false;
}
finally
{
if (os != null)
- os.Close();
+ os.Dispose();
}
// Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
- StreamReader sr = null;
try
{
- WebResponse webResponse = helloNeighbourRequest.GetResponse();
- if (webResponse == null)
+ using (WebResponse webResponse = helloNeighbourRequest.GetResponse())
{
- m_log.DebugFormat(
- "[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
- thisRegion.RegionName, region.RegionName);
+ if (webResponse == null)
+ {
+ m_log.DebugFormat(
+ "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
+ thisRegion.RegionName, region.RegionName);
+ }
+
+ using (Stream s = webResponse.GetResponseStream())
+ {
+ using (StreamReader sr = new StreamReader(s))
+ {
+ //reply = sr.ReadToEnd().Trim();
+ sr.ReadToEnd().Trim();
+ //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
+ }
+ }
}
-
- sr = new StreamReader(webResponse.GetResponseStream());
- //reply = sr.ReadToEnd().Trim();
- sr.ReadToEnd().Trim();
- //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
-
}
catch (Exception e)
{
- m_log.WarnFormat(
- "[NEIGHBOUR SERVICE CONNCTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2}{3}",
- region.RegionName, thisRegion.RegionName, e.Message, e.StackTrace);
+ m_log.Warn(string.Format(
+ "[NEIGHBOUR SERVICES CONNECTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2} ",
+ region.RegionName, thisRegion.RegionName, e.Message), e);
return false;
}
- finally
- {
- if (sr != null)
- sr.Close();
- }
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
index f7d8c53..b7e95c4 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class PresenceServicesConnector : IPresenceService
+ public class PresenceServicesConnector : BaseServiceConnector, IPresenceService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors
throw new Exception("Presence connector init error");
}
m_ServerURI = serviceURI;
+
+ base.Initialise(source, "PresenceService");
}
@@ -104,7 +107,8 @@ namespace OpenSim.Services.Connectors
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -149,7 +153,8 @@ namespace OpenSim.Services.Connectors
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -193,7 +198,8 @@ namespace OpenSim.Services.Connectors
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -238,7 +244,8 @@ namespace OpenSim.Services.Connectors
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -283,7 +290,8 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply");
@@ -293,6 +301,7 @@ namespace OpenSim.Services.Connectors
catch (Exception e)
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
+ return null;
}
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
@@ -327,7 +336,8 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null or empty reply");
diff --git a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
index bfb681b..c581a59 100644
--- a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
index 95e4bab..cd4781d 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
Util.FireAndForget(delegate(object o)
{
m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
- });
+ }, null, "SimianActivityDetector.SetLastPositionOnMakeRootAgent");
}
public void OnNewClient(IClientAPI client)
@@ -94,7 +94,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
Util.FireAndForget(delegate(object o)
{
m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
- });
+ }, null, "SimianActivityDetector.SetLastPositionOnEnteringNewParcel");
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 63a32e7..9ad4a7a 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Reflection;
@@ -122,7 +123,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
m_Enabled = true;
}
- #region IAssetService
+#region IAssetService
public AssetBase Get(string id)
{
@@ -140,8 +141,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
return asset;
}
- return GetRemote(id);
+ return SimianGetOperation(id);
}
+
public AssetBase GetCached(string id)
{
@@ -164,8 +166,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
throw new InvalidOperationException();
}
- AssetMetadata metadata = null;
-
// Cache fetch
if (m_cache != null)
{
@@ -174,50 +174,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
return asset.Metadata;
}
- Uri url;
-
- // Determine if id is an absolute URL or a grid-relative UUID
- if (!Uri.TryCreate(id, UriKind.Absolute, out url))
- url = new Uri(m_serverUrl + id);
-
- try
- {
- HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
- request.Method = "HEAD";
-
- using (WebResponse response = request.GetResponse())
- {
- using (Stream responseStream = response.GetResponseStream())
- {
- // Create the metadata object
- metadata = new AssetMetadata();
- metadata.ContentType = response.ContentType;
- metadata.ID = id;
-
- UUID uuid;
- if (UUID.TryParse(id, out uuid))
- metadata.FullID = uuid;
-
- string lastModifiedStr = response.Headers.Get("Last-Modified");
- if (!String.IsNullOrEmpty(lastModifiedStr))
- {
- DateTime lastModified;
- if (DateTime.TryParse(lastModifiedStr, out lastModified))
- metadata.CreationDate = lastModified;
- }
- }
- }
- }
- catch (Exception ex)
- {
- m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
- }
-
- return metadata;
+ // return GetRemoteMetadata(id);
+ return SimianGetMetadataOperation(id);
}
-
+
public byte[] GetData(string id)
{
+ if (String.IsNullOrEmpty(m_serverUrl))
+ {
+ m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
+ throw new InvalidOperationException();
+ }
+
AssetBase asset = Get(id);
if (asset != null)
@@ -255,14 +223,34 @@ namespace OpenSim.Services.Connectors.SimianGrid
Util.FireAndForget(
delegate(object o)
{
- AssetBase asset = GetRemote(id);
+ AssetBase asset = SimianGetOperation(id);
handler(id, sender, asset);
- }
+ }, null, "SimianAssetServiceConnector.GetFromService"
);
return true;
}
+ public bool[] AssetsExist(string[] ids)
+ {
+ if (String.IsNullOrEmpty(m_serverUrl))
+ {
+ m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
+ throw new InvalidOperationException();
+ }
+
+ bool[] exist = new bool[ids.Length];
+
+ for (int i = 0; i < ids.Length; i++)
+ {
+ AssetMetadata metadata = GetMetadata(ids[i]);
+ if (metadata != null)
+ exist[i] = true;
+ }
+
+ return exist;
+ }
+
///
/// Creates a new asset
///
@@ -278,7 +266,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
}
bool storedInCache = false;
- string errorMessage = null;
// AssetID handling
if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID)
@@ -307,80 +294,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
return asset.ID;
}
- // Distinguish public and private assets
- bool isPublic = true;
- switch ((AssetType)asset.Type)
- {
- case AssetType.CallingCard:
- case AssetType.Gesture:
- case AssetType.LSLBytecode:
- case AssetType.LSLText:
- isPublic = false;
- break;
- }
-
- // Make sure ContentType is set
- if (String.IsNullOrEmpty(asset.Metadata.ContentType))
- asset.Metadata.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type);
-
- // Build the remote storage request
- List postParameters = new List()
- {
- new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
- new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
- new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
- new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
- new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
- };
-
- // Make the remote storage request
- try
- {
- // Simian does not require the asset ID to be in the URL because it's in the post data.
- // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
- HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
-
- HttpWebResponse response = MultipartForm.Post(request, postParameters);
- using (Stream responseStream = response.GetResponseStream())
- {
- string responseStr = null;
-
- try
- {
- responseStr = responseStream.GetStreamString();
- OSD responseOSD = OSDParser.Deserialize(responseStr);
- if (responseOSD.Type == OSDType.Map)
- {
- OSDMap responseMap = (OSDMap)responseOSD;
- if (responseMap["Success"].AsBoolean())
- return asset.ID;
- else
- errorMessage = "Upload failed: " + responseMap["Message"].AsString();
- }
- else
- {
- errorMessage = "Response format was invalid:\n" + responseStr;
- }
- }
- catch (Exception ex)
- {
- if (!String.IsNullOrEmpty(responseStr))
- errorMessage = "Failed to parse the response:\n" + responseStr;
- else
- errorMessage = "Failed to retrieve the response: " + ex.Message;
- }
- }
- }
- catch (WebException ex)
- {
- errorMessage = ex.Message;
- }
-
- m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
- asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
- return null;
+ return SimianStoreOperation(asset);
}
-
+
///
/// Update an asset's content
///
@@ -390,11 +306,17 @@ namespace OpenSim.Services.Connectors.SimianGrid
///
public bool UpdateContent(string id, byte[] data)
{
+ if (String.IsNullOrEmpty(m_serverUrl))
+ {
+ m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
+ throw new InvalidOperationException();
+ }
+
AssetBase asset = Get(id);
if (asset == null)
{
- m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset " + id + " for updating");
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id);
return false;
}
@@ -417,83 +339,347 @@ namespace OpenSim.Services.Connectors.SimianGrid
throw new InvalidOperationException();
}
- //string errorMessage = String.Empty;
- string url = m_serverUrl + id;
-
if (m_cache != null)
m_cache.Expire(id);
+ return SimianDeleteOperation(id);
+ }
+
+#endregion IAssetService
+
+#region SimianOperations
+ ///
+ /// Invokes the xRemoveAsset operation on the simian server to delete an asset
+ ///
+ ///
+ ///
+ private bool SimianDeleteOperation(string id)
+ {
try
{
- HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
- request.Method = "DELETE";
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "xRemoveAsset" },
+ { "AssetID", id }
+ };
- using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
+ OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
+ if (! response["Success"].AsBoolean())
{
- if (response.StatusCode != HttpStatusCode.NoContent)
- {
- m_log.Warn("[SIMIAN ASSET CONNECTOR]: Unexpected response when deleting asset " + url + ": " +
- response.StatusCode + " (" + response.StatusDescription + ")");
- }
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString());
+ return false;
}
-
+
return true;
+
}
catch (Exception ex)
{
- m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to delete asset " + id + " from the asset service: " + ex.Message);
- return false;
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message);
}
- }
- #endregion IAssetService
+ return false;
+ }
- private AssetBase GetRemote(string id)
+ ///
+ /// Invokes the xAddAsset operation on the simian server to create or update an asset
+ ///
+ ///
+ ///
+ private string SimianStoreOperation(AssetBase asset)
{
- AssetBase asset = null;
- Uri url;
+ try
+ {
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "xAddAsset" },
+ { "ContentType", asset.Metadata.ContentType },
+ { "EncodedData", Convert.ToBase64String(asset.Data) },
+ { "AssetID", asset.FullID.ToString() },
+ { "CreatorID", asset.Metadata.CreatorID },
+ { "Temporary", asset.Temporary ? "1" : "0" },
+ { "Name", asset.Name }
+ };
+
+ OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
+ if (! response["Success"].AsBoolean())
+ {
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString());
+ return null;
+ }
- // Determine if id is an absolute URL or a grid-relative UUID
- if (!Uri.TryCreate(id, UriKind.Absolute, out url))
- url = new Uri(m_serverUrl + id);
+ // asset.ID is always set before calling this function
+ return asset.ID;
+
+ }
+ catch (Exception ex)
+ {
+ m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message);
+ }
+
+ return null;
+ }
- try
+ ///
+ /// Invokes the xGetAsset operation on the simian server to get data associated with an asset
+ ///
+ ///
+ ///
+ private AssetBase SimianGetOperation(string id)
+ {
+ try
{
- HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "xGetAsset" },
+ { "ID", id }
+ };
- using (WebResponse response = request.GetResponse())
+ OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
+ if (! response["Success"].AsBoolean())
{
- using (Stream responseStream = response.GetResponseStream())
- {
- string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
-
- // Create the asset object
- asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
-
- UUID assetID;
- if (UUID.TryParse(id, out assetID))
- asset.FullID = assetID;
-
- // Grab the asset data from the response stream
- using (MemoryStream stream = new MemoryStream())
- {
- responseStream.CopyStream(stream, Int32.MaxValue);
- asset.Data = stream.ToArray();
- }
- }
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString());
+ return null;
}
+
+ AssetBase asset = new AssetBase();
- // Cache store
- if (m_cache != null && asset != null)
- m_cache.Cache(asset);
+ asset.ID = id;
+ asset.Name = String.Empty;
+ asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property
+ asset.CreatorID = response["CreatorID"].AsString();
+ asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString());
+ asset.Local = false;
+ asset.Temporary = response["Temporary"];
return asset;
}
catch (Exception ex)
{
- m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message);
- return null;
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message);
+ }
+
+ return null;
+ }
+
+ ///
+ /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset
+ /// This operation is generally used to determine if an asset exists in the database
+ ///
+ ///
+ ///
+ private AssetMetadata SimianGetMetadataOperation(string id)
+ {
+ try
+ {
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "xGetAssetMetadata" },
+ { "ID", id }
+ };
+
+ OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
+ if (! response["Success"].AsBoolean())
+ {
+ // this is not really an error, this call is used to test existence
+ // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString());
+ return null;
+ }
+
+ AssetMetadata metadata = new AssetMetadata();
+ metadata.ID = id;
+ metadata.ContentType = response["ContentType"].AsString();
+ metadata.CreatorID = response["CreatorID"].AsString();
+ metadata.Local = false;
+ metadata.Temporary = response["Temporary"];
+
+ string lastModifiedStr = response["Last-Modified"].AsString();
+ if (! String.IsNullOrEmpty(lastModifiedStr))
+ {
+ DateTime lastModified;
+ if (DateTime.TryParse(lastModifiedStr, out lastModified))
+ metadata.CreationDate = lastModified;
+ }
+
+ return metadata;
+ }
+ catch (Exception ex)
+ {
+ m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message);
}
+
+ return null;
}
+#endregion
+
+ // private AssetMetadata GetRemoteMetadata(string id)
+ // {
+ // Uri url;
+ // AssetMetadata metadata = null;
+
+ // // Determine if id is an absolute URL or a grid-relative UUID
+ // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
+ // url = new Uri(m_serverUrl + id);
+
+ // try
+ // {
+ // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
+ // request.Method = "HEAD";
+
+ // using (WebResponse response = request.GetResponse())
+ // {
+ // using (Stream responseStream = response.GetResponseStream())
+ // {
+ // // Create the metadata object
+ // metadata = new AssetMetadata();
+ // metadata.ContentType = response.ContentType;
+ // metadata.ID = id;
+
+ // UUID uuid;
+ // if (UUID.TryParse(id, out uuid))
+ // metadata.FullID = uuid;
+
+ // string lastModifiedStr = response.Headers.Get("Last-Modified");
+ // if (!String.IsNullOrEmpty(lastModifiedStr))
+ // {
+ // DateTime lastModified;
+ // if (DateTime.TryParse(lastModifiedStr, out lastModified))
+ // metadata.CreationDate = lastModified;
+ // }
+ // }
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
+ // }
+
+ // return metadata;
+ // }
+
+ // private AssetBase GetRemote(string id)
+ // {
+ // AssetBase asset = null;
+ // Uri url;
+
+ // // Determine if id is an absolute URL or a grid-relative UUID
+ // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
+ // url = new Uri(m_serverUrl + id);
+
+ // try
+ // {
+ // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
+
+ // using (WebResponse response = request.GetResponse())
+ // {
+ // using (Stream responseStream = response.GetResponseStream())
+ // {
+ // string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
+
+ // // Create the asset object
+ // asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
+
+ // UUID assetID;
+ // if (UUID.TryParse(id, out assetID))
+ // asset.FullID = assetID;
+
+ // // Grab the asset data from the response stream
+ // using (MemoryStream stream = new MemoryStream())
+ // {
+ // responseStream.CopyStream(stream, Int32.MaxValue);
+ // asset.Data = stream.ToArray();
+ // }
+ // }
+ // }
+
+ // // Cache store
+ // if (m_cache != null && asset != null)
+ // m_cache.Cache(asset);
+
+ // return asset;
+ // }
+ // catch (Exception ex)
+ // {
+ // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message);
+ // return null;
+ // }
+ // }
+
+ // private string StoreRemote(AssetBase asset)
+ // {
+ // // Distinguish public and private assets
+ // bool isPublic = true;
+ // switch ((AssetType)asset.Type)
+ // {
+ // case AssetType.CallingCard:
+ // case AssetType.Gesture:
+ // case AssetType.LSLBytecode:
+ // case AssetType.LSLText:
+ // isPublic = false;
+ // break;
+ // }
+
+ // string errorMessage = null;
+
+ // // Build the remote storage request
+ // List postParameters = new List()
+ // {
+ // new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
+ // new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
+ // new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
+ // new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
+ // new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
+ // };
+
+ // // Make the remote storage request
+ // try
+ // {
+ // // Simian does not require the asset ID to be in the URL because it's in the post data.
+ // // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
+ // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
+
+ // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
+ // {
+ // using (Stream responseStream = response.GetResponseStream())
+ // {
+ // string responseStr = null;
+
+ // try
+ // {
+ // responseStr = responseStream.GetStreamString();
+ // OSD responseOSD = OSDParser.Deserialize(responseStr);
+ // if (responseOSD.Type == OSDType.Map)
+ // {
+ // OSDMap responseMap = (OSDMap)responseOSD;
+ // if (responseMap["Success"].AsBoolean())
+ // return asset.ID;
+ // else
+ // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
+ // }
+ // else
+ // {
+ // errorMessage = "Response format was invalid:\n" + responseStr;
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // if (!String.IsNullOrEmpty(responseStr))
+ // errorMessage = "Failed to parse the response:\n" + responseStr;
+ // else
+ // errorMessage = "Failed to retrieve the response: " + ex.Message;
+ // }
+ // }
+ // }
+ // }
+ // catch (WebException ex)
+ // {
+ // errorMessage = ex.Message;
+ // }
+
+ // m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
+ // asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
+
+ // return null;
+ // }
}
}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 6603f6e..3bd11d9 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", principalID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Identities"] is OSDArray)
{
bool md5hashFound = false;
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "SessionID", token }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
return true;
@@ -175,7 +175,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", principalID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
return true;
@@ -198,7 +198,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", principalID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["User"] is OSDMap)
{
OSDMap userMap = (OSDMap)response["User"];
@@ -218,7 +218,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", principalID.ToString() }
};
- response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -297,7 +297,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
return response["SessionID"].AsUUID().ToString();
else
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index 841bfa0..a397740 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
OSDMap map = null;
@@ -168,7 +168,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (! success)
@@ -189,7 +189,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
OSDMap map = null;
@@ -306,7 +306,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "LLAttachments", OSDParser.SerializeJsonString(items) }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
new file mode 100644
index 0000000..764e71f
--- /dev/null
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.IO;
+using System.Web;
+
+using log4net;
+using Nini.Config;
+using Mono.Addins;
+
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
+using Caps = OpenSim.Framework.Capabilities.Caps;
+
+namespace OpenSim.Services.Connectors.SimianGrid
+{
+ [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
+ public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private bool m_enabled = true;
+ private Scene m_scene;
+ private String m_simianURL;
+
+#region IRegionModule Members
+
+ public string Name
+ {
+ get { return this.GetType().Name; }
+ }
+
+ public void Initialise(IConfigSource config)
+ {
+ try
+ {
+ IConfig m_config;
+
+ if ((m_config = config.Configs["SimianExternalCaps"]) != null)
+ {
+ m_enabled = m_config.GetBoolean("Enabled", m_enabled);
+ if ((m_config = config.Configs["SimianGrid"]) != null)
+ {
+ m_simianURL = m_config.GetString("SimianServiceURL");
+ if (String.IsNullOrEmpty(m_simianURL))
+ {
+ //m_log.DebugFormat("[SimianGrid] service URL is not defined");
+ m_enabled = false;
+ return;
+ }
+ }
+ }
+ else
+ m_enabled = false;
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
+ return;
+ }
+ }
+
+ public void PostInitialise() { }
+ public void Close() { }
+
+ public void AddRegion(Scene scene)
+ {
+ if (! m_enabled)
+ return;
+
+ m_scene = scene;
+ m_scene.RegisterModuleInterface(this);
+ }
+
+ public void RemoveRegion(Scene scene)
+ {
+ if (! m_enabled)
+ return;
+
+ m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler;
+ m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler;
+ }
+
+ public void RegionLoaded(Scene scene)
+ {
+ if (! m_enabled)
+ return;
+
+ m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler;
+ m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler;
+ }
+
+ public Type ReplaceableInterface
+ {
+ get { return null; }
+ }
+
+#endregion
+
+#region IExternalCapsModule
+ // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/"
+ public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel)
+ {
+ UUID cap = UUID.Random();
+
+ // Call to simian to register the cap we generated
+ // NameValueCollection requestArgs = new NameValueCollection
+ // {
+ // { "RequestMethod", "AddCapability" },
+ // { "Resource", "user" },
+ // { "Expiration", 0 },
+ // { "OwnerID", agentID.ToString() },
+ // { "CapabilityID", cap.ToString() }
+ // };
+
+ // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs);
+
+ Dictionary subs = new Dictionary();
+ subs["%OP%"] = capName;
+ subs["%USR%"] = agentID.ToString();
+ subs["%CAP%"] = cap.ToString();
+ subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString();
+
+ caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs));
+ return true;
+ }
+
+#endregion
+
+#region EventHandlers
+ public void RegisterCapsEventHandler(UUID agentID, Caps caps) { }
+ public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { }
+#endregion
+
+ private String ExpandSkeletonURL(String urlSkel, Dictionary subs)
+ {
+ String result = urlSkel;
+
+ foreach (KeyValuePair kvp in subs)
+ {
+ result = result.Replace(kvp.Key,kvp.Value);
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index 7422d94..9a8164c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Value", flags.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -180,7 +180,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Key", friend }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -200,7 +200,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Type", "Friend" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
{
return (OSDArray)response["Entries"];
@@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Type", "Friend" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
{
return (OSDArray)response["Entries"];
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
index 847319c..a35d749 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
@@ -26,8 +26,122 @@
*/
using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Reflection;
+using log4net;
using Mono.Addins;
using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
-[assembly: Addin("SimianGrid", "1.0")]
-[assembly: AddinDependency("OpenSim", "0.5")]
+[assembly: Addin("SimianGrid", OpenSim.VersionInfo.VersionNumber)]
+[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
+
+namespace OpenSim.Services.Connectors.SimianGrid
+{
+ [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
+ public class SimianGrid : ISharedRegionModule
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private IConfig m_config = null;
+
+ private String m_simianURL;
+
+#region IRegionModule Members
+
+ public string Name
+ {
+ get { return this.GetType().Name; }
+ }
+
+ public void Initialise(IConfigSource config)
+ {
+ try
+ {
+ m_config = config.Configs["SimianGrid"];
+
+ if (m_config != null)
+ {
+ m_simianURL = m_config.GetString("SimianServiceURL");
+ if (String.IsNullOrEmpty(m_simianURL))
+ {
+ // m_log.DebugFormat("[SimianGrid] service URL is not defined");
+ return;
+ }
+
+ InitialiseSimCap();
+ SimulatorCapability = SimulatorCapability.Trim();
+ m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
+ return;
+ }
+ }
+
+ public void PostInitialise() { }
+ public void Close() { }
+ public void AddRegion(Scene scene) { }
+ public void RemoveRegion(Scene scene) { }
+ public void RegionLoaded(Scene scene) { }
+
+ public Type ReplaceableInterface
+ {
+ get { return null; }
+ }
+
+ ///
+ /// Try a variety of methods for finding the simian simulator capability; first check the
+ /// configuration itself, then look for a file that contains the cap, then finally look
+ /// for an environment variable that contains it.
+ ///
+ private void InitialiseSimCap()
+ {
+ if (m_config.Contains("SimulatorCapability"))
+ {
+ SimulatorCapability = m_config.GetString("SimulatorCapability");
+ return;
+ }
+
+ if (m_config.Contains("SimulatorCapabilityFile"))
+ {
+ String filename = m_config.GetString("SimulatorCapabilityFile");
+ if (System.IO.File.Exists(filename))
+ {
+ SimulatorCapability = System.IO.File.ReadAllText(filename);
+ return;
+ }
+ }
+
+ if (m_config.Contains("SimulatorCapabilityVariable"))
+ {
+ String envname = m_config.GetString("SimulatorCapabilityVariable");
+ String envvalue = System.Environment.GetEnvironmentVariable(envname);
+ if (envvalue != null)
+ {
+ SimulatorCapability = envvalue;
+ return;
+ }
+ }
+
+ m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability");
+ }
+
+#endregion
+
+ public static String SimulatorCapability = UUID.Zero.ToString();
+ public static OSDMap PostToService(string url, NameValueCollection data)
+ {
+ data["cap"] = SimulatorCapability;
+ return WebUtil.PostToService(url, data);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
index 93fdae3..8375c95 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Reflection;
using System.Net;
using System.IO;
@@ -43,7 +44,8 @@ using OpenSim.Region.Framework.Scenes;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
-namespace OpenSim.Region.OptionalModules.Simian
+//namespace OpenSim.Region.OptionalModules.Simian
+namespace OpenSim.Services.Connectors.SimianGrid
{
///
///
@@ -179,7 +181,6 @@ namespace OpenSim.Region.OptionalModules.Simian
m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName);
// Create a PNG map tile and upload it to the AddMapTile API
- byte[] pngData = Utils.EmptyBytes;
IMapImageGenerator tileGenerator = scene.RequestModuleInterface();
if (tileGenerator == null)
{
@@ -187,76 +188,79 @@ namespace OpenSim.Region.OptionalModules.Simian
return;
}
- using (Image mapTile = tileGenerator.CreateMapTile())
- {
- using (MemoryStream stream = new MemoryStream())
- {
- mapTile.Save(stream, ImageFormat.Png);
- pngData = stream.ToArray();
- }
- }
-
- List postParameters = new List()
- {
- new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
- new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
- new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
- };
-
- string errorMessage = null;
- int tickstart = Util.EnvironmentTickCount();
-
- // Make the remote storage request
- try
+ using (Bitmap mapTile = tileGenerator.CreateMapTile())
{
- HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
- request.Timeout = 20000;
- request.ReadWriteTimeout = 5000;
-
- using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
+ if (mapTile != null)
{
- using (Stream responseStream = response.GetResponseStream())
+ // If the region/maptile is legacy sized, just upload the one tile like it has always been done
+ if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
{
- string responseStr = responseStream.GetStreamString();
- OSD responseOSD = OSDParser.Deserialize(responseStr);
- if (responseOSD.Type == OSDType.Map)
+ ConvertAndUploadMaptile(mapTile, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY);
+ }
+ else
+ {
+ // For larger regions (varregion) we must cut the region image into legacy sized
+ // pieces since that is how the maptile system works.
+ // Note the assumption that varregions are always a multiple of legacy size.
+ for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
{
- OSDMap responseMap = (OSDMap)responseOSD;
- if (responseMap["Success"].AsBoolean())
- return;
+ for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
+ {
+ // Images are addressed from the upper left corner so have to do funny
+ // math to pick out the sub-tile since regions are numbered from
+ // the lower left.
+ Rectangle rect = new Rectangle(
+ (int)xx,
+ mapTile.Height - (int)yy - (int)Constants.RegionSize,
+ (int)Constants.RegionSize, (int)Constants.RegionSize);
- errorMessage = "Upload failed: " + responseMap["Message"].AsString();
- }
- else
- {
- errorMessage = "Response format was invalid:\n" + responseStr;
+ using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
+ {
+ uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize);
+ uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize);
+
+ ConvertAndUploadMaptile(subMapTile, locX, locY);
+ }
+ }
}
}
}
- }
- catch (WebException we)
- {
- errorMessage = we.Message;
- if (we.Status == WebExceptionStatus.ProtocolError)
+ else
{
- HttpWebResponse webResponse = (HttpWebResponse)we.Response;
- errorMessage = String.Format("[{0}] {1}",
- webResponse.StatusCode,webResponse.StatusDescription);
+ m_log.WarnFormat("[SIMIAN MAPTILE] Tile image generation failed");
}
}
- catch (Exception ex)
+
+ }
+
+ ///
+ ///
+ ///
+ private void ConvertAndUploadMaptile(Image mapTile, uint locX, uint locY)
+ {
+ //m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for location {0}, {1}", locX, locY);
+
+ byte[] pngData = Utils.EmptyBytes;
+ using (MemoryStream stream = new MemoryStream())
{
- errorMessage = ex.Message;
+ mapTile.Save(stream, ImageFormat.Png);
+ pngData = stream.ToArray();
}
- finally
+
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "xAddMapTile" },
+ { "X", locX.ToString() },
+ { "Y", locY.ToString() },
+ { "ContentType", "image/png" },
+ { "EncodedData", System.Convert.ToBase64String(pngData) }
+ };
+
+ OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
+ if (! response["Success"].AsBoolean())
{
- // This just dumps a warning for any operation that takes more than 100 ms
- int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
- m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
+ m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString());
}
-
- m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
- pngData.Length, scene.RegionInfo.RegionName, errorMessage);
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 038a4bf..b031f21 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
{
Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
- Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
+ Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
OSDMap extraData = new OSDMap
{
@@ -129,7 +129,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ExtraData", OSDParser.SerializeJsonString(extraData) }
};
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
return String.Empty;
else
@@ -145,7 +145,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Enabled", "0" }
};
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -156,15 +156,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
public List GetNeighbours(UUID scopeID, UUID regionID)
{
- const int NEIGHBOR_RADIUS = 128;
-
GridRegion region = GetRegionByUUID(scopeID, regionID);
+ int NEIGHBOR_RADIUS = Math.Max(region.RegionSizeX, region.RegionSizeY) / 2;
+
if (region != null)
{
List regions = GetRegionRange(scopeID,
- region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + (int)Constants.RegionSize + NEIGHBOR_RADIUS,
- region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + (int)Constants.RegionSize + NEIGHBOR_RADIUS);
+ region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + region.RegionSizeX + NEIGHBOR_RADIUS,
+ region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + region.RegionSizeY + NEIGHBOR_RADIUS);
for (int i = 0; i < regions.Count; i++)
{
@@ -192,7 +192,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString());
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString());
@@ -220,7 +220,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString());
@@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
else
{
// m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
- // x / Constants.RegionSize, y / Constants.RegionSize);
+ // Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
return null;
}
}
@@ -261,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name);
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
//m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
OSDArray array = response["Scenes"] as OSDArray;
@@ -330,6 +330,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
return new List(0);
}
+ public List GetDefaultHypergridRegions(UUID scopeID)
+ {
+ // TODO: Allow specifying the default grid location
+ return GetDefaultRegions(scopeID);
+ }
+
public List GetFallbackRegions(UUID scopeID, int x, int y)
{
GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true);
@@ -350,7 +356,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Enabled", "1" }
};
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -380,7 +386,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString());
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
OSDMap extraData = response["ExtraData"] as OSDMap;
@@ -396,6 +402,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
return -1;
}
}
+
+ public Dictionary GetExtraFeatures()
+ {
+ /// See SimulatorFeaturesModule - Need to get map, search and destination guide
+ Dictionary extraFeatures = new Dictionary();
+ return extraFeatures;
+ }
#endregion IGridService
@@ -410,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
if (onlyEnabled)
requestArgs["Enabled"] = "1";
- OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
return ResponseToGridRegion(response);
@@ -437,9 +450,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
region.RegionName = response["Name"].AsString();
Vector3d minPosition = response["MinPosition"].AsVector3d();
+ Vector3d maxPosition = response["MaxPosition"].AsVector3d();
region.RegionLocX = (int)minPosition.X;
region.RegionLocY = (int)minPosition.Y;
-
+
+ region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X;
+ region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y;
+
if ( ! extraData["HyperGrid"] ) {
Uri httpAddress = response["Address"].AsUri();
region.ExternalHostName = httpAddress.Host;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index a391275..e793420 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -38,12 +38,14 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
+using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Services.Connectors.SimianGrid
{
///
/// Permissions bitflags
///
+ /*
[Flags]
public enum PermissionMask : uint
{
@@ -55,6 +57,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
Damage = 1 << 20,
All = 0x7FFFFFFF
}
+ */
///
/// Connects avatar inventories to the SimianGrid backend
@@ -71,6 +74,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
// private object m_gestureSyncRoot = new object();
private bool m_Enabled = false;
+ private const double CACHE_EXPIRATION_SECONDS = 20.0;
+ private static ExpiringCache m_ItemCache;
+
#region ISharedRegionModule
public Type ReplaceableInterface { get { return null; } }
@@ -96,6 +102,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
url = url + '/';
m_serverUrl = url;
+ if (m_ItemCache == null)
+ m_ItemCache = new ExpiringCache();
+
}
public void Initialise(IConfigSource source)
@@ -129,6 +138,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
{
m_userServerUrl = serviceUrl;
m_Enabled = true;
+ if (m_ItemCache == null)
+ m_ItemCache = new ExpiringCache();
}
}
}
@@ -153,7 +164,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "OwnerID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -179,7 +190,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ChildrenOnly", "0" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
OSDArray items = (OSDArray)response["Items"];
@@ -194,37 +205,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
}
///
- /// Synchronous inventory fetch.
- ///
- ///
- ///
- [Obsolete]
- public InventoryCollection GetUserInventory(UUID userID)
- {
- m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID);
-
- InventoryCollection inventory = new InventoryCollection();
- inventory.UserID = userID;
- inventory.Folders = new List();
- inventory.Items = new List();
-
- return inventory;
- }
-
- ///
- /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the
- /// inventory has been received
- ///
- ///
- ///
- [Obsolete]
- public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
- {
- m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID);
- callback(new List(0), new List(0));
- }
-
- ///
/// Retrieve the root inventory folder for the given user.
///
///
@@ -241,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ChildrenOnly", "1" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
OSDArray items = (OSDArray)response["Items"];
@@ -260,7 +240,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
///
///
///
- public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
+ public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
{
string contentType = SLUtil.SLAssetTypeToContentType((int)type);
@@ -271,7 +251,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "OwnerID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Folder"] is OSDMap)
{
OSDMap folder = (OSDMap)response["Folder"];
@@ -299,6 +279,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
///
public InventoryItemBase GetItem(InventoryItemBase item)
{
+ InventoryItemBase retrieved = null;
+ if (m_ItemCache.TryGetValue(item.ID, out retrieved))
+ return retrieved;
+
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetInventoryNode" },
@@ -309,7 +293,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ChildrenOnly", "1" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
List items = GetItemsFromResponse((OSDArray)response["Items"]);
@@ -320,7 +304,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
for (int i = 0; i < items.Count; i++)
{
if (items[i].ID == item.ID)
- return items[i];
+ {
+ retrieved = items[i];
+ m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS);
+ return retrieved;
+ }
}
}
}
@@ -329,6 +317,21 @@ namespace OpenSim.Services.Connectors.SimianGrid
return null;
}
+ public InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
+ {
+ InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length];
+ int i = 0;
+ InventoryItemBase item = new InventoryItemBase();
+ item.Owner = principalID;
+ foreach (UUID id in itemIDs)
+ {
+ item.ID = id;
+ result[i++] = GetItem(item);
+ }
+
+ return result;
+ }
+
///
/// Get a folder, given by its UUID
///
@@ -346,7 +349,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ChildrenOnly", "1" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
OSDArray items = (OSDArray)response["Items"];
@@ -368,7 +371,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
InventoryCollection inventory = new InventoryCollection();
- inventory.UserID = userID;
+ inventory.OwnerID = userID;
NameValueCollection requestArgs = new NameValueCollection
{
@@ -380,7 +383,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ChildrenOnly", "1" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
OSDArray items = (OSDArray)response["Items"];
@@ -399,6 +402,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
return inventory;
}
+ public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
+ {
+ InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
+ int i = 0;
+ foreach (UUID fid in folderIDs)
+ {
+ invColl[i++] = GetFolderContent(principalID, fid);
+ }
+
+ return invColl;
+ }
+
///
/// Gets the items inside a folder
///
@@ -408,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
public List GetFolderItems(UUID userID, UUID folderID)
{
InventoryCollection inventory = new InventoryCollection();
- inventory.UserID = userID;
+ inventory.OwnerID = userID;
NameValueCollection requestArgs = new NameValueCollection
{
@@ -420,7 +435,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ChildrenOnly", "1" }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
OSDArray items = (OSDArray)response["Items"];
@@ -451,7 +466,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -515,7 +530,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ItemID", itemID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -543,7 +558,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "FolderID", folder.ID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -565,7 +580,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
// A folder of UUID.Zero means we need to find the most appropriate home for this item
if (item.Folder == UUID.Zero)
{
- InventoryFolderBase folder = GetFolderForType(item.Owner, (AssetType)item.AssetType);
+ InventoryFolderBase folder = null;
+ if (Enum.IsDefined(typeof(FolderType), (sbyte)item.AssetType))
+ folder = GetFolderForType(item.Owner, (FolderType)item.AssetType);
if (folder != null && folder.ID != UUID.Zero)
item.Folder = folder.ID;
else
@@ -620,7 +637,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "ExtraData", OSDParser.SerializeJsonString(extraData) }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -844,7 +861,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Items", String.Join(",", itemIDs) }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -882,7 +899,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
if (response["Success"].AsBoolean())
{
OSDMap user = response["User"] as OSDMap;
@@ -913,7 +930,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "Gestures", OSDParser.SerializeJsonString(gestures) }
};
- OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
if (!response["Success"].AsBoolean())
{
m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " +
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 854bea4..211b775 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
public void PostInitialise() { }
public void Close() { }
- public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); }
+ public SimianPresenceServiceConnector() { }
public string Name { get { return "SimianPresenceServiceConnector"; } }
public void AddRegion(Scene scene)
{
@@ -121,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
serviceUrl = serviceUrl + '/';
m_serverUrl = serviceUrl;
+ m_activityDetector = new SimianActivityDetector(this);
m_Enabled = true;
}
}
@@ -137,17 +138,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
userID, sessionID, secureSessionID);
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "AddSession" },
- { "UserID", userID.ToString() }
- };
+ {
+ { "RequestMethod", "AddSession" },
+ { "UserID", userID.ToString() }
+ };
+
if (sessionID != UUID.Zero)
{
requestArgs["SessionID"] = sessionID.ToString();
requestArgs["SecureSessionID"] = secureSessionID.ToString();
}
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -158,15 +160,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
public bool LogoutAgent(UUID sessionID)
{
-// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
+ // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "RemoveSession" },
- { "SessionID", sessionID.ToString() }
- };
+ {
+ { "RequestMethod", "RemoveSession" },
+ { "SessionID", sessionID.ToString() }
+ };
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -177,15 +179,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
public bool LogoutRegionAgents(UUID regionID)
{
-// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID);
+ // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID);
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "RemoveSessions" },
- { "SceneID", regionID.ToString() }
- };
+ {
+ { "RequestMethod", "RemoveSessions" },
+ { "SceneID", regionID.ToString() }
+ };
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -202,49 +204,46 @@ namespace OpenSim.Services.Connectors.SimianGrid
public PresenceInfo GetAgent(UUID sessionID)
{
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent with sessionID " + sessionID);
-
- NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "GetSession" },
- { "SessionID", sessionID.ToString() }
- };
-
- OSDMap sessionResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
- if (sessionResponse["Success"].AsBoolean())
+ OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID);
+ if (sessionResponse == null)
{
- UUID userID = sessionResponse["UserID"].AsUUID();
- m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
-
- requestArgs = new NameValueCollection
- {
- { "RequestMethod", "GetUser" },
- { "UserID", userID.ToString() }
- };
-
- OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
- if (userResponse["Success"].AsBoolean())
- return ResponseToPresenceInfo(sessionResponse, userResponse);
- else
- m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
+ m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString());
+ return null;
}
- else
+
+ UUID userID = sessionResponse["UserID"].AsUUID();
+ OSDMap userResponse = GetUserData(userID);
+ if (userResponse == null)
{
- m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session " + sessionID + ": " + sessionResponse["Message"].AsString());
+ m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString());
+ return null;
}
- return null;
+ return ResponseToPresenceInfo(sessionResponse);
}
public PresenceInfo[] GetAgents(string[] userIDs)
{
- List presences = new List(userIDs.Length);
+ List presences = new List();
+
+ NameValueCollection requestArgs = new NameValueCollection
+ {
+ { "RequestMethod", "GetSessions" },
+ { "UserIDList", String.Join(",",userIDs) }
+ };
- for (int i = 0; i < userIDs.Length; i++)
+ OSDMap sessionListResponse = SimianGrid.PostToService(m_serverUrl, requestArgs);
+ if (! sessionListResponse["Success"].AsBoolean())
{
- UUID userID;
- if (UUID.TryParse(userIDs[i], out userID) && userID != UUID.Zero)
- presences.AddRange(GetSessions(userID));
+ m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString());
+ return null;
+ }
+
+ OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray;
+ for (int i = 0; i < sessionList.Count; i++)
+ {
+ OSDMap sessionInfo = sessionList[i] as OSDMap;
+ presences.Add(ResponseToPresenceInfo(sessionInfo));
}
return presences.ToArray();
@@ -262,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
{
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
+ // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
// Remove the session to mark this user offline
if (!LogoutAgent(sessionID))
@@ -270,13 +269,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
// Save our last position as user data
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "AddUserData" },
- { "UserID", userID.ToString() },
- { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
- };
+ {
+ { "RequestMethod", "AddUserData" },
+ { "UserID", userID.ToString() },
+ { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
+ };
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -287,16 +286,16 @@ namespace OpenSim.Services.Connectors.SimianGrid
public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
{
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
+ // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "AddUserData" },
- { "UserID", userID.ToString() },
- { "HomeLocation", SerializeLocation(regionID, position, lookAt) }
- };
+ {
+ { "RequestMethod", "AddUserData" },
+ { "UserID", userID.ToString() },
+ { "HomeLocation", SerializeLocation(regionID, position, lookAt) }
+ };
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -312,24 +311,19 @@ namespace OpenSim.Services.Connectors.SimianGrid
public GridUserInfo GetGridUserInfo(string user)
{
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
+ // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
UUID userID = new UUID(user);
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
+ OSDMap userResponse = GetUserData(userID);
- NameValueCollection requestArgs = new NameValueCollection
+ if (userResponse == null)
{
- { "RequestMethod", "GetUser" },
- { "UserID", userID.ToString() }
- };
+ m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID);
+ }
- OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
- if (userResponse["Success"].AsBoolean())
- return ResponseToGridUserInfo(userResponse);
- else
- m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
+ // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null.
+ return ResponseToGridUserInfo(userResponse);
- return null;
}
#endregion
@@ -338,67 +332,51 @@ namespace OpenSim.Services.Connectors.SimianGrid
private OSDMap GetUserData(UUID userID)
{
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
+ // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "GetUser" },
- { "UserID", userID.ToString() }
- };
+ {
+ { "RequestMethod", "GetUser" },
+ { "UserID", userID.ToString() }
+ };
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["User"] is OSDMap)
return response;
- else
- m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + response["Message"].AsString());
+ m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString());
return null;
}
- private List GetSessions(UUID userID)
+ private OSDMap GetSessionDataFromSessionID(UUID sessionID)
{
- List presences = new List(1);
-
- OSDMap userResponse = GetUserData(userID);
- if (userResponse != null)
- {
-// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting sessions for " + userID);
-
- NameValueCollection requestArgs = new NameValueCollection
+ NameValueCollection requestArgs = new NameValueCollection
{
- { "RequestMethod", "GetSession" },
- { "UserID", userID.ToString() }
+ { "RequestMethod", "GetSession" },
+ { "SessionID", sessionID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
- if (response["Success"].AsBoolean())
- {
- PresenceInfo presence = ResponseToPresenceInfo(response, userResponse);
- if (presence != null)
- presences.Add(presence);
- }
-// else
-// {
-// m_log.Debug("[SIMIAN PRESENCE CONNECTOR]: No session returned for " + userID + ": " + response["Message"].AsString());
-// }
- }
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
+ if (response["Success"].AsBoolean())
+ return response;
- return presences;
+ m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString());
+ return null;
}
private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
{
// Save our current location as session data
NameValueCollection requestArgs = new NameValueCollection
- {
- { "RequestMethod", "UpdateSession" },
- { "SessionID", sessionID.ToString() },
- { "SceneID", regionID.ToString() },
- { "ScenePosition", lastPosition.ToString() },
- { "SceneLookAt", lastLookAt.ToString() }
- };
+ {
+ { "RequestMethod", "UpdateSession" },
+ { "SessionID", sessionID.ToString() },
+ { "SceneID", regionID.ToString() },
+ { "ScenePosition", lastPosition.ToString() },
+ { "SceneLookAt", lastLookAt.ToString() }
+ };
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -407,7 +385,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
return success;
}
- private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse)
+ private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse)
{
if (sessionResponse == null)
return null;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
index bd8069f..8fc766d 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
@@ -392,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", client.AgentId.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
string email = response["Email"].AsString();
if (!response["Success"].AsBoolean())
@@ -425,7 +425,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
estate.EstateID, admin.Name);
estate.EstateOwner = admin.PrincipalID;
- estate.Save();
+ scene.EstateDataService.StoreEstateSettings(estate);
}
else
{
@@ -443,7 +443,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ key, OSDParser.SerializeJsonString(value) }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
@@ -462,7 +462,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserID", userID.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["User"] is OSDMap)
{
return (OSDMap)response["User"];
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 6e32b3a..698c4c0 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -165,7 +165,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "NameQuery", query }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
OSDArray array = response["Users"] as OSDArray;
@@ -191,6 +191,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
return accounts;
}
+ public void InvalidateCache(UUID userID)
+ {
+ m_accountCache.Remove(userID);
+ }
+
public bool StoreUserAccount(UserAccount data)
{
// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
@@ -204,7 +209,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "AccessLevel", data.UserLevel.ToString() }
};
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
@@ -219,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ "UserTitle", data.UserTitle }
};
- response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ response = SimianGrid.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (success)
@@ -252,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)";
// m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue);
- OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
+ OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
OSDMap user = response["User"] as OSDMap;
diff --git a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs
deleted file mode 100644
index cdcdecf..0000000
--- a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using OpenMetaverse;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using System.Reflection;
-using OpenSim.Services.Base;
-using OpenSim.Services.Interfaces;
-using OpenSim.Data;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Services.Connectors
-{
- public class EstateDataService : ServiceBase, IEstateDataService
- {
-// private static readonly ILog m_log =
-// LogManager.GetLogger(
-// MethodBase.GetCurrentMethod().DeclaringType);
-
- protected IEstateDataStore m_database;
-
- public EstateDataService(IConfigSource config)
- : base(config)
- {
- string dllName = String.Empty;
- string connString = String.Empty;
-
- // Try reading the [DatabaseService] section, if it exists
- IConfig dbConfig = config.Configs["DatabaseService"];
- if (dbConfig != null)
- {
- dllName = dbConfig.GetString("StorageProvider", String.Empty);
- connString = dbConfig.GetString("ConnectionString", String.Empty);
- connString = dbConfig.GetString("EstateConnectionString", connString);
- }
-
- // Try reading the [EstateDataStore] section, if it exists
- IConfig estConfig = config.Configs["EstateDataStore"];
- if (estConfig != null)
- {
- dllName = estConfig.GetString("StorageProvider", dllName);
- connString = estConfig.GetString("ConnectionString", connString);
- }
-
- // We tried, but this doesn't exist. We can't proceed
- if (dllName == String.Empty)
- throw new Exception("No StorageProvider configured");
-
- m_database = LoadPlugin(dllName, new Object[] { connString });
- if (m_database == null)
- throw new Exception("Could not find a storage interface in the given module");
- }
-
- public EstateSettings LoadEstateSettings(UUID regionID, bool create)
- {
- return m_database.LoadEstateSettings(regionID, create);
- }
-
- public EstateSettings LoadEstateSettings(int estateID)
- {
- return m_database.LoadEstateSettings(estateID);
- }
-
- public EstateSettings CreateNewEstate()
- {
- return m_database.CreateNewEstate();
- }
-
- public List LoadEstateSettingsAll()
- {
- return m_database.LoadEstateSettingsAll();
- }
-
- public void StoreEstateSettings(EstateSettings es)
- {
- m_database.StoreEstateSettings(es);
- }
-
- public List GetEstates(string search)
- {
- return m_database.GetEstates(search);
- }
-
- public List GetEstatesAll()
- {
- return m_database.GetEstatesAll();
- }
-
- public List GetEstatesByOwner(UUID ownerID)
- {
- return m_database.GetEstatesByOwner(ownerID);
- }
-
- public bool LinkRegion(UUID regionID, int estateID)
- {
- return m_database.LinkRegion(regionID, estateID);
- }
-
- public List GetRegions(int estateID)
- {
- return m_database.GetRegions(estateID);
- }
-
- public bool DeleteEstate(int estateID)
- {
- return m_database.DeleteEstate(estateID);
- }
- }
-}
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
deleted file mode 100644
index 504fcaf..0000000
--- a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using OpenMetaverse;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using System.Reflection;
-using OpenSim.Services.Base;
-using OpenSim.Services.Interfaces;
-using OpenSim.Data;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Services.Connectors
-{
- public class SimulationDataService : ServiceBase, ISimulationDataService
- {
-// private static readonly ILog m_log =
-// LogManager.GetLogger(
-// MethodBase.GetCurrentMethod().DeclaringType);
-
- protected ISimulationDataStore m_database;
-
- public SimulationDataService(IConfigSource config)
- : base(config)
- {
- string dllName = String.Empty;
- string connString = String.Empty;
-
- // Try reading the [DatabaseService] section, if it exists
- IConfig dbConfig = config.Configs["DatabaseService"];
- if (dbConfig != null)
- {
- dllName = dbConfig.GetString("StorageProvider", String.Empty);
- connString = dbConfig.GetString("ConnectionString", String.Empty);
- }
-
- // Try reading the [SimulationDataStore] section
- IConfig simConfig = config.Configs["SimulationDataStore"];
- if (simConfig != null)
- {
- dllName = simConfig.GetString("StorageProvider", dllName);
- connString = simConfig.GetString("ConnectionString", connString);
- }
-
- // We tried, but this doesn't exist. We can't proceed
- if (dllName == String.Empty)
- throw new Exception("No StorageProvider configured");
-
- m_database = LoadPlugin(dllName, new Object[] { connString });
- if (m_database == null)
- throw new Exception("Could not find a storage interface in the given module");
- }
-
- public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
- {
- m_database.StoreObject(obj, regionUUID);
- }
-
- public void RemoveObject(UUID uuid, UUID regionUUID)
- {
- m_database.RemoveObject(uuid, regionUUID);
- }
-
- public void StorePrimInventory(UUID primID, ICollection items)
- {
- m_database.StorePrimInventory(primID, items);
- }
-
- public List LoadObjects(UUID regionUUID)
- {
- return m_database.LoadObjects(regionUUID);
- }
-
- public void StoreTerrain(double[,] terrain, UUID regionID)
- {
- m_database.StoreTerrain(terrain, regionID);
- }
-
- public double[,] LoadTerrain(UUID regionID)
- {
- return m_database.LoadTerrain(regionID);
- }
-
- public void StoreLandObject(ILandObject Parcel)
- {
- m_database.StoreLandObject(Parcel);
- }
-
- public void RemoveLandObject(UUID globalID)
- {
- m_database.RemoveLandObject(globalID);
- }
-
- public List LoadLandObjects(UUID regionUUID)
- {
- return m_database.LoadLandObjects(regionUUID);
- }
-
- public void StoreRegionSettings(RegionSettings rs)
- {
- m_database.StoreRegionSettings(rs);
- }
-
- public RegionSettings LoadRegionSettings(UUID regionUUID)
- {
- return m_database.LoadRegionSettings(regionUUID);
- }
-
- public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
- {
- return m_database.LoadRegionWindlightSettings(regionUUID);
- }
-
- public void StoreRegionWindlightSettings(RegionLightShareData wl)
- {
- m_database.StoreRegionWindlightSettings(wl);
- }
- public void RemoveRegionWindlightSettings(UUID regionID)
- {
- m_database.RemoveRegionWindlightSettings(regionID);
- }
-
- public string LoadRegionEnvironmentSettings(UUID regionUUID)
- {
- return m_database.LoadRegionEnvironmentSettings(regionUUID);
- }
-
- public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
- {
- m_database.StoreRegionEnvironmentSettings(regionUUID, settings);
- }
-
- public void RemoveRegionEnvironmentSettings(UUID regionUUID)
- {
- m_database.RemoveRegionEnvironmentSettings(regionUUID);
- }
-
- public void SaveExtra(UUID regionID, string name, string val)
- {
- m_database.SaveExtra(regionID, name, val);
- }
-
- public void RemoveExtra(UUID regionID, string name)
- {
- m_database.RemoveExtra(regionID, name);
- }
-
- public Dictionary GetExtra(UUID regionID)
- {
- return m_database.GetExtra(regionID);
- }
- }
-}
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 57f2ffa..cea870b 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -79,11 +79,37 @@ namespace OpenSim.Services.Connectors.Simulation
return "agent/";
}
- public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
+ protected virtual void PackData(OSDMap args, GridRegion source, AgentCircuitData aCircuit, GridRegion destination, uint flags)
{
- // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start");
-
+ if (source != null)
+ {
+ args["source_x"] = OSD.FromString(source.RegionLocX.ToString());
+ args["source_y"] = OSD.FromString(source.RegionLocY.ToString());
+ args["source_name"] = OSD.FromString(source.RegionName);
+ args["source_uuid"] = OSD.FromString(source.RegionID.ToString());
+ if (!String.IsNullOrEmpty(source.RawServerURI))
+ args["source_server_uri"] = OSD.FromString(source.RawServerURI);
+ }
+
+ args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
+ args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
+ args["destination_name"] = OSD.FromString(destination.RegionName);
+ args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
+ args["teleport_flags"] = OSD.FromString(flags.ToString());
+ }
+
+ public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
+ {
+ string tmp = String.Empty;
+ return CreateAgent(source, destination, aCircuit, flags, out tmp, out reason);
+ }
+
+ public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
+ {
+ m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
reason = String.Empty;
+ myipaddress = String.Empty;
+
if (destination == null)
{
m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
@@ -95,12 +121,7 @@ namespace OpenSim.Services.Connectors.Simulation
try
{
OSDMap args = aCircuit.PackAgentCircuitData();
-
- args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
- args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
- args["destination_name"] = OSD.FromString(destination.RegionName);
- args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
- args["teleport_flags"] = OSD.FromString(flags.ToString());
+ PackData(args, source, aCircuit, destination, flags);
OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
bool success = result["success"].AsBoolean();
@@ -110,11 +131,12 @@ namespace OpenSim.Services.Connectors.Simulation
reason = data["reason"].AsString();
success = data["success"].AsBoolean();
+ myipaddress = data["your_ip"].AsString();
return success;
}
// Try the old version, uncompressed
- result = WebUtil.PostToService(uri, args, 30000);
+ result = WebUtil.PostToService(uri, args, 30000, false);
if (result["Success"].AsBoolean())
{
@@ -124,6 +146,7 @@ namespace OpenSim.Services.Connectors.Simulation
reason = data["reason"].AsString();
success = data["success"].AsBoolean();
+ myipaddress = data["your_ip"].AsString();
m_log.WarnFormat(
"[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
return success;
@@ -228,7 +251,7 @@ namespace OpenSim.Services.Connectors.Simulation
///
private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout)
{
- // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent start");
+ // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI);
// Eventually, we want to use a caps url instead of the agentID
string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/";
@@ -258,48 +281,10 @@ namespace OpenSim.Services.Connectors.Simulation
return false;
}
- ///
- /// Not sure what sequence causes this function to be invoked. The only calling
- /// path is through the GET method
- ///
- public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
- {
- // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start");
-
- agent = null;
-
- // Eventually, we want to use a caps url instead of the agentID
- string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
-
- try
- {
- OSDMap result = WebUtil.GetFromService(uri, 10000);
- if (result["Success"].AsBoolean())
- {
- // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString());
- OSDMap args = (OSDMap)result["_Result"];
- if (args != null)
- {
- agent = new CompleteAgentData();
- agent.Unpack(args, null);
- return true;
- }
- }
- }
- catch (Exception e)
- {
- m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString());
- }
-
- return false;
- }
- ///
- ///
- public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
+ public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List featuresAvailable, EntityTransferContext ctx, out string reason)
{
reason = "Failed to contact destination";
- version = "Unknown";
// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);
@@ -307,14 +292,32 @@ namespace OpenSim.Services.Connectors.Simulation
if (ext == null) return false;
// Eventually, we want to use a caps url instead of the agentID
- string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
+ string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/";
OSDMap request = new OSDMap();
+ request.Add("viaTeleport", OSD.FromBoolean(viaTeleport));
request.Add("position", OSD.FromString(position.ToString()));
+ // To those who still understad this field, we're telling them
+ // the lowest version just to be safe
+ request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin)));
+ // New simulation service negotiation
+ request.Add("simulation_service_supported_min", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMin));
+ request.Add("simulation_service_supported_max", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMax));
+ request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin));
+ request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax));
+
+ OSDArray features = new OSDArray();
+ foreach (UUID feature in featuresAvailable)
+ features.Add(OSD.FromString(feature.ToString()));
+
+ request.Add("features", features);
+
+ if (agentHomeURI != null)
+ request.Add("agent_home_uri", OSD.FromString(agentHomeURI));
try
{
- OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false);
+ OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false);
bool success = result["success"].AsBoolean();
if (result.ContainsKey("_Result"))
{
@@ -325,15 +328,32 @@ namespace OpenSim.Services.Connectors.Simulation
success = data["success"];
reason = data["reason"].AsString();
- if (data["version"] != null && data["version"].AsString() != string.Empty)
- version = data["version"].AsString();
+ // We will need to plumb this and start sing the outbound version as well
+ // TODO: lay the pipe for version plumbing
+ if (data.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null)
+ {
+ ctx.InboundVersion = (float)data["negotiated_inbound_version"].AsReal();
+ ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal();
+ }
+ else if (data["version"] != null && data["version"].AsString() != string.Empty)
+ {
+ string versionString = data["version"].AsString();
+ String[] parts = versionString.Split(new char[] {'/'});
+ if (parts.Length > 1)
+ {
+ ctx.InboundVersion = float.Parse(parts[1]);
+ ctx.OutboundVersion = float.Parse(parts[1]);
+ }
+ }
+ if (data.ContainsKey("variable_wearables_count_supported"))
+ ctx.VariableWearablesSupported = true;
m_log.DebugFormat(
- "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3} ({4})",
- uri, success, reason, version, data["version"].AsString());
+ "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}",
+ uri, success, reason, ctx.InboundVersion, ctx.OutboundVersion);
}
- if (!success)
+ if (!success || ctx.InboundVersion == 0f || ctx.OutboundVersion == 0f)
{
// If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the
// actual failure message
@@ -359,6 +379,17 @@ namespace OpenSim.Services.Connectors.Simulation
return false;
}
+
+ featuresAvailable.Clear();
+
+ if (result.ContainsKey("features"))
+ {
+ OSDArray array = (OSDArray)result["features"];
+
+ foreach (OSD o in array)
+ featuresAvailable.Add(new UUID(o.AsString()));
+ }
+
return success;
}
catch (Exception e)
@@ -377,7 +408,7 @@ namespace OpenSim.Services.Connectors.Simulation
try
{
- WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false);
+ WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false);
}
catch (Exception e)
{
@@ -389,15 +420,14 @@ namespace OpenSim.Services.Connectors.Simulation
///
///
- public bool CloseAgent(GridRegion destination, UUID id)
+ public bool CloseAgent(GridRegion destination, UUID id, string auth_code)
{
-// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start");
-
- string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
+ string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/?auth=" + auth_code;
+ m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent {0}", uri);
try
{
- WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false);
+ WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false);
}
catch (Exception e)
{
@@ -444,11 +474,18 @@ namespace OpenSim.Services.Connectors.Simulation
args["destination_name"] = OSD.FromString(destination.RegionName);
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
- WebUtil.PostToService(uri, args, 40000);
+ OSDMap result = WebUtil.PostToService(uri, args, 40000, false);
+
+ if (result == null)
+ return false;
+ bool success = result["success"].AsBoolean();
+ if (!success)
+ return false;
}
catch (Exception e)
{
m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString());
+ return false;
}
return true;
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
index 6d5ce28..c21db54 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
@@ -32,14 +32,15 @@ using System.IO;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
+
+using OpenSim.Framework.ServiceAuth;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
namespace OpenSim.Services.Connectors
{
- public class UserAccountServicesConnector : IUserAccountService
+ public class UserAccountServicesConnector : BaseServiceConnector, IUserAccountService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors
throw new Exception("User account connector init error");
}
m_ServerURI = serviceURI;
+
+ base.Initialise(source, "UserAccountService");
}
public virtual UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
@@ -144,7 +147,8 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply");
@@ -162,7 +166,7 @@ namespace OpenSim.Services.Connectors
if (replyData != null)
{
- if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null")
+ if (replyData.ContainsKey("result") && replyData["result"].ToString() == "null")
{
return accounts;
}
@@ -187,6 +191,10 @@ namespace OpenSim.Services.Connectors
return accounts;
}
+ public void InvalidateCache(UUID userID)
+ {
+ }
+
public virtual bool StoreUserAccount(UserAccount data)
{
Dictionary sendData = new Dictionary();
@@ -207,9 +215,39 @@ namespace OpenSim.Services.Connectors
sendData[kvp.Key] = kvp.Value.ToString();
}
- return SendAndGetBoolReply(sendData);
+ if (SendAndGetReply(sendData) != null)
+ return true;
+ else
+ return false;
}
+ ///
+ /// Create user remotely. Note this this is not part of the IUserAccountsService
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual UserAccount CreateUser(string first, string last, string password, string email, UUID scopeID)
+ {
+ Dictionary sendData = new Dictionary();
+ //sendData["SCOPEID"] = scopeID.ToString();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "createuser";
+
+ sendData["FirstName"] = first;
+ sendData["LastName"] = last;
+ sendData["Password"] = password;
+ if (!string.IsNullOrEmpty(email))
+ sendData["Email"] = first;
+ sendData["ScopeID"] = scopeID.ToString();
+
+ return SendAndGetReply(sendData);
+ }
+
private UserAccount SendAndGetReply(Dictionary sendData)
{
string reply = string.Empty;
@@ -220,7 +258,8 @@ namespace OpenSim.Services.Connectors
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply");
@@ -251,14 +290,16 @@ namespace OpenSim.Services.Connectors
{
string reqString = ServerUtils.BuildQueryString(sendData);
string uri = m_ServerURI + "/accounts";
- // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
+ //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
try
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
- reqString);
+ reqString,
+ m_Auth);
if (reply != string.Empty)
{
+ //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: reply = {0}", reply);
Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData.ContainsKey("result"))
diff --git a/OpenSim/Services/EstateService/EstateDataService.cs b/OpenSim/Services/EstateService/EstateDataService.cs
new file mode 100644
index 0000000..f6a8654
--- /dev/null
+++ b/OpenSim/Services/EstateService/EstateDataService.cs
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using OpenMetaverse;
+using log4net;
+using Nini.Config;
+using System.Reflection;
+using OpenSim.Services.Base;
+using OpenSim.Services.Interfaces;
+using OpenSim.Data;
+using OpenSim.Framework;
+
+namespace OpenSim.Services.EstateService
+{
+ public class EstateDataService : ServiceBase, IEstateDataService
+ {
+// private static readonly ILog m_log =
+// LogManager.GetLogger(
+// MethodBase.GetCurrentMethod().DeclaringType);
+
+ protected IEstateDataStore m_database;
+
+ public EstateDataService(IConfigSource config)
+ : base(config)
+ {
+ string dllName = String.Empty;
+ string connString = String.Empty;
+
+ // Try reading the [DatabaseService] section, if it exists
+ IConfig dbConfig = config.Configs["DatabaseService"];
+ if (dbConfig != null)
+ {
+ dllName = dbConfig.GetString("StorageProvider", String.Empty);
+ connString = dbConfig.GetString("ConnectionString", String.Empty);
+ connString = dbConfig.GetString("EstateConnectionString", connString);
+ }
+
+ // Try reading the [EstateDataStore] section, if it exists
+ IConfig estConfig = config.Configs["EstateDataStore"];
+ if (estConfig != null)
+ {
+ dllName = estConfig.GetString("StorageProvider", dllName);
+ connString = estConfig.GetString("ConnectionString", connString);
+ }
+
+ // We tried, but this doesn't exist. We can't proceed
+ if (dllName == String.Empty)
+ throw new Exception("No StorageProvider configured");
+
+ m_database = LoadPlugin(dllName, new Object[] { connString });
+ if (m_database == null)
+ throw new Exception("Could not find a storage interface in the given module");
+ }
+
+ public EstateSettings LoadEstateSettings(UUID regionID, bool create)
+ {
+ return m_database.LoadEstateSettings(regionID, create);
+ }
+
+ public EstateSettings LoadEstateSettings(int estateID)
+ {
+ return m_database.LoadEstateSettings(estateID);
+ }
+
+ public EstateSettings CreateNewEstate()
+ {
+ return m_database.CreateNewEstate();
+ }
+
+ public List LoadEstateSettingsAll()
+ {
+ return m_database.LoadEstateSettingsAll();
+ }
+
+ public void StoreEstateSettings(EstateSettings es)
+ {
+ m_database.StoreEstateSettings(es);
+ }
+
+ public List GetEstates(string search)
+ {
+ return m_database.GetEstates(search);
+ }
+
+ public List GetEstatesAll()
+ {
+ return m_database.GetEstatesAll();
+ }
+
+ public List GetEstatesByOwner(UUID ownerID)
+ {
+ return m_database.GetEstatesByOwner(ownerID);
+ }
+
+ public bool LinkRegion(UUID regionID, int estateID)
+ {
+ return m_database.LinkRegion(regionID, estateID);
+ }
+
+ public List GetRegions(int estateID)
+ {
+ return m_database.GetRegions(estateID);
+ }
+
+ public bool DeleteEstate(int estateID)
+ {
+ return m_database.DeleteEstate(estateID);
+ }
+ }
+}
diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs
new file mode 100644
index 0000000..1bab687
--- /dev/null
+++ b/OpenSim/Services/FSAssetService/FSAssetService.cs
@@ -0,0 +1,723 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
+using System.Text;
+using System.Threading;
+using System.Reflection;
+using OpenSim.Data;
+using OpenSim.Framework;
+using OpenSim.Framework.Serialization.External;
+using OpenSim.Framework.Console;
+using OpenSim.Server.Base;
+using OpenSim.Services.Base;
+using OpenSim.Services.Interfaces;
+using Nini.Config;
+using log4net;
+using OpenMetaverse;
+using System.Security.Cryptography;
+
+namespace OpenSim.Services.FSAssetService
+{
+ public class FSAssetConnector : ServiceBase, IAssetService
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
+ static SHA256CryptoServiceProvider SHA256 = new SHA256CryptoServiceProvider();
+
+ static byte[] ToCString(string s)
+ {
+ byte[] ret = enc.GetBytes(s);
+ Array.Resize(ref ret, ret.Length + 1);
+ ret[ret.Length - 1] = 0;
+
+ return ret;
+ }
+
+ protected IAssetLoader m_AssetLoader = null;
+ protected IFSAssetDataPlugin m_DataConnector = null;
+ protected IAssetService m_FallbackService;
+ protected Thread m_WriterThread;
+ protected Thread m_StatsThread;
+ protected string m_SpoolDirectory;
+ protected object m_readLock = new object();
+ protected object m_statsLock = new object();
+ protected int m_readCount = 0;
+ protected int m_readTicks = 0;
+ protected int m_missingAssets = 0;
+ protected int m_missingAssetsFS = 0;
+ protected string m_FSBase;
+
+ private static bool m_Initialized;
+ private bool m_MainInstance;
+
+ public FSAssetConnector(IConfigSource config)
+ : this(config, "AssetService")
+ {
+ }
+
+ public FSAssetConnector(IConfigSource config, string configName) : base(config)
+ {
+ if (!m_Initialized)
+ {
+ m_Initialized = true;
+ m_MainInstance = true;
+
+ MainConsole.Instance.Commands.AddCommand("fs", false,
+ "show assets", "show assets", "Show asset stats",
+ HandleShowAssets);
+ MainConsole.Instance.Commands.AddCommand("fs", false,
+ "show digest", "show digest ", "Show asset digest",
+ HandleShowDigest);
+ MainConsole.Instance.Commands.AddCommand("fs", false,
+ "delete asset", "delete asset ",
+ "Delete asset from database",
+ HandleDeleteAsset);
+ MainConsole.Instance.Commands.AddCommand("fs", false,
+ "import", "import [ ]",
+ "Import legacy assets",
+ HandleImportAssets);
+ MainConsole.Instance.Commands.AddCommand("fs", false,
+ "force import", "force import [ ]",
+ "Import legacy assets, overwriting current content",
+ HandleImportAssets);
+ }
+
+ IConfig assetConfig = config.Configs[configName];
+
+ if (assetConfig == null)
+ throw new Exception("No AssetService configuration");
+
+ // Get Database Connector from Asset Config (If present)
+ string dllName = assetConfig.GetString("StorageProvider", string.Empty);
+ string m_ConnectionString = assetConfig.GetString("ConnectionString", string.Empty);
+ string m_Realm = assetConfig.GetString("Realm", "fsassets");
+
+ int SkipAccessTimeDays = assetConfig.GetInt("DaysBetweenAccessTimeUpdates", 0);
+
+ // If not found above, fallback to Database defaults
+ IConfig dbConfig = config.Configs["DatabaseService"];
+
+ if (dbConfig != null)
+ {
+ if (dllName == String.Empty)
+ dllName = dbConfig.GetString("StorageProvider", String.Empty);
+
+ if (m_ConnectionString == String.Empty)
+ m_ConnectionString = dbConfig.GetString("ConnectionString", String.Empty);
+ }
+
+ // No databse connection found in either config
+ if (dllName.Equals(String.Empty))
+ throw new Exception("No StorageProvider configured");
+
+ if (m_ConnectionString.Equals(String.Empty))
+ throw new Exception("Missing database connection string");
+
+ // Create Storage Provider
+ m_DataConnector = LoadPlugin(dllName);
+
+ if (m_DataConnector == null)
+ throw new Exception(string.Format("Could not find a storage interface in the module {0}", dllName));
+
+ // Initialize DB And perform any migrations required
+ m_DataConnector.Initialise(m_ConnectionString, m_Realm, SkipAccessTimeDays);
+
+ // Setup Fallback Service
+ string str = assetConfig.GetString("FallbackService", string.Empty);
+
+ if (str != string.Empty)
+ {
+ object[] args = new object[] { config };
+ m_FallbackService = LoadPlugin(str, args);
+ if (m_FallbackService != null)
+ {
+ m_log.Info("[FSASSETS]: Fallback service loaded");
+ }
+ else
+ {
+ m_log.Error("[FSASSETS]: Failed to load fallback service");
+ }
+ }
+
+ // Setup directory structure including temp directory
+ m_SpoolDirectory = assetConfig.GetString("SpoolDirectory", "/tmp");
+
+ string spoolTmp = Path.Combine(m_SpoolDirectory, "spool");
+
+ Directory.CreateDirectory(spoolTmp);
+
+ m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty);
+ if (m_FSBase == String.Empty)
+ {
+ m_log.ErrorFormat("[FSASSETS]: BaseDirectory not specified");
+ throw new Exception("Configuration error");
+ }
+
+ if (m_MainInstance)
+ {
+ string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty);
+ if (loader != string.Empty)
+ {
+ m_AssetLoader = LoadPlugin(loader);
+ string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string.Empty);
+ m_log.InfoFormat("[FSASSETS]: Loading default asset set from {0}", loaderArgs);
+ m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs,
+ delegate(AssetBase a)
+ {
+ Store(a, false);
+ });
+ }
+
+ m_WriterThread = new Thread(Writer);
+ m_WriterThread.Start();
+ m_StatsThread = new Thread(Stats);
+ m_StatsThread.Start();
+ }
+
+ m_log.Info("[FSASSETS]: FS asset service enabled");
+ }
+
+ private void Stats()
+ {
+ while (true)
+ {
+ Thread.Sleep(60000);
+
+ lock (m_statsLock)
+ {
+ if (m_readCount > 0)
+ {
+ double avg = (double)m_readTicks / (double)m_readCount;
+// if (avg > 10000)
+// Environment.Exit(0);
+ m_log.InfoFormat("[FSASSETS]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS);
+ }
+ m_readCount = 0;
+ m_readTicks = 0;
+ m_missingAssets = 0;
+ m_missingAssetsFS = 0;
+ }
+ }
+ }
+
+ private void Writer()
+ {
+ m_log.Info("[FSASSETS]: Writer started");
+
+ while (true)
+ {
+ string[] files = Directory.GetFiles(m_SpoolDirectory);
+
+ if (files.Length > 0)
+ {
+ int tickCount = Environment.TickCount;
+ for (int i = 0 ; i < files.Length ; i++)
+ {
+ string hash = Path.GetFileNameWithoutExtension(files[i]);
+ string s = HashToFile(hash);
+ string diskFile = Path.Combine(m_FSBase, s);
+
+ Directory.CreateDirectory(Path.GetDirectoryName(diskFile));
+ try
+ {
+ byte[] data = File.ReadAllBytes(files[i]);
+
+ using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Create), CompressionMode.Compress))
+ {
+ gz.Write(data, 0, data.Length);
+ gz.Close();
+ }
+ File.Delete(files[i]);
+
+ //File.Move(files[i], diskFile);
+ }
+ catch(System.IO.IOException e)
+ {
+ if (e.Message.StartsWith("Win32 IO returned ERROR_ALREADY_EXISTS"))
+ File.Delete(files[i]);
+ else
+ throw;
+ }
+ }
+ int totalTicks = System.Environment.TickCount - tickCount;
+ if (totalTicks > 0) // Wrap?
+ {
+ m_log.InfoFormat("[FSASSETS]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length);
+ }
+ }
+
+ Thread.Sleep(1000);
+ }
+ }
+
+ string GetSHA256Hash(byte[] data)
+ {
+ byte[] hash = SHA256.ComputeHash(data);
+
+ return BitConverter.ToString(hash).Replace("-", String.Empty);
+ }
+
+ public string HashToPath(string hash)
+ {
+ if (hash == null || hash.Length < 10)
+ return "junkyard";
+
+ return Path.Combine(hash.Substring(0, 3),
+ Path.Combine(hash.Substring(3, 3)));
+ /*
+ * The below is what core would normally use.
+ * This is modified to work in OSGrid, as seen
+ * above, because the SRAS data is structured
+ * that way.
+ */
+ /*
+ return Path.Combine(hash.Substring(0, 2),
+ Path.Combine(hash.Substring(2, 2),
+ Path.Combine(hash.Substring(4, 2),
+ hash.Substring(6, 4))));
+ */
+ }
+
+ private bool AssetExists(string hash)
+ {
+ string s = HashToFile(hash);
+ string diskFile = Path.Combine(m_FSBase, s);
+
+ if (File.Exists(diskFile + ".gz") || File.Exists(diskFile))
+ return true;
+
+ return false;
+ }
+
+ public virtual bool[] AssetsExist(string[] ids)
+ {
+ UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
+ return m_DataConnector.AssetsExist(uuid);
+ }
+
+ public string HashToFile(string hash)
+ {
+ return Path.Combine(HashToPath(hash), hash);
+ }
+
+ public virtual AssetBase Get(string id)
+ {
+ string hash;
+
+ return Get(id, out hash);
+ }
+
+ private AssetBase Get(string id, out string sha)
+ {
+ string hash = string.Empty;
+
+ int startTime = System.Environment.TickCount;
+ AssetMetadata metadata;
+
+ lock (m_readLock)
+ {
+ metadata = m_DataConnector.Get(id, out hash);
+ }
+
+ sha = hash;
+
+ if (metadata == null)
+ {
+ AssetBase asset = null;
+ if (m_FallbackService != null)
+ {
+ asset = m_FallbackService.Get(id);
+ if (asset != null)
+ {
+ asset.Metadata.ContentType =
+ SLUtil.SLAssetTypeToContentType((int)asset.Type);
+ sha = GetSHA256Hash(asset.Data);
+ m_log.InfoFormat("[FSASSETS]: Added asset {0} from fallback to local store", id);
+ Store(asset);
+ }
+ }
+ if (asset == null)
+ {
+ // m_log.InfoFormat("[FSASSETS]: Asset {0} not found", id);
+ m_missingAssets++;
+ }
+ return asset;
+ }
+ AssetBase newAsset = new AssetBase();
+ newAsset.Metadata = metadata;
+ try
+ {
+ newAsset.Data = GetFsData(hash);
+ if (newAsset.Data.Length == 0)
+ {
+ AssetBase asset = null;
+ if (m_FallbackService != null)
+ {
+ asset = m_FallbackService.Get(id);
+ if (asset != null)
+ {
+ asset.Metadata.ContentType =
+ SLUtil.SLAssetTypeToContentType((int)asset.Type);
+ sha = GetSHA256Hash(asset.Data);
+ m_log.InfoFormat("[FSASSETS]: Added asset {0} from fallback to local store", id);
+ Store(asset);
+ }
+ }
+ if (asset == null)
+ m_missingAssetsFS++;
+ // m_log.InfoFormat("[FSASSETS]: Asset {0}, hash {1} not found in FS", id, hash);
+ else
+ {
+ // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
+ // Fix bad assets before sending them elsewhere
+ if (asset.Type == (int)AssetType.Object && asset.Data != null)
+ {
+ string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
+ asset.Data = Utils.StringToBytes(xml);
+ }
+ return asset;
+ }
+ }
+
+ lock (m_statsLock)
+ {
+ m_readTicks += Environment.TickCount - startTime;
+ m_readCount++;
+ }
+
+ // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
+ // Fix bad assets before sending them elsewhere
+ if (newAsset.Type == (int)AssetType.Object && newAsset.Data != null)
+ {
+ string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(newAsset.Data));
+ newAsset.Data = Utils.StringToBytes(xml);
+ }
+
+ return newAsset;
+ }
+ catch (Exception exception)
+ {
+ m_log.Error(exception.ToString());
+ Thread.Sleep(5000);
+ Environment.Exit(1);
+ return null;
+ }
+ }
+
+ public virtual AssetMetadata GetMetadata(string id)
+ {
+ string hash;
+ return m_DataConnector.Get(id, out hash);
+ }
+
+ public virtual byte[] GetData(string id)
+ {
+ string hash;
+ if (m_DataConnector.Get(id, out hash) == null)
+ return null;
+
+ return GetFsData(hash);
+ }
+
+ public bool Get(string id, Object sender, AssetRetrieved handler)
+ {
+ AssetBase asset = Get(id);
+
+ handler(id, sender, asset);
+
+ return true;
+ }
+
+ public byte[] GetFsData(string hash)
+ {
+ string spoolFile = Path.Combine(m_SpoolDirectory, hash + ".asset");
+
+ if (File.Exists(spoolFile))
+ {
+ try
+ {
+ byte[] content = File.ReadAllBytes(spoolFile);
+
+ return content;
+ }
+ catch
+ {
+ }
+ }
+
+ string file = HashToFile(hash);
+ string diskFile = Path.Combine(m_FSBase, file);
+
+ if (File.Exists(diskFile + ".gz"))
+ {
+ try
+ {
+ using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Open, FileAccess.Read), CompressionMode.Decompress))
+ {
+ using (MemoryStream ms = new MemoryStream())
+ {
+ byte[] data = new byte[32768];
+ int bytesRead;
+
+ do
+ {
+ bytesRead = gz.Read(data, 0, 32768);
+ if (bytesRead > 0)
+ ms.Write(data, 0, bytesRead);
+ } while (bytesRead > 0);
+
+ return ms.ToArray();
+ }
+ }
+ }
+ catch (Exception)
+ {
+ return new Byte[0];
+ }
+ }
+ else if (File.Exists(diskFile))
+ {
+ try
+ {
+ byte[] content = File.ReadAllBytes(diskFile);
+
+ return content;
+ }
+ catch
+ {
+ }
+ }
+ return new Byte[0];
+
+ }
+
+ public virtual string Store(AssetBase asset)
+ {
+ return Store(asset, false);
+ }
+
+ private string Store(AssetBase asset, bool force)
+ {
+ int tickCount = Environment.TickCount;
+ string hash = GetSHA256Hash(asset.Data);
+
+ if (!AssetExists(hash))
+ {
+ string tempFile = Path.Combine(Path.Combine(m_SpoolDirectory, "spool"), hash + ".asset");
+ string finalFile = Path.Combine(m_SpoolDirectory, hash + ".asset");
+
+ if (!File.Exists(finalFile))
+ {
+ // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
+ // Fix bad assets before storing on this server
+ if (asset.Type == (int)AssetType.Object && asset.Data != null)
+ {
+ string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
+ asset.Data = Utils.StringToBytes(xml);
+ }
+
+ FileStream fs = File.Create(tempFile);
+
+ fs.Write(asset.Data, 0, asset.Data.Length);
+
+ fs.Close();
+
+ File.Move(tempFile, finalFile);
+ }
+ }
+
+ if (asset.ID == string.Empty)
+ {
+ if (asset.FullID == UUID.Zero)
+ {
+ asset.FullID = UUID.Random();
+ }
+ asset.ID = asset.FullID.ToString();
+ }
+ else if (asset.FullID == UUID.Zero)
+ {
+ UUID uuid = UUID.Zero;
+ if (UUID.TryParse(asset.ID, out uuid))
+ {
+ asset.FullID = uuid;
+ }
+ else
+ {
+ asset.FullID = UUID.Random();
+ }
+ }
+
+ if (!m_DataConnector.Store(asset.Metadata, hash))
+ {
+ return UUID.Zero.ToString();
+ }
+ else
+ {
+ return asset.ID;
+ }
+ }
+
+ public bool UpdateContent(string id, byte[] data)
+ {
+ return false;
+
+// string oldhash;
+// AssetMetadata meta = m_DataConnector.Get(id, out oldhash);
+//
+// if (meta == null)
+// return false;
+//
+// AssetBase asset = new AssetBase();
+// asset.Metadata = meta;
+// asset.Data = data;
+//
+// Store(asset);
+//
+// return true;
+ }
+
+ public virtual bool Delete(string id)
+ {
+ m_DataConnector.Delete(id);
+
+ return true;
+ }
+
+ private void HandleShowAssets(string module, string[] args)
+ {
+ int num = m_DataConnector.Count();
+ MainConsole.Instance.Output(string.Format("Total asset count: {0}", num));
+ }
+
+ private void HandleShowDigest(string module, string[] args)
+ {
+ if (args.Length < 3)
+ {
+ MainConsole.Instance.Output("Syntax: show digest ");
+ return;
+ }
+
+ string hash;
+ AssetBase asset = Get(args[2], out hash);
+
+ if (asset == null || asset.Data.Length == 0)
+ {
+ MainConsole.Instance.Output("Asset not found");
+ return;
+ }
+
+ int i;
+
+ MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name));
+ MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description));
+ MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type));
+ MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType));
+ MainConsole.Instance.Output(String.Format("Flags: {0}", asset.Metadata.Flags.ToString()));
+ MainConsole.Instance.Output(String.Format("FS file: {0}", HashToFile(hash)));
+
+ 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));
+ }
+ }
+
+ private void HandleDeleteAsset(string module, string[] args)
+ {
+ if (args.Length < 3)
+ {
+ MainConsole.Instance.Output("Syntax: delete asset ");
+ return;
+ }
+
+ AssetBase asset = Get(args[2]);
+
+ if (asset == null || asset.Data.Length == 0)
+ {
+ MainConsole.Instance.Output("Asset not found");
+ return;
+ }
+
+ m_DataConnector.Delete(args[2]);
+
+ MainConsole.Instance.Output("Asset deleted");
+ }
+
+ private void HandleImportAssets(string module, string[] args)
+ {
+ bool force = false;
+ if (args[0] == "force")
+ {
+ force = true;
+ List list = new List(args);
+ list.RemoveAt(0);
+ args = list.ToArray();
+ }
+ if (args.Length < 3)
+ {
+ MainConsole.Instance.Output("Syntax: import [ ]");
+ }
+ else
+ {
+ string conn = args[1];
+ string table = args[2];
+ int start = 0;
+ int count = -1;
+ if (args.Length > 3)
+ {
+ start = Convert.ToInt32(args[3]);
+ }
+ if (args.Length > 4)
+ {
+ count = Convert.ToInt32(args[4]);
+ }
+ m_DataConnector.Import(conn, table, start, count, force, new FSStoreDelegate(Store));
+ }
+ }
+
+ public AssetBase GetCached(string id)
+ {
+ return Get(id);
+ }
+ }
+}
diff --git a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
index 58c7283..1e3560b 100644
--- a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
index dddb091..87fb6a9 100644
--- a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.7.5.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("0.8.3.*")]
+
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index ee3b858..0c502a2 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Services.GridService
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
+ private string LogHeader = "[GRID SERVICE]";
private bool m_DeleteOnUnregister = true;
private static GridService m_RootInstance = null;
@@ -56,6 +57,10 @@ namespace OpenSim.Services.GridService
protected bool m_AllowDuplicateNames = false;
protected bool m_AllowHypergridMapSearch = false;
+ protected bool m_SuppressVarregionOverlapCheckOnRegistration = false;
+
+ private static Dictionary m_ExtraFeatures = new Dictionary();
+
public GridService(IConfigSource config)
: base(config)
{
@@ -63,6 +68,9 @@ namespace OpenSim.Services.GridService
m_config = config;
IConfig gridConfig = config.Configs["GridService"];
+
+ bool suppressConsoleCommands = false;
+
if (gridConfig != null)
{
m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
@@ -76,32 +84,33 @@ namespace OpenSim.Services.GridService
}
m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
+
+ m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration);
+
+ // This service is also used locally by a simulator running in grid mode. This switches prevents
+ // inappropriate console commands from being registered
+ suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands);
}
-
+
if (m_RootInstance == null)
{
m_RootInstance = this;
- if (MainConsole.Instance != null)
+ if (!suppressConsoleCommands && MainConsole.Instance != null)
{
MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region id",
- "deregister region id ",
+ "deregister region id +",
"Deregister a region manually.",
String.Empty,
HandleDeregisterRegion);
- // A messy way of stopping this command being added if we are in standalone (since the simulator
- // has an identically named command
- //
- // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
- if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
- MainConsole.Instance.Commands.AddCommand("Regions", true,
- "show regions",
- "show regions",
- "Show details on all regions",
- String.Empty,
- HandleShowRegions);
+ MainConsole.Instance.Commands.AddCommand("Regions", true,
+ "show regions",
+ "show regions",
+ "Show details on all regions",
+ String.Empty,
+ HandleShowRegions);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region name",
@@ -117,17 +126,72 @@ namespace OpenSim.Services.GridService
"For example, show region at 1000 1000",
HandleShowRegionAt);
- MainConsole.Instance.Commands.AddCommand("Regions", true,
- "set region flags",
- "set region flags ",
- "Set database flags for region",
+ MainConsole.Instance.Commands.AddCommand("General", true,
+ "show grid size",
+ "show grid size",
+ "Show the current grid size (excluding hyperlink references)",
String.Empty,
- HandleSetFlags);
+ HandleShowGridSize);
+
+ MainConsole.Instance.Commands.AddCommand("Regions", true,
+ "set region flags",
+ "set region flags ",
+ "Set database flags for region",
+ String.Empty,
+ HandleSetFlags);
}
+
+ if (!suppressConsoleCommands)
+ SetExtraServiceURLs(config);
+
m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
}
}
+ private void SetExtraServiceURLs(IConfigSource config)
+ {
+ IConfig loginConfig = config.Configs["LoginService"];
+ IConfig gridConfig = config.Configs["GridService"];
+
+ if (loginConfig == null || gridConfig == null)
+ return;
+
+ string configVal;
+
+ configVal = loginConfig.GetString("SearchURL", string.Empty);
+ if (!string.IsNullOrEmpty(configVal))
+ m_ExtraFeatures["search-server-url"] = configVal;
+
+ configVal = loginConfig.GetString("MapTileURL", string.Empty);
+ if (!string.IsNullOrEmpty(configVal))
+ {
+ // This URL must end with '/', the viewer doesn't check
+ configVal = configVal.Trim();
+ if (!configVal.EndsWith("/"))
+ configVal = configVal + "/";
+ m_ExtraFeatures["map-server-url"] = configVal;
+ }
+
+ configVal = loginConfig.GetString("DestinationGuide", string.Empty);
+ if (!string.IsNullOrEmpty(configVal))
+ m_ExtraFeatures["destination-guide-url"] = configVal;
+
+ configVal = Util.GetConfigVarFromSections(
+ config, "GatekeeperURI", new string[] { "Startup", "Hypergrid" }, String.Empty);
+ if (!string.IsNullOrEmpty(configVal))
+ m_ExtraFeatures["GridURL"] = configVal;
+
+ configVal = Util.GetConfigVarFromSections(
+ config, "GridName", new string[] { "Const", "Hypergrid" }, String.Empty);
+ if (string.IsNullOrEmpty(configVal))
+ configVal = Util.GetConfigVarFromSections