Merge branch 'master' into test-merge0418

bulletsim
Mic Bowman 2011-04-18 11:29:43 -07:00
commit 452ae375f0
22 changed files with 626 additions and 801 deletions

View File

@ -94,7 +94,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public void Initialise()
{
m_log.Info("[RADMIN]: " + Name + " cannot be default-initialized!");
m_log.Error("[RADMIN]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException(Name);
}
@ -111,7 +111,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
else
{
m_config = m_configSource.Configs["RemoteAdmin"];
m_log.Info("[RADMIN]: Remote Admin Plugin Enabled");
m_log.Debug("[RADMIN]: Remote Admin Plugin Enabled");
m_requiredPassword = m_config.GetString("access_password", String.Empty);
int port = m_config.GetInt("port", 0);
@ -130,6 +130,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
availableMethods["admin_restart"] = XmlRpcRestartMethod;
availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod;
// User management
availableMethods["admin_create_user"] = XmlRpcCreateUserMethod;
availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod;
@ -230,8 +231,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN]: Restart region: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0} {1}", e.Message, e.StackTrace);
responseData["accepted"] = false;
responseData["success"] = false;
responseData["rebooting"] = false;
@ -277,8 +277,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message, e.StackTrace);
responseData["accepted"] = false;
responseData["success"] = false;
@ -301,7 +300,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
Hashtable requestData = (Hashtable) request.Params[0];
m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString());
m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request);
// foreach (string k in requestData.Keys)
// {
// m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}",
@ -348,8 +347,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN]: Terrain Loading: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN]: Terrain Loading: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: Terrain Loading: failed: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -360,6 +358,61 @@ namespace OpenSim.ApplicationPlugins.RemoteController
return response;
}
public XmlRpcResponse XmlRpcSaveHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
m_log.Info("[RADMIN]: Save height maps request started");
try
{
Hashtable requestData = (Hashtable)request.Params[0];
m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString());
CheckStringParameters(request, new string[] { "password", "filename", "regionid" });
if (m_requiredPassword != String.Empty &&
(!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword))
throw new Exception("wrong password");
string file = (string)requestData["filename"];
UUID regionID = (UUID)(string)requestData["regionid"];
m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file);
responseData["accepted"] = true;
Scene region = null;
if (!m_application.SceneManager.TryGetScene(regionID, out region))
throw new Exception("1: unable to get a scene with that name");
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
if (null == terrainModule) throw new Exception("terrain module not available");
terrainModule.SaveToFile(file);
responseData["success"] = false;
response.Value = responseData;
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN]: Terrain Saving: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN]: Terrain Saving: failed: {0}", e.ToString());
responseData["success"] = false;
responseData["error"] = e.Message;
}
m_log.Info("[RADMIN]: Save height maps request complete");
return response;
}
public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: Received Shutdown Administrator Request");
@ -417,14 +470,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: Shutdown: failed: {0} {1}", e.Message, e.StackTrace);
responseData["accepted"] = false;
responseData["error"] = e.Message;
response.Value = responseData;
}
m_log.Info("[RADMIN]: Shutdown Administrator Request complete");
return response;
}
@ -725,8 +778,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message);
m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString());
m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -792,8 +844,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message);
m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString());
m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -884,8 +935,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] CloseRegion: failed {0}", e.Message);
m_log.DebugFormat("[RADMIN] CloseRegion: failed {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: CloseRegion: failed {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -982,8 +1032,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] ModifyRegion: failed {0}", e.Message);
m_log.DebugFormat("[RADMIN] ModifyRegion: failed {0}", e.ToString());
m_log.ErrorFormat("[RADMIN] ModifyRegion: failed {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -1106,8 +1155,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: CreateUser: failed: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["avatar_uuid"] = UUID.Zero.ToString();
@ -1198,8 +1246,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] UserExists: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN] UserExists: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: UserExists: failed: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -1372,9 +1419,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["avatar_uuid"] = UUID.Zero.ToString();
@ -1382,6 +1427,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
response.Value = responseData;
}
m_log.Info("[RADMIN]: UpdateUserAccount: request complete");
return response;
}
@ -1397,7 +1443,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void UpdateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
{
m_log.DebugFormat("[RADMIN] updateUserAppearance");
m_log.DebugFormat("[RADMIN]: updateUserAppearance");
string defaultMale = m_config.GetString("default_male", "Default Male");
string defaultFemale = m_config.GetString("default_female", "Default Female");
@ -1437,16 +1483,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (String.IsNullOrEmpty(model))
{
m_log.DebugFormat("[RADMIN] Appearance update not requested");
m_log.DebugFormat("[RADMIN]: Appearance update not requested");
return;
}
m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model <{1}>", userid, model);
m_log.DebugFormat("[RADMIN]: Setting appearance for avatar {0}, using model <{1}>", userid, model);
string[] modelSpecifiers = model.Split();
if (modelSpecifiers.Length != 2)
{
m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
m_log.WarnFormat("[RADMIN]: User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
// modelSpecifiers = dmodel.Split();
return;
}
@ -1457,7 +1503,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (modelProfile == null)
{
m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model);
m_log.WarnFormat("[RADMIN]: Requested model ({0}) not found. Appearance unchanged", model);
return;
}
@ -1467,7 +1513,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
EstablishAppearance(userid, modelProfile.PrincipalID);
m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}",
m_log.DebugFormat("[RADMIN]: Finished setting appearance for avatar {0}, using model {1}",
userid, model);
}
@ -1479,7 +1525,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void EstablishAppearance(UUID destination, UUID source)
{
m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", destination, source);
m_log.DebugFormat("[RADMIN]: Initializing inventory for {0} from {1}", destination, source);
Scene scene = m_application.SceneManager.CurrentOrFirstScene;
// If the model has no associated appearance we're done.
@ -1501,7 +1547,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}",
m_log.WarnFormat("[RADMIN]: Error transferring appearance for {0} : {1}",
destination, e.Message);
}
@ -1532,7 +1578,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}",
m_log.WarnFormat("[RADMIN]: Error transferring appearance for {0} : {1}",
destination, e.Message);
}
@ -1567,7 +1613,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID;
destinationFolder.Version = 1;
inventoryService.AddFolder(destinationFolder); // store base record
m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", source);
m_log.ErrorFormat("[RADMIN]: Created folder for destination {0}", source);
}
// Wearables
@ -1587,6 +1633,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
destinationItem.Name = item.Name;
destinationItem.Owner = destination;
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
@ -1606,6 +1653,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationItem.Flags = item.Flags;
destinationItem.CreationDate = item.CreationDate;
destinationItem.Folder = destinationFolder.ID;
ApplyNextOwnerPermissions(destinationItem);
m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
@ -1640,6 +1688,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
destinationItem.Name = item.Name;
destinationItem.Owner = destination;
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
@ -1659,6 +1708,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationItem.Flags = item.Flags;
destinationItem.CreationDate = item.CreationDate;
destinationItem.Folder = destinationFolder.ID;
ApplyNextOwnerPermissions(destinationItem);
m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
@ -1716,13 +1766,17 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
destinationFolder = new InventoryFolderBase();
destinationFolder.ID = UUID.Random();
destinationFolder.Name = assetType.ToString();
if (assetType == AssetType.Clothing) {
destinationFolder.Name = "Clothing";
} else {
destinationFolder.Name = "Body Parts";
}
destinationFolder.Owner = destination;
destinationFolder.Type = (short)assetType;
destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID;
destinationFolder.Version = 1;
inventoryService.AddFolder(destinationFolder); // store base record
m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", source);
m_log.ErrorFormat("[RADMIN]: Created folder for destination {0}", source);
}
InventoryFolderBase extraFolder;
@ -1740,7 +1794,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
extraFolder.ParentID = destinationFolder.ID;
inventoryService.AddFolder(extraFolder);
m_log.DebugFormat("[RADMIN] Added folder {0} to folder {1}", extraFolder.ID, sourceFolder.ID);
m_log.DebugFormat("[RADMIN]: Added folder {0} to folder {1}", extraFolder.ID, sourceFolder.ID);
List<InventoryItemBase> items = inventoryService.GetFolderContent(source, folder.ID).Items;
@ -1748,6 +1802,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
destinationItem.Name = item.Name;
destinationItem.Owner = destination;
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
@ -1767,6 +1822,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationItem.Flags = item.Flags;
destinationItem.CreationDate = item.CreationDate;
destinationItem.Folder = extraFolder.ID;
ApplyNextOwnerPermissions(destinationItem);
m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
inventoryMap.Add(item.ID, destinationItem.ID);
@ -1783,6 +1839,29 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
}
/// <summary>
/// Apply next owner permissions.
/// </summary>
private void ApplyNextOwnerPermissions(InventoryItemBase item)
{
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
}
item.CurrentPermissions &= item.NextPermissions;
item.BasePermissions &= item.NextPermissions;
item.EveryOnePermissions &= item.NextPermissions;
// item.OwnerChanged = true;
// item.PermsMask = 0;
// item.PermsGranter = UUID.Zero;
}
/// <summary>
/// This method is called if a given model avatar name can not be found. If the external
/// file has already been loaded once, then control returns immediately. If not, then it
@ -1792,7 +1871,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
/// indicate which outfit is the default, and this outfit will be automatically worn. The
/// other outfits are provided to allow "real" avatars a way to easily change their outfits.
/// </summary>
private bool CreateDefaultAvatars()
{
// Only load once
@ -1801,7 +1879,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
return false;
}
m_log.DebugFormat("[RADMIN] Creating default avatar entries");
m_log.DebugFormat("[RADMIN]: Creating default avatar entries");
m_defaultAvatarsLoaded = true;
@ -1857,7 +1935,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
foreach (XmlElement avatar in avatars)
{
m_log.DebugFormat("[RADMIN] Loading appearance for {0}, gender = {1}",
m_log.DebugFormat("[RADMIN]: Loading appearance for {0}, gender = {1}",
GetStringAttribute(avatar,"name","?"), GetStringAttribute(avatar,"gender","?"));
// Create the user identified by the avatar entry
@ -1879,7 +1957,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
account = CreateUser(scopeID, names[0], names[1], password, email);
if (null == account)
{
m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", names[0], names[1]);
m_log.ErrorFormat("[RADMIN]: Avatar {0} {1} was not created", names[0], names[1]);
return false;
}
}
@ -1897,12 +1975,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
ID = account.PrincipalID;
m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID);
m_log.DebugFormat("[RADMIN]: User {0}[{1}] created or retrieved", name, ID);
include = true;
}
catch (Exception e)
{
m_log.DebugFormat("[RADMIN] Error creating user {0} : {1}", name, e.Message);
m_log.DebugFormat("[RADMIN]: Error creating user {0} : {1}", name, e.Message);
include = false;
}
@ -1942,7 +2020,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
clothingFolder.ParentID = inventoryService.GetRootFolder(ID).ID;
clothingFolder.Version = 1;
inventoryService.AddFolder(clothingFolder); // store base record
m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID);
m_log.ErrorFormat("[RADMIN]: Created clothing folder for {0}/{1}", name, ID);
}
// OK, now we have an inventory for the user, read in the outfits from the
@ -1955,7 +2033,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
foreach (XmlElement outfit in outfits)
{
m_log.DebugFormat("[RADMIN] Loading outfit {0} for {1}",
m_log.DebugFormat("[RADMIN]: Loading outfit {0} for {1}",
GetStringAttribute(outfit,"name","?"), GetStringAttribute(avatar,"name","?"));
outfitName = GetStringAttribute(outfit,"name","");
@ -1979,7 +2057,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// Otherwise, we must create the folder.
if (extraFolder == null)
{
m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", outfitName, name);
m_log.DebugFormat("[RADMIN]: Creating outfit folder {0} for {1}", outfitName, name);
extraFolder = new InventoryFolderBase();
extraFolder.ID = UUID.Random();
extraFolder.Name = outfitName;
@ -1988,7 +2066,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
extraFolder.Version = 1;
extraFolder.ParentID = clothingFolder.ID;
inventoryService.AddFolder(extraFolder);
m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", extraFolder.ID, clothingFolder.ID);
m_log.DebugFormat("[RADMIN]: Adding outfile folder {0} to folder {1}", extraFolder.ID, clothingFolder.ID);
}
// Now get the pieces that make up the outfit
@ -2003,7 +2081,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
switch (child.Name)
{
case "Permissions" :
m_log.DebugFormat("[RADMIN] Permissions specified");
m_log.DebugFormat("[RADMIN]: Permissions specified");
perms = child;
break;
case "Asset" :
@ -2053,7 +2131,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
inventoryItem.Folder = extraFolder.ID; // Parent folder
m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(inventoryItem);
m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", inventoryItem.ID, extraFolder.ID);
m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", inventoryItem.ID, extraFolder.ID);
}
// Attach item, if attachpoint is specified
@ -2061,7 +2139,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (attachpoint != 0)
{
avatarAppearance.SetAttachment(attachpoint, inventoryItem.ID, inventoryItem.AssetID);
m_log.DebugFormat("[RADMIN] Attached {0}", inventoryItem.ID);
m_log.DebugFormat("[RADMIN]: Attached {0}", inventoryItem.ID);
}
// Record whether or not the item is to be initially worn
@ -2074,32 +2152,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.WarnFormat("[RADMIN] Error wearing item {0} : {1}", inventoryItem.ID, e.Message);
m_log.WarnFormat("[RADMIN]: Error wearing item {0} : {1}", inventoryItem.ID, e.Message);
}
} // foreach item in outfit
m_log.DebugFormat("[RADMIN] Outfit {0} load completed", outfitName);
m_log.DebugFormat("[RADMIN]: Outfit {0} load completed", outfitName);
} // foreach outfit
m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name);
m_log.DebugFormat("[RADMIN]: Inventory update complete for {0}", name);
scene.AvatarService.SetAppearance(ID, avatarAppearance);
}
catch (Exception e)
{
m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}",
m_log.WarnFormat("[RADMIN]: Inventory processing incomplete for user {0} : {1}",
name, e.Message);
}
} // End of include
}
m_log.DebugFormat("[RADMIN] Default avatar loading complete");
m_log.DebugFormat("[RADMIN]: Default avatar loading complete");
}
else
{
m_log.DebugFormat("[RADMIN] No default avatar information available");
m_log.DebugFormat("[RADMIN]: No default avatar information available");
return false;
}
}
catch (Exception e)
{
m_log.WarnFormat("[RADMIN] Exception whilst loading default avatars ; {0}", e.Message);
m_log.WarnFormat("[RADMIN]: Exception whilst loading default avatars ; {0}", e.Message);
return false;
}
@ -2194,8 +2272,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message);
m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: LoadOAR: {0} {1}", e.Message, e.StackTrace);
responseData["loaded"] = false;
responseData["error"] = e.Message;
@ -2300,8 +2377,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] SaveOAR: {0}", e.Message);
m_log.DebugFormat("[RADMIN] SaveOAR: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: SaveOAR: {0} {1}", e.Message, e.StackTrace);
responseData["saved"] = false;
responseData["error"] = e.Message;
@ -2315,7 +2391,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void RemoteAdminOarSaveCompleted(Guid uuid, string name)
{
m_log.DebugFormat("[RADMIN] File processing complete for {0}", name);
m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name);
lock (m_saveOarLock) Monitor.Pulse(m_saveOarLock);
}
@ -2353,14 +2429,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2391,8 +2467,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN] LoadXml: {0} {1}", e.Message, e.StackTrace);
responseData["loaded"] = false;
responseData["switched"] = false;
@ -2438,14 +2513,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2477,8 +2552,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] SaveXml: {0}", e.Message);
m_log.DebugFormat("[RADMIN] SaveXml: {0}", e.ToString());
m_log.ErrorFormat("[RADMIN]: SaveXml: {0} {1}", e.Message, e.StackTrace);
responseData["saved"] = false;
responseData["switched"] = false;
@ -2517,14 +2591,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2536,7 +2610,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] RegionQuery: {0}", e.Message);
m_log.InfoFormat("[RADMIN]: RegionQuery: {0}", e.Message);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -2577,7 +2651,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] ConsoleCommand: {0}", e.Message);
m_log.InfoFormat("[RADMIN]: ConsoleCommand: {0}", e.Message);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -2614,14 +2688,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2632,7 +2706,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] Access List Clear Request: {0}", e.Message);
m_log.ErrorFormat("[RADMIN]: Access List Clear Request: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -2671,14 +2745,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2698,7 +2772,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (account != null)
{
uuids.Add(account.PrincipalID);
m_log.DebugFormat("[RADMIN] adding \"{0}\" to ACL for \"{1}\"", name, scene.RegionInfo.RegionName);
m_log.DebugFormat("[RADMIN]: adding \"{0}\" to ACL for \"{1}\"", name, scene.RegionInfo.RegionName);
}
}
List<UUID> accessControlList = new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess);
@ -2719,7 +2793,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] Access List Add Request: {0}", e.Message);
m_log.ErrorFormat("[RADMIN]: Access List Add Request: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -2758,14 +2832,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2806,7 +2880,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] Access List Remove Request: {0}", e.Message);
m_log.ErrorFormat("[RADMIN]: Access List Remove Request: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;
@ -2845,14 +2919,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID region_uuid = (UUID) (string) requestData["region_uuid"];
if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
}
else if (requestData.Contains("region_name"))
{
string region_name = (string) requestData["region_name"];
if (!m_application.SceneManager.TrySetCurrentScene(region_name))
throw new Exception(String.Format("failed to switch to region {0}", region_name));
m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
}
else throw new Exception("neither region_name nor region_uuid given");
@ -2874,7 +2948,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
catch (Exception e)
{
m_log.InfoFormat("[RADMIN] Acces List List: {0}", e.Message);
m_log.ErrorFormat("[RADMIN]: Access List List: {0} {1}", e.Message, e.StackTrace);
responseData["success"] = false;
responseData["error"] = e.Message;

View File

@ -223,7 +223,7 @@ namespace OpenSim.Framework
reqnum,url,method,tickdiff,tickdata);
}
m_log.WarnFormat("[WEB UTIL] <{0}> osd request failed: {1}",reqnum,errorMessage);
m_log.WarnFormat("[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage);
return ErrorResponseMap(errorMessage);
}

