aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs21
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs215
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs155
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs680
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs478
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs59
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs102
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs6
23 files changed, 1115 insertions, 798 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 6ed4867..9adb68b 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -92,9 +92,9 @@ namespace Flotsam.RegionModules.AssetCache
92 // Expiration is expressed in hours. 92 // Expiration is expressed in hours.
93 private const double m_DefaultMemoryExpiration = 1.0; 93 private const double m_DefaultMemoryExpiration = 1.0;
94 private const double m_DefaultFileExpiration = 48; 94 private const double m_DefaultFileExpiration = 48;
95 private TimeSpan m_MemoryExpiration = TimeSpan.Zero; 95 private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration);
96 private TimeSpan m_FileExpiration = TimeSpan.Zero; 96 private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration);
97 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero; 97 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration);
98 98
99 private static int m_CacheDirectoryTiers = 1; 99 private static int m_CacheDirectoryTiers = 1;
100 private static int m_CacheDirectoryTierLen = 3; 100 private static int m_CacheDirectoryTierLen = 3;
@@ -147,7 +147,7 @@ namespace Flotsam.RegionModules.AssetCache
147 } 147 }
148 148
149 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); 149 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
150 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); 150 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory);
151 151
152 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); 152 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
153 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); 153 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
@@ -245,16 +245,7 @@ namespace Flotsam.RegionModules.AssetCache
245 private void UpdateMemoryCache(string key, AssetBase asset) 245 private void UpdateMemoryCache(string key, AssetBase asset)
246 { 246 {
247 if (m_MemoryCacheEnabled) 247 if (m_MemoryCacheEnabled)
248 { 248 m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration);
249 if (m_MemoryExpiration > TimeSpan.Zero)
250 {
251 m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration);
252 }
253 else
254 {
255 m_MemoryCache.AddOrUpdate(key, asset, Double.MaxValue);
256 }
257 }
258 } 249 }
259 250
260 public void Cache(AssetBase asset) 251 public void Cache(AssetBase asset)
@@ -450,7 +441,7 @@ namespace Flotsam.RegionModules.AssetCache
450 private void CleanupExpiredFiles(object source, ElapsedEventArgs e) 441 private void CleanupExpiredFiles(object source, ElapsedEventArgs e)
451 { 442 {
452 if (m_LogLevel >= 2) 443 if (m_LogLevel >= 2)
453 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); 444 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration);
454 445
455 // Purge all files last accessed prior to this point 446 // Purge all files last accessed prior to this point
456 DateTime purgeLine = DateTime.Now - m_FileExpiration; 447 DateTime purgeLine = DateTime.Now - m_FileExpiration;
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index f8ce444..08ac624 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
167 } 167 }
168 } 168 }
169 169
170 m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); 170 m_log.DebugFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId);
171 171
172 // If we only found default textures, then the appearance is not cached 172 // If we only found default textures, then the appearance is not cached
173 return (defonly ? false : true); 173 return (defonly ? false : true);
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 2b3d2a9..8a977c9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -49,16 +49,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
49 { 49 {
50 m_scene = scene; 50 m_scene = scene;
51 m_scene.RegisterModuleInterface<IDialogModule>(this); 51 m_scene.RegisterModuleInterface<IDialogModule>(this);
52 52
53 m_scene.AddCommand( 53 m_scene.AddCommand(
54 this, "alert", "alert <first> <last> <message>", 54 this, "alert", "alert <message>",
55 "Send an alert to a user", 55 "Send an alert to everyone",
56 HandleAlertConsoleCommand); 56 HandleAlertConsoleCommand);
57 57
58 m_scene.AddCommand( 58 m_scene.AddCommand(
59 this, "alert general", "alert [general] <message>", 59 this, "alert-user", "alert-user <first> <last> <message>",
60 "Send an alert to everyone", 60 "Send an alert to a user",
61 "If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.",
62 HandleAlertConsoleCommand); 61 HandleAlertConsoleCommand);
63 } 62 }
64 63
@@ -177,55 +176,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
177 { 176 {
178 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) 177 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
179 return; 178 return;
180 179
181 bool isGeneral = false;
182 string firstName = string.Empty;
183 string lastName = string.Empty;
184 string message = string.Empty; 180 string message = string.Empty;
185 181
186 if (cmdparams.Length > 1) 182 if (cmdparams[0].ToLower().Equals("alert"))
187 {
188 firstName = cmdparams[1];
189 isGeneral = firstName.ToLower().Equals("general");
190 }
191 if (cmdparams.Length == 2 && !isGeneral)
192 { 183 {
193 // alert "message" 184 message = CombineParams(cmdparams, 1);
194 message = cmdparams[1]; 185 m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}",
195 isGeneral = true; 186 m_scene.RegionInfo.RegionName, message);
196 } 187 SendGeneralAlert(message);
197 else if (cmdparams.Length > 2 && isGeneral)
198 {
199 // alert general <message>
200 message = CombineParams(cmdparams, 2);
201 } 188 }
202 else if (cmdparams.Length > 3) 189 else if (cmdparams.Length > 3)
203 { 190 {
204 // alert <first> <last> <message> 191 string firstName = cmdparams[1];
205 lastName = cmdparams[2]; 192 string lastName = cmdparams[2];
206 message = CombineParams(cmdparams, 3); 193 message = CombineParams(cmdparams, 3);
194 m_log.InfoFormat(
195 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
196 m_scene.RegionInfo.RegionName, firstName, lastName, message);
197 SendAlertToUser(firstName, lastName, message, false);
207 } 198 }
208 else 199 else
209 { 200 {
210 OpenSim.Framework.Console.MainConsole.Instance.Output( 201 OpenSim.Framework.Console.MainConsole.Instance.Output(
211 "Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); 202 "Usage: alert <message> | alert-user <first> <last> <message>");
212 return; 203 return;
213 } 204 }
214
215 if (isGeneral)
216 {
217 m_log.InfoFormat(
218 "[DIALOG]: Sending general alert in region {0} with message {1}",
219 m_scene.RegionInfo.RegionName, message);
220 SendGeneralAlert(message);
221 }
222 else
223 {
224 m_log.InfoFormat(
225 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
226 m_scene.RegionInfo.RegionName, firstName, lastName, message);
227 SendAlertToUser(firstName, lastName, message, false);
228 }
229 } 205 }
230 206
231 private string CombineParams(string[] commandParams, int pos) 207 private string CombineParams(string[] commandParams, int pos)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 6030706..9b98de3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization;
41using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
42using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
46 47
@@ -75,6 +76,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 /// The stream from which the inventory archive will be loaded. 76 /// The stream from which the inventory archive will be loaded.
76 /// </value> 77 /// </value>
77 private Stream m_loadStream; 78 private Stream m_loadStream;
79
80 protected bool m_controlFileLoaded;
81 protected bool m_assetsLoaded;
82 protected bool m_inventoryNodesLoaded;
83
84 protected int m_successfulAssetRestores;
85 protected int m_failedAssetRestores;
86 protected int m_successfulItemRestores;
87
88 /// <summary>
89 /// Root destination folder for the IAR load.
90 /// </summary>
91 protected InventoryFolderBase m_rootDestinationFolder;
92
93 /// <summary>
94 /// Inventory nodes loaded from the iar.
95 /// </summary>
96 protected HashSet<InventoryNodeBase> m_loadedNodes = new HashSet<InventoryNodeBase>();
97
98 /// <summary>
99 /// In order to load identically named folders, we need to keep track of the folders that we have already
100 /// resolved.
101 /// </summary>
102 Dictionary <string, InventoryFolderBase> m_resolvedFolders = new Dictionary<string, InventoryFolderBase>();
103
104 /// <summary>
105 /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids
106 /// after OSP resolution (since OSP creators are only stored in the item
107 /// </summary>
108 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
78 109
79 public InventoryArchiveReadRequest( 110 public InventoryArchiveReadRequest(
80 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) 111 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
@@ -100,20 +131,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 /// <summary> 131 /// <summary>
101 /// Execute the request 132 /// Execute the request
102 /// </summary> 133 /// </summary>
134 /// <remarks>
135 /// Only call this once. To load another IAR, construct another request object.
136 /// </remarks>
103 /// <returns> 137 /// <returns>
104 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are 138 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
105 /// returned 139 /// returned
106 /// </returns> 140 /// </returns>
141 /// <exception cref="System.Exception">Thrown if load fails.</exception>
107 public HashSet<InventoryNodeBase> Execute() 142 public HashSet<InventoryNodeBase> Execute()
108 { 143 {
109 try 144 try
110 { 145 {
111 string filePath = "ERROR"; 146 string filePath = "ERROR";
112 int successfulAssetRestores = 0;
113 int failedAssetRestores = 0;
114 int successfulItemRestores = 0;
115
116 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
117 147
118 List<InventoryFolderBase> folderCandidates 148 List<InventoryFolderBase> folderCandidates
119 = InventoryArchiveUtils.FindFolderByPath( 149 = InventoryArchiveUtils.FindFolderByPath(
@@ -124,16 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 // Possibly provide an option later on to automatically create this folder if it does not exist 154 // Possibly provide an option later on to automatically create this folder if it does not exist
125 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 155 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
126 156
127 return loadedNodes; 157 return m_loadedNodes;
128 } 158 }
129 159
130 InventoryFolderBase rootDestinationFolder = folderCandidates[0]; 160 m_rootDestinationFolder = folderCandidates[0];
131 archive = new TarArchiveReader(m_loadStream); 161 archive = new TarArchiveReader(m_loadStream);
132
133 // In order to load identically named folders, we need to keep track of the folders that we have already
134 // resolved
135 Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>();
136
137 byte[] data; 162 byte[] data;
138 TarArchiveReader.TarEntryType entryType; 163 TarArchiveReader.TarEntryType entryType;
139 164
@@ -142,45 +167,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
142 if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 167 if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
143 { 168 {
144 LoadControlFile(filePath, data); 169 LoadControlFile(filePath, data);
145 } 170 }
146 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 171 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
147 { 172 {
148 if (LoadAsset(filePath, data)) 173 LoadAssetFile(filePath, data);
149 successfulAssetRestores++;
150 else
151 failedAssetRestores++;
152
153 if ((successfulAssetRestores) % 50 == 0)
154 m_log.DebugFormat(
155 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
156 successfulAssetRestores);
157 } 174 }
158 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) 175 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
159 { 176 {
160 filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); 177 LoadInventoryFile(filePath, entryType, data);
161
162 // Trim off the file portion if we aren't already dealing with a directory path
163 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
164 filePath = filePath.Remove(filePath.LastIndexOf("/") + 1);
165
166 InventoryFolderBase foundFolder
167 = ReplicateArchivePathToUserInventory(
168 filePath, rootDestinationFolder, resolvedFolders, loadedNodes);
169
170 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
171 {
172 InventoryItemBase item = LoadItem(data, foundFolder);
173
174 if (item != null)
175 {
176 successfulItemRestores++;
177
178 // If we aren't loading the folder containing the item then well need to update the
179 // viewer separately for that item.
180 if (!loadedNodes.Contains(foundFolder))
181 loadedNodes.Add(item);
182 }
183 }
184 } 178 }
185 } 179 }
186 180
@@ -188,10 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
188 182
189 m_log.DebugFormat( 183 m_log.DebugFormat(
190 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", 184 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
191 successfulAssetRestores, failedAssetRestores); 185 m_successfulAssetRestores, m_failedAssetRestores);
192 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); 186 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores);
193 187
194 return loadedNodes; 188 return m_loadedNodes;
195 } 189 }
196 finally 190 finally
197 { 191 {
@@ -400,9 +394,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 394 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
401 if (UUID.Zero != ospResolvedId) // The user exists in this grid 395 if (UUID.Zero != ospResolvedId) // The user exists in this grid
402 { 396 {
397// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId);
398
403 item.CreatorIdAsUuid = ospResolvedId; 399 item.CreatorIdAsUuid = ospResolvedId;
404 400
405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 401 // Don't preserve the OSPA in the creator id (which actually gets persisted to the
406 // database). Instead, replace with the UUID that we found. 402 // database). Instead, replace with the UUID that we found.
407 item.CreatorId = ospResolvedId.ToString(); 403 item.CreatorId = ospResolvedId.ToString();
408 404
@@ -410,7 +406,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
410 } 406 }
411 else if (item.CreatorData == null || item.CreatorData == String.Empty) 407 else if (item.CreatorData == null || item.CreatorData == String.Empty)
412 { 408 {
413 item.CreatorIdAsUuid = m_userInfo.PrincipalID; 409 item.CreatorId = m_userInfo.PrincipalID.ToString();
410 item.CreatorIdAsUuid = new UUID(item.CreatorId);
414 } 411 }
415 412
416 item.Owner = m_userInfo.PrincipalID; 413 item.Owner = m_userInfo.PrincipalID;
@@ -418,6 +415,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
418 // Reset folder ID to the one in which we want to load it 415 // Reset folder ID to the one in which we want to load it
419 item.Folder = loadFolder.ID; 416 item.Folder = loadFolder.ID;
420 417
418 // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset
419 // is loaded.
420 // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger
421 // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than
422 // relying on native tar tools.
423 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
424
421 m_scene.AddInventoryItem(item); 425 m_scene.AddInventoryItem(item);
422 426
423 return item; 427 return item;
@@ -446,18 +450,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
446 } 450 }
447 451
448 string extension = filename.Substring(i); 452 string extension = filename.Substring(i);
449 string uuid = filename.Remove(filename.Length - extension.Length); 453 string rawUuid = filename.Remove(filename.Length - extension.Length);
454 UUID assetId = new UUID(rawUuid);
450 455
451 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) 456 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
452 { 457 {
453 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 458 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
454 459
455 if (assetType == (sbyte)AssetType.Unknown) 460 if (assetType == (sbyte)AssetType.Unknown)
456 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); 461 {
462 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
463 }
464 else if (assetType == (sbyte)AssetType.Object)
465 {
466 if (m_creatorIdForAssetId.ContainsKey(assetId))
467 {
468 string xmlData = Utils.BytesToString(data);
469 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
470 foreach (SceneObjectPart sop in sog.Parts)
471 {
472 if (sop.CreatorData == null || sop.CreatorData == "")
473 {
474 sop.CreatorID = m_creatorIdForAssetId[assetId];
475 }
476 }
477
478 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
479 }
480 }
457 481
458 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 482 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
459 483
460 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); 484 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
461 asset.Data = data; 485 asset.Data = data;
462 486
463 m_scene.AssetService.Store(asset); 487 m_scene.AssetService.Store(asset);
@@ -495,7 +519,88 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
495 majorVersion, MAX_MAJOR_VERSION)); 519 majorVersion, MAX_MAJOR_VERSION));
496 } 520 }
497 521
498 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); 522 m_controlFileLoaded = true;
523 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
499 } 524 }
525
526 /// <summary>
527 /// Load inventory file
528 /// </summary>
529 /// <param name="path"></param>
530 /// <param name="entryType"></param>
531 /// <param name="data"></param>
532 protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
533 {
534 if (!m_controlFileLoaded)
535 throw new Exception(
536 string.Format(
537 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
538 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH));
539
540 if (m_assetsLoaded)
541 throw new Exception(
542 string.Format(
543 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
544 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
545
546 path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length);
547
548 // Trim off the file portion if we aren't already dealing with a directory path
549 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
550 path = path.Remove(path.LastIndexOf("/") + 1);
551
552 InventoryFolderBase foundFolder
553 = ReplicateArchivePathToUserInventory(
554 path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes);
555
556 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
557 {
558 InventoryItemBase item = LoadItem(data, foundFolder);
559
560 if (item != null)
561 {
562 m_successfulItemRestores++;
563
564 // If we aren't loading the folder containing the item then well need to update the
565 // viewer separately for that item.
566 if (!m_loadedNodes.Contains(foundFolder))
567 m_loadedNodes.Add(item);
568 }
569 }
570
571 m_inventoryNodesLoaded = true;
572 }
573
574 /// <summary>
575 /// Load asset file
576 /// </summary>
577 /// <param name="path"></param>
578 /// <param name="data"></param>
579 protected void LoadAssetFile(string path, byte[] data)
580 {
581 if (!m_controlFileLoaded)
582 throw new Exception(
583 string.Format(
584 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
585 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH));
586
587 if (!m_inventoryNodesLoaded)
588 throw new Exception(
589 string.Format(
590 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
591 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
592
593 if (LoadAsset(path, data))
594 m_successfulAssetRestores++;
595 else
596 m_failedAssetRestores++;
597
598 if ((m_successfulAssetRestores) % 50 == 0)
599 m_log.DebugFormat(
600 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
601 m_successfulAssetRestores);
602
603 m_assetsLoaded = true;
604 }
500 } 605 }
501} \ No newline at end of file 606} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 26edba4..576a154 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
109 109
110 scene.AddCommand( 110 scene.AddCommand(
111 this, "load iar", 111 this, "load iar",
112 "load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]", 112 "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]",
113 "Load user inventory archive (IAR).", 113 "Load user inventory archive (IAR).",
114 "--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" 114 "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones"
115 + "<first> is user's first name." + Environment.NewLine 115 + "<first> is user's first name." + Environment.NewLine
116 + "<last> is user's last name." + Environment.NewLine 116 + "<last> is user's last name." + Environment.NewLine
117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine 117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
@@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
181 catch (EntryPointNotFoundException e) 181 catch (EntryPointNotFoundException e)
182 { 182 {
183 m_log.ErrorFormat( 183 m_log.ErrorFormat(
184 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 184 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
185 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 185 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
186 m_log.Error(e); 186 m_log.Error(e);
187 187
@@ -221,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
221 catch (EntryPointNotFoundException e) 221 catch (EntryPointNotFoundException e)
222 { 222 {
223 m_log.ErrorFormat( 223 m_log.ErrorFormat(
224 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 224 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
225 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 225 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
226 m_log.Error(e); 226 m_log.Error(e);
227 227
@@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
269 catch (EntryPointNotFoundException e) 269 catch (EntryPointNotFoundException e)
270 { 270 {
271 m_log.ErrorFormat( 271 m_log.ErrorFormat(
272 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 272 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
273 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 273 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
274 m_log.Error(e); 274 m_log.Error(e);
275 275
@@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
317 catch (EntryPointNotFoundException e) 317 catch (EntryPointNotFoundException e)
318 { 318 {
319 m_log.ErrorFormat( 319 m_log.ErrorFormat(
320 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 320 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
321 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 321 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
322 m_log.Error(e); 322 m_log.Error(e);
323 323
@@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
358 if (mainParams.Count < 6) 358 if (mainParams.Count < 6)
359 { 359 {
360 m_log.Error( 360 m_log.Error(
361 "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); 361 "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]");
362 return; 362 return;
363 } 363 }
364 364
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
new file mode 100644
index 0000000..e5127a0
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -0,0 +1,155 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class InventoryArchiveTestCase
53 {
54 protected ManualResetEvent mre = new ManualResetEvent(false);
55
56 /// <summary>
57 /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test.
58 /// </summary>
59 protected byte[] m_iarStreamBytes;
60
61 /// <summary>
62 /// Stream of data representing a common IAR for load tests.
63 /// </summary>
64 protected MemoryStream m_iarStream;
65
66 protected UserAccount m_uaMT
67 = new UserAccount {
68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
69 FirstName = "Mr",
70 LastName = "Tiddles" };
71 protected UserAccount m_uaLL1
72 = new UserAccount {
73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
74 FirstName = "Lord",
75 LastName = "Lucan" };
76 protected UserAccount m_uaLL2
77 = new UserAccount {
78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
79 FirstName = "Lord",
80 LastName = "Lucan" };
81 protected string m_item1Name = "Ray Gun Item";
82
83 [SetUp]
84 public virtual void SetUp()
85 {
86 m_iarStream = new MemoryStream(m_iarStreamBytes);
87 }
88
89 [TestFixtureSetUp]
90 public void FixtureSetup()
91 {
92 ConstructDefaultIarBytesForTestLoad();
93 }
94
95 protected void ConstructDefaultIarBytesForTestLoad()
96 {
97// log4net.Config.XmlConfigurator.Configure();
98
99 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
100 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
101 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
102
103 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
104
105 MemoryStream archiveWriteStream = new MemoryStream();
106
107 // Create asset
108 SceneObjectGroup object1;
109 SceneObjectPart part1;
110 {
111 string partName = "Ray Gun Object";
112 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
113 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
114 Vector3 groupPosition = new Vector3(10, 20, 30);
115 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
116 Vector3 offsetPosition = new Vector3(5, 10, 15);
117
118 part1
119 = new SceneObjectPart(
120 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
121 part1.Name = partName;
122
123 object1 = new SceneObjectGroup(part1);
124 scene.AddNewSceneObject(object1, false);
125 }
126
127 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
128 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
129 scene.AssetService.Store(asset1);
130
131 // Create item
132 InventoryItemBase item1 = new InventoryItemBase();
133 item1.Name = m_item1Name;
134 item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
135 item1.AssetID = asset1.FullID;
136 item1.GroupID = UUID.Random();
137 item1.CreatorIdAsUuid = m_uaLL1.PrincipalID;
138 item1.Owner = m_uaLL1.PrincipalID;
139 item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
140 scene.AddInventoryItem(item1);
141
142 archiverModule.ArchiveInventory(
143 Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream);
144
145 m_iarStreamBytes = archiveWriteStream.ToArray();
146 }
147
148 protected void SaveCompleted(
149 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
150 Exception reportedException)
151 {
152 mre.Set();
153 }
154 }
155} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 76d0b85..7f156f8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -31,7 +31,6 @@ using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Data; 35using OpenSim.Data;
37using OpenSim.Framework; 36using OpenSim.Framework;
@@ -50,182 +49,21 @@ using OpenSim.Tests.Common.Setup;
50namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests 49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
51{ 50{
52 [TestFixture] 51 [TestFixture]
53 public class InventoryArchiverTests 52 public class InventoryArchiverTests : InventoryArchiveTestCase
54 { 53 {
55 protected ManualResetEvent mre = new ManualResetEvent(false); 54 protected TestScene m_scene;
56 55 protected InventoryArchiverModule m_archiverModule;
57 /// <summary> 56
58 /// Stream of data representing a common IAR that can be reused in load tests.
59 /// </summary>
60 protected MemoryStream m_iarStream;
61
62 protected UserAccount m_ua1
63 = new UserAccount {
64 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
65 FirstName = "Mr",
66 LastName = "Tiddles" };
67 protected UserAccount m_ua2
68 = new UserAccount {
69 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
70 FirstName = "Lord",
71 LastName = "Lucan" };
72 string m_item1Name = "b.lsl";
73
74 private void SaveCompleted(
75 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
76 Exception reportedException)
77 {
78 mre.Set();
79 }
80
81 [SetUp] 57 [SetUp]
82 public void Init() 58 public override void SetUp()
83 {
84 ConstructDefaultIarForTestLoad();
85 }
86
87 protected void ConstructDefaultIarForTestLoad()
88 {
89 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
90
91 MemoryStream archiveWriteStream = new MemoryStream();
92 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
93
94 InventoryItemBase item1 = new InventoryItemBase();
95 item1.Name = m_item1Name;
96 item1.AssetID = UUID.Random();
97 item1.GroupID = UUID.Random();
98 //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
99 //item1.CreatorId = userUuid.ToString();
100 item1.CreatorId = m_ua2.PrincipalID.ToString();
101 item1.Owner = UUID.Zero;
102
103 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
104 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
105
106 string item1FileName
107 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
108 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
109 tar.Close();
110 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
111 }
112
113 /// <summary>
114 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
115 /// (subject to change since there is no fixed format yet).
116 /// </summary>
117 [Test]
118 public void TestSavePathToIarV0_1()
119 { 59 {
120 TestHelper.InMethod(); 60 base.SetUp();
121// log4net.Config.XmlConfigurator.Configure();
122
123 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
124
125 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
126 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
127
128 // Create user
129 string userFirstName = "Jock";
130 string userLastName = "Stirrup";
131 string userPassword = "troll";
132 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
133 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
134 61
135 // Create asset 62 SerialiserModule serialiserModule = new SerialiserModule();
136 SceneObjectGroup object1; 63 m_archiverModule = new InventoryArchiverModule();
137 SceneObjectPart part1;
138 {
139 string partName = "My Little Dog Object";
140 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
141 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
142 Vector3 groupPosition = new Vector3(10, 20, 30);
143 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
144 Vector3 offsetPosition = new Vector3(5, 10, 15);
145
146 part1
147 = new SceneObjectPart(
148 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
149 part1.Name = partName;
150
151 object1 = new SceneObjectGroup(part1);
152 scene.AddNewSceneObject(object1, false);
153 }
154
155 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
156 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
157 scene.AssetService.Store(asset1);
158
159 // Create item
160 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
161 InventoryItemBase item1 = new InventoryItemBase();
162 item1.Name = "My Little Dog";
163 item1.AssetID = asset1.FullID;
164 item1.ID = item1Id;
165 InventoryFolderBase objsFolder
166 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
167 item1.Folder = objsFolder.ID;
168 scene.AddInventoryItem(item1);
169
170 MemoryStream archiveWriteStream = new MemoryStream();
171 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
172
173 // Test saving a particular path
174 mre.Reset();
175 archiverModule.ArchiveInventory(
176 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
177 mre.WaitOne(60000, false);
178
179 byte[] archive = archiveWriteStream.ToArray();
180 MemoryStream archiveReadStream = new MemoryStream(archive);
181 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
182
183 //bool gotControlFile = false;
184 bool gotObject1File = false;
185 //bool gotObject2File = false;
186 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
187 string expectedObject1FilePath = string.Format(
188 "{0}{1}{2}",
189 ArchiveConstants.INVENTORY_PATH,
190 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
191 expectedObject1FileName);
192
193 string filePath;
194 TarArchiveReader.TarEntryType tarEntryType;
195
196// Console.WriteLine("Reading archive");
197
198 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
199 {
200// Console.WriteLine("Got {0}", filePath);
201
202// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
203// {
204// gotControlFile = true;
205// }
206
207 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
208 {
209// string fileName = filePath.Remove(0, "Objects/".Length);
210//
211// if (fileName.StartsWith(part1.Name))
212// {
213 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
214 gotObject1File = true;
215// }
216// else if (fileName.StartsWith(part2.Name))
217// {
218// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
219// gotObject2File = true;
220// }
221 }
222 }
223
224// Assert.That(gotControlFile, Is.True, "No control file in archive");
225 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
226// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
227 64
228 // TODO: Test presence of more files and contents of files. 65 m_scene = SceneSetupHelpers.SetupScene("Inventory");
66 SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
229 } 67 }
230 68
231 /// <summary> 69 /// <summary>
@@ -238,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
238 TestHelper.InMethod(); 76 TestHelper.InMethod();
239// log4net.Config.XmlConfigurator.Configure(); 77// log4net.Config.XmlConfigurator.Configure();
240 78
241 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
242
243 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
244 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
245
246 // Create user 79 // Create user
247 string userFirstName = "Jock"; 80 string userFirstName = "Jock";
248 string userLastName = "Stirrup"; 81 string userLastName = "Stirrup";
249 string userPassword = "troll"; 82 string userPassword = "troll";
250 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 83 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
251 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); 84 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
252 85
253 // Create asset 86 // Create asset
254 SceneObjectGroup object1; 87 SceneObjectGroup object1;
@@ -267,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
267 part1.Name = partName; 100 part1.Name = partName;
268 101
269 object1 = new SceneObjectGroup(part1); 102 object1 = new SceneObjectGroup(part1);
270 scene.AddNewSceneObject(object1, false); 103 m_scene.AddNewSceneObject(object1, false);
271 } 104 }
272 105
273 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 106 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
274 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 107 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
275 scene.AssetService.Store(asset1); 108 m_scene.AssetService.Store(asset1);
276 109
277 // Create item 110 // Create item
278 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); 111 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
@@ -282,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
282 item1.AssetID = asset1.FullID; 115 item1.AssetID = asset1.FullID;
283 item1.ID = item1Id; 116 item1.ID = item1Id;
284 InventoryFolderBase objsFolder 117 InventoryFolderBase objsFolder
285 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; 118 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];
286 item1.Folder = objsFolder.ID; 119 item1.Folder = objsFolder.ID;
287 scene.AddInventoryItem(item1); 120 m_scene.AddInventoryItem(item1);
288 121
289 MemoryStream archiveWriteStream = new MemoryStream(); 122 MemoryStream archiveWriteStream = new MemoryStream();
290 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 123 m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
291 124
292 mre.Reset(); 125 mre.Reset();
293 archiverModule.ArchiveInventory( 126 m_archiverModule.ArchiveInventory(
294 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); 127 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream);
295 mre.WaitOne(60000, false); 128 mre.WaitOne(60000, false);
296 129
@@ -346,474 +179,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
346 } 179 }
347 180
348 /// <summary> 181 /// <summary>
349 /// Test that things work when the load path specified starts with a slash 182 /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized
350 /// </summary> 183 /// objects.
184 /// </summary>
351 [Test] 185 [Test]
352 public void TestLoadIarPathStartsWithSlash() 186 public void TestLoadIarCreatorAccountPresent()
353 { 187 {
354 TestHelper.InMethod(); 188 TestHelper.InMethod();
355// log4net.Config.XmlConfigurator.Configure(); 189// log4net.Config.XmlConfigurator.Configure();
356
357 SerialiserModule serialiserModule = new SerialiserModule();
358 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
359 Scene scene = SceneSetupHelpers.SetupScene("inventory");
360 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
361
362 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
363 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream);
364 190
191 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
192
193 m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream);
365 InventoryItemBase foundItem1 194 InventoryItemBase foundItem1
366 = InventoryArchiveUtils.FindItemByPath( 195 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
367 scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); 196
197 Assert.That(
198 foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()),
199 "Loaded item non-uuid creator doesn't match original");
200 Assert.That(
201 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID),
202 "Loaded item uuid creator doesn't match original");
203 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID),
204 "Loaded item owner doesn't match inventory reciever");
368 205
369 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); 206 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
207 string xmlData = Utils.BytesToString(asset1.Data);
208 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
209
210 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
370 } 211 }
371 212
372 /// <summary> 213 /// <summary>
373 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 214 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
374 /// an account exists with the creator name. 215 /// an account exists with the same name as the creator, though not the same id.
375 /// </summary> 216 /// </summary>
376 ///
377 /// This test also does some deeper probing of loading into nested inventory structures
378 [Test] 217 [Test]
379 public void TestLoadIarV0_1ExistingUsers() 218 public void TestLoadIarV0_1SameNameCreator()
380 { 219 {
381 TestHelper.InMethod(); 220 TestHelper.InMethod();
382 //log4net.Config.XmlConfigurator.Configure(); 221// log4net.Config.XmlConfigurator.Configure();
383
384 SerialiserModule serialiserModule = new SerialiserModule();
385 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
386
387 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
388 Scene scene = SceneSetupHelpers.SetupScene("inventory");
389
390 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
391 222
392 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 223 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
393 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 224 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
394 225
395 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); 226 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
396
397 InventoryItemBase foundItem1 227 InventoryItemBase foundItem1
398 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 228 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
399
400 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
401 229
402// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
403// UUID, not the OSPA itself.
404// Assert.That(
405// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
406// "Loaded item non-uuid creator doesn't match original");
407 Assert.That( 230 Assert.That(
408 foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), 231 foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
409 "Loaded item non-uuid creator doesn't match original"); 232 "Loaded item non-uuid creator doesn't match original");
410
411 Assert.That( 233 Assert.That(
412 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), 234 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
413 "Loaded item uuid creator doesn't match original"); 235 "Loaded item uuid creator doesn't match original");
414 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), 236 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
415 "Loaded item owner doesn't match inventory reciever"); 237 "Loaded item owner doesn't match inventory reciever");
416
417 // Now try loading to a root child folder
418 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
419 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
420 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);
421
422 InventoryItemBase foundItem2
423 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);
424 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
425
426 // Now try loading to a more deeply nested folder
427 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
428 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
429 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);
430
431 InventoryItemBase foundItem3
432 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);
433 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
434 }
435
436 [Test]
437 public void TestIarV0_1WithEscapedChars()
438 {
439 TestHelper.InMethod();
440// log4net.Config.XmlConfigurator.Configure();
441
442 string itemName = "You & you are a mean/man/";
443 string humanEscapedItemName = @"You & you are a mean\/man\/";
444 string userPassword = "meowfood";
445
446 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
447
448 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
449 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
450
451 // Create user
452 string userFirstName = "Jock";
453 string userLastName = "Stirrup";
454 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
455 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
456
457 // Create asset
458 SceneObjectGroup object1;
459 SceneObjectPart part1;
460 {
461 string partName = "part name";
462 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
463 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
464 Vector3 groupPosition = new Vector3(10, 20, 30);
465 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
466 Vector3 offsetPosition = new Vector3(5, 10, 15);
467
468 part1
469 = new SceneObjectPart(
470 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
471 part1.Name = partName;
472
473 object1 = new SceneObjectGroup(part1);
474 scene.AddNewSceneObject(object1, false);
475 }
476
477 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
478 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
479 scene.AssetService.Store(asset1);
480
481 // Create item
482 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
483 InventoryItemBase item1 = new InventoryItemBase();
484 item1.Name = itemName;
485 item1.AssetID = asset1.FullID;
486 item1.ID = item1Id;
487 InventoryFolderBase objsFolder
488 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
489 item1.Folder = objsFolder.ID;
490 scene.AddInventoryItem(item1);
491
492 MemoryStream archiveWriteStream = new MemoryStream();
493 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
494
495 mre.Reset();
496 archiverModule.ArchiveInventory(
497 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
498 mre.WaitOne(60000, false);
499
500 // LOAD ITEM
501 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
502 238
503 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); 239 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
504 240 string xmlData = Utils.BytesToString(asset1.Data);
505 InventoryItemBase foundItem1 241 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
506 = InventoryArchiveUtils.FindItemByPath(
507 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
508 242
509 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 243 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
510// Assert.That(
511// foundItem1.CreatorId, Is.EqualTo(userUuid),
512// "Loaded item non-uuid creator doesn't match that of the loading user");
513 Assert.That(
514 foundItem1.Name, Is.EqualTo(itemName),
515 "Loaded item name doesn't match saved name");
516 } 244 }
517 245
518 /// <summary> 246 /// <summary>
519 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 247 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
520 /// embedded creators do not exist in the system 248 /// the creator or an account with the creator's name does not exist within the system.
521 /// </summary> 249 /// </summary>
522 ///
523 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
524 /// (as tested in the a later commented out test)
525 /// This test is currently disabled
526 [Test] 250 [Test]
527 public void TestLoadIarV0_1AbsentUsers() 251 public void TestLoadIarV0_1AbsentCreator()
528 { 252 {
529 TestHelper.InMethod(); 253 TestHelper.InMethod();
530 //log4net.Config.XmlConfigurator.Configure(); 254// log4net.Config.XmlConfigurator.Configure();
531
532 string userFirstName = "Charlie";
533 string userLastName = "Chan";
534 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
535 string userItemCreatorFirstName = "Bat";
536 string userItemCreatorLastName = "Man";
537 //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
538
539 string itemName = "b.lsl";
540 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
541
542 MemoryStream archiveWriteStream = new MemoryStream();
543 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
544
545 InventoryItemBase item1 = new InventoryItemBase();
546 item1.Name = itemName;
547 item1.AssetID = UUID.Random();
548 item1.GroupID = UUID.Random();
549 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
550 //item1.CreatorId = userUuid.ToString();
551 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
552 item1.Owner = UUID.Zero;
553
554 string item1FileName
555 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
556 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
557 tar.Close();
558
559 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
560 SerialiserModule serialiserModule = new SerialiserModule();
561 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
562
563 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
564 Scene scene = SceneSetupHelpers.SetupScene("inventory");
565
566 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
567 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
568 255
569 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 256 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password");
257 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream);
570 258
571 InventoryItemBase foundItem1 259 InventoryItemBase foundItem1
572 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); 260 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
573 261
574 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 262 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
575// Assert.That(
576// foundItem1.CreatorId, Is.EqualTo(userUuid),
577// "Loaded item non-uuid creator doesn't match that of the loading user");
578 Assert.That( 263 Assert.That(
579 foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), 264 foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()),
265 "Loaded item non-uuid creator doesn't match that of the loading user");
266 Assert.That(
267 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID),
580 "Loaded item uuid creator doesn't match that of the loading user"); 268 "Loaded item uuid creator doesn't match that of the loading user");
581 }
582
583 /// <summary>
584 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
585 /// no account exists with the creator name
586 /// </summary>
587 /// Disabled since temporary profiles have not yet been implemented.
588 ///
589 //[Test]
590 //public void TestLoadIarV0_1TempProfiles()
591 //{
592 // TestHelper.InMethod();
593
594 // //log4net.Config.XmlConfigurator.Configure();
595 269
596 // string userFirstName = "Dennis"; 270 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
597 // string userLastName = "Menace"; 271 string xmlData = Utils.BytesToString(asset1.Data);
598 // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); 272 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
599 // string user2FirstName = "Walter";
600 // string user2LastName = "Mitty";
601 273
602 // string itemName = "b.lsl"; 274 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID));
603 // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
604
605 // MemoryStream archiveWriteStream = new MemoryStream();
606 // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
607
608 // InventoryItemBase item1 = new InventoryItemBase();
609 // item1.Name = itemName;
610 // item1.AssetID = UUID.Random();
611 // item1.GroupID = UUID.Random();
612 // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
613 // item1.Owner = UUID.Zero;
614
615 // string item1FileName
616 // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
617 // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
618 // tar.Close();
619
620 // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
621 // SerialiserModule serialiserModule = new SerialiserModule();
622 // InventoryArchiverModule archiverModule = new InventoryArchiverModule();
623
624 // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
625 // Scene scene = SceneSetupHelpers.SetupScene();
626 // IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
627
628 // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
629 // userAdminService.AddUser(
630 // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
631
632 // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
633
634 // // Check that a suitable temporary user profile has been created.
635 // UserProfileData user2Profile
636 // = scene.CommsManager.UserService.GetUserProfile(
637 // OspResolver.HashName(user2FirstName + " " + user2LastName));
638 // Assert.That(user2Profile, Is.Not.Null);
639 // Assert.That(user2Profile.FirstName == user2FirstName);
640 // Assert.That(user2Profile.SurName == user2LastName);
641
642 // CachedUserInfo userInfo
643 // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
644 // userInfo.OnInventoryReceived += InventoryReceived;
645
646 // lock (this)
647 // {
648 // userInfo.FetchInventory();
649 // Monitor.Wait(this, 60000);
650 // }
651
652 // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
653
654 // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
655 // Assert.That(
656 // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName)));
657 // Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
658
659 // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod());
660 //}
661
662 /// <summary>
663 /// Test replication of an archive path to the user's inventory.
664 /// </summary>
665 [Test]
666 public void TestNewIarPath()
667 {
668 TestHelper.InMethod();
669// log4net.Config.XmlConfigurator.Configure();
670
671 Scene scene = SceneSetupHelpers.SetupScene("inventory");
672 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
673
674 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
675 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
676
677 string folder1Name = "1";
678 string folder2aName = "2a";
679 string folder2bName = "2b";
680
681 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
682 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
683 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
684
685 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
686 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
687
688 {
689 // Test replication of path1
690 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
691 .ReplicateArchivePathToUserInventory(
692 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
693 foldersCreated, nodesLoaded);
694
695 List<InventoryFolderBase> folder1Candidates
696 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
697 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
698
699 InventoryFolderBase folder1 = folder1Candidates[0];
700 List<InventoryFolderBase> folder2aCandidates
701 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
702 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
703 }
704
705 {
706 // Test replication of path2
707 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
708 .ReplicateArchivePathToUserInventory(
709 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
710 foldersCreated, nodesLoaded);
711
712 List<InventoryFolderBase> folder1Candidates
713 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
714 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
715
716 InventoryFolderBase folder1 = folder1Candidates[0];
717
718 List<InventoryFolderBase> folder2aCandidates
719 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
720 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
721
722 List<InventoryFolderBase> folder2bCandidates
723 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
724 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
725 }
726 }
727
728 /// <summary>
729 /// Test replication of a partly existing archive path to the user's inventory. This should create
730 /// a duplicate path without the merge option.
731 /// </summary>
732 [Test]
733 public void TestPartExistingIarPath()
734 {
735 TestHelper.InMethod();
736 //log4net.Config.XmlConfigurator.Configure();
737
738 Scene scene = SceneSetupHelpers.SetupScene("inventory");
739 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
740
741 string folder1ExistingName = "a";
742 string folder2Name = "b";
743
744 InventoryFolderBase folder1
745 = UserInventoryTestUtils.CreateInventoryFolder(
746 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
747
748 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
749 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
750
751 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
752
753 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
754 .ReplicateArchivePathToUserInventory(
755 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
756 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
757
758 List<InventoryFolderBase> folder1PostCandidates
759 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
760 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
761
762 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
763 InventoryFolderBase folder1Post = null;
764 foreach (InventoryFolderBase folder in folder1PostCandidates)
765 {
766 if (folder.ID != folder1.ID)
767 {
768 folder1Post = folder;
769 break;
770 }
771 }
772// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
773
774 List<InventoryFolderBase> folder2PostCandidates
775 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
776 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
777 }
778
779 /// <summary>
780 /// Test replication of a partly existing archive path to the user's inventory. This should create
781 /// a merged path.
782 /// </summary>
783 [Test]
784 public void TestMergeIarPath()
785 {
786 TestHelper.InMethod();
787// log4net.Config.XmlConfigurator.Configure();
788
789 Scene scene = SceneSetupHelpers.SetupScene("inventory");
790 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
791
792 string folder1ExistingName = "a";
793 string folder2Name = "b";
794
795 InventoryFolderBase folder1
796 = UserInventoryTestUtils.CreateInventoryFolder(
797 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
798
799 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
800 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
801
802 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
803
804 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
805 .ReplicateArchivePathToUserInventory(
806 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
807 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
808
809 List<InventoryFolderBase> folder1PostCandidates
810 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
811 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
812 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
813
814 List<InventoryFolderBase> folder2PostCandidates
815 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
816 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
817 } 275 }
818 } 276 }
819} \ No newline at end of file 277} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
new file mode 100644
index 0000000..0e8f647
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
@@ -0,0 +1,478 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class PathTests : InventoryArchiveTestCase
53 {
54 /// <summary>
55 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
56 /// (subject to change since there is no fixed format yet).
57 /// </summary>
58 [Test]
59 public void TestSavePathToIarV0_1()
60 {
61 TestHelper.InMethod();
62// log4net.Config.XmlConfigurator.Configure();
63
64 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
65
66 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
68
69 // Create user
70 string userFirstName = "Jock";
71 string userLastName = "Stirrup";
72 string userPassword = "troll";
73 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
74 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
75
76 // Create asset
77 SceneObjectGroup object1;
78 SceneObjectPart part1;
79 {
80 string partName = "My Little Dog Object";
81 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
82 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
83 Vector3 groupPosition = new Vector3(10, 20, 30);
84 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
85 Vector3 offsetPosition = new Vector3(5, 10, 15);
86
87 part1 = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition);
88 part1.Name = partName;
89
90 object1 = new SceneObjectGroup(part1);
91 scene.AddNewSceneObject(object1, false);
92 }
93
94 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
95 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
96 scene.AssetService.Store(asset1);
97
98 // Create item
99 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
100 InventoryItemBase item1 = new InventoryItemBase();
101 item1.Name = "My Little Dog";
102 item1.AssetID = asset1.FullID;
103 item1.ID = item1Id;
104 InventoryFolderBase objsFolder
105 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
106 item1.Folder = objsFolder.ID;
107 scene.AddInventoryItem(item1);
108
109 MemoryStream archiveWriteStream = new MemoryStream();
110 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
111
112 // Test saving a particular path
113 mre.Reset();
114 archiverModule.ArchiveInventory(
115 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
116 mre.WaitOne(60000, false);
117
118 byte[] archive = archiveWriteStream.ToArray();
119 MemoryStream archiveReadStream = new MemoryStream(archive);
120 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
121
122 //bool gotControlFile = false;
123 bool gotObject1File = false;
124 //bool gotObject2File = false;
125 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
126 string expectedObject1FilePath = string.Format(
127 "{0}{1}{2}",
128 ArchiveConstants.INVENTORY_PATH,
129 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
130 expectedObject1FileName);
131
132 string filePath;
133 TarArchiveReader.TarEntryType tarEntryType;
134
135// Console.WriteLine("Reading archive");
136
137 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
138 {
139// Console.WriteLine("Got {0}", filePath);
140
141// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
142// {
143// gotControlFile = true;
144// }
145
146 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
147 {
148// string fileName = filePath.Remove(0, "Objects/".Length);
149//
150// if (fileName.StartsWith(part1.Name))
151// {
152 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
153 gotObject1File = true;
154// }
155// else if (fileName.StartsWith(part2.Name))
156// {
157// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
158// gotObject2File = true;
159// }
160 }
161 }
162
163// Assert.That(gotControlFile, Is.True, "No control file in archive");
164 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
165// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
166
167 // TODO: Test presence of more files and contents of files.
168 }
169
170 /// <summary>
171 /// Test loading an IAR to various different inventory paths.
172 /// </summary>
173 [Test]
174 public void TestLoadIarToInventoryPaths()
175 {
176 TestHelper.InMethod();
177// log4net.Config.XmlConfigurator.Configure();
178
179 SerialiserModule serialiserModule = new SerialiserModule();
180 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
181
182 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
183 Scene scene = SceneSetupHelpers.SetupScene("inventory");
184
185 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
186
187 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood");
188 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
189
190 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
191 InventoryItemBase foundItem1
192 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
193
194 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
195
196 // Now try loading to a root child folder
197 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA");
198 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
199 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream);
200
201 InventoryItemBase foundItem2
202 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);
203 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
204
205 // Now try loading to a more deeply nested folder
206 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC");
207 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
208 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream);
209
210 InventoryItemBase foundItem3
211 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);
212 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
213 }
214
215 /// <summary>
216 /// Test that things work when the load path specified starts with a slash
217 /// </summary>
218 [Test]
219 public void TestLoadIarPathStartsWithSlash()
220 {
221 TestHelper.InMethod();
222// log4net.Config.XmlConfigurator.Configure();
223
224 SerialiserModule serialiserModule = new SerialiserModule();
225 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
226 Scene scene = SceneSetupHelpers.SetupScene("inventory");
227 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
228
229 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
230 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream);
231
232 InventoryItemBase foundItem1
233 = InventoryArchiveUtils.FindItemByPath(
234 scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name);
235
236 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
237 }
238
239 [Test]
240 public void TestLoadIarPathWithEscapedChars()
241 {
242 TestHelper.InMethod();
243// log4net.Config.XmlConfigurator.Configure();
244
245 string itemName = "You & you are a mean/man/";
246 string humanEscapedItemName = @"You & you are a mean\/man\/";
247 string userPassword = "meowfood";
248
249 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
250
251 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
252 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
253
254 // Create user
255 string userFirstName = "Jock";
256 string userLastName = "Stirrup";
257 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
258 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
259
260 // Create asset
261 SceneObjectGroup object1;
262 SceneObjectPart part1;
263 {
264 string partName = "part name";
265 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
266 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
267 Vector3 groupPosition = new Vector3(10, 20, 30);
268 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
269 Vector3 offsetPosition = new Vector3(5, 10, 15);
270
271 part1
272 = new SceneObjectPart(
273 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
274 part1.Name = partName;
275
276 object1 = new SceneObjectGroup(part1);
277 scene.AddNewSceneObject(object1, false);
278 }
279
280 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
281 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
282 scene.AssetService.Store(asset1);
283
284 // Create item
285 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
286 InventoryItemBase item1 = new InventoryItemBase();
287 item1.Name = itemName;
288 item1.AssetID = asset1.FullID;
289 item1.ID = item1Id;
290 InventoryFolderBase objsFolder
291 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
292 item1.Folder = objsFolder.ID;
293 scene.AddInventoryItem(item1);
294
295 MemoryStream archiveWriteStream = new MemoryStream();
296 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
297
298 mre.Reset();
299 archiverModule.ArchiveInventory(
300 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
301 mre.WaitOne(60000, false);
302
303 // LOAD ITEM
304 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
305
306 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
307
308 InventoryItemBase foundItem1
309 = InventoryArchiveUtils.FindItemByPath(
310 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
311
312 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
313// Assert.That(
314// foundItem1.CreatorId, Is.EqualTo(userUuid),
315// "Loaded item non-uuid creator doesn't match that of the loading user");
316 Assert.That(
317 foundItem1.Name, Is.EqualTo(itemName),
318 "Loaded item name doesn't match saved name");
319 }
320
321 /// <summary>
322 /// Test replication of an archive path to the user's inventory.
323 /// </summary>
324 [Test]
325 public void TestNewIarPath()
326 {
327 TestHelper.InMethod();
328// log4net.Config.XmlConfigurator.Configure();
329
330 Scene scene = SceneSetupHelpers.SetupScene("inventory");
331 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
332
333 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
334 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
335
336 string folder1Name = "1";
337 string folder2aName = "2a";
338 string folder2bName = "2b";
339
340 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
341 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
342 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
343
344 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
345 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
346
347 {
348 // Test replication of path1
349 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
350 .ReplicateArchivePathToUserInventory(
351 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
352 foldersCreated, nodesLoaded);
353
354 List<InventoryFolderBase> folder1Candidates
355 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
356 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
357
358 InventoryFolderBase folder1 = folder1Candidates[0];
359 List<InventoryFolderBase> folder2aCandidates
360 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
361 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
362 }
363
364 {
365 // Test replication of path2
366 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
367 .ReplicateArchivePathToUserInventory(
368 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
369 foldersCreated, nodesLoaded);
370
371 List<InventoryFolderBase> folder1Candidates
372 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
373 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
374
375 InventoryFolderBase folder1 = folder1Candidates[0];
376
377 List<InventoryFolderBase> folder2aCandidates
378 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
379 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
380
381 List<InventoryFolderBase> folder2bCandidates
382 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
383 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
384 }
385 }
386
387 /// <summary>
388 /// Test replication of a partly existing archive path to the user's inventory. This should create
389 /// a duplicate path without the merge option.
390 /// </summary>
391 [Test]
392 public void TestPartExistingIarPath()
393 {
394 TestHelper.InMethod();
395 //log4net.Config.XmlConfigurator.Configure();
396
397 Scene scene = SceneSetupHelpers.SetupScene("inventory");
398 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
399
400 string folder1ExistingName = "a";
401 string folder2Name = "b";
402
403 InventoryFolderBase folder1
404 = UserInventoryTestUtils.CreateInventoryFolder(
405 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
406
407 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
408 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
409
410 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
411
412 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
413 .ReplicateArchivePathToUserInventory(
414 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
415 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
416
417 List<InventoryFolderBase> folder1PostCandidates
418 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
419 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
420
421 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
422 InventoryFolderBase folder1Post = null;
423 foreach (InventoryFolderBase folder in folder1PostCandidates)
424 {
425 if (folder.ID != folder1.ID)
426 {
427 folder1Post = folder;
428 break;
429 }
430 }
431// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
432
433 List<InventoryFolderBase> folder2PostCandidates
434 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
435 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
436 }
437
438 /// <summary>
439 /// Test replication of a partly existing archive path to the user's inventory. This should create
440 /// a merged path.
441 /// </summary>
442 [Test]
443 public void TestMergeIarPath()
444 {
445 TestHelper.InMethod();
446// log4net.Config.XmlConfigurator.Configure();
447
448 Scene scene = SceneSetupHelpers.SetupScene("inventory");
449 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
450
451 string folder1ExistingName = "a";
452 string folder2Name = "b";
453
454 InventoryFolderBase folder1
455 = UserInventoryTestUtils.CreateInventoryFolder(
456 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
457
458 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
459 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
460
461 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
462
463 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
464 .ReplicateArchivePathToUserInventory(
465 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
466 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
467
468 List<InventoryFolderBase> folder1PostCandidates
469 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
470 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
471 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
472
473 List<InventoryFolderBase> folder2PostCandidates
474 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
475 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
476 }
477 }
478} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 1337143..c88be7d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -284,9 +284,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
284 return; 284 return;
285 } 285 }
286 286
287 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero)) 287 string reason;
288 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out reason))
288 { 289 {
289 sp.ControllingClient.SendTeleportFailed("The destination region has refused access"); 290 sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason);
290 return; 291 return;
291 } 292 }
292 293
@@ -317,14 +318,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
317 agentCircuit.Id0 = currentAgentCircuit.Id0; 318 agentCircuit.Id0 = currentAgentCircuit.Id0;
318 } 319 }
319 320
320 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 321 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
321 { 322 {
322 // brand new agent, let's create a new caps seed 323 // brand new agent, let's create a new caps seed
323 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 324 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
324 } 325 }
325 326
326 string reason = String.Empty;
327
328 // Let's create an agent there if one doesn't exist yet. 327 // Let's create an agent there if one doesn't exist yet.
329 bool logout = false; 328 bool logout = false;
330 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) 329 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
@@ -337,7 +336,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
337 // OK, it got this agent. Let's close some child agents 336 // OK, it got this agent. Let's close some child agents
338 sp.CloseChildAgents(newRegionX, newRegionY); 337 sp.CloseChildAgents(newRegionX, newRegionY);
339 IClientIPEndpoint ipepClient; 338 IClientIPEndpoint ipepClient;
340 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 339 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
341 { 340 {
342 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); 341 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
343 #region IP Translation for NAT 342 #region IP Translation for NAT
@@ -400,6 +399,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
400 if (!UpdateAgent(reg, finalDestination, agent)) 399 if (!UpdateAgent(reg, finalDestination, agent))
401 { 400 {
402 // Region doesn't take it 401 // Region doesn't take it
402 m_log.WarnFormat(
403 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.",
404 sp.Name, finalDestination.RegionName);
405
403 Fail(sp, finalDestination); 406 Fail(sp, finalDestination);
404 return; 407 return;
405 } 408 }
@@ -426,16 +429,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
426 // that the client contacted the destination before we send the attachments and close things here. 429 // that the client contacted the destination before we send the attachments and close things here.
427 if (!WaitForCallback(sp.UUID)) 430 if (!WaitForCallback(sp.UUID))
428 { 431 {
429 Fail(sp, finalDestination); 432 m_log.WarnFormat(
433 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.",
434 sp.Name, finalDestination.RegionName);
435
436 Fail(sp, finalDestination);
430 return; 437 return;
431 } 438 }
432 439
433
434 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it 440 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
435 CrossAttachmentsIntoNewRegion(finalDestination, sp, true); 441 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
436 442
437 // Well, this is it. The agent is over there. 443 // Well, this is it. The agent is over there.
438
439 KillEntity(sp.Scene, sp.LocalId); 444 KillEntity(sp.Scene, sp.LocalId);
440 445
441 // May need to logout or other cleanup 446 // May need to logout or other cleanup
@@ -448,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
448 453
449 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 454 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
450 455
451 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 456 if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
452 { 457 {
453 Thread.Sleep(5000); 458 Thread.Sleep(5000);
454 sp.Close(); 459 sp.Close();
@@ -522,14 +527,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
522 return region; 527 return region;
523 } 528 }
524 529
525 protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) 530 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
526 { 531 {
527 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); 532 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
528 } 533 }
529 534
530 protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 535 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
531 { 536 {
532 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); 537 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
533 } 538 }
534 539
535 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) 540 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
@@ -778,7 +783,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
778 783
779 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); 784 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
780 785
781 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos)) 786 string reason;
787 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out reason))
782 { 788 {
783 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); 789 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
784 if (r == null) 790 if (r == null)
@@ -1045,7 +1051,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1045 1051
1046 if (m_regionInfo != null) 1052 if (m_regionInfo != null)
1047 { 1053 {
1048 neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 1054 neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
1049 } 1055 }
1050 else 1056 else
1051 { 1057 {
@@ -1272,8 +1278,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1272 /// <param name="pRegionLocX"></param> 1278 /// <param name="pRegionLocX"></param>
1273 /// <param name="pRegionLocY"></param> 1279 /// <param name="pRegionLocY"></param>
1274 /// <returns></returns> 1280 /// <returns></returns>
1275 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) 1281 protected List<GridRegion> RequestNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
1276 { 1282 {
1283 Scene pScene = avatar.Scene;
1277 RegionInfo m_regionInfo = pScene.RegionInfo; 1284 RegionInfo m_regionInfo = pScene.RegionInfo;
1278 1285
1279 Border[] northBorders = pScene.NorthBorders.ToArray(); 1286 Border[] northBorders = pScene.NorthBorders.ToArray();
@@ -1281,10 +1288,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1281 Border[] eastBorders = pScene.EastBorders.ToArray(); 1288 Border[] eastBorders = pScene.EastBorders.ToArray();
1282 Border[] westBorders = pScene.WestBorders.ToArray(); 1289 Border[] westBorders = pScene.WestBorders.ToArray();
1283 1290
1284 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 1291 // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
1292 // clear what should be done with a "far view" given that megaregions already extended the
1293 // view to include everything in the megaregion
1285 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 1294 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
1286 { 1295 {
1287 return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); 1296 int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance;
1297
1298 int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
1299 int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
1300
1301 int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
1302 int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
1303
1304 List<GridRegion> neighbours =
1305 avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
1306
1307 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
1308 return neighbours;
1288 } 1309 }
1289 else 1310 else
1290 { 1311 {
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 35dcd95..79e76b4 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -130,9 +130,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
130 return region; 130 return region;
131 } 131 }
132 132
133 protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 133 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
134 { 134 {
135 if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 135 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
136 return true; 136 return true;
137 137
138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 7bb8789..798547a 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -148,6 +148,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
148 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 148 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
149 item = m_Scene.InventoryService.GetItem(item); 149 item = m_Scene.InventoryService.GetItem(item);
150 150
151 if (item.Owner != remoteClient.AgentId)
152 return UUID.Zero;
153
151 if (item != null) 154 if (item != null)
152 { 155 {
153 if ((InventoryType)item.InvType == InventoryType.Notecard) 156 if ((InventoryType)item.InvType == InventoryType.Notecard)
@@ -524,6 +527,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
524 527
525 if (item != null) 528 if (item != null)
526 { 529 {
530 item.Owner = remoteClient.AgentId;
531
527 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 532 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
528 533
529 if (rezAsset != null) 534 if (rezAsset != null)
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index 88f392d..00b0aa9 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
75 m_scene = scene; 75 m_scene = scene;
76 m_scene.RegisterModuleInterface<IRegionModule>(this); 76 m_scene.RegisterModuleInterface<IRegionModule>(this);
77 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 77 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
78 78
79 // ini file settings 79 // ini file settings
80 try 80 try
81 { 81 {
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
229 { 229 {
230 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast"); 230 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
231 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin"); 231 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
232 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin"); 232 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Disable the windlight plugin");
233 233
234 m_commander.RegisterCommand("load", wlload); 234 m_commander.RegisterCommand("load", wlload);
235 m_commander.RegisterCommand("enable", wlenable); 235 m_commander.RegisterCommand("enable", wlenable);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index e54ee02..18db9fa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
index ef910f4..e471f75 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 56720b7..a298b65 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -257,15 +257,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
257 return false; 257 return false;
258 } 258 }
259 259
260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
261 { 261 {
262 reason = "Communications failure";
262 if (destination == null) 263 if (destination == null)
263 return false; 264 return false;
264 265
265 foreach (Scene s in m_sceneList) 266 foreach (Scene s in m_sceneList)
266 { 267 {
267 if (s.RegionInfo.RegionID == destination.RegionID) 268 if (s.RegionInfo.RegionID == destination.RegionID)
268 return s.QueryAccess(id, position); 269 return s.QueryAccess(id, position, out reason);
269 } 270 }
270 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); 271 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
271 return false; 272 return false;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index c4919b3..67f4d60 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -192,15 +192,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
192 return false; 192 return false;
193 193
194 // Try local first 194 // Try local first
195 if (m_localBackend.UpdateAgent(destination, cAgentData)) 195 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
196 return true; 196 return m_localBackend.UpdateAgent(destination, cAgentData);
197
198 // else do the remote thing
199 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
200 return m_remoteConnector.UpdateAgent(destination, cAgentData);
201
202 return false;
203 197
198 return m_remoteConnector.UpdateAgent(destination, cAgentData);
204 } 199 }
205 200
206 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) 201 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
@@ -209,15 +204,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
209 return false; 204 return false;
210 205
211 // Try local first 206 // Try local first
212 if (m_localBackend.UpdateAgent(destination, cAgentData)) 207 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
213 return true; 208 return m_localBackend.UpdateAgent(destination, cAgentData);
214
215 // else do the remote thing
216 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
217 return m_remoteConnector.UpdateAgent(destination, cAgentData);
218
219 return false;
220 209
210 return m_remoteConnector.UpdateAgent(destination, cAgentData);
221 } 211 }
222 212
223 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 213 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
@@ -239,18 +229,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
239 229
240 } 230 }
241 231
242 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 232 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
243 { 233 {
234 reason = "Communications failure";
244 if (destination == null) 235 if (destination == null)
245 return false; 236 return false;
246 237
247 // Try local first 238 // Try local first
248 if (m_localBackend.QueryAccess(destination, id, position)) 239 if (m_localBackend.QueryAccess(destination, id, position, out reason))
249 return true; 240 return true;
250 241
251 // else do the remote thing 242 // else do the remote thing
252 if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) 243 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
253 return m_remoteConnector.QueryAccess(destination, id, position); 244 return m_remoteConnector.QueryAccess(destination, id, position, out reason);
254 245
255 return false; 246 return false;
256 247
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 04b6e3d..e2760a2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
38using OpenSim.Framework; 37using OpenSim.Framework;
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index 071314a..aa14054 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
188 } 188 }
189 catch (DllNotFoundException) 189 catch (DllNotFoundException)
190 { 190 {
191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id); 191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id);
192 192
193 } 193 }
194 catch (IndexOutOfRangeException) 194 catch (IndexOutOfRangeException)
195 { 195 {
196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); 196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
197 197
198 } 198 }
199 catch (Exception) 199 catch (Exception)
200 { 200 {
201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); 201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
202 202
203 } 203 }
204 return null; 204 return null;
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 7c5d044..898ca4a 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray; 50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap; 51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52 52
53namespace OpenSim.Region.CoreModules.Media.Moap 53namespace OpenSim.Region.CoreModules.World.Media.Moap
54{ 54{
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")]
56 public class MoapModule : INonSharedRegionModule, IMoapModule 56 public class MoapModule : INonSharedRegionModule, IMoapModule
@@ -225,24 +225,62 @@ namespace OpenSim.Region.CoreModules.Media.Moap
225 return me; 225 return me;
226 } 226 }
227 227
228 /// <summary>
229 /// Set the media entry on the face of the given part.
230 /// </summary>
231 /// <param name="part">/param>
232 /// <param name="face"></param>
233 /// <param name="me">If null, then the media entry is cleared.</param>
228 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) 234 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
229 { 235 {
236// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
237
230 CheckFaceParam(part, face); 238 CheckFaceParam(part, face);
231 239
232 if (null == part.Shape.Media) 240 if (null == part.Shape.Media)
233 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); 241 {
234 242 if (me == null)
243 return;
244 else
245 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
246 }
247
235 lock (part.Shape.Media) 248 lock (part.Shape.Media)
236 part.Shape.Media[face] = me; 249 part.Shape.Media[face] = me;
237 250
238 UpdateMediaUrl(part, UUID.Zero); 251 UpdateMediaUrl(part, UUID.Zero);
252
253 SetPartMediaFlags(part, face, me != null);
254
239 part.ScheduleFullUpdate(); 255 part.ScheduleFullUpdate();
240 part.TriggerScriptChangedEvent(Changed.MEDIA); 256 part.TriggerScriptChangedEvent(Changed.MEDIA);
241 } 257 }
242 258
259 /// <summary>
260 /// Clear the media entry from the face of the given part.
261 /// </summary>
262 /// <param name="part"></param>
263 /// <param name="face"></param>
243 public void ClearMediaEntry(SceneObjectPart part, int face) 264 public void ClearMediaEntry(SceneObjectPart part, int face)
244 { 265 {
245 SetMediaEntry(part, face, null); 266 SetMediaEntry(part, face, null);
267 }
268
269 /// <summary>
270 /// Set the media flags on the texture face of the given part.
271 /// </summary>
272 /// <remarks>
273 /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY.
274 /// </remarks>
275 /// <param name="part"></param>
276 /// <param name="face"></param>
277 /// <param name="flag"></param>
278 protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag)
279 {
280 Primitive.TextureEntry te = part.Shape.Textures;
281 Primitive.TextureEntryFace teFace = te.CreateFace((uint)face);
282 teFace.MediaFlags = flag;
283 part.Shape.Textures = te;
246 } 284 }
247 285
248 /// <summary> 286 /// <summary>
@@ -333,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
333 } 371 }
334 372
335// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); 373// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
336 374//
337// for (int i = 0; i < omu.FaceMedia.Length; i++) 375// for (int i = 0; i < omu.FaceMedia.Length; i++)
338// { 376// {
339// MediaEntry me = omu.FaceMedia[i]; 377// MediaEntry me = omu.FaceMedia[i];
@@ -368,10 +406,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
368 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get 406 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get
369 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry 407 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry
370 // directly. 408 // directly.
371 Primitive.TextureEntry te = part.Shape.Textures; 409 SetPartMediaFlags(part, i, true);
372 Primitive.TextureEntryFace face = te.CreateFace((uint)i);
373 face.MediaFlags = true;
374 part.Shape.Textures = te;
375// m_log.DebugFormat( 410// m_log.DebugFormat(
376// "[MOAP]: Media flags for face {0} is {1}", 411// "[MOAP]: Media flags for face {0} is {1}",
377// i, part.Shape.Textures.FaceTextures[i].MediaFlags); 412// i, part.Shape.Textures.FaceTextures[i].MediaFlags);
@@ -380,6 +415,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap
380 } 415 }
381 else 416 else
382 { 417 {
418// m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name);
419
383 // We need to go through the media textures one at a time to make sure that we have permission 420 // We need to go through the media textures one at a time to make sure that we have permission
384 // to change them 421 // to change them
385 422
@@ -401,8 +438,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
401 if (null == media[i]) 438 if (null == media[i])
402 continue; 439 continue;
403 440
404 Primitive.TextureEntryFace face = te.CreateFace((uint)i); 441 SetPartMediaFlags(part, i, true);
405 face.MediaFlags = true;
406 442
407 // m_log.DebugFormat( 443 // m_log.DebugFormat(
408 // "[MOAP]: Media flags for face {0} is {1}", 444 // "[MOAP]: Media flags for face {0} is {1}",
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
new file mode 100644
index 0000000..5b85830
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -0,0 +1,102 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.World.Media.Moap;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization;
41using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43using OpenSim.Tests.Common.Setup;
44
45namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
46{
47 [TestFixture]
48 public class MoapTests
49 {
50 protected TestScene m_scene;
51 protected MoapModule m_module;
52
53 [SetUp]
54 public void SetUp()
55 {
56 m_module = new MoapModule();
57 m_scene = SceneSetupHelpers.SetupScene();
58 SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
59 }
60
61 [Test]
62 public void TestClearMediaUrl()
63 {
64 TestHelper.InMethod();
65// log4net.Config.XmlConfigurator.Configure();
66
67 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
68 MediaEntry me = new MediaEntry();
69
70 m_module.SetMediaEntry(part, 1, me);
71 m_module.ClearMediaEntry(part, 1);
72
73 Assert.That(part.Shape.Media[1], Is.EqualTo(null));
74
75 // Although we've cleared one face, other faces may still be present. So we need to check for an
76 // update media url version
77 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
78
79 // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
80 // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
81 // Not at all confusing, eh?
82 Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
83 }
84
85 [Test]
86 public void TestSetMediaUrl()
87 {
88 TestHelper.InMethod();
89
90 string homeUrl = "opensimulator.org";
91
92 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
93 MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
94
95 m_module.SetMediaEntry(part, 1, me);
96
97 Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
98 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));
99 Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True);
100 }
101 }
102} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 364dd6c..170c35f 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -642,7 +642,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
642 /// implemented by callers. 642 /// implemented by callers.
643 /// </summary> 643 /// </summary>
644 /// <param name="currentUser"></param> 644 /// <param name="currentUser"></param>
645 /// <param name="objId"></param> 645 /// <param name="objId">This is a scene object group UUID</param>
646 /// <param name="denyOnLocked"></param> 646 /// <param name="denyOnLocked"></param>
647 /// <returns></returns> 647 /// <returns></returns>
648 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked) 648 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
@@ -1896,7 +1896,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1896// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 1896// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
1897// agentID, primID, face, me.ControlPermissions); 1897// agentID, primID, face, me.ControlPermissions);
1898 1898
1899 return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); 1899 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true);
1900 } 1900 }
1901 1901
1902 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 1902 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index f10e848..dafaa0c 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -30,7 +30,6 @@ using System.IO;
30using System.Xml; 30using System.Xml;
31using log4net.Config; 31using log4net.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index a9e46d0..7bb7544 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
113 data = new MapBlockData(); 113 data = new MapBlockData();
114 data.Agents = 0; 114 data.Agents = 0;
115 data.Access = info.Access; 115 data.Access = info.Access;
116 data.MapImageId = info.TerrainImage; 116 data.MapImageId = UUID.Zero; // could use info.TerrainImage but it seems to break viewer2
117 data.Name = info.RegionName; 117 data.Name = info.RegionName;
118 data.RegionFlags = 0; // TODO not used? 118 data.RegionFlags = 0; // TODO not used?
119 data.WaterHeight = 0; // not used 119 data.WaterHeight = 0; // not used
@@ -135,7 +135,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
135 data.Y = 0; 135 data.Y = 0;
136 blocks.Add(data); 136 blocks.Add(data);
137 137
138 remoteClient.SendMapBlock(blocks, 0); 138 // not sure what the flags do here, but seems to be necessary
139 // to set to "2" for viewer 2
140 remoteClient.SendMapBlock(blocks, 2);
139 } 141 }
140 142
141// private Scene GetClientScene(IClientAPI client) 143// private Scene GetClientScene(IClientAPI client)