mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
Preservation of creator information now also working in IARs. Cleaned up usage help. Moved Osp around, deleted unnecessary OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in a generic ExternalRepresentationUtils function.
This commit is contained in:
@@ -35,6 +35,7 @@ using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.AssetService;
|
||||
@@ -131,48 +132,7 @@ namespace OpenSim.Services.HypergridService
|
||||
protected byte[] AdjustIdentifiers(byte[] data)
|
||||
{
|
||||
string xml = Utils.BytesToString(data);
|
||||
return Utils.StringToBytes(RewriteSOP(xml));
|
||||
}
|
||||
|
||||
protected string RewriteSOP(string xml)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(xml);
|
||||
XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
|
||||
|
||||
foreach (XmlNode sop in sops)
|
||||
{
|
||||
UserAccount creator = null;
|
||||
bool hasCreatorData = false;
|
||||
XmlNodeList nodes = sop.ChildNodes;
|
||||
foreach (XmlNode node in nodes)
|
||||
{
|
||||
if (node.Name == "CreatorID")
|
||||
creator = m_Cache.GetUser(node.InnerText);
|
||||
if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
|
||||
hasCreatorData = true;
|
||||
|
||||
//if (node.Name == "OwnerID")
|
||||
//{
|
||||
// UserAccount owner = GetUser(node.InnerText);
|
||||
// if (owner != null)
|
||||
// node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
|
||||
//}
|
||||
}
|
||||
if (!hasCreatorData && creator != null)
|
||||
{
|
||||
XmlElement creatorData = doc.CreateElement("CreatorData");
|
||||
creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
|
||||
sop.AppendChild(creatorData);
|
||||
}
|
||||
}
|
||||
|
||||
using (StringWriter wr = new StringWriter())
|
||||
{
|
||||
doc.Save(wr);
|
||||
return wr.ToString();
|
||||
}
|
||||
|
||||
return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user