View File

@ -471,16 +471,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (m_creatorIdForAssetId.ContainsKey(assetId))
{
string xmlData = Utils.BytesToString(data);
SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
foreach (SceneObjectPart sop in sog.Parts)
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
CoalescedSceneObjects coa = null;
if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa))
{
if (sop.CreatorData == null || sop.CreatorData == "")
{
sop.CreatorID = m_creatorIdForAssetId[assetId];
}
// m_log.DebugFormat(
// "[INVENTORY ARCHIVER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count);
sceneObjects.AddRange(coa.Objects);
}
else
{
sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData));
}
data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
foreach (SceneObjectGroup sog in sceneObjects)
foreach (SceneObjectPart sop in sog.Parts)
if (sop.CreatorData == null || sop.CreatorData == "")
sop.CreatorID = m_creatorIdForAssetId[assetId];
if (coa != null)
data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa));
else
data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sceneObjects[0]));
}
}

View File

@ -68,17 +68,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
FirstName = "Mr",
LastName = "Tiddles" };
protected UserAccount m_uaLL1
= new UserAccount {
PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
FirstName = "Lord",
LastName = "Lucan" };
protected UserAccount m_uaLL2
= new UserAccount {
PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
FirstName = "Lord",
LastName = "Lucan" };
protected string m_item1Name = "Ray Gun Item";
protected string m_coaItemName = "Coalesced Item";
[SetUp]
public virtual void SetUp()
@ -97,38 +101,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// log4net.Config.XmlConfigurator.Configure();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
MemoryStream archiveWriteStream = new MemoryStream();
// Create asset
SceneObjectGroup object1;
SceneObjectPart part1;
{
string partName = "Ray Gun Object";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15);
part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = partName;
object1 = new SceneObjectGroup(part1);
scene.AddNewSceneObject(object1, false);
}
// Create scene object asset
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
scene.AssetService.Store(asset1);
// Create item
// Create scene object item
InventoryItemBase item1 = new InventoryItemBase();
item1.Name = m_item1Name;
item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
@ -139,8 +127,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
scene.AddInventoryItem(item1);
// Create coalesced objects asset
SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);
cobj1.AbsolutePosition = new Vector3(15, 30, 45);
SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);
cobj2.AbsolutePosition = new Vector3(25, 50, 75);
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2);
AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa);
scene.AssetService.Store(coaAsset);
// Create coalesced objects inventory item
InventoryItemBase coaItem = new InventoryItemBase();
coaItem.Name = m_coaItemName;
coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180");
coaItem.AssetID = coaAsset.FullID;
coaItem.GroupID = UUID.Random();
coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID;
coaItem.Owner = m_uaLL1.PrincipalID;
coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
scene.AddInventoryItem(coaItem);
archiverModule.ArchiveInventory(
Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream);
Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream);
m_iarStreamBytes = archiveWriteStream.ToArray();
}

