aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-06-04 22:17:23 +0100
committerJustin Clark-Casey (justincc)2010-06-04 22:17:23 +0100
commit72bd68a21f916db918aeb3dd60a1f391e41ed7c2 (patch)
treed6159745733603efbd457e1e616aefb72b85cba2 /OpenSim/Region
parentbring TestLoadIarV0_1AbsentUsers() back online (diff)
downloadopensim-SC_OLD-72bd68a21f916db918aeb3dd60a1f391e41ed7c2.zip
opensim-SC_OLD-72bd68a21f916db918aeb3dd60a1f391e41ed7c2.tar.gz
opensim-SC_OLD-72bd68a21f916db918aeb3dd60a1f391e41ed7c2.tar.bz2
opensim-SC_OLD-72bd68a21f916db918aeb3dd60a1f391e41ed7c2.tar.xz
add ability for load iar/save iar to take in arbitrary options
not used for anything yet
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs67
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs29
2 files changed, 76 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index ab5f485..cfefbe9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -30,11 +30,11 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using NDesk.Options;
33using Nini.Config; 34using Nini.Config;
34using OpenMetaverse; 35using OpenMetaverse;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
@@ -91,9 +91,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
91 91
92 scene.AddCommand( 92 scene.AddCommand(
93 this, "load iar", 93 this, "load iar",
94 "load iar <first> <last> <inventory path> <password> [<IAR path>]", 94 "load iar <first> <last> <inventory path> <password> [<IAR path>]",
95 //"load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]",
95 "Load user inventory archive (IAR).", 96 "Load user inventory archive (IAR).",
96 "<first> is user's first name." + Environment.NewLine 97 //"--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones"
98 //+ "<first> is user's first name." + Environment.NewLine
99 "<first> is user's first name." + Environment.NewLine
97 + "<last> is user's last name." + Environment.NewLine 100 + "<last> is user's last name." + Environment.NewLine
98 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine 101 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
99 + "<password> is the user's password." + Environment.NewLine 102 + "<password> is the user's password." + Environment.NewLine
@@ -133,8 +136,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
133 if (handlerInventoryArchiveSaved != null) 136 if (handlerInventoryArchiveSaved != null)
134 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); 137 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
135 } 138 }
136 139
137 public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) 140 public bool ArchiveInventory(
141 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream)
142 {
143 return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>());
144 }
145
146 public bool ArchiveInventory(
147 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream,
148 Dictionary<string, object> options)
138 { 149 {
139 if (m_scenes.Count > 0) 150 if (m_scenes.Count > 0)
140 { 151 {
@@ -172,7 +183,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
172 return false; 183 return false;
173 } 184 }
174 185
175 public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, string savePath) 186 public bool ArchiveInventory(
187 Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
188 Dictionary<string, object> options)
176 { 189 {
177 if (m_scenes.Count > 0) 190 if (m_scenes.Count > 0)
178 { 191 {
@@ -209,8 +222,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
209 222
210 return false; 223 return false;
211 } 224 }
212 225
213 public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) 226 public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream)
227 {
228 return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>());
229 }
230
231 public bool DearchiveInventory(
232 string firstName, string lastName, string invPath, string pass, Stream loadStream,
233 Dictionary<string, object> options)
214 { 234 {
215 if (m_scenes.Count > 0) 235 if (m_scenes.Count > 0)
216 { 236 {
@@ -252,7 +272,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
252 return false; 272 return false;
253 } 273 }
254 274
255 public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, string loadPath) 275 public bool DearchiveInventory(
276 string firstName, string lastName, string invPath, string pass, string loadPath,
277 Dictionary<string, object> options)
256 { 278 {
257 if (m_scenes.Count > 0) 279 if (m_scenes.Count > 0)
258 { 280 {
@@ -300,29 +322,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
300 /// <param name="cmdparams"></param> 322 /// <param name="cmdparams"></param>
301 protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams) 323 protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams)
302 { 324 {
303 if (cmdparams.Length < 6) 325 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
326
327 Dictionary<string, object> options = new Dictionary<string, object>();
328 OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; });
329
330 List<string> mainParams = optionSet.Parse(cmdparams);
331
332 if (mainParams.Count < 6)
304 { 333 {
305 m_log.Error( 334 m_log.Error(
306 "[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <user password> [<load file path>]"); 335 "[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <user password> [<load file path>]");
307 return; 336 return;
308 } 337 }
309 338
310 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); 339 string firstName = mainParams[2];
311 340 string lastName = mainParams[3];
312 string firstName = cmdparams[2]; 341 string invPath = mainParams[4];
313 string lastName = cmdparams[3]; 342 string pass = mainParams[5];
314 string invPath = cmdparams[4]; 343 string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
315 string pass = cmdparams[5];
316 string loadPath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
317 344
318 m_log.InfoFormat( 345 m_log.InfoFormat(
319 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", 346 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
320 loadPath, invPath, firstName, lastName); 347 loadPath, invPath, firstName, lastName);
321 348
322 if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath)) 349 if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options))
323 m_log.InfoFormat( 350 m_log.InfoFormat(
324 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", 351 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}",
325 loadPath, firstName, lastName); 352 loadPath, firstName, lastName);
326 } 353 }
327 354
328 /// <summary> 355 /// <summary>
@@ -351,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
351 savePath, invPath, firstName, lastName); 378 savePath, invPath, firstName, lastName);
352 379
353 Guid id = Guid.NewGuid(); 380 Guid id = Guid.NewGuid();
354 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath); 381 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>());
355 382
356 lock (m_pendingConsoleSaves) 383 lock (m_pendingConsoleSaves)
357 m_pendingConsoleSaves.Add(id); 384 m_pendingConsoleSaves.Add(id);
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
index fbadd91..01066e6 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.IO; 30using System.IO;
30using OpenSim.Services.Interfaces; 31using OpenSim.Services.Interfaces;
31 32
@@ -59,6 +60,20 @@ namespace OpenSim.Region.Framework.Interfaces
59 /// <param name="loadStream">The stream from which the inventory archive will be loaded</param> 60 /// <param name="loadStream">The stream from which the inventory archive will be loaded</param>
60 /// <returns>true if the first stage of the operation succeeded, false otherwise</returns> 61 /// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
61 bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream); 62 bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream);
63
64 /// <summary>
65 /// Dearchive a user's inventory folder from the given stream
66 /// </summary>
67 /// <param name="firstName"></param>
68 /// <param name="lastName"></param>
69 /// <param name="invPath">The inventory path in which to place the loaded folders and items</param>
70 /// <param name="loadStream">The stream from which the inventory archive will be loaded</param>
71 /// <param name="options">Dearchiving options. At the moment, the only option is ("merge", true). This merges
72 /// the loaded IAR with existing folders where possible.</param>
73 /// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
74 bool DearchiveInventory(
75 string firstName, string lastName, string invPath, string pass, Stream loadStream,
76 Dictionary<string, object> options);
62 77
63 /// <summary> 78 /// <summary>
64 /// Archive a user's inventory folder to the given stream 79 /// Archive a user's inventory folder to the given stream
@@ -70,5 +85,19 @@ namespace OpenSim.Region.Framework.Interfaces
70 /// <param name="saveStream">The stream to which the inventory archive will be saved</param> 85 /// <param name="saveStream">The stream to which the inventory archive will be saved</param>
71 /// <returns>true if the first stage of the operation succeeded, false otherwise</returns> 86 /// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
72 bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream); 87 bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream);
88
89 /// <summary>
90 /// Archive a user's inventory folder to the given stream
91 /// </summary>
92 /// <param name="id">ID representing this request. This will later be returned in the save event</param>
93 /// <param name="firstName"></param>
94 /// <param name="lastName"></param>
95 /// <param name="invPath">The inventory path from which the inventory should be saved.</param>
96 /// <param name="saveStream">The stream to which the inventory archive will be saved</param>
97 /// <param name="options">Archiving options. Currently, there are none.</param>
98 /// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
99 bool ArchiveInventory(
100 Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream,
101 Dictionary<string, object> options);
73 } 102 }
74} 103}