aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-12 17:41:09 +0000
committerJustin Clarke Casey2009-02-12 17:41:09 +0000
commitf74326c1b05237e5a9eb3fce897ed1bec3085961 (patch)
tree192d667de632d54d8dc68077badd01a227e0a155
parent* Remove some pointless CachedUserInfo != null tests since these are already ... (diff)
downloadopensim-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 '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs44
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs47
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs84
3 files changed, 85 insertions, 90 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 5ae5b4b..6f8fa3c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -48,8 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
48 protected TarArchiveReader archive; 48 protected TarArchiveReader archive;
49 private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 49 private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
50 50
51 private string m_firstName; 51 private CachedUserInfo m_userInfo;
52 private string m_lastName;
53 private string m_invPath; 52 private string m_invPath;
54 53
55 /// <value> 54 /// <value>
@@ -60,10 +59,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
60 CommunicationsManager commsManager; 59 CommunicationsManager commsManager;
61 60
62 public InventoryArchiveReadRequest( 61 public InventoryArchiveReadRequest(
63 string firstName, string lastName, string invPath, string loadPath, CommunicationsManager commsManager) 62 CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager)
64 : this( 63 : this(
65 firstName, 64 userInfo,
66 lastName,
67 invPath, 65 invPath,
68 new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), 66 new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress),
69 commsManager) 67 commsManager)
@@ -71,10 +69,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
71 } 69 }
72 70
73 public InventoryArchiveReadRequest( 71 public InventoryArchiveReadRequest(
74 string firstName, string lastName, string invPath, Stream loadStream, CommunicationsManager commsManager) 72 CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager)
75 { 73 {
76 m_firstName = firstName; 74 m_userInfo = userInfo;
77 m_lastName = lastName;
78 m_invPath = invPath; 75 m_invPath = invPath;
79 m_loadStream = loadStream; 76 m_loadStream = loadStream;
80 this.commsManager = commsManager; 77 this.commsManager = commsManager;
@@ -174,33 +171,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
174 int successfulItemRestores = 0; 171 int successfulItemRestores = 0;
175 List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); 172 List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
176 173
177 UserProfileData userProfile = commsManager.UserService.GetUserProfile(m_firstName, m_lastName); 174 if (!m_userInfo.HasReceivedInventory)
178 if (null == userProfile)
179 {
180 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", m_firstName, m_lastName);
181 return nodesLoaded;
182 }
183
184 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
185 if (null == userInfo)
186 {
187 m_log.ErrorFormat(
188 "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}",
189 m_firstName, m_lastName, userProfile.ID);
190
191 return nodesLoaded;
192 }
193
194 if (!userInfo.HasReceivedInventory)
195 { 175 {
196 m_log.ErrorFormat( 176 m_log.ErrorFormat(
197 "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1} {2}", 177 "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}",
198 m_firstName, m_lastName, userProfile.ID); 178 m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID);
199 179
200 return nodesLoaded; 180 return nodesLoaded;
201 } 181 }
202 182
203 InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(m_invPath); 183 InventoryFolderImpl inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
204 184
205 if (null == inventoryFolder) 185 if (null == inventoryFolder)
206 { 186 {
@@ -232,15 +212,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
232 212
233 if (item != null) 213 if (item != null)
234 { 214 {
235 item.Creator = userProfile.ID; 215 item.Creator = m_userInfo.UserProfile.ID;
236 item.Owner = userProfile.ID; 216 item.Owner = m_userInfo.UserProfile.ID;
237 217
238 // Reset folder ID to the one in which we want to load it 218 // Reset folder ID to the one in which we want to load it
239 // TODO: Properly restore entire folder structure. At the moment all items are dumped in this 219 // TODO: Properly restore entire folder structure. At the moment all items are dumped in this
240 // single folder no matter where in the saved folder structure they are. 220 // single folder no matter where in the saved folder structure they are.
241 item.Folder = inventoryFolder.ID; 221 item.Folder = inventoryFolder.ID;
242 222
243 userInfo.AddItem(item); 223 m_userInfo.AddItem(item);
244 successfulItemRestores++; 224 successfulItemRestores++;
245 nodesLoaded.Add(item); 225 nodesLoaded.Add(item);
246 } 226 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index da4785b..622ba86 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -48,8 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
48 protected CommunicationsManager commsManager; 48 protected CommunicationsManager commsManager;
49 protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); 49 protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
50 50
51 private string m_firstName; 51 private CachedUserInfo m_userInfo;
52 private string m_lastName;
53 private string m_invPath; 52 private string m_invPath;
54 53
55 /// <value> 54 /// <value>
@@ -61,13 +60,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
61 /// Constructor 60 /// Constructor
62 /// </summary> 61 /// </summary>
63 public InventoryArchiveWriteRequest( 62 public InventoryArchiveWriteRequest(
64 string firstName, string lastName, string invPath, string savePath, CommunicationsManager commsManager) 63 CachedUserInfo userInfo, string invPath, string savePath, CommunicationsManager commsManager)
65 : this( 64 : this(
66 firstName, 65 userInfo,
67 lastName, 66 invPath,
68 invPath, 67 new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress),
69 new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress), 68 commsManager)
70 commsManager)
71 { 69 {
72 } 70 }
73 71
@@ -75,10 +73,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 /// Constructor 73 /// Constructor
76 /// </summary> 74 /// </summary>
77 public InventoryArchiveWriteRequest( 75 public InventoryArchiveWriteRequest(
78 string firstName, string lastName, string invPath, Stream saveStream, CommunicationsManager commsManager) 76 CachedUserInfo userInfo, string invPath, Stream saveStream, CommunicationsManager commsManager)
79 { 77 {
80 m_firstName = firstName; 78 m_userInfo = userInfo;
81 m_lastName = lastName;
82 m_invPath = invPath; 79 m_invPath = invPath;
83 m_saveStream = saveStream; 80 m_saveStream = saveStream;
84 this.commsManager = commsManager; 81 this.commsManager = commsManager;
@@ -183,26 +180,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
183 180
184 public void Execute() 181 public void Execute()
185 { 182 {
186 UserProfileData userProfile = commsManager.UserService.GetUserProfile(m_firstName, m_lastName);
187 if (null == userProfile)
188 {
189 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", m_firstName, m_lastName);
190 return;
191 }
192
193 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
194 if (null == userInfo)
195 {
196 m_log.ErrorFormat(
197 "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}",
198 m_firstName, m_lastName, userProfile.ID);
199 return;
200 }
201
202 InventoryFolderImpl inventoryFolder = null; 183 InventoryFolderImpl inventoryFolder = null;
203 InventoryItemBase inventoryItem = null; 184 InventoryItemBase inventoryItem = null;
204 185
205 if (userInfo.HasReceivedInventory) 186 if (m_userInfo.HasReceivedInventory)
206 { 187 {
207 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl 188 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
208 // itself (possibly at a small loss in efficiency). 189 // itself (possibly at a small loss in efficiency).
@@ -218,25 +199,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
218 // Therefore if we still start with a / after the split, then we need the root folder 199 // Therefore if we still start with a / after the split, then we need the root folder
219 if (m_invPath.Length == 0) 200 if (m_invPath.Length == 0)
220 { 201 {
221 inventoryFolder = userInfo.RootFolder; 202 inventoryFolder = m_userInfo.RootFolder;
222 } 203 }
223 else 204 else
224 { 205 {
225 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); 206 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
226 inventoryFolder = userInfo.RootFolder.FindFolderByPath(m_invPath); 207 inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
227 } 208 }
228 209
229 // The path may point to an item instead 210 // The path may point to an item instead
230 if (inventoryFolder == null) 211 if (inventoryFolder == null)
231 { 212 {
232 inventoryItem = userInfo.RootFolder.FindItemByPath(m_invPath); 213 inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
233 } 214 }
234 } 215 }
235 else 216 else
236 { 217 {
237 m_log.ErrorFormat( 218 m_log.ErrorFormat(
238 "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1} {2}", 219 "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}",
239 m_firstName, m_lastName, userProfile.ID); 220 m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID);
240 return; 221 return;
241 } 222 }
242 223
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;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 38using 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 {