View File

@ -62,10 +62,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
m_archiverModule = new InventoryArchiverModule();
m_scene = SceneSetupHelpers.SetupScene("Inventory");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
}
[Test]
public void TestLoadCoalesecedItem()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password");
m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream);
InventoryItemBase coaItem
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1");
string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID);
CoalescedSceneObjects coa;
bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa);
Assert.That(readResult, Is.True);
Assert.That(coa.Count, Is.EqualTo(2));
List<SceneObjectGroup> coaObjects = coa.Objects;
Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120")));
Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45)));
Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
}
/// <summary>
/// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
/// (subject to change since there is no fixed format yet).
@ -84,24 +114,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
// Create asset
SceneObjectGroup object1;
SceneObjectPart part1;
{
string partName = "My Little Dog Object";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15);
part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = partName;
object1 = new SceneObjectGroup(part1);
m_scene.AddNewSceneObject(object1, false);
}
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);

View File

@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
// Create user
@ -180,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
@ -223,7 +223,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
SerialiserModule serialiserModule = new SerialiserModule();
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
// Create user
@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
@ -394,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
string folder1ExistingName = "a";
@ -445,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
string folder1ExistingName = "a";

View File

@ -129,35 +129,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
///
/// DeleteToInventory
/// Used in DeleteToInventory
///
public override UUID DeleteToInventory(DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
protected override void ExportAsset(UUID agentID, UUID assetID)
{
UUID ret = UUID.Zero;
// HACK: Only works for lists of length one.
// Intermediate version, just to make things compile
foreach (SceneObjectGroup g in objectGroups)
ret = DeleteToInventory(action, folderID, g, remoteClient);
return ret;
}
// DO NOT OVERRIDE THE BASE METHOD
public new virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
SceneObjectGroup objectGroup, IClientAPI remoteClient)
{
UUID assetID = base.DeleteToInventory(action, folderID, new List<SceneObjectGroup>() {objectGroup}, remoteClient);
if (!assetID.Equals(UUID.Zero))
{
if (remoteClient != null)
UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
}
UploadInventoryItem(agentID, assetID, "", 0);
else
m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
return assetID;
}
///

