mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
Merge branch 'master-core' into mantis5110
This commit is contained in:
@@ -43,44 +43,51 @@ namespace OpenSim.Services.AssetService
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected static AssetService m_RootInstance;
|
||||
|
||||
public AssetService(IConfigSource config) : base(config)
|
||||
{
|
||||
MainConsole.Instance.Commands.AddCommand("kfs", false,
|
||||
"show digest",
|
||||
"show digest <ID>",
|
||||
"Show asset digest", HandleShowDigest);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("kfs", false,
|
||||
"delete asset",
|
||||
"delete asset <ID>",
|
||||
"Delete asset from database", HandleDeleteAsset);
|
||||
|
||||
if (m_AssetLoader != null)
|
||||
if (m_RootInstance == null)
|
||||
{
|
||||
IConfig assetConfig = config.Configs["AssetService"];
|
||||
if (assetConfig == null)
|
||||
throw new Exception("No AssetService configuration");
|
||||
m_RootInstance = this;
|
||||
|
||||
string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
|
||||
String.Empty);
|
||||
MainConsole.Instance.Commands.AddCommand("kfs", false,
|
||||
"show digest",
|
||||
"show digest <ID>",
|
||||
"Show asset digest", HandleShowDigest);
|
||||
|
||||
bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
|
||||
MainConsole.Instance.Commands.AddCommand("kfs", false,
|
||||
"delete asset",
|
||||
"delete asset <ID>",
|
||||
"Delete asset from database", HandleDeleteAsset);
|
||||
|
||||
if (assetLoaderEnabled)
|
||||
if (m_AssetLoader != null)
|
||||
{
|
||||
m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs);
|
||||
m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs,
|
||||
delegate(AssetBase a)
|
||||
{
|
||||
Store(a);
|
||||
});
|
||||
IConfig assetConfig = config.Configs["AssetService"];
|
||||
if (assetConfig == null)
|
||||
throw new Exception("No AssetService configuration");
|
||||
|
||||
string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
|
||||
String.Empty);
|
||||
|
||||
bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
|
||||
|
||||
if (assetLoaderEnabled)
|
||||
{
|
||||
m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs);
|
||||
m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs,
|
||||
delegate(AssetBase a)
|
||||
{
|
||||
Store(a);
|
||||
});
|
||||
}
|
||||
|
||||
m_log.Info("[ASSET SERVICE]: Local asset service enabled");
|
||||
}
|
||||
|
||||
m_log.Info("[ASSET SERVICE]: Local asset service enabled");
|
||||
}
|
||||
}
|
||||
|
||||
public AssetBase Get(string id)
|
||||
public virtual AssetBase Get(string id)
|
||||
{
|
||||
UUID assetID;
|
||||
|
||||
@@ -93,12 +100,12 @@ namespace OpenSim.Services.AssetService
|
||||
return m_Database.GetAsset(assetID);
|
||||
}
|
||||
|
||||
public AssetBase GetCached(string id)
|
||||
public virtual AssetBase GetCached(string id)
|
||||
{
|
||||
return Get(id);
|
||||
}
|
||||
|
||||
public AssetMetadata GetMetadata(string id)
|
||||
public virtual AssetMetadata GetMetadata(string id)
|
||||
{
|
||||
UUID assetID;
|
||||
|
||||
@@ -112,7 +119,7 @@ namespace OpenSim.Services.AssetService
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] GetData(string id)
|
||||
public virtual byte[] GetData(string id)
|
||||
{
|
||||
UUID assetID;
|
||||
|
||||
@@ -123,7 +130,7 @@ namespace OpenSim.Services.AssetService
|
||||
return asset.Data;
|
||||
}
|
||||
|
||||
public bool Get(string id, Object sender, AssetRetrieved handler)
|
||||
public virtual bool Get(string id, Object sender, AssetRetrieved handler)
|
||||
{
|
||||
//m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
|
||||
|
||||
@@ -141,7 +148,7 @@ namespace OpenSim.Services.AssetService
|
||||
return true;
|
||||
}
|
||||
|
||||
public string Store(AssetBase asset)
|
||||
public virtual string Store(AssetBase asset)
|
||||
{
|
||||
//m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
|
||||
m_Database.StoreAsset(asset);
|
||||
@@ -154,7 +161,7 @@ namespace OpenSim.Services.AssetService
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Delete(string id)
|
||||
public virtual bool Delete(string id)
|
||||
{
|
||||
m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
|
||||
UUID assetID;
|
||||
|
||||
@@ -333,7 +333,8 @@ namespace OpenSim.Services.HypergridService
|
||||
|
||||
string addressee = parts[0];
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, m_ExternalName);
|
||||
return (addressee == m_ExternalName);
|
||||
|
||||
return string.Equals(addressee, m_ExternalName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
145
OpenSim/Services/HypergridService/HGAssetService.cs
Normal file
145
OpenSim/Services/HypergridService/HGAssetService.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
using Nini.Config;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.AssetService;
|
||||
|
||||
namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
/// <summary>
|
||||
/// Hypergrid asset service. It serves the IAssetService interface,
|
||||
/// but implements it in ways that are appropriate for inter-grid
|
||||
/// asset exchanges.
|
||||
/// </summary>
|
||||
public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private string m_ProfileServiceURL;
|
||||
private IUserAccountService m_UserAccountService;
|
||||
|
||||
private UserAccountCache m_Cache;
|
||||
|
||||
public HGAssetService(IConfigSource config) : base(config)
|
||||
{
|
||||
m_log.Debug("[HGAsset Service]: Starting");
|
||||
IConfig assetConfig = config.Configs["HGAssetService"];
|
||||
if (assetConfig == null)
|
||||
throw new Exception("No HGAssetService configuration");
|
||||
|
||||
string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty);
|
||||
if (userAccountsDll == string.Empty)
|
||||
throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
|
||||
if (m_UserAccountService == null)
|
||||
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
|
||||
|
||||
m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty);
|
||||
|
||||
m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
|
||||
}
|
||||
|
||||
#region IAssetService overrides
|
||||
public override AssetBase Get(string id)
|
||||
{
|
||||
AssetBase asset = base.Get(id);
|
||||
|
||||
if (asset == null)
|
||||
return null;
|
||||
|
||||
if (asset.Metadata.Type == (sbyte)AssetType.Object)
|
||||
asset.Data = AdjustIdentifiers(asset.Data); ;
|
||||
|
||||
AdjustIdentifiers(asset.Metadata);
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
public override AssetMetadata GetMetadata(string id)
|
||||
{
|
||||
AssetMetadata meta = base.GetMetadata(id);
|
||||
|
||||
if (meta == null)
|
||||
return null;
|
||||
|
||||
AdjustIdentifiers(meta);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
public override byte[] GetData(string id)
|
||||
{
|
||||
byte[] data = base.GetData(id);
|
||||
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
return AdjustIdentifiers(data);
|
||||
}
|
||||
|
||||
//public virtual bool Get(string id, Object sender, AssetRetrieved handler)
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
// NOGO
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void AdjustIdentifiers(AssetMetadata meta)
|
||||
{
|
||||
UserAccount creator = m_Cache.GetUser(meta.CreatorID);
|
||||
if (creator != null)
|
||||
meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
|
||||
}
|
||||
|
||||
protected byte[] AdjustIdentifiers(byte[] data)
|
||||
{
|
||||
string xml = Utils.BytesToString(data);
|
||||
return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,11 +33,20 @@ using Nini.Config;
|
||||
using System.Reflection;
|
||||
using OpenSim.Services.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.InventoryService;
|
||||
using OpenSim.Data;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Server.Base;
|
||||
|
||||
namespace OpenSim.Services.InventoryService
|
||||
namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
/// <summary>
|
||||
/// Hypergrid inventory service. It serves the IInventoryService interface,
|
||||
/// but implements it in ways that are appropriate for inter-grid
|
||||
/// inventory exchanges. Specifically, it does not performs deletions
|
||||
/// and it responds to GetRootFolder requests with the ID of the
|
||||
/// Suitcase folder, not the actual "My Inventory" folder.
|
||||
/// </summary>
|
||||
public class HGInventoryService : XInventoryService, IInventoryService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
@@ -46,9 +55,16 @@ namespace OpenSim.Services.InventoryService
|
||||
|
||||
protected new IXInventoryData m_Database;
|
||||
|
||||
private string m_ProfileServiceURL;
|
||||
private IUserAccountService m_UserAccountService;
|
||||
|
||||
private UserAccountCache m_Cache;
|
||||
|
||||
public HGInventoryService(IConfigSource config)
|
||||
: base(config)
|
||||
{
|
||||
m_log.Debug("[HGInventory Service]: Starting");
|
||||
|
||||
string dllName = String.Empty;
|
||||
string connString = String.Empty;
|
||||
//string realm = "Inventory"; // OSG version doesn't use this
|
||||
@@ -68,12 +84,25 @@ namespace OpenSim.Services.InventoryService
|
||||
//
|
||||
// Try reading the [InventoryService] section, if it exists
|
||||
//
|
||||
IConfig authConfig = config.Configs["InventoryService"];
|
||||
if (authConfig != null)
|
||||
IConfig invConfig = config.Configs["HGInventoryService"];
|
||||
if (invConfig != null)
|
||||
{
|
||||
dllName = authConfig.GetString("StorageProvider", dllName);
|
||||
connString = authConfig.GetString("ConnectionString", connString);
|
||||
dllName = invConfig.GetString("StorageProvider", dllName);
|
||||
connString = invConfig.GetString("ConnectionString", connString);
|
||||
|
||||
// realm = authConfig.GetString("Realm", realm);
|
||||
string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
|
||||
if (userAccountsDll == string.Empty)
|
||||
throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
|
||||
if (m_UserAccountService == null)
|
||||
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
|
||||
|
||||
m_ProfileServiceURL = invConfig.GetString("ProfileServerURI", string.Empty);
|
||||
|
||||
m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -282,9 +311,18 @@ namespace OpenSim.Services.InventoryService
|
||||
//{
|
||||
//}
|
||||
|
||||
//public InventoryItemBase GetItem(InventoryItemBase item)
|
||||
//{
|
||||
//}
|
||||
public override InventoryItemBase GetItem(InventoryItemBase item)
|
||||
{
|
||||
InventoryItemBase it = base.GetItem(item);
|
||||
|
||||
UserAccount user = m_Cache.GetUser(it.CreatorId);
|
||||
|
||||
// Adjust the creator data
|
||||
if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty))
|
||||
it.CreatorData = m_ProfileServiceURL + "/" + it.CreatorId + ";" + user.FirstName + " " + user.LastName;
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
//public InventoryFolderBase GetFolder(InventoryFolderBase folder)
|
||||
//{
|
||||
105
OpenSim/Services/HypergridService/UserAccountCache.cs
Normal file
105
OpenSim/Services/HypergridService/UserAccountCache.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
public class UserAccountCache : IUserAccountService
|
||||
{
|
||||
private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
|
||||
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private ExpiringCache<UUID, UserAccount> m_UUIDCache;
|
||||
|
||||
private IUserAccountService m_UserAccountService;
|
||||
|
||||
private static UserAccountCache m_Singleton;
|
||||
|
||||
public static UserAccountCache CreateUserAccountCache(IUserAccountService u)
|
||||
{
|
||||
if (m_Singleton == null)
|
||||
m_Singleton = new UserAccountCache(u);
|
||||
|
||||
return m_Singleton;
|
||||
}
|
||||
|
||||
private UserAccountCache(IUserAccountService u)
|
||||
{
|
||||
m_UUIDCache = new ExpiringCache<UUID, UserAccount>();
|
||||
m_UserAccountService = u;
|
||||
}
|
||||
|
||||
public void Cache(UUID userID, UserAccount account)
|
||||
{
|
||||
// Cache even null accounts
|
||||
m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
|
||||
|
||||
//m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
|
||||
}
|
||||
|
||||
public UserAccount Get(UUID userID, out bool inCache)
|
||||
{
|
||||
UserAccount account = null;
|
||||
inCache = false;
|
||||
if (m_UUIDCache.TryGetValue(userID, out account))
|
||||
{
|
||||
//m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
|
||||
inCache = true;
|
||||
return account;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserAccount GetUser(string id)
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
UUID.TryParse(id, out uuid);
|
||||
bool inCache = false;
|
||||
UserAccount account = Get(uuid, out inCache);
|
||||
if (!inCache)
|
||||
{
|
||||
account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid);
|
||||
Cache(uuid, account);
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
#region IUserAccountService
|
||||
public UserAccount GetUserAccount(UUID scopeID, UUID userID)
|
||||
{
|
||||
return GetUser(userID.ToString());
|
||||
}
|
||||
|
||||
public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserAccount GetUserAccount(UUID scopeID, string Email)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool StoreUserAccount(UserAccount data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -761,6 +761,7 @@ namespace OpenSim.Services.LLLoginService
|
||||
if (account.ServiceURLs == null)
|
||||
return;
|
||||
|
||||
// Old style: get the service keys from the DB
|
||||
foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
|
||||
{
|
||||
if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty))
|
||||
@@ -772,6 +773,21 @@ namespace OpenSim.Services.LLLoginService
|
||||
aCircuit.ServiceURLs[kvp.Key] = kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// New style: service keys start with SRV_; override the previous
|
||||
string[] keys = m_LoginServerConfig.GetKeys();
|
||||
|
||||
if (keys.Length > 0)
|
||||
{
|
||||
IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_"));
|
||||
foreach (string serviceKey in serviceKeys)
|
||||
{
|
||||
string keyName = serviceKey.Replace("SRV_", "");
|
||||
aCircuit.ServiceURLs[keyName] = m_LoginServerConfig.GetString(serviceKey, string.Empty);
|
||||
m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason)
|
||||
|
||||
Reference in New Issue
Block a user