aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserManager.cs108
1 files changed, 68 insertions, 40 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs
index c40201e..515c2bf 100644
--- a/OpenSim/Grid/UserServer.Modules/UserManager.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserManager.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Grid.UserServer.Modules
41{ 41{
42 public delegate void logOffUser(UUID AgentID); 42 public delegate void logOffUser(UUID AgentID);
43 43
44 public class UserManager 44 public class UserManager
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
@@ -50,12 +50,12 @@ namespace OpenSim.Grid.UserServer.Modules
50 50
51 private UserDataBaseService m_userDataBaseService; 51 private UserDataBaseService m_userDataBaseService;
52 private BaseHttpServer m_httpServer; 52 private BaseHttpServer m_httpServer;
53 53
54 /// <summary> 54 /// <summary>
55 /// 55 ///
56 /// </summary> 56 /// </summary>
57 /// <param name="userDataBaseService"></param> 57 /// <param name="userDataBaseService"></param>
58 public UserManager( UserDataBaseService userDataBaseService) 58 public UserManager(UserDataBaseService userDataBaseService)
59 { 59 {
60 m_userDataBaseService = userDataBaseService; 60 m_userDataBaseService = userDataBaseService;
61 } 61 }
@@ -70,10 +70,38 @@ namespace OpenSim.Grid.UserServer.Modules
70 70
71 } 71 }
72 72
73 private string RESTGetUserProfile(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
74 {
75 UUID id;
76 UserProfileData userProfile;
77
78 try
79 {
80 id = new UUID(param);
81 }
82 catch (Exception)
83 {
84 httpResponse.StatusCode = 500;
85 return "Malformed Param [" + param + "]";
86 }
87
88 userProfile = m_userDataBaseService.GetUserProfile(id);
89
90 if (userProfile == null)
91 {
92 httpResponse.StatusCode = 404;
93 return "Not Found.";
94 }
95
96 return ProfileToXmlRPCResponse(userProfile).ToString();
97 }
98
73 public void RegisterHandlers(BaseHttpServer httpServer) 99 public void RegisterHandlers(BaseHttpServer httpServer)
74 { 100 {
75 m_httpServer = httpServer; 101 m_httpServer = httpServer;
76 102
103 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/users/", RESTGetUserProfile));
104
77 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); 105 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName);
78 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); 106 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
79 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); 107 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
@@ -191,24 +219,24 @@ namespace OpenSim.Grid.UserServer.Modules
191 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) 219 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request)
192 { 220 {
193 // XmlRpcResponse response = new XmlRpcResponse(); 221 // XmlRpcResponse response = new XmlRpcResponse();
194 Hashtable requestData = (Hashtable) request.Params[0]; 222 Hashtable requestData = (Hashtable)request.Params[0];
195 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); 223 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>();
196 UUID queryID = new UUID(UUID.Zero.ToString()); 224 UUID queryID = new UUID(UUID.Zero.ToString());
197 225
198 if (requestData.Contains("avquery") && requestData.Contains("queryid")) 226 if (requestData.Contains("avquery") && requestData.Contains("queryid"))
199 { 227 {
200 queryID = new UUID((string) requestData["queryid"]); 228 queryID = new UUID((string)requestData["queryid"]);
201 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); 229 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string)requestData["avquery"]);
202 } 230 }
203 231
204 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); 232 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string)requestData["avquery"]);
205 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); 233 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar);
206 } 234 }
207 235
208 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request) 236 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request)
209 { 237 {
210 XmlRpcResponse response = new XmlRpcResponse(); 238 XmlRpcResponse response = new XmlRpcResponse();
211 Hashtable requestData = (Hashtable) request.Params[0]; 239 Hashtable requestData = (Hashtable)request.Params[0];
212 Hashtable responseData = new Hashtable(); 240 Hashtable responseData = new Hashtable();
213 string returnstring = "FALSE"; 241 string returnstring = "FALSE";
214 242
@@ -219,14 +247,14 @@ namespace OpenSim.Grid.UserServer.Modules
219 UUID regionUUID; 247 UUID regionUUID;
220 UUID avatarUUID; 248 UUID avatarUUID;
221 249
222 UUID.TryParse((string) requestData["avatar_id"], out avatarUUID); 250 UUID.TryParse((string)requestData["avatar_id"], out avatarUUID);
223 UUID.TryParse((string) requestData["region_uuid"], out regionUUID); 251 UUID.TryParse((string)requestData["region_uuid"], out regionUUID);
224 252
225 if (avatarUUID != UUID.Zero) 253 if (avatarUUID != UUID.Zero)
226 { 254 {
227 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID); 255 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID);
228 userProfile.CurrentAgent.Region = regionUUID; 256 userProfile.CurrentAgent.Region = regionUUID;
229 userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); 257 userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
230 //userProfile.CurrentAgent. 258 //userProfile.CurrentAgent.
231 m_userDataBaseService.CommitAgent(ref userProfile); 259 m_userDataBaseService.CommitAgent(ref userProfile);
232 //setUserProfile(userProfile); 260 //setUserProfile(userProfile);
@@ -243,11 +271,11 @@ namespace OpenSim.Grid.UserServer.Modules
243 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) 271 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
244 { 272 {
245 // XmlRpcResponse response = new XmlRpcResponse(); 273 // XmlRpcResponse response = new XmlRpcResponse();
246 Hashtable requestData = (Hashtable) request.Params[0]; 274 Hashtable requestData = (Hashtable)request.Params[0];
247 UserProfileData userProfile; 275 UserProfileData userProfile;
248 if (requestData.Contains("avatar_name")) 276 if (requestData.Contains("avatar_name"))
249 { 277 {
250 string query = (string) requestData["avatar_name"]; 278 string query = (string)requestData["avatar_name"];
251 279
252 if (null == query) 280 if (null == query)
253 return CreateUnknownUserErrorResponse(); 281 return CreateUnknownUserErrorResponse();
@@ -280,7 +308,7 @@ namespace OpenSim.Grid.UserServer.Modules
280 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) 308 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
281 { 309 {
282 // XmlRpcResponse response = new XmlRpcResponse(); 310 // XmlRpcResponse response = new XmlRpcResponse();
283 Hashtable requestData = (Hashtable) request.Params[0]; 311 Hashtable requestData = (Hashtable)request.Params[0];
284 UserProfileData userProfile; 312 UserProfileData userProfile;
285 //CFK: this clogs the UserServer log and is not necessary at this time. 313 //CFK: this clogs the UserServer log and is not necessary at this time.
286 //CFK: m_log.Debug("METHOD BY UUID CALLED"); 314 //CFK: m_log.Debug("METHOD BY UUID CALLED");
@@ -288,7 +316,7 @@ namespace OpenSim.Grid.UserServer.Modules
288 { 316 {
289 try 317 try
290 { 318 {
291 UUID guess = new UUID((string) requestData["avatar_uuid"]); 319 UUID guess = new UUID((string)requestData["avatar_uuid"]);
292 320
293 userProfile = m_userDataBaseService.GetUserProfile(guess); 321 userProfile = m_userDataBaseService.GetUserProfile(guess);
294 } 322 }
@@ -313,7 +341,7 @@ namespace OpenSim.Grid.UserServer.Modules
313 public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request) 341 public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request)
314 { 342 {
315 XmlRpcResponse response = new XmlRpcResponse(); 343 XmlRpcResponse response = new XmlRpcResponse();
316 Hashtable requestData = (Hashtable) request.Params[0]; 344 Hashtable requestData = (Hashtable)request.Params[0];
317 UserProfileData userProfile; 345 UserProfileData userProfile;
318 //CFK: this clogs the UserServer log and is not necessary at this time. 346 //CFK: this clogs the UserServer log and is not necessary at this time.
319 //CFK: m_log.Debug("METHOD BY UUID CALLED"); 347 //CFK: m_log.Debug("METHOD BY UUID CALLED");
@@ -321,7 +349,7 @@ namespace OpenSim.Grid.UserServer.Modules
321 { 349 {
322 UUID guess; 350 UUID guess;
323 351
324 UUID.TryParse((string) requestData["avatar_uuid"], out guess); 352 UUID.TryParse((string)requestData["avatar_uuid"], out guess);
325 353
326 if (guess == UUID.Zero) 354 if (guess == UUID.Zero)
327 { 355 {
@@ -362,7 +390,7 @@ namespace OpenSim.Grid.UserServer.Modules
362 public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request) 390 public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request)
363 { 391 {
364 XmlRpcResponse response = new XmlRpcResponse(); 392 XmlRpcResponse response = new XmlRpcResponse();
365 Hashtable requestData = (Hashtable) request.Params[0]; 393 Hashtable requestData = (Hashtable)request.Params[0];
366 UserProfileData userProfile; 394 UserProfileData userProfile;
367 395
368 string authed = "FALSE"; 396 string authed = "FALSE";
@@ -371,12 +399,12 @@ namespace OpenSim.Grid.UserServer.Modules
371 UUID guess_aid; 399 UUID guess_aid;
372 UUID guess_sid; 400 UUID guess_sid;
373 401
374 UUID.TryParse((string) requestData["avatar_uuid"], out guess_aid); 402 UUID.TryParse((string)requestData["avatar_uuid"], out guess_aid);
375 if (guess_aid == UUID.Zero) 403 if (guess_aid == UUID.Zero)
376 { 404 {
377 return CreateUnknownUserErrorResponse(); 405 return CreateUnknownUserErrorResponse();
378 } 406 }
379 UUID.TryParse((string) requestData["session_id"], out guess_sid); 407 UUID.TryParse((string)requestData["session_id"], out guess_sid);
380 if (guess_sid == UUID.Zero) 408 if (guess_sid == UUID.Zero)
381 { 409 {
382 return CreateUnknownUserErrorResponse(); 410 return CreateUnknownUserErrorResponse();
@@ -404,7 +432,7 @@ namespace OpenSim.Grid.UserServer.Modules
404 { 432 {
405 m_log.Debug("[UserManager]: Got request to update user profile"); 433 m_log.Debug("[UserManager]: Got request to update user profile");
406 XmlRpcResponse response = new XmlRpcResponse(); 434 XmlRpcResponse response = new XmlRpcResponse();
407 Hashtable requestData = (Hashtable) request.Params[0]; 435 Hashtable requestData = (Hashtable)request.Params[0];
408 Hashtable responseData = new Hashtable(); 436 Hashtable responseData = new Hashtable();
409 437
410 if (!requestData.Contains("avatar_uuid")) 438 if (!requestData.Contains("avatar_uuid"))
@@ -412,7 +440,7 @@ namespace OpenSim.Grid.UserServer.Modules
412 return CreateUnknownUserErrorResponse(); 440 return CreateUnknownUserErrorResponse();
413 } 441 }
414 442
415 UUID UserUUID = new UUID((string) requestData["avatar_uuid"]); 443 UUID UserUUID = new UUID((string)requestData["avatar_uuid"]);
416 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); 444 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID);
417 if (null == userProfile) 445 if (null == userProfile)
418 { 446 {
@@ -424,11 +452,11 @@ namespace OpenSim.Grid.UserServer.Modules
424 } 452 }
425 if (requestData.Contains("FLImageID")) 453 if (requestData.Contains("FLImageID"))
426 { 454 {
427 userProfile.FirstLifeImage = new UUID((string) requestData["FLImageID"]); 455 userProfile.FirstLifeImage = new UUID((string)requestData["FLImageID"]);
428 } 456 }
429 if (requestData.Contains("ImageID")) 457 if (requestData.Contains("ImageID"))
430 { 458 {
431 userProfile.Image = new UUID((string) requestData["ImageID"]); 459 userProfile.Image = new UUID((string)requestData["ImageID"]);
432 } 460 }
433 // dont' know how yet 461 // dont' know how yet
434 if (requestData.Contains("MaturePublish")) 462 if (requestData.Contains("MaturePublish"))
@@ -436,11 +464,11 @@ namespace OpenSim.Grid.UserServer.Modules
436 } 464 }
437 if (requestData.Contains("AboutText")) 465 if (requestData.Contains("AboutText"))
438 { 466 {
439 userProfile.AboutText = (string) requestData["AboutText"]; 467 userProfile.AboutText = (string)requestData["AboutText"];
440 } 468 }
441 if (requestData.Contains("FLAboutText")) 469 if (requestData.Contains("FLAboutText"))
442 { 470 {
443 userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"]; 471 userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"];
444 } 472 }
445 // not in DB yet. 473 // not in DB yet.
446 if (requestData.Contains("ProfileURL")) 474 if (requestData.Contains("ProfileURL"))
@@ -450,7 +478,7 @@ namespace OpenSim.Grid.UserServer.Modules
450 { 478 {
451 try 479 try
452 { 480 {
453 userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]); 481 userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]);
454 } 482 }
455 catch (ArgumentException) 483 catch (ArgumentException)
456 { 484 {
@@ -468,14 +496,14 @@ namespace OpenSim.Grid.UserServer.Modules
468 if (requestData.Contains("home_region_id")) 496 if (requestData.Contains("home_region_id"))
469 { 497 {
470 UUID regionID; 498 UUID regionID;
471 UUID.TryParse((string) requestData["home_region_id"], out regionID); 499 UUID.TryParse((string)requestData["home_region_id"], out regionID);
472 userProfile.HomeRegionID = regionID; 500 userProfile.HomeRegionID = regionID;
473 } 501 }
474 if (requestData.Contains("home_pos_x")) 502 if (requestData.Contains("home_pos_x"))
475 { 503 {
476 try 504 try
477 { 505 {
478 userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]); 506 userProfile.HomeLocationX = (float)Convert.ToDecimal((string)requestData["home_pos_x"]);
479 } 507 }
480 catch (InvalidCastException) 508 catch (InvalidCastException)
481 { 509 {
@@ -486,7 +514,7 @@ namespace OpenSim.Grid.UserServer.Modules
486 { 514 {
487 try 515 try
488 { 516 {
489 userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]); 517 userProfile.HomeLocationY = (float)Convert.ToDecimal((string)requestData["home_pos_y"]);
490 } 518 }
491 catch (InvalidCastException) 519 catch (InvalidCastException)
492 { 520 {
@@ -497,7 +525,7 @@ namespace OpenSim.Grid.UserServer.Modules
497 { 525 {
498 try 526 try
499 { 527 {
500 userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]); 528 userProfile.HomeLocationZ = (float)Convert.ToDecimal((string)requestData["home_pos_z"]);
501 } 529 }
502 catch (InvalidCastException) 530 catch (InvalidCastException)
503 { 531 {
@@ -508,7 +536,7 @@ namespace OpenSim.Grid.UserServer.Modules
508 { 536 {
509 try 537 try
510 { 538 {
511 userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]); 539 userProfile.HomeLookAtX = (float)Convert.ToDecimal((string)requestData["home_look_x"]);
512 } 540 }
513 catch (InvalidCastException) 541 catch (InvalidCastException)
514 { 542 {
@@ -519,7 +547,7 @@ namespace OpenSim.Grid.UserServer.Modules
519 { 547 {
520 try 548 try
521 { 549 {
522 userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]); 550 userProfile.HomeLookAtY = (float)Convert.ToDecimal((string)requestData["home_look_y"]);
523 } 551 }
524 catch (InvalidCastException) 552 catch (InvalidCastException)
525 { 553 {
@@ -530,7 +558,7 @@ namespace OpenSim.Grid.UserServer.Modules
530 { 558 {
531 try 559 try
532 { 560 {
533 userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]); 561 userProfile.HomeLookAtZ = (float)Convert.ToDecimal((string)requestData["home_look_z"]);
534 } 562 }
535 catch (InvalidCastException) 563 catch (InvalidCastException)
536 { 564 {
@@ -541,7 +569,7 @@ namespace OpenSim.Grid.UserServer.Modules
541 { 569 {
542 try 570 try
543 { 571 {
544 userProfile.UserFlags = Convert.ToInt32((string) requestData["user_flags"]); 572 userProfile.UserFlags = Convert.ToInt32((string)requestData["user_flags"]);
545 } 573 }
546 catch (InvalidCastException) 574 catch (InvalidCastException)
547 { 575 {
@@ -552,7 +580,7 @@ namespace OpenSim.Grid.UserServer.Modules
552 { 580 {
553 try 581 try
554 { 582 {
555 userProfile.GodLevel = Convert.ToInt32((string) requestData["god_level"]); 583 userProfile.GodLevel = Convert.ToInt32((string)requestData["god_level"]);
556 } 584 }
557 catch (InvalidCastException) 585 catch (InvalidCastException)
558 { 586 {
@@ -563,7 +591,7 @@ namespace OpenSim.Grid.UserServer.Modules
563 { 591 {
564 try 592 try
565 { 593 {
566 userProfile.CustomType = (string) requestData["custom_type"]; 594 userProfile.CustomType = (string)requestData["custom_type"];
567 } 595 }
568 catch (InvalidCastException) 596 catch (InvalidCastException)
569 { 597 {
@@ -574,7 +602,7 @@ namespace OpenSim.Grid.UserServer.Modules
574 { 602 {
575 try 603 try
576 { 604 {
577 userProfile.Partner = new UUID((string) requestData["partner"]); 605 userProfile.Partner = new UUID((string)requestData["partner"]);
578 } 606 }
579 catch (InvalidCastException) 607 catch (InvalidCastException)
580 { 608 {
@@ -596,7 +624,7 @@ namespace OpenSim.Grid.UserServer.Modules
596 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) 624 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
597 { 625 {
598 XmlRpcResponse response = new XmlRpcResponse(); 626 XmlRpcResponse response = new XmlRpcResponse();
599 Hashtable requestData = (Hashtable) request.Params[0]; 627 Hashtable requestData = (Hashtable)request.Params[0];
600 628
601 if (requestData.Contains("avatar_uuid")) 629 if (requestData.Contains("avatar_uuid"))
602 { 630 {
@@ -685,6 +713,6 @@ namespace OpenSim.Grid.UserServer.Modules
685 public void HandleRegionShutdown(UUID regionID) 713 public void HandleRegionShutdown(UUID regionID)
686 { 714 {
687 m_userDataBaseService.LogoutUsers(regionID); 715 m_userDataBaseService.LogoutUsers(regionID);
688 } 716 }
689 } 717 }
690} 718}