View File

@ -274,153 +274,21 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
foreach (SceneObjectGroup objectGroup in objlist)
objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
// Get the user info of the item destination
//
UUID userID = UUID.Zero;
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
action == DeRezAction.SaveToExistingUserInventoryItem)
{
// Take or take copy require a taker
// Saving changes requires a local user
//
if (remoteClient == null)
return UUID.Zero;
userID = remoteClient.AgentId;
}
else
{
// All returns / deletes go to the object owner
//
userID = objlist[0].RootPart.OwnerID;
}
if (userID == UUID.Zero) // Can't proceed
{
InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID);
if (item == null)
return UUID.Zero;
}
// If we're returning someone's item, it goes back to the
// owner's Lost And Found folder.
// Delete is treated like return in this case
// Deleting your own items makes them go to trash
//
InventoryFolderBase folder = null;
InventoryItemBase item = null;
if (DeRezAction.SaveToExistingUserInventoryItem == action)
// Can't know creator is the same, so null it in inventory
if (objlist.Count > 1)
{
item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID);
item = m_Scene.InventoryService.GetItem(item);
//item = userInfo.RootFolder.FindItem(
// objectGroup.RootPart.FromUserInventoryItemID);
if (null == item)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
objlist[0].Name, objlist[0].UUID);
return UUID.Zero;
}
item.CreatorId = UUID.Zero.ToString();
item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
}
else
{
// Folder magic
//
if (action == DeRezAction.Delete)
{
// Deleting someone else's item
//
if (remoteClient == null ||
objlist[0].OwnerID != remoteClient.AgentId)
{
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
else
{
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
}
}
else if (action == DeRezAction.Return)
{
// Dump to lost + found unconditionally
//
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
if (folderID == UUID.Zero && folder == null)
{
if (action == DeRezAction.Delete)
{
// Deletes go to trash by default
//
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
}
else
{
if (remoteClient == null ||
objlist[0].OwnerID != remoteClient.AgentId)
{
// Taking copy of another person's item. Take to
// Objects folder.
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
}
else
{
// Catch all. Use lost & found
//
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
}
}
// Override and put into where it came from, if it came
// from anywhere in inventory
//
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
{
if (objlist[0].RootPart.FromFolderID != UUID.Zero)
{
InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
folder = m_Scene.InventoryService.GetFolder(f);
}
}
if (folder == null) // None of the above
{
folder = new InventoryFolderBase(folderID);
if (folder == null) // Nowhere to put it
{
return UUID.Zero;
}
}
item = new InventoryItemBase();
// Can't know creator is the same, so null it in inventory
if (objlist.Count > 1)
item.CreatorId = UUID.Zero.ToString();
else
item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
item.ID = UUID.Random();
item.InvType = (int)InventoryType.Object;
item.Folder = folder.ID;
item.Owner = userID;
if (objlist.Count > 1)
{
item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
}
else
{
item.SaleType = objlist[0].RootPart.ObjectSaleType;
item.SalePrice = objlist[0].RootPart.SalePrice;
}
item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
item.SaleType = objlist[0].RootPart.ObjectSaleType;
item.SalePrice = objlist[0].RootPart.SalePrice;
}
AssetBase asset = CreateAsset(
@ -430,59 +298,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
Utils.StringToBytes(itemXml),
objlist[0].OwnerID.ToString());
m_Scene.AssetService.Store(asset);
item.AssetID = asset.FullID;
assetID = asset.FullID;
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item.AssetID = asset.FullID;
m_Scene.InventoryService.UpdateItem(item);
}
else
{
item.AssetID = asset.FullID;
uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
foreach (SceneObjectGroup grp in objlist)
effectivePerms &= grp.GetEffectivePermissions();
effectivePerms |= (uint)PermissionMask.Move;
if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
{
uint perms = effectivePerms;
uint nextPerms = (perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
// Magic number badness. Maybe this deserves an enum.
// bit 4 (16) is the "Slam" bit, it means treat as passed
// and apply next owner perms on rez
item.CurrentPermissions |= 16; // Slam!
}
else
{
item.BasePermissions = effectivePerms;
item.CurrentPermissions = effectivePerms;
item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
item.CurrentPermissions &=
((uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer |
(uint)PermissionMask.Modify |
(uint)PermissionMask.Move |
7); // Preserve folded permissions
}
AddPermissions(item, objlist[0], objlist, remoteClient);
item.CreationDate = Util.UnixTimeSinceEpoch();
item.Description = asset.Description;
@ -504,10 +330,224 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
}
}
// This is a hook to do some per-asset post-processing for subclasses that need that
ExportAsset(remoteClient.AgentId, assetID);
}
return assetID;
}
protected virtual void ExportAsset(UUID agentID, UUID assetID)
{
// nothing to do here
}
/// <summary>
/// Add relevant permissions for an object to the item.
/// </summary>
/// <param name="item"></param>
/// <param name="so"></param>
/// <param name="objsForEffectivePermissions"></param>
/// <param name="remoteClient"></param>
/// <returns></returns>
protected InventoryItemBase AddPermissions(
InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions,
IClientAPI remoteClient)
{
uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
foreach (SceneObjectGroup grp in objsForEffectivePermissions)
effectivePerms &= grp.GetEffectivePermissions();
effectivePerms |= (uint)PermissionMask.Move;
if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
{
uint perms = effectivePerms;
uint nextPerms = (perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
item.BasePermissions = perms & so.RootPart.NextOwnerMask;
item.CurrentPermissions = item.BasePermissions;
item.NextPermissions = perms & so.RootPart.NextOwnerMask;
item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask;
item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask;
// Magic number badness. Maybe this deserves an enum.
// bit 4 (16) is the "Slam" bit, it means treat as passed
// and apply next owner perms on rez
item.CurrentPermissions |= 16; // Slam!
}
else
{
item.BasePermissions = effectivePerms;
item.CurrentPermissions = effectivePerms;
item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms;
item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms;
item.GroupPermissions = so.RootPart.GroupMask & effectivePerms;
item.CurrentPermissions &=
((uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer |
(uint)PermissionMask.Modify |
(uint)PermissionMask.Move |
7); // Preserve folded permissions
}
return item;
}
/// <summary>
/// Create an item using details for the given scene object.
/// </summary>
/// <param name="action"></param>
/// <param name="remoteClient"></param>
/// <param name="so"></param>
/// <param name="folderID"></param>
/// <returns></returns>
protected InventoryItemBase CreateItemForObject(
DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID)
{
// Get the user info of the item destination
//
UUID userID = UUID.Zero;
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
action == DeRezAction.SaveToExistingUserInventoryItem)
{
// Take or take copy require a taker
// Saving changes requires a local user
//
if (remoteClient == null)
return null;
userID = remoteClient.AgentId;
}
else
{
// All returns / deletes go to the object owner
//
userID = so.RootPart.OwnerID;
}
if (userID == UUID.Zero) // Can't proceed
{
return null;
}
// If we're returning someone's item, it goes back to the
// owner's Lost And Found folder.
// Delete is treated like return in this case
// Deleting your own items makes them go to trash
//
InventoryFolderBase folder = null;
InventoryItemBase item = null;
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID);
item = m_Scene.InventoryService.GetItem(item);
//item = userInfo.RootFolder.FindItem(
// objectGroup.RootPart.FromUserInventoryItemID);
if (null == item)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
so.Name, so.UUID);
return null;
}
}
else
{
// Folder magic
//
if (action == DeRezAction.Delete)
{
// Deleting someone else's item
//
if (remoteClient == null ||
so.OwnerID != remoteClient.AgentId)
{
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
else
{
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
}
}
else if (action == DeRezAction.Return)
{
// Dump to lost + found unconditionally
//
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
if (folderID == UUID.Zero && folder == null)
{
if (action == DeRezAction.Delete)
{
// Deletes go to trash by default
//
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
}
else
{
if (remoteClient == null || so.OwnerID != remoteClient.AgentId)
{
// Taking copy of another person's item. Take to
// Objects folder.
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
}
else
{
// Catch all. Use lost & found
//
folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
}
}
// Override and put into where it came from, if it came
// from anywhere in inventory
//
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
{
if (so.RootPart.FromFolderID != UUID.Zero)
{
InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID);
folder = m_Scene.InventoryService.GetFolder(f);
}
}
if (folder == null) // None of the above
{
folder = new InventoryFolderBase(folderID);
if (folder == null) // Nowhere to put it
{
return null;
}
}
item = new InventoryItemBase();
item.ID = UUID.Random();
item.InvType = (int)InventoryType.Object;
item.Folder = folder.ID;
item.Owner = userID;
}
return item;
}
/// <summary>
/// Rez an object into the scene from the user's inventory
/// </summary>

View File

@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
m_scene = SceneSetupHelpers.SetupScene("Inventory");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam);
// Create user
@ -87,41 +87,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1;
{
string partName = "Object1";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = Quaternion.Identity;
Vector3 offsetPosition = new Vector3(5, 10, 15);
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20);
object1.AbsolutePosition = new Vector3(15, 30, 45);
SceneObjectPart part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Scale = new Vector3(1, 1, 1);
part1.Name = partName;
object1 = new SceneObjectGroup(part1);
}
SceneObjectGroup object2;
{
string partName = "Object2";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(20, 40, 60);
Quaternion rotationOffset = Quaternion.Identity;
Vector3 offsetPosition = new Vector3(5, 10, 15);
SceneObjectPart part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Scale = new Vector3(1, 1, 1);
part1.Name = partName;
object2 = new SceneObjectGroup(part1);
}
SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40);
object2.AbsolutePosition = new Vector3(25, 50, 75);
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2);
@ -173,23 +143,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1;
SceneObjectPart part1;
{
string partName = "My Little Dog Object";
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
Vector3 groupPosition = new Vector3(10, 20, 30);
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
Vector3 offsetPosition = new Vector3(5, 10, 15);
part1
= new SceneObjectPart(
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = partName;
object1 = new SceneObjectGroup(part1);
}
SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40);
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);

