diff options
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Services/Connectors')
7 files changed, 225 insertions, 18 deletions
diff --git a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs index bb5d51f..c395178 100644 --- a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs | |||
@@ -45,6 +45,24 @@ namespace OpenSim.Services.Connectors | |||
45 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private Dictionary<IAssetService, object> m_endpointSerializer = new Dictionary<IAssetService, object>(); | ||
49 | private object EndPointLock(IAssetService connector) | ||
50 | { | ||
51 | lock (m_endpointSerializer) | ||
52 | { | ||
53 | object eplock = null; | ||
54 | |||
55 | if (! m_endpointSerializer.TryGetValue(connector, out eplock)) | ||
56 | { | ||
57 | eplock = new object(); | ||
58 | m_endpointSerializer.Add(connector, eplock); | ||
59 | // m_log.WarnFormat("[WEB UTIL] add a new host to end point serializer {0}",endpoint); | ||
60 | } | ||
61 | |||
62 | return eplock; | ||
63 | } | ||
64 | } | ||
65 | |||
48 | private Dictionary<string, IAssetService> m_connectors = new Dictionary<string, IAssetService>(); | 66 | private Dictionary<string, IAssetService> m_connectors = new Dictionary<string, IAssetService>(); |
49 | 67 | ||
50 | public HGAssetServiceConnector(IConfigSource source) | 68 | public HGAssetServiceConnector(IConfigSource source) |
@@ -197,7 +215,8 @@ namespace OpenSim.Services.Connectors | |||
197 | IAssetService connector = GetConnector(url); | 215 | IAssetService connector = GetConnector(url); |
198 | // Restore the assetID to a simple UUID | 216 | // Restore the assetID to a simple UUID |
199 | asset.ID = assetID; | 217 | asset.ID = assetID; |
200 | return connector.Store(asset); | 218 | lock (EndPointLock(connector)) |
219 | return connector.Store(asset); | ||
201 | } | 220 | } |
202 | 221 | ||
203 | return String.Empty; | 222 | return String.Empty; |
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs index eea9853..3fd0c53 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs | |||
@@ -43,8 +43,18 @@ namespace OpenSim.Services.Connectors.Friends | |||
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | protected virtual string ServicePath() | ||
47 | { | ||
48 | return "friends"; | ||
49 | } | ||
50 | |||
46 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) | 51 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) |
47 | { | 52 | { |
53 | return FriendshipOffered(region, userID, friendID, message, String.Empty); | ||
54 | } | ||
55 | |||
56 | public virtual bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message, string userName) | ||
57 | { | ||
48 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 58 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
49 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | 59 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
50 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | 60 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
@@ -53,9 +63,10 @@ namespace OpenSim.Services.Connectors.Friends | |||
53 | sendData["FromID"] = userID.ToString(); | 63 | sendData["FromID"] = userID.ToString(); |
54 | sendData["ToID"] = friendID.ToString(); | 64 | sendData["ToID"] = friendID.ToString(); |
55 | sendData["Message"] = message; | 65 | sendData["Message"] = message; |
66 | if (userName != String.Empty) | ||
67 | sendData["FromName"] = userName; | ||
56 | 68 | ||
57 | return Call(region, sendData); | 69 | return Call(region, sendData); |
58 | |||
59 | } | 70 | } |
60 | 71 | ||
61 | public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) | 72 | public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) |
@@ -138,8 +149,11 @@ namespace OpenSim.Services.Connectors.Friends | |||
138 | if (region == null) | 149 | if (region == null) |
139 | return false; | 150 | return false; |
140 | 151 | ||
141 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: region: {0}", region.ExternalHostName + ":" + region.HttpPort); | 152 | string path = ServicePath(); |
142 | string uri = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/friends"; | 153 | if (!region.ServerURI.EndsWith("/")) |
154 | path = "/" + path; | ||
155 | string uri = region.ServerURI + path; | ||
156 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); | ||
143 | 157 | ||
144 | try | 158 | try |
145 | { | 159 | { |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs index af4b0da..e984a54 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs | |||
@@ -40,7 +40,7 @@ using OpenMetaverse; | |||
40 | 40 | ||
41 | namespace OpenSim.Services.Connectors.Hypergrid | 41 | namespace OpenSim.Services.Connectors.Hypergrid |
42 | { | 42 | { |
43 | public class HGFriendsServicesConnector | 43 | public class HGFriendsServicesConnector : FriendsSimConnector |
44 | { | 44 | { |
45 | private static readonly ILog m_log = | 45 | private static readonly ILog m_log = |
46 | LogManager.GetLogger( | 46 | LogManager.GetLogger( |
@@ -66,6 +66,11 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
66 | m_SessionID = sessionID; | 66 | m_SessionID = sessionID; |
67 | } | 67 | } |
68 | 68 | ||
69 | protected override string ServicePath() | ||
70 | { | ||
71 | return "hgfriends"; | ||
72 | } | ||
73 | |||
69 | #region IFriendsService | 74 | #region IFriendsService |
70 | 75 | ||
71 | public uint GetFriendPerms(UUID PrincipalID, UUID friendID) | 76 | public uint GetFriendPerms(UUID PrincipalID, UUID friendID) |
@@ -187,23 +192,121 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
187 | { | 192 | { |
188 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 193 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
189 | 194 | ||
190 | if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null)) | 195 | if (replyData.ContainsKey("RESULT")) |
191 | { | 196 | { |
192 | bool success = false; | 197 | if (replyData["RESULT"].ToString().ToLower() == "true") |
193 | Boolean.TryParse(replyData["Result"].ToString(), out success); | 198 | return true; |
194 | return success; | 199 | else |
200 | return false; | ||
195 | } | 201 | } |
196 | else | 202 | else |
197 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Delete {0} {1} received null response", | 203 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: reply data does not contain result field"); |
198 | PrincipalID, Friend); | 204 | |
199 | } | 205 | } |
200 | else | 206 | else |
201 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: DeleteFriend received null reply"); | 207 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: received empty reply"); |
202 | 208 | ||
203 | return false; | 209 | return false; |
204 | 210 | ||
205 | } | 211 | } |
206 | 212 | ||
213 | public bool ValidateFriendshipOffered(UUID fromID, UUID toID) | ||
214 | { | ||
215 | FriendInfo finfo = new FriendInfo(); | ||
216 | finfo.PrincipalID = fromID; | ||
217 | finfo.Friend = toID.ToString(); | ||
218 | |||
219 | Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); | ||
220 | |||
221 | sendData["METHOD"] = "validate_friendship_offered"; | ||
222 | |||
223 | string reply = string.Empty; | ||
224 | string uri = m_ServerURI + "/hgfriends"; | ||
225 | try | ||
226 | { | ||
227 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
228 | uri, | ||
229 | ServerUtils.BuildQueryString(sendData)); | ||
230 | } | ||
231 | catch (Exception e) | ||
232 | { | ||
233 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); | ||
234 | return false; | ||
235 | } | ||
236 | |||
237 | if (reply != string.Empty) | ||
238 | { | ||
239 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
240 | |||
241 | if (replyData.ContainsKey("RESULT")) | ||
242 | { | ||
243 | if (replyData["RESULT"].ToString().ToLower() == "true") | ||
244 | return true; | ||
245 | else | ||
246 | return false; | ||
247 | } | ||
248 | else | ||
249 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: reply data does not contain result field"); | ||
250 | |||
251 | } | ||
252 | else | ||
253 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: received empty reply"); | ||
254 | |||
255 | return false; | ||
256 | |||
257 | } | ||
258 | |||
259 | public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online) | ||
260 | { | ||
261 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
262 | List<UUID> friendsOnline = new List<UUID>(); | ||
263 | |||
264 | sendData["METHOD"] = "statusnotification"; | ||
265 | sendData["userID"] = userID.ToString(); | ||
266 | sendData["online"] = online.ToString(); | ||
267 | int i = 0; | ||
268 | foreach (string s in friends) | ||
269 | { | ||
270 | sendData["friend_" + i.ToString()] = s; | ||
271 | i++; | ||
272 | } | ||
273 | |||
274 | string reply = string.Empty; | ||
275 | string uri = m_ServerURI + "/hgfriends"; | ||
276 | try | ||
277 | { | ||
278 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
279 | uri, | ||
280 | ServerUtils.BuildQueryString(sendData)); | ||
281 | } | ||
282 | catch (Exception e) | ||
283 | { | ||
284 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); | ||
285 | return friendsOnline; | ||
286 | } | ||
287 | |||
288 | if (reply != string.Empty) | ||
289 | { | ||
290 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
291 | |||
292 | // Here is the actual response | ||
293 | foreach (string key in replyData.Keys) | ||
294 | { | ||
295 | if (key.StartsWith("friend_") && replyData[key] != null) | ||
296 | { | ||
297 | UUID uuid; | ||
298 | if (UUID.TryParse(replyData[key].ToString(), out uuid)) | ||
299 | friendsOnline.Add(uuid); | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | else | ||
304 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Received empty reply from remote StatusNotify"); | ||
305 | |||
306 | return friendsOnline; | ||
307 | |||
308 | } | ||
309 | |||
207 | #endregion | 310 | #endregion |
208 | } | 311 | } |
209 | } \ No newline at end of file | 312 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 5b27cf6..2f263ae 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -417,6 +417,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
417 | GetBoolResponse(request, out reason); | 417 | GetBoolResponse(request, out reason); |
418 | } | 418 | } |
419 | 419 | ||
420 | [Obsolete] | ||
420 | public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online) | 421 | public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online) |
421 | { | 422 | { |
422 | Hashtable hash = new Hashtable(); | 423 | Hashtable hash = new Hashtable(); |
@@ -789,13 +790,72 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
789 | } | 790 | } |
790 | catch | 791 | catch |
791 | { | 792 | { |
792 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); | 793 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response."); |
793 | // reason = "Exception: " + e.Message; | 794 | // reason = "Exception: " + e.Message; |
794 | } | 795 | } |
795 | 796 | ||
796 | return uui; | 797 | return uui; |
797 | } | 798 | } |
798 | 799 | ||
800 | public UUID GetUUID(String first, String last) | ||
801 | { | ||
802 | Hashtable hash = new Hashtable(); | ||
803 | hash["first"] = first; | ||
804 | hash["last"] = last; | ||
805 | |||
806 | IList paramList = new ArrayList(); | ||
807 | paramList.Add(hash); | ||
808 | |||
809 | XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList); | ||
810 | // string reason = string.Empty; | ||
811 | |||
812 | // Send and get reply | ||
813 | UUID uuid = UUID.Zero; | ||
814 | XmlRpcResponse response = null; | ||
815 | try | ||
816 | { | ||
817 | response = request.Send(m_ServerURL, 10000); | ||
818 | } | ||
819 | catch | ||
820 | { | ||
821 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL); | ||
822 | // reason = "Exception: " + e.Message; | ||
823 | return uuid; | ||
824 | } | ||
825 | |||
826 | if (response.IsFault) | ||
827 | { | ||
828 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString); | ||
829 | // reason = "XMLRPC Fault"; | ||
830 | return uuid; | ||
831 | } | ||
832 | |||
833 | hash = (Hashtable)response.Value; | ||
834 | //foreach (Object o in hash) | ||
835 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
836 | try | ||
837 | { | ||
838 | if (hash == null) | ||
839 | { | ||
840 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); | ||
841 | // reason = "Internal error 1"; | ||
842 | return uuid; | ||
843 | } | ||
844 | |||
845 | // Here's the actual response | ||
846 | if (hash.ContainsKey("UUID")) | ||
847 | UUID.TryParse(hash["UUID"].ToString(), out uuid); | ||
848 | |||
849 | } | ||
850 | catch | ||
851 | { | ||
852 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); | ||
853 | // reason = "Exception: " + e.Message; | ||
854 | } | ||
855 | |||
856 | return uuid; | ||
857 | } | ||
858 | |||
799 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) | 859 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) |
800 | { | 860 | { |
801 | //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); | 861 | //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); |
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index a662abb..39e983b 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs | |||
@@ -48,6 +48,8 @@ namespace OpenSim.Services.Connectors | |||
48 | 48 | ||
49 | private string m_ServerURI = String.Empty; | 49 | private string m_ServerURI = String.Empty; |
50 | 50 | ||
51 | private object m_Lock = new object(); | ||
52 | |||
51 | public XInventoryServicesConnector() | 53 | public XInventoryServicesConnector() |
52 | { | 54 | { |
53 | } | 55 | } |
@@ -514,9 +516,11 @@ namespace OpenSim.Services.Connectors | |||
514 | { | 516 | { |
515 | sendData["METHOD"] = method; | 517 | sendData["METHOD"] = method; |
516 | 518 | ||
517 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | 519 | string reply = string.Empty; |
518 | m_ServerURI + "/xinventory", | 520 | lock (m_Lock) |
519 | ServerUtils.BuildQueryString(sendData)); | 521 | reply = SynchronousRestFormsRequester.MakeRequest("POST", |
522 | m_ServerURI + "/xinventory", | ||
523 | ServerUtils.BuildQueryString(sendData)); | ||
520 | 524 | ||
521 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( | 525 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( |
522 | reply); | 526 | reply); |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 99523a1..6bfc5cc 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -477,7 +477,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
477 | // Grab the asset data from the response stream | 477 | // Grab the asset data from the response stream |
478 | using (MemoryStream stream = new MemoryStream()) | 478 | using (MemoryStream stream = new MemoryStream()) |
479 | { | 479 | { |
480 | responseStream.CopyTo(stream, 4096); | 480 | responseStream.CopyStream(stream, Int32.MaxValue); |
481 | asset.Data = stream.ToArray(); | 481 | asset.Data = stream.ToArray(); |
482 | } | 482 | } |
483 | } | 483 | } |
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs index 609dafe..6d5ce28 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs | |||
@@ -197,8 +197,15 @@ namespace OpenSim.Services.Connectors | |||
197 | 197 | ||
198 | Dictionary<string, object> structData = data.ToKeyValuePairs(); | 198 | Dictionary<string, object> structData = data.ToKeyValuePairs(); |
199 | 199 | ||
200 | foreach (KeyValuePair<string,object> kvp in structData) | 200 | foreach (KeyValuePair<string, object> kvp in structData) |
201 | { | ||
202 | if (kvp.Value == null) | ||
203 | { | ||
204 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Null value for {0}", kvp.Key); | ||
205 | continue; | ||
206 | } | ||
201 | sendData[kvp.Key] = kvp.Value.ToString(); | 207 | sendData[kvp.Key] = kvp.Value.ToString(); |
208 | } | ||
202 | 209 | ||
203 | return SendAndGetBoolReply(sendData); | 210 | return SendAndGetBoolReply(sendData); |
204 | } | 211 | } |