aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2010-01-15 17:24:41 -0800
committerDiva Canto2010-01-15 17:24:41 -0800
commit32bfbdab6f6bbbfaae0df0ab410af7b9c42a3a4f (patch)
treee20c1afa3edc76101eea15765a447b13b3c4946e /OpenSim/Services
parentComment (diff)
parentMerge branch 'master' into presence-refactor (diff)
downloadopensim-SC_OLD-32bfbdab6f6bbbfaae0df0ab410af7b9c42a3a4f.zip
opensim-SC_OLD-32bfbdab6f6bbbfaae0df0ab410af7b9c42a3a4f.tar.gz
opensim-SC_OLD-32bfbdab6f6bbbfaae0df0ab410af7b9c42a3a4f.tar.bz2
opensim-SC_OLD-32bfbdab6f6bbbfaae0df0ab410af7b9c42a3a4f.tar.xz
Merge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs3
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs18
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs535
-rw-r--r--OpenSim/Services/GridService/GridService.cs37
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs2
5 files changed, 580 insertions, 15 deletions
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
index a1c032e..4eb4bd2 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors
67 IConfig authorizationConfig = source.Configs["AuthorizationService"]; 67 IConfig authorizationConfig = source.Configs["AuthorizationService"];
68 if (authorizationConfig == null) 68 if (authorizationConfig == null)
69 { 69 {
70 m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini"); 70 //m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
71 throw new Exception("Authorization connector init error"); 71 throw new Exception("Authorization connector init error");
72 } 72 }
73 73
@@ -86,6 +86,7 @@ namespace OpenSim.Services.Connectors
86 bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true); 86 bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true);
87 87
88 m_ResponseOnFailure = responseOnFailure; 88 m_ResponseOnFailure = responseOnFailure;
89 m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService initialized");
89 } 90 }
90 91
91 public bool IsAuthorizedForRegion(string userID, string firstname, string surname, string email, string regionName, string regionID, out string message) 92 public bool IsAuthorizedForRegion(string userID, string firstname, string surname, string email, string regionName, string regionID, out string message)
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index cf112e1..a1ca58e 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Services.Connectors
86 86
87 #region IGridService 87 #region IGridService
88 88
89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) 89 public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo)
90 { 90 {
91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); 91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
92 Dictionary<string, object> sendData = new Dictionary<string,object>(); 92 Dictionary<string, object> sendData = new Dictionary<string,object>();
@@ -110,11 +110,23 @@ namespace OpenSim.Services.Connectors
110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
111 111
112 if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success")) 112 if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
113 return true; 113 {
114 return String.Empty;
115 }
116 else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
117 {
118 m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
119 return replyData["Message"].ToString();
120 }
114 else if (!replyData.ContainsKey("Result")) 121 else if (!replyData.ContainsKey("Result"))
122 {
115 m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); 123 m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
124 }
116 else 125 else
126 {
117 m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); 127 m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
128 return "Unexpected result "+replyData["Result"].ToString();
129 }
118 130
119 } 131 }
120 else 132 else
@@ -125,7 +137,7 @@ namespace OpenSim.Services.Connectors
125 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); 137 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
126 } 138 }
127 139
128 return false; 140 return "Error communicating with grid service";
129 } 141 }
130 142
131 public virtual bool DeregisterRegion(UUID regionID) 143 public virtual bool DeregisterRegion(UUID regionID)
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
new file mode 100644
index 0000000..b9ccd7e
--- /dev/null
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
@@ -0,0 +1,535 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Services.Interfaces;
39using OpenSim.Server.Base;
40using OpenMetaverse;
41
42namespace OpenSim.Services.Connectors
43{
44 public class XInventoryServicesConnector : IInventoryService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 public XInventoryServicesConnector()
53 {
54 }
55
56 public XInventoryServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public XInventoryServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig assetConfig = source.Configs["InventoryService"];
69 if (assetConfig == null)
70 {
71 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpanSim.ini");
72 throw new Exception("Inventory connector init error");
73 }
74
75 string serviceURI = assetConfig.GetString("InventoryServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[INVENTORY CONNECTOR]: No Server URI named in section InventoryService");
81 throw new Exception("Inventory connector init error");
82 }
83 m_ServerURI = serviceURI;
84 }
85
86 public bool CreateUserInventory(UUID principalID)
87 {
88 Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY",
89 new Dictionary<string,object> {
90 { "PRINCIPAL", principalID.ToString() }
91 });
92
93 if (ret == null)
94 return false;
95
96 return bool.Parse(ret["RESULT"].ToString());
97 }
98
99 public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
100 {
101 Dictionary<string,object> ret = MakeRequest("GETINVENTORYSKELETON",
102 new Dictionary<string,object> {
103 { "PRINCIPAL", principalID.ToString() }
104 });
105
106 if (ret == null)
107 return null;
108
109 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
110
111 foreach (Object o in ret.Values)
112 folders.Add(BuildFolder((Dictionary<string,object>)o));
113
114 return folders;
115 }
116
117 public InventoryFolderBase GetRootFolder(UUID principalID)
118 {
119 Dictionary<string,object> ret = MakeRequest("GETROOTFOLDER",
120 new Dictionary<string,object> {
121 { "PRINCIPAL", principalID.ToString() }
122 });
123
124 if (ret == null)
125 return null;
126
127 if (ret.Count == 0)
128 return null;
129
130 return BuildFolder(ret);
131 }
132
133 public InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
134 {
135 Dictionary<string,object> ret = MakeRequest("GETFOLDERFORTYPE",
136 new Dictionary<string,object> {
137 { "PRINCIPAL", principalID.ToString() },
138 { "TYPE", ((int)type).ToString() }
139 });
140
141 if (ret == null)
142 return null;
143
144 if (ret.Count == 0)
145 return null;
146
147 return BuildFolder(ret);
148 }
149
150 public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
151 {
152 Dictionary<string,object> ret = MakeRequest("GETFOLDERCONTENT",
153 new Dictionary<string,object> {
154 { "PRINCIPAL", principalID.ToString() },
155 { "FOLDER", folderID.ToString() }
156 });
157
158 if (ret == null)
159 return null;
160
161 if (ret.Count == 0)
162 return null;
163
164
165 InventoryCollection inventory = new InventoryCollection();
166 inventory.Folders = new List<InventoryFolderBase>();
167 inventory.Items = new List<InventoryItemBase>();
168 inventory.UserID = principalID;
169
170 Dictionary<string,object> folders =
171 (Dictionary<string,object>)ret["FOLDERS"];
172 Dictionary<string,object> items =
173 (Dictionary<string,object>)ret["ITEMS"];
174
175 foreach (Object o in folders.Values)
176 inventory.Folders.Add(BuildFolder((Dictionary<string,object>)o));
177 foreach (Object o in items.Values)
178 inventory.Items.Add(BuildItem((Dictionary<string,object>)o));
179
180 return inventory;
181 }
182
183 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
184 {
185 Dictionary<string,object> ret = MakeRequest("GETFOLDERCONTENT",
186 new Dictionary<string,object> {
187 { "PRINCIPAL", principalID.ToString() },
188 { "FOLDER", folderID.ToString() }
189 });
190
191 if (ret == null)
192 return null;
193
194 if (ret.Count == 0)
195 return null;
196
197
198 List<InventoryItemBase> items = new List<InventoryItemBase>();
199
200 foreach (Object o in ret.Values)
201 items.Add(BuildItem((Dictionary<string,object>)o));
202
203 return items;
204 }
205
206 public bool AddFolder(InventoryFolderBase folder)
207 {
208 Dictionary<string,object> ret = MakeRequest("ADDFOLDER",
209 new Dictionary<string,object> {
210 { "ParentID", folder.ParentID.ToString() },
211 { "Type", folder.Type.ToString() },
212 { "Version", folder.Version.ToString() },
213 { "Name", folder.Name.ToString() },
214 { "Owner", folder.Owner.ToString() },
215 { "ID", folder.ID.ToString() }
216 });
217
218 if (ret == null)
219 return false;
220
221 return bool.Parse(ret["RESULT"].ToString());
222 }
223
224 public bool UpdateFolder(InventoryFolderBase folder)
225 {
226 Dictionary<string,object> ret = MakeRequest("UPDATEFOLDER",
227 new Dictionary<string,object> {
228 { "ParentID", folder.ParentID.ToString() },
229 { "Type", folder.Type.ToString() },
230 { "Version", folder.Version.ToString() },
231 { "Name", folder.Name.ToString() },
232 { "Owner", folder.Owner.ToString() },
233 { "ID", folder.ID.ToString() }
234 });
235
236 if (ret == null)
237 return false;
238
239 return bool.Parse(ret["RESULT"].ToString());
240 }
241
242 public bool MoveFolder(InventoryFolderBase folder)
243 {
244 Dictionary<string,object> ret = MakeRequest("MOVEFOLDER",
245 new Dictionary<string,object> {
246 { "ParentID", folder.ParentID.ToString() },
247 { "ID", folder.ID.ToString() }
248 });
249
250 if (ret == null)
251 return false;
252
253 return bool.Parse(ret["RESULT"].ToString());
254 }
255
256 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
257 {
258 List<string> slist = new List<string>();
259
260 foreach (UUID f in folderIDs)
261 slist.Add(f.ToString());
262
263 Dictionary<string,object> ret = MakeRequest("DELETEFOLDERS",
264 new Dictionary<string,object> {
265 { "PRINCIPAL", principalID.ToString() },
266 { "FOLDERS", slist }
267 });
268
269 if (ret == null)
270 return false;
271
272 return bool.Parse(ret["RESULT"].ToString());
273 }
274
275 public bool PurgeFolder(InventoryFolderBase folder)
276 {
277 Dictionary<string,object> ret = MakeRequest("PURGEFOLDER",
278 new Dictionary<string,object> {
279 { "ID", folder.ID.ToString() }
280 });
281
282 if (ret == null)
283 return false;
284
285 return bool.Parse(ret["RESULT"].ToString());
286 }
287
288 public bool AddItem(InventoryItemBase item)
289 {
290 Dictionary<string,object> ret = MakeRequest("ADDITEM",
291 new Dictionary<string,object> {
292 { "AssetID", item.AssetID.ToString() },
293 { "AssetType", item.AssetType.ToString() },
294 { "Name", item.Name.ToString() },
295 { "Owner", item.Owner.ToString() },
296 { "ID", item.ID.ToString() },
297 { "InvType", item.InvType.ToString() },
298 { "Folder", item.Folder.ToString() },
299 { "CreatorId", item.CreatorId.ToString() },
300 { "Description", item.Description.ToString() },
301 { "NextPermissions", item.NextPermissions.ToString() },
302 { "CurrentPermissions", item.CurrentPermissions.ToString() },
303 { "BasePermissions", item.BasePermissions.ToString() },
304 { "EveryOnePermissions", item.EveryOnePermissions.ToString() },
305 { "GroupPermissions", item.GroupPermissions.ToString() },
306 { "GroupID", item.GroupID.ToString() },
307 { "GroupOwned", item.GroupOwned.ToString() },
308 { "SalePrice", item.SalePrice.ToString() },
309 { "SaleType", item.SaleType.ToString() },
310 { "Flags", item.Flags.ToString() },
311 { "CreationDate", item.CreationDate.ToString() }
312 });
313
314 if (ret == null)
315 return false;
316
317 return bool.Parse(ret["RESULT"].ToString());
318 }
319
320 public bool UpdateItem(InventoryItemBase item)
321 {
322 Dictionary<string,object> ret = MakeRequest("UPDATEITEM",
323 new Dictionary<string,object> {
324 { "AssetID", item.AssetID.ToString() },
325 { "AssetType", item.AssetType.ToString() },
326 { "Name", item.Name.ToString() },
327 { "Owner", item.Owner.ToString() },
328 { "ID", item.ID.ToString() },
329 { "InvType", item.InvType.ToString() },
330 { "Folder", item.Folder.ToString() },
331 { "CreatorId", item.CreatorId.ToString() },
332 { "Description", item.Description.ToString() },
333 { "NextPermissions", item.NextPermissions.ToString() },
334 { "CurrentPermissions", item.CurrentPermissions.ToString() },
335 { "BasePermissions", item.BasePermissions.ToString() },
336 { "EveryOnePermissions", item.EveryOnePermissions.ToString() },
337 { "GroupPermissions", item.GroupPermissions.ToString() },
338 { "GroupID", item.GroupID.ToString() },
339 { "GroupOwned", item.GroupOwned.ToString() },
340 { "SalePrice", item.SalePrice.ToString() },
341 { "SaleType", item.SaleType.ToString() },
342 { "Flags", item.Flags.ToString() },
343 { "CreationDate", item.CreationDate.ToString() }
344 });
345
346 if (ret == null)
347 return false;
348
349 return bool.Parse(ret["RESULT"].ToString());
350 }
351
352 public bool MoveItems(UUID principalID, List<InventoryItemBase> items)
353 {
354 List<string> idlist = new List<string>();
355 List<string> destlist = new List<string>();
356
357 foreach (InventoryItemBase item in items)
358 {
359 idlist.Add(item.ID.ToString());
360 destlist.Add(item.Folder.ToString());
361 }
362
363 Dictionary<string,object> ret = MakeRequest("MOVEITEMS",
364 new Dictionary<string,object> {
365 { "PrincipalID", principalID.ToString() },
366 { "IDLIST", idlist },
367 { "DESTLIST", destlist }
368 });
369
370 if (ret == null)
371 return false;
372
373 return bool.Parse(ret["RESULT"].ToString());
374 }
375
376 public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
377 {
378 List<string> slist = new List<string>();
379
380 foreach (UUID f in itemIDs)
381 slist.Add(f.ToString());
382
383 Dictionary<string,object> ret = MakeRequest("DELETEITEMS",
384 new Dictionary<string,object> {
385 { "PRINCIPAL", principalID.ToString() },
386 { "ITEMS", slist }
387 });
388
389 if (ret == null)
390 return false;
391
392 return bool.Parse(ret["RESULT"].ToString());
393 }
394
395 public InventoryItemBase GetItem(InventoryItemBase item)
396 {
397 Dictionary<string,object> ret = MakeRequest("GETITEM",
398 new Dictionary<string,object> {
399 { "ID", item.ID.ToString() }
400 });
401
402 if (ret == null)
403 return null;
404
405 if (ret.Count == 0)
406 return null;
407
408 return BuildItem(ret);
409 }
410
411 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
412 {
413 Dictionary<string,object> ret = MakeRequest("GETFOLDER",
414 new Dictionary<string,object> {
415 { "ID", folder.ID.ToString() }
416 });
417
418 if (ret == null)
419 return null;
420
421 if (ret.Count == 0)
422 return null;
423
424 return BuildFolder(ret);
425 }
426
427 public List<InventoryItemBase> GetActiveGestures(UUID principalID)
428 {
429 Dictionary<string,object> ret = MakeRequest("GETACTIVEGESTURES",
430 new Dictionary<string,object> {
431 { "PRINCIPAL", principalID.ToString() }
432 });
433
434 if (ret == null)
435 return null;
436
437 List<InventoryItemBase> items = new List<InventoryItemBase>();
438
439 foreach (Object o in ret.Values)
440 items.Add(BuildItem((Dictionary<string,object>)o));
441
442 return items;
443 }
444
445 public int GetAssetPermissions(UUID principalID, UUID assetID)
446 {
447 Dictionary<string,object> ret = MakeRequest("GETASSETPERMISSIONS",
448 new Dictionary<string,object> {
449 { "PRINCIPAL", principalID.ToString() },
450 { "ASSET", assetID.ToString() }
451 });
452
453 if (ret == null)
454 return 0;
455
456 return int.Parse(ret["RESULT"].ToString());
457 }
458
459
460 // These are either obsolete or unused
461 //
462 public InventoryCollection GetUserInventory(UUID principalID)
463 {
464 return null;
465 }
466
467 public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback)
468 {
469 }
470
471 public bool HasInventoryForUser(UUID principalID)
472 {
473 return false;
474 }
475
476 // Helpers
477 //
478 private Dictionary<string,object> MakeRequest(string method,
479 Dictionary<string,object> sendData)
480 {
481 sendData["METHOD"] = method;
482
483 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
484 m_ServerURI + "/xinventory",
485 ServerUtils.BuildQueryString(sendData));
486
487 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
488 reply);
489
490 return replyData;
491 }
492
493 private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
494 {
495 InventoryFolderBase folder = new InventoryFolderBase();
496
497 folder.ParentID = new UUID(data["ParentID"].ToString());
498 folder.Type = short.Parse(data["Type"].ToString());
499 folder.Version = ushort.Parse(data["Version"].ToString());
500 folder.Name = data["Name"].ToString();
501 folder.Owner = new UUID(data["Owner"].ToString());
502 folder.ID = new UUID(data["ID"].ToString());
503
504 return folder;
505 }
506
507 private InventoryItemBase BuildItem(Dictionary<string,object> data)
508 {
509 InventoryItemBase item = new InventoryItemBase();
510
511 item.AssetID = new UUID(data["AssetID"].ToString());
512 item.AssetType = int.Parse(data["AssetType"].ToString());
513 item.Name = data["Name"].ToString();
514 item.Owner = new UUID(data["Owner"].ToString());
515 item.ID = new UUID(data["ID"].ToString());
516 item.InvType = int.Parse(data["InvType"].ToString());
517 item.Folder = new UUID(data["Folder"].ToString());
518 item.CreatorId = data["CreatorId"].ToString();
519 item.Description = data["Description"].ToString();
520 item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
521 item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());
522 item.BasePermissions = uint.Parse(data["BasePermissions"].ToString());
523 item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString());
524 item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString());
525 item.GroupID = new UUID(data["GroupID"].ToString());
526 item.GroupOwned = bool.Parse(data["GroupOwned"].ToString());
527 item.SalePrice = int.Parse(data["SalePrice"].ToString());
528 item.SaleType = byte.Parse(data["SaleType"].ToString());
529 item.Flags = uint.Parse(data["Flags"].ToString());
530 item.CreationDate = int.Parse(data["CreationDate"].ToString());
531
532 return item;
533 }
534 }
535}
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 5c55c0b..e912705 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Services.GridService
52 protected IConfigSource m_config; 52 protected IConfigSource m_config;
53 53
54 protected IAuthenticationService m_AuthenticationService = null; 54 protected IAuthenticationService m_AuthenticationService = null;
55 protected bool m_AllowDuplicateNames = false;
55 56
56 public GridService(IConfigSource config) 57 public GridService(IConfigSource config)
57 : base(config) 58 : base(config)
@@ -71,6 +72,7 @@ namespace OpenSim.Services.GridService
71 Object[] args = new Object[] { config }; 72 Object[] args = new Object[] { config };
72 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 73 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
73 } 74 }
75 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
74 } 76 }
75 77
76 if (m_RootInstance == null) 78 if (m_RootInstance == null)
@@ -95,7 +97,7 @@ namespace OpenSim.Services.GridService
95 97
96 #region IGridService 98 #region IGridService
97 99
98 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) 100 public string RegisterRegion(UUID scopeID, GridRegion regionInfos)
99 { 101 {
100 IConfig gridConfig = m_config.Configs["GridService"]; 102 IConfig gridConfig = m_config.Configs["GridService"];
101 // This needs better sanity testing. What if regionInfo is registering in 103 // This needs better sanity testing. What if regionInfo is registering in
@@ -116,7 +118,7 @@ namespace OpenSim.Services.GridService
116 // Regions reserved for the null key cannot be taken. 118 // Regions reserved for the null key cannot be taken.
117 // 119 //
118 if (region.Data["PrincipalID"] == UUID.Zero.ToString()) 120 if (region.Data["PrincipalID"] == UUID.Zero.ToString())
119 return false; 121 return "Region location us reserved";
120 122
121 // Treat it as an auth request 123 // Treat it as an auth request
122 // 124 //
@@ -132,12 +134,10 @@ namespace OpenSim.Services.GridService
132 // Can we authenticate at all? 134 // Can we authenticate at all?
133 // 135 //
134 if (m_AuthenticationService == null) 136 if (m_AuthenticationService == null)
135 return false; 137 return "No authentication possible";
136 138
137 if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30)) 139 if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30))
138 return false; 140 return "Bad authentication";
139
140 return false;
141 } 141 }
142 } 142 }
143 143
@@ -145,13 +145,13 @@ namespace OpenSim.Services.GridService
145 { 145 {
146 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", 146 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
147 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 147 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
148 return false; 148 return "Region overlaps another region";
149 } 149 }
150 if ((region != null) && (region.RegionID == regionInfos.RegionID) && 150 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
151 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) 151 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
152 { 152 {
153 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) 153 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0)
154 return false; 154 return "Can't move this region";
155 155
156 // Region reregistering in other coordinates. Delete the old entry 156 // Region reregistering in other coordinates. Delete the old entry
157 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", 157 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
@@ -167,6 +167,23 @@ namespace OpenSim.Services.GridService
167 } 167 }
168 } 168 }
169 169
170 if (!m_AllowDuplicateNames)
171 {
172 List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID);
173 if (dupe != null && dupe.Count > 0)
174 {
175 foreach (RegionData d in dupe)
176 {
177 if (d.RegionID != regionInfos.RegionID)
178 {
179 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.",
180 regionInfos.RegionName, regionInfos.RegionID);
181 return "Duplicate region name";
182 }
183 }
184 }
185 }
186
170 // Everything is ok, let's register 187 // Everything is ok, let's register
171 RegionData rdata = RegionInfo2RegionData(regionInfos); 188 RegionData rdata = RegionInfo2RegionData(regionInfos);
172 rdata.ScopeID = scopeID; 189 rdata.ScopeID = scopeID;
@@ -175,7 +192,7 @@ namespace OpenSim.Services.GridService
175 { 192 {
176 int oldFlags = Convert.ToInt32(region.Data["flags"]); 193 int oldFlags = Convert.ToInt32(region.Data["flags"]);
177 if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) 194 if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0)
178 return false; 195 return "Region locked out";
179 196
180 oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; 197 oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation;
181 198
@@ -211,7 +228,7 @@ namespace OpenSim.Services.GridService
211 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", 228 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}",
212 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); 229 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
213 230
214 return true; 231 return String.Empty;
215 } 232 }
216 233
217 public bool DeregisterRegion(UUID regionID) 234 public bool DeregisterRegion(UUID regionID)
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 6b6b347..6186d80 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Services.Interfaces
42 /// <param name="regionInfos"> </param> 42 /// <param name="regionInfos"> </param>
43 /// <returns></returns> 43 /// <returns></returns>
44 /// <exception cref="System.Exception">Thrown if region registration failed</exception> 44 /// <exception cref="System.Exception">Thrown if region registration failed</exception>
45 bool RegisterRegion(UUID scopeID, GridRegion regionInfos); 45 string RegisterRegion(UUID scopeID, GridRegion regionInfos);
46 46
47 /// <summary> 47 /// <summary>
48 /// Deregister a region with the grid service. 48 /// Deregister a region with the grid service.