View File

@ -195,6 +195,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
public byte[] GetData(string id)
{
// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Requesting data for asset {0}", id);
AssetBase asset = m_Cache.Get(id);
if (asset != null)

View File

@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
public void Init()
{
m_serialiserModule = new SerialiserModule();
m_scene = SceneSetupHelpers.SetupScene("");
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule);
}

View File

@ -296,11 +296,14 @@ namespace OpenSim.Region.Framework.Scenes
{
Vector3 val = value;
if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
|| m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
&& !IsAttachmentCheckFull() && (!m_scene.LoadingPrims))
if (Scene != null)
{
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
|| Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
&& !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
{
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
}
}
if (RootPart.GetStatusSandbox())
@ -308,8 +311,11 @@ namespace OpenSim.Region.Framework.Scenes
if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
{
RootPart.ScriptSetPhysicsStatus(false);
Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
if (Scene != null)
Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
return;
}
}
@ -326,7 +332,8 @@ namespace OpenSim.Region.Framework.Scenes
//m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
//}
m_scene.EventManager.TriggerParcelPrimCountTainted();
if (Scene != null)
Scene.EventManager.TriggerParcelPrimCountTainted();
}
}

View File

@ -56,10 +56,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
/// <returns></returns>
public static string ToXml(CoalescedSceneObjects coa)
{
// TODO: Should probably return an empty xml serialization rather than a blank string
if (!coa.HasObjects)
return "";
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
@ -105,10 +101,49 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
string output = sw.ToString();
// m_log.Debug(output);
// Console.WriteLine(output);
return output;
}
}
public static bool TryFromXml(string xml, out CoalescedSceneObjects coa)
{
// m_log.DebugFormat("[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() deserializing {0}", xml);
coa = null;
using (StringReader sr = new StringReader(xml))
{
using (XmlTextReader reader = new XmlTextReader(sr))
{
reader.Read();
if (reader.Name != "CoalescedObject")
{
// m_log.DebugFormat(
// "[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() root element was {0} so returning false",
// reader.Name);
return false;
}
coa = new CoalescedSceneObjects(UUID.Zero);
reader.Read();
while (reader.NodeType != XmlNodeType.EndElement && reader.Name != "CoalescedObject")
{
if (reader.Name == "SceneObjectGroup")
{
string soXml = reader.ReadOuterXml();
coa.Add(SceneObjectSerializer.FromOriginalXmlFormat(soXml));
}
}
reader.ReadEndElement(); // CoalescedObject
}
}
return true;
}
}
}

