diff options
author | Justin Clarke Casey | 2009-02-12 17:41:09 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-12 17:41:09 +0000 |
commit | f74326c1b05237e5a9eb3fce897ed1bec3085961 (patch) | |
tree | 192d667de632d54d8dc68077badd01a227e0a155 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |
parent | * Remove some pointless CachedUserInfo != null tests since these are already ... (diff) | |
download | opensim-SC_OLD-f74326c1b05237e5a9eb3fce897ed1bec3085961.zip opensim-SC_OLD-f74326c1b05237e5a9eb3fce897ed1bec3085961.tar.gz opensim-SC_OLD-f74326c1b05237e5a9eb3fce897ed1bec3085961.tar.bz2 opensim-SC_OLD-f74326c1b05237e5a9eb3fce897ed1bec3085961.tar.xz |
* move userinfo for inventory archiving up to module class so that it only has to be done once
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 84 |
1 files changed, 59 insertions, 25 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index b025a31..5684b84 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -32,7 +32,8 @@ using log4net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
38 | 39 | ||
@@ -85,22 +86,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
85 | m_scenes[scene.RegionInfo.RegionID] = scene; | 86 | m_scenes[scene.RegionInfo.RegionID] = scene; |
86 | } | 87 | } |
87 | 88 | ||
88 | public void PostInitialise() | 89 | public void PostInitialise() {} |
89 | { | ||
90 | } | ||
91 | 90 | ||
92 | public void Close() | 91 | public void Close() {} |
93 | { | ||
94 | } | ||
95 | 92 | ||
96 | public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) | 93 | public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) |
97 | { | 94 | { |
98 | if (m_scenes.Count > 0) | 95 | if (m_scenes.Count > 0) |
99 | { | 96 | { |
100 | InventoryArchiveReadRequest request = | 97 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
101 | new InventoryArchiveReadRequest(firstName, lastName, invPath, loadStream, m_commsManager); | 98 | |
102 | 99 | if (userInfo != null) | |
103 | UpdateClientWithLoadedNodes(firstName, lastName, request.Execute()); | 100 | { |
101 | InventoryArchiveReadRequest request = | ||
102 | new InventoryArchiveReadRequest(userInfo, invPath, loadStream, m_commsManager); | ||
103 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | ||
104 | } | ||
104 | } | 105 | } |
105 | } | 106 | } |
106 | 107 | ||
@@ -108,18 +109,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
108 | { | 109 | { |
109 | if (m_scenes.Count > 0) | 110 | if (m_scenes.Count > 0) |
110 | { | 111 | { |
111 | new InventoryArchiveWriteRequest(firstName, lastName, invPath, saveStream, m_commsManager).Execute(); | 112 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
113 | |||
114 | if (userInfo != null) | ||
115 | new InventoryArchiveWriteRequest(userInfo, invPath, saveStream, m_commsManager).Execute(); | ||
112 | } | 116 | } |
113 | } | 117 | } |
114 | 118 | ||
115 | public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) | 119 | public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) |
116 | { | 120 | { |
117 | if (m_scenes.Count > 0) | 121 | if (m_scenes.Count > 0) |
118 | { | 122 | { |
119 | InventoryArchiveReadRequest request = | 123 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
120 | new InventoryArchiveReadRequest(firstName, lastName, invPath, loadPath, m_commsManager); | ||
121 | 124 | ||
122 | UpdateClientWithLoadedNodes(firstName, lastName, request.Execute()); | 125 | if (userInfo != null) |
126 | { | ||
127 | InventoryArchiveReadRequest request = | ||
128 | new InventoryArchiveReadRequest(userInfo, invPath, loadPath, m_commsManager); | ||
129 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | ||
130 | } | ||
123 | } | 131 | } |
124 | } | 132 | } |
125 | 133 | ||
@@ -127,9 +135,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
127 | { | 135 | { |
128 | if (m_scenes.Count > 0) | 136 | if (m_scenes.Count > 0) |
129 | { | 137 | { |
130 | new InventoryArchiveWriteRequest(firstName, lastName, invPath, savePath, m_commsManager).Execute(); | 138 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
139 | |||
140 | if (userInfo != null) | ||
141 | new InventoryArchiveWriteRequest(userInfo, invPath, savePath, m_commsManager).Execute(); | ||
131 | } | 142 | } |
132 | } | 143 | } |
133 | 144 | ||
134 | /// <summary> | 145 | /// <summary> |
135 | /// Load inventory from an inventory file archive | 146 | /// Load inventory from an inventory file archive |
@@ -174,22 +185,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
174 | } | 185 | } |
175 | 186 | ||
176 | /// <summary> | 187 | /// <summary> |
188 | /// Get user information for the given name. | ||
189 | /// </summary> | ||
190 | /// <param name="firstName"></param> | ||
191 | /// <param name="lastName"></param> | ||
192 | /// <returns></returns> | ||
193 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) | ||
194 | { | ||
195 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); | ||
196 | |||
197 | if (null == userProfile) | ||
198 | { | ||
199 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", firstName, lastName); | ||
200 | return null; | ||
201 | } | ||
202 | |||
203 | CachedUserInfo userInfo = m_commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); | ||
204 | if (null == userInfo) | ||
205 | { | ||
206 | m_log.ErrorFormat( | ||
207 | "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}", | ||
208 | firstName, lastName, userProfile.ID); | ||
209 | return null; | ||
210 | } | ||
211 | |||
212 | return userInfo; | ||
213 | } | ||
214 | |||
215 | /// <summary> | ||
177 | /// Notify the client of loaded nodes if they are logged in | 216 | /// Notify the client of loaded nodes if they are logged in |
178 | /// </summary> | 217 | /// </summary> |
179 | /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param> | 218 | /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param> |
180 | private void UpdateClientWithLoadedNodes(string firstName, string lastName, List<InventoryNodeBase> loadedNodes) | 219 | private void UpdateClientWithLoadedNodes(CachedUserInfo userInfo, List<InventoryNodeBase> loadedNodes) |
181 | { | 220 | { |
182 | if (loadedNodes.Count == 0) | 221 | if (loadedNodes.Count == 0) |
183 | return; | 222 | return; |
184 | |||
185 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); | ||
186 | |||
187 | if (null == userProfile) | ||
188 | return; | ||
189 | 223 | ||
190 | foreach (Scene scene in m_scenes.Values) | 224 | foreach (Scene scene in m_scenes.Values) |
191 | { | 225 | { |
192 | ScenePresence user = scene.GetScenePresence(userProfile.ID); | 226 | ScenePresence user = scene.GetScenePresence(userInfo.UserProfile.ID); |
193 | 227 | ||
194 | if (user != null && !user.IsChildAgent) | 228 | if (user != null && !user.IsChildAgent) |
195 | { | 229 | { |