aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework
diff options
context:
space:
mode:
authorMelanie2010-12-03 02:36:13 +0000
committerMelanie2010-12-03 02:36:13 +0000
commit342dc532ec64642d5997f23050a9776f663facdf (patch)
treeb0be3997967aa6e4d79873281f535ad436b841e4 /OpenSim/Region/CoreModules/Framework
parentChange the way sim health reporting reports sim startup (diff)
parentOnly force prim persistence before delete if the prim is the result of an unp... (diff)
downloadopensim-SC-342dc532ec64642d5997f23050a9776f663facdf.zip
opensim-SC-342dc532ec64642d5997f23050a9776f663facdf.tar.gz
opensim-SC-342dc532ec64642d5997f23050a9776f663facdf.tar.bz2
opensim-SC-342dc532ec64642d5997f23050a9776f663facdf.tar.xz
Merge branch 'master' into careminster-presence-refactor
Also prevent god takes from ending up in Lost and Found
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs83
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs5
4 files changed, 118 insertions, 12 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
index ccb892e..81b65c5 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -27,8 +27,11 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Threading; 32using System.Threading;
33using System.Xml;
34
32using log4net; 35using log4net;
33using OpenMetaverse; 36using OpenMetaverse;
34using OpenSim.Framework; 37using OpenSim.Framework;
@@ -52,14 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); 55// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53 56
54 private Scene m_scene; 57 private Scene m_scene;
58 private string m_ProfileServerURI;
55 59
56 #endregion 60 #endregion
57 61
58 #region Constructor 62 #region Constructor
59 63
60 public HGAssetMapper(Scene scene) 64 public HGAssetMapper(Scene scene, string profileURL)
61 { 65 {
62 m_scene = scene; 66 m_scene = scene;
67 m_ProfileServerURI = profileURL;
63 } 68 }
64 69
65 #endregion 70 #endregion
@@ -95,16 +100,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
95 try 100 try
96 { 101 {
97 asset1.ID = url + "/" + asset.ID; 102 asset1.ID = url + "/" + asset.ID;
98// UUID temp = UUID.Zero;
99 // TODO: if the creator is local, stick this grid's URL in front
100 //if (UUID.TryParse(asset.Metadata.CreatorID, out temp))
101 // asset1.Metadata.CreatorID = ??? + "/" + asset.Metadata.CreatorID;
102 } 103 }
103 catch 104 catch
104 { 105 {
105 m_log.Warn("[HG ASSET MAPPER]: Oops."); 106 m_log.Warn("[HG ASSET MAPPER]: Oops.");
106 } 107 }
107 108
109 AdjustIdentifiers(asset1.Metadata);
110 if (asset1.Metadata.Type == (sbyte)AssetType.Object)
111 asset1.Data = AdjustIdentifiers(asset.Data);
112 else
113 asset1.Data = asset.Data;
114
108 m_scene.AssetService.Store(asset1); 115 m_scene.AssetService.Store(asset1);
109 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); 116 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
110 } 117 }
@@ -118,7 +125,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
118 125
119 private void Copy(AssetBase from, AssetBase to) 126 private void Copy(AssetBase from, AssetBase to)
120 { 127 {
121 to.Data = from.Data; 128 //to.Data = from.Data; // don't copy this, it's copied elsewhere
122 to.Description = from.Description; 129 to.Description = from.Description;
123 to.FullID = from.FullID; 130 to.FullID = from.FullID;
124 to.ID = from.ID; 131 to.ID = from.ID;
@@ -129,6 +136,70 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
129 136
130 } 137 }
131 138
139 private void AdjustIdentifiers(AssetMetadata meta)
140 {
141 if (meta.CreatorID != null && meta.CreatorID != string.Empty)
142 {
143 UUID uuid = UUID.Zero;
144 UUID.TryParse(meta.CreatorID, out uuid);
145 UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
146 if (creator != null)
147 meta.CreatorID = m_ProfileServerURI + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
148 }
149 }
150
151 protected byte[] AdjustIdentifiers(byte[] data)
152 {
153 string xml = Utils.BytesToString(data);
154 return Utils.StringToBytes(RewriteSOP(xml));
155 }
156
157 protected string RewriteSOP(string xml)
158 {
159 XmlDocument doc = new XmlDocument();
160 doc.LoadXml(xml);
161 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
162
163 foreach (XmlNode sop in sops)
164 {
165 UserAccount creator = null;
166 bool hasCreatorData = false;
167 XmlNodeList nodes = sop.ChildNodes;
168 foreach (XmlNode node in nodes)
169 {
170 if (node.Name == "CreatorID")
171 {
172 UUID uuid = UUID.Zero;
173 UUID.TryParse(node.InnerText, out uuid);
174 creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
175 }
176 if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
177 hasCreatorData = true;
178
179 //if (node.Name == "OwnerID")
180 //{
181 // UserAccount owner = GetUser(node.InnerText);
182 // if (owner != null)
183 // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
184 //}
185 }
186
187 if (!hasCreatorData && creator != null)
188 {
189 XmlElement creatorData = doc.CreateElement("CreatorData");
190 creatorData.InnerText = m_ProfileServerURI + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
191 sop.AppendChild(creatorData);
192 }
193 }
194
195 using (StringWriter wr = new StringWriter())
196 {
197 doc.Save(wr);
198 return wr.ToString();
199 }
200
201 }
202
132 // TODO: unused 203 // TODO: unused
133 // private void Dump(Dictionary<UUID, bool> lst) 204 // private void Dump(Dictionary<UUID, bool> lst)
134 // { 205 // {
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 125a397..34b8114 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
54 get { return m_assMapper; } 54 get { return m_assMapper; }
55 } 55 }
56 56
57 private string m_ProfileServerURI;
58
57// private bool m_Initialized = false; 59// private bool m_Initialized = false;
58 60
59 #region INonSharedRegionModule 61 #region INonSharedRegionModule
@@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
73 { 75 {
74 m_Enabled = true; 76 m_Enabled = true;
75 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); 77 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
78
79 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"];
80 if (thisModuleConfig != null)
81 m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty);
82 else
83 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
76 } 84 }
77 } 85 }
78 } 86 }
@@ -83,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
83 return; 91 return;
84 92
85 base.AddRegion(scene); 93 base.AddRegion(scene);
86 m_assMapper = new HGAssetMapper(scene); 94 m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI);
87 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; 95 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
88 96
89 } 97 }
@@ -97,7 +105,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
97 string userAssetServer = string.Empty; 105 string userAssetServer = string.Empty;
98 if (IsForeignUser(avatarID, out userAssetServer)) 106 if (IsForeignUser(avatarID, out userAssetServer))
99 { 107 {
100 m_assMapper.Post(assetID, avatarID, userAssetServer); 108 Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); });
101 } 109 }
102 } 110 }
103 111
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 22da665..623cd3a 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -54,6 +54,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
54 54
55 protected bool m_Enabled = false; 55 protected bool m_Enabled = false;
56 protected Scene m_Scene; 56 protected Scene m_Scene;
57 protected IUserManagement m_UserManagement;
58 protected IUserManagement UserManagementModule
59 {
60 get
61 {
62 if (m_UserManagement == null)
63 m_UserManagement = m_Scene.RequestModuleInterface<IUserManagement>();
64 return m_UserManagement;
65 }
66 }
67
57 68
58 #region INonSharedRegionModule 69 #region INonSharedRegionModule
59 70
@@ -416,7 +427,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
416 // 427 //
417 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 428 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
418 { 429 {
419 if (objlist[0].RootPart.FromFolderID != UUID.Zero) 430 if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId)
420 { 431 {
421 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID); 432 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
422 folder = m_Scene.InventoryService.GetFolder(f); 433 folder = m_Scene.InventoryService.GetFolder(f);
@@ -863,6 +874,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
863 return null; 874 return null;
864 } 875 }
865 876
877 protected void AddUserData(SceneObjectGroup sog)
878 {
879 UserManagementModule.AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData);
880 foreach (SceneObjectPart sop in sog.Parts)
881 UserManagementModule.AddUser(sop.CreatorID, sop.CreatorData);
882 }
883
866 public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) 884 public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
867 { 885 {
868 } 886 }
@@ -943,9 +961,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
943 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) 961 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
944 { 962 {
945 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); 963 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>();
946 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID); 964 InventoryItemBase item = new InventoryItemBase(itemID, agentID);
947 assetRequestItem = invService.GetItem(assetRequestItem); 965 item = invService.GetItem(item);
948 return assetRequestItem; 966
967 if (item.CreatorData != null && item.CreatorData != string.Empty)
968 UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData);
969
970 return item;
949 } 971 }
950 972
951 #endregion 973 #endregion
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 0d94baa..bf84100 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -275,6 +275,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
275 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); 275 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
276 } 276 }
277 277
278 public void AddUser(UUID uuid, string first, string last, string profileURL)
279 {
280 AddUser(uuid, profileURL + ";" + first + " " + last);
281 }
282
278 //public void AddUser(UUID uuid, string userData) 283 //public void AddUser(UUID uuid, string userData)
279 //{ 284 //{
280 // if (m_UserCache.ContainsKey(uuid)) 285 // if (m_UserCache.ContainsKey(uuid))