View File

@ -117,11 +117,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid");
Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010);
SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
sceneB.RegisterRegionWithGrid();
Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid");
Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000);
SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
sceneA.RegisterRegionWithGrid();

View File

@ -101,7 +101,7 @@ namespace OpenSim.Region.Framework.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount user1 = CreateUser(scene);
SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID);
SceneObjectPart sop1 = sog1.RootPart;
@ -127,7 +127,7 @@ namespace OpenSim.Region.Framework.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount user1 = CreateUser(scene);
SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID);
SceneObjectPart sop1 = sog1.RootPart;

View File

@ -47,7 +47,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
[SetUp]
public void Init()
{
m_assetService = new MockAssetService();
// FIXME: We don't need a full scene here - it would be enough to set up the asset service.
Scene scene = SceneSetupHelpers.SetupScene();
m_assetService = scene.AssetService;
m_uuidGatherer = new UuidGatherer(m_assetService);
}

View File

@ -89,6 +89,8 @@ namespace OpenSim.Services.AssetService
public virtual AssetBase Get(string id)
{
// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID))
@ -107,6 +109,8 @@ namespace OpenSim.Services.AssetService
public virtual AssetMetadata GetMetadata(string id)
{
// m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID))
@ -121,6 +125,8 @@ namespace OpenSim.Services.AssetService
public virtual byte[] GetData(string id)
{
// m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID))
@ -150,7 +156,9 @@ namespace OpenSim.Services.AssetService
public virtual string Store(AssetBase asset)
{
//m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
// m_log.DebugFormat(
// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length);
m_Database.StoreAsset(asset);
return asset.ID;

View File

@ -48,6 +48,11 @@ namespace OpenSim.Services.Interfaces
/// <returns></returns>
AssetMetadata GetMetadata(string id);
/// <summary>
/// Get an asset's data, ignoring the metadata.
/// </summary>
/// <param name="id"></param>
/// <returns>null if there is no such asset</returns>
byte[] GetData(string id);
/// <summary>

View File

@ -1,109 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Data;
using OpenSim.Services.Interfaces;
using Nini.Config;
namespace OpenSim.Tests.Common.Mock
{
public class MockAssetService : IAssetService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>();
public MockAssetService() {}
/// <summary>
/// This constructor is required if the asset service is being created reflectively (which is the case in some
/// tests).
/// </summary>
/// <param name="config"></param>
public MockAssetService(IConfigSource config) {}
public AssetBase Get(string id)
{
m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id);
AssetBase asset;
if (Assets.ContainsKey(id))
asset = Assets[id];
else
asset = null;
return asset;
}
public AssetBase GetCached(string id)
{
return Get(id);
}
public AssetMetadata GetMetadata(string id)
{
throw new System.NotImplementedException();
}
public byte[] GetData(string id)
{
throw new System.NotImplementedException();
}
public bool Get(string id, object sender, AssetRetrieved handler)
{
handler(id, sender, Get(id));
return true;
}
public string Store(AssetBase asset)
{
m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID);
Assets[asset.ID] = asset;
return asset.ID;
}
public bool UpdateContent(string id, byte[] data)
{
throw new System.NotImplementedException();
}
public bool Delete(string id)
{
throw new System.NotImplementedException();
}
}
}

View File

@ -1,186 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
using OpenMetaverse;
using OpenSim.Services.Interfaces;
using Nini.Config;
namespace OpenSim.Tests.Common.Mock
{
public class MockInventoryService : IInventoryService
{
public MockInventoryService() {}
public MockInventoryService(IConfigSource config) {}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public bool CreateUserInventory(UUID userId)
{
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
{
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
InventoryFolderBase folder = new InventoryFolderBase();
folder.ID = UUID.Random();
folder.Owner = userId;
folders.Add(folder);
return folders;
}
public InventoryFolderBase GetRootFolder(UUID userID)
{
return new InventoryFolderBase();
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
return null;
}
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
{
return null;
}
/// <summary>
/// Returns a list of all the active gestures in a user's inventory.
/// </summary>
/// <param name="userId">
/// The <see cref="UUID"/> of the user
/// </param>
/// <returns>
/// A flat list of the gesture items.
/// </returns>
public List<InventoryItemBase> GetActiveGestures(UUID userId)
{
return null;
}
public InventoryCollection GetUserInventory(UUID userID)
{
return null;
}
public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
{
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return null;
}
public bool AddFolder(InventoryFolderBase folder)
{
return false;
}
public bool UpdateFolder(InventoryFolderBase folder)
{
return false;
}
public bool MoveFolder(InventoryFolderBase folder)
{
return false;
}
public bool DeleteFolders(UUID ownerID, List<UUID> ids)
{
return false;
}
public bool PurgeFolder(InventoryFolderBase folder)
{
return false;
}
public bool AddItem(InventoryItemBase item)
{
return true;
}
public bool UpdateItem(InventoryItemBase item)
{
return false;
}
public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
{
return false;
}
public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
{
return false;
}
public InventoryItemBase GetItem(InventoryItemBase item)
{
return null;
}
public InventoryFolderBase GetFolder(InventoryFolderBase folder)
{
return null;
}
public bool HasInventoryForUser(UUID userID)
{
return false;
}
public InventoryFolderBase RequestRootFolder(UUID userID)
{
InventoryFolderBase root = new InventoryFolderBase();
root.ID = UUID.Random();
root.Owner = userID;
root.ParentID = UUID.Zero;
return root;
}
public int GetAssetPermissions(UUID userID, UUID assetID)
{
return 1;
}
}
}

View File

@ -30,6 +30,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
namespace OpenSim.Tests.Common
{
@ -72,6 +73,20 @@ namespace OpenSim.Tests.Common
sog.OwnerID);
}
/// <summary>
/// Create an asset from the given scene object.
/// </summary>
/// <param name="assetUuidTailZ">
/// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
/// will be used.
/// </param>
/// <param name="coa"></param>
/// <returns></returns>
public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa)
{
return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa);
}
/// <summary>
/// Create an asset from the given scene object.
/// </summary>
@ -104,5 +119,11 @@ namespace OpenSim.Tests.Common
asset.Data = data;
return asset;
}
public static string ReadAssetAsString(IAssetService assetService, UUID uuid)
{
byte[] assetData = assetService.GetData(uuid.ToString());
return Encoding.ASCII.GetString(assetData);
}
}
}

