diff options
author | Diva Canto | 2010-11-29 08:43:33 -0800 |
---|---|---|
committer | Diva Canto | 2010-11-29 08:43:33 -0800 |
commit | f86c438653fc3c8356a8f0c43a055b1928183f02 (patch) | |
tree | b8ad05db04efde6385eeaed48dcbe4e896133ad5 /OpenSim/Services | |
parent | Changed the parser for InventoryItem deserialization. Moved some utility func... (diff) | |
download | opensim-SC_OLD-f86c438653fc3c8356a8f0c43a055b1928183f02.zip opensim-SC_OLD-f86c438653fc3c8356a8f0c43a055b1928183f02.tar.gz opensim-SC_OLD-f86c438653fc3c8356a8f0c43a055b1928183f02.tar.bz2 opensim-SC_OLD-f86c438653fc3c8356a8f0c43a055b1928183f02.tar.xz |
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.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/HypergridService/HGAssetService.cs | 44 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/UserAccountCache.cs | 105 |
2 files changed, 107 insertions, 42 deletions
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 9b098a0..584ab6f 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs | |||
@@ -35,6 +35,7 @@ using log4net; | |||
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | 36 | ||
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Serialization.External; | ||
38 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
39 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
40 | using OpenSim.Services.AssetService; | 41 | using OpenSim.Services.AssetService; |
@@ -131,48 +132,7 @@ namespace OpenSim.Services.HypergridService | |||
131 | protected byte[] AdjustIdentifiers(byte[] data) | 132 | protected byte[] AdjustIdentifiers(byte[] data) |
132 | { | 133 | { |
133 | string xml = Utils.BytesToString(data); | 134 | string xml = Utils.BytesToString(data); |
134 | return Utils.StringToBytes(RewriteSOP(xml)); | 135 | return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero)); |
135 | } | ||
136 | |||
137 | protected string RewriteSOP(string xml) | ||
138 | { | ||
139 | XmlDocument doc = new XmlDocument(); | ||
140 | doc.LoadXml(xml); | ||
141 | XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); | ||
142 | |||
143 | foreach (XmlNode sop in sops) | ||
144 | { | ||
145 | UserAccount creator = null; | ||
146 | bool hasCreatorData = false; | ||
147 | XmlNodeList nodes = sop.ChildNodes; | ||
148 | foreach (XmlNode node in nodes) | ||
149 | { | ||
150 | if (node.Name == "CreatorID") | ||
151 | creator = m_Cache.GetUser(node.InnerText); | ||
152 | if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty) | ||
153 | hasCreatorData = true; | ||
154 | |||
155 | //if (node.Name == "OwnerID") | ||
156 | //{ | ||
157 | // UserAccount owner = GetUser(node.InnerText); | ||
158 | // if (owner != null) | ||
159 | // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName; | ||
160 | //} | ||
161 | } | ||
162 | if (!hasCreatorData && creator != null) | ||
163 | { | ||
164 | XmlElement creatorData = doc.CreateElement("CreatorData"); | ||
165 | creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; | ||
166 | sop.AppendChild(creatorData); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | using (StringWriter wr = new StringWriter()) | ||
171 | { | ||
172 | doc.Save(wr); | ||
173 | return wr.ToString(); | ||
174 | } | ||
175 | |||
176 | } | 136 | } |
177 | 137 | ||
178 | } | 138 | } |
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs new file mode 100644 index 0000000..3e9aea1 --- /dev/null +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs | |||
@@ -0,0 +1,105 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | |||
5 | using log4net; | ||
6 | using OpenMetaverse; | ||
7 | |||
8 | using OpenSim.Services.Interfaces; | ||
9 | |||
10 | namespace OpenSim.Services.HypergridService | ||
11 | { | ||
12 | public class UserAccountCache : IUserAccountService | ||
13 | { | ||
14 | private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! | ||
15 | |||
16 | private static readonly ILog m_log = | ||
17 | LogManager.GetLogger( | ||
18 | MethodBase.GetCurrentMethod().DeclaringType); | ||
19 | private ExpiringCache<UUID, UserAccount> m_UUIDCache; | ||
20 | |||
21 | private IUserAccountService m_UserAccountService; | ||
22 | |||
23 | private static UserAccountCache m_Singleton; | ||
24 | |||
25 | public static UserAccountCache CreateUserAccountCache(IUserAccountService u) | ||
26 | { | ||
27 | if (m_Singleton == null) | ||
28 | m_Singleton = new UserAccountCache(u); | ||
29 | |||
30 | return m_Singleton; | ||
31 | } | ||
32 | |||
33 | private UserAccountCache(IUserAccountService u) | ||
34 | { | ||
35 | m_UUIDCache = new ExpiringCache<UUID, UserAccount>(); | ||
36 | m_UserAccountService = u; | ||
37 | } | ||
38 | |||
39 | public void Cache(UUID userID, UserAccount account) | ||
40 | { | ||
41 | // Cache even null accounts | ||
42 | m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); | ||
43 | |||
44 | //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); | ||
45 | } | ||
46 | |||
47 | public UserAccount Get(UUID userID, out bool inCache) | ||
48 | { | ||
49 | UserAccount account = null; | ||
50 | inCache = false; | ||
51 | if (m_UUIDCache.TryGetValue(userID, out account)) | ||
52 | { | ||
53 | //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); | ||
54 | inCache = true; | ||
55 | return account; | ||
56 | } | ||
57 | |||
58 | return null; | ||
59 | } | ||
60 | |||
61 | public UserAccount GetUser(string id) | ||
62 | { | ||
63 | UUID uuid = UUID.Zero; | ||
64 | UUID.TryParse(id, out uuid); | ||
65 | bool inCache = false; | ||
66 | UserAccount account = Get(uuid, out inCache); | ||
67 | if (!inCache) | ||
68 | { | ||
69 | account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid); | ||
70 | Cache(uuid, account); | ||
71 | } | ||
72 | |||
73 | return account; | ||
74 | } | ||
75 | |||
76 | #region IUserAccountService | ||
77 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
78 | { | ||
79 | return GetUser(userID.ToString()); | ||
80 | } | ||
81 | |||
82 | public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) | ||
83 | { | ||
84 | return null; | ||
85 | } | ||
86 | |||
87 | public UserAccount GetUserAccount(UUID scopeID, string Email) | ||
88 | { | ||
89 | return null; | ||
90 | } | ||
91 | |||
92 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
93 | { | ||
94 | return null; | ||
95 | } | ||
96 | |||
97 | public bool StoreUserAccount(UserAccount data) | ||
98 | { | ||
99 | return false; | ||
100 | } | ||
101 | #endregion | ||
102 | |||
103 | } | ||
104 | |||
105 | } | ||