View File

@ -66,32 +66,7 @@ namespace OpenSim.Tests.Common.Setup
/// <returns></returns>
public static TestScene SetupScene()
{
return SetupScene("");
}
/// <summary>
/// Set up a test scene
/// </summary>
///
/// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
/// <returns></returns>
public static TestScene SetupScene(String realServices)
{
return SetupScene("Unit test region", UUID.Random(), 1000, 1000, realServices);
}
/// <summary>
/// Set up a test scene
/// </summary>
/// <param name="name">Name of the region</param>
/// <param name="id">ID of the region</param>
/// <param name="x">X co-ordinate of the region</param>
/// <param name="y">Y co-ordinate of the region</param>
/// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
/// <returns></returns>
public static TestScene SetupScene(string name, UUID id, uint x, uint y)
{
return SetupScene(name, id, x, y, "");
return SetupScene("Unit test region", UUID.Random(), 1000, 1000);
}
/// <summary>
@ -103,10 +78,8 @@ namespace OpenSim.Tests.Common.Setup
/// <param name="x">X co-ordinate of the region</param>
/// <param name="y">Y co-ordinate of the region</param>
/// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
/// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
/// <returns></returns>
public static TestScene SetupScene(
string name, UUID id, uint x, uint y, String realServices)
public static TestScene SetupScene(string name, UUID id, uint x, uint y)
{
Console.WriteLine("Setting up test scene {0}", name);
@ -130,15 +103,11 @@ namespace OpenSim.Tests.Common.Setup
IRegionModule godsModule = new GodsModule();
godsModule.Initialise(testScene, new IniConfigSource());
testScene.AddModule(godsModule.Name, godsModule);
realServices = realServices.ToLower();
LocalAssetServicesConnector assetService = StartAssetService(testScene, realServices.Contains("asset"));
// For now, always started a 'real' authentication service
StartAuthenticationService(testScene, true);
LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene, realServices.Contains("inventory"));
StartGridService(testScene, true);
LocalAssetServicesConnector assetService = StartAssetService(testScene);
StartAuthenticationService(testScene);
LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene);
StartGridService(testScene);
LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene);
LocalPresenceServicesConnector presenceService = StartPresenceService(testScene);
@ -164,18 +133,17 @@ namespace OpenSim.Tests.Common.Setup
return testScene;
}
private static LocalAssetServicesConnector StartAssetService(Scene testScene, bool real)
private static LocalAssetServicesConnector StartAssetService(Scene testScene)
{
LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("AssetService");
config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
if (real)
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
else
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService");
config.AddConfig("AssetService");
config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
assetService.Initialise(config);
assetService.AddRegion(testScene);
assetService.RegionLoaded(testScene);
@ -184,20 +152,18 @@ namespace OpenSim.Tests.Common.Setup
return assetService;
}
private static void StartAuthenticationService(Scene testScene, bool real)
private static void StartAuthenticationService(Scene testScene)
{
ISharedRegionModule service = new LocalAuthenticationServicesConnector();
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("AuthenticationService");
config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector");
if (real)
config.Configs["AuthenticationService"].Set(
"LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
else
config.Configs["AuthenticationService"].Set(
"LocalServiceModule", "OpenSim.Tests.Common.dll:MockAuthenticationService");
config.Configs["AuthenticationService"].Set(
"LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
service.Initialise(config);
service.AddRegion(testScene);
service.RegionLoaded(testScene);
@ -205,24 +171,17 @@ namespace OpenSim.Tests.Common.Setup
//m_authenticationService = service;
}
private static LocalInventoryServicesConnector StartInventoryService(Scene testScene, bool real)
private static LocalInventoryServicesConnector StartInventoryService(Scene testScene)
{
LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("InventoryService");
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
if (real)
{
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
}
else
{
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockInventoryService");
}
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
inventoryService.Initialise(config);
inventoryService.AddRegion(testScene);
inventoryService.RegionLoaded(testScene);
@ -231,24 +190,19 @@ namespace OpenSim.Tests.Common.Setup
return inventoryService;
}
private static LocalGridServicesConnector StartGridService(Scene testScene, bool real)
private static LocalGridServicesConnector StartGridService(Scene testScene)
{
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.AddConfig("GridService");
config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
if (real)
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
LocalGridServicesConnector gridService = new LocalGridServicesConnector();
gridService.Initialise(config);
//else
// config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
gridService.AddRegion(testScene);
gridService.RegionLoaded(testScene);
//testScene.AddRegionModule(m_gridService.Name, m_gridService);
return gridService;
}
@ -475,7 +429,7 @@ namespace OpenSim.Tests.Common.Setup
{
return new SceneObjectPart(
ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = name, UUID = id };
{ Name = name, UUID = id, Scale = new Vector3(1, 1, 1) };
}
/// <summary>