diff options
author | Sean Dague | 2008-12-03 19:19:46 +0000 |
---|---|---|
committer | Sean Dague | 2008-12-03 19:19:46 +0000 |
commit | b337088997c021194069952344e3377ef9ece136 (patch) | |
tree | 8ae974d5f3fff507b850552eed8638e892aaadac /OpenSim/ApplicationPlugins | |
parent | Extends Avatar Appearance tests (diff) | |
download | opensim-SC_OLD-b337088997c021194069952344e3377ef9ece136.zip opensim-SC_OLD-b337088997c021194069952344e3377ef9ece136.tar.gz opensim-SC_OLD-b337088997c021194069952344e3377ef9ece136.tar.bz2 opensim-SC_OLD-b337088997c021194069952344e3377ef9ece136.tar.xz |
* Locked some RemoteAdmin methods due to racing condition bad behavior.
* Methods locked: CreateRegion, DeleteRegion, CreateUser, CreateUserMethodEmail,
UpdateUserAccountMethod, LoadOARMethod, LoadXMLMethod
* An example of bad behavior was multiple region creation where same UUID and
grid location was possible, by running multiple XMLRPC threads.
From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
Diffstat (limited to 'OpenSim/ApplicationPlugins')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 799 |
1 files changed, 407 insertions, 392 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index cf60484..44f9c1a 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -380,165 +380,166 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
380 | XmlRpcResponse response = new XmlRpcResponse(); | 380 | XmlRpcResponse response = new XmlRpcResponse(); |
381 | Hashtable responseData = new Hashtable(); | 381 | Hashtable responseData = new Hashtable(); |
382 | 382 | ||
383 | int m_regionLimit = m_config.GetInt("region_limit", 0); | 383 | lock(this) { |
384 | int m_regionLimit = m_config.GetInt("region_limit", 0); | ||
384 | 385 | ||
385 | try { | 386 | try { |
386 | Hashtable requestData = (Hashtable) request.Params[0]; | 387 | Hashtable requestData = (Hashtable) request.Params[0]; |
387 | 388 | ||
388 | checkStringParameters(request, new string[] { "password", | 389 | checkStringParameters(request, new string[] { "password", |
389 | "region_name", | 390 | "region_name", |
390 | "region_master_first", "region_master_last", | 391 | "region_master_first", "region_master_last", |
391 | "region_master_password", | 392 | "region_master_password", |
392 | "listen_ip", "external_address"}); | 393 | "listen_ip", "external_address"}); |
393 | checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); | 394 | checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); |
394 | 395 | ||
395 | // check password | 396 | // check password |
396 | if (!String.IsNullOrEmpty(requiredPassword) && | 397 | if (!String.IsNullOrEmpty(requiredPassword) && |
397 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | 398 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); |
398 | 399 | ||
399 | // check whether we still have space left (iff we are using limits) | 400 | // check whether we still have space left (iff we are using limits) |
400 | if (m_regionLimit != 0 && m_app.SceneManager.Scenes.Count >= m_regionLimit) | 401 | if (m_regionLimit != 0 && m_app.SceneManager.Scenes.Count >= m_regionLimit) |
401 | throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first", m_regionLimit)); | 402 | throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first", m_regionLimit)); |
402 | 403 | ||
403 | 404 | ||
404 | // extract or generate region ID now | 405 | // extract or generate region ID now |
405 | Scene scene = null; | 406 | Scene scene = null; |
406 | UUID regionID = UUID.Zero; | 407 | UUID regionID = UUID.Zero; |
407 | if (requestData.ContainsKey("region_id") && | 408 | if (requestData.ContainsKey("region_id") && |
408 | !String.IsNullOrEmpty((string)requestData["region_id"])) | 409 | !String.IsNullOrEmpty((string)requestData["region_id"])) |
409 | { | 410 | { |
410 | regionID = (UUID)(string)requestData["region_id"]; | 411 | regionID = (UUID)(string)requestData["region_id"]; |
411 | if (m_app.SceneManager.TryGetScene(regionID, out scene)) | 412 | if (m_app.SceneManager.TryGetScene(regionID, out scene)) |
412 | throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", | 413 | throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", |
413 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | 414 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, |
414 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | 415 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); |
415 | } | 416 | } |
416 | else | 417 | else |
417 | { | 418 | { |
418 | regionID = UUID.Random(); | 419 | regionID = UUID.Random(); |
419 | m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID); | 420 | m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID); |
420 | } | 421 | } |
421 | 422 | ||
422 | // create volatile or persistent region info | 423 | // create volatile or persistent region info |
423 | RegionInfo region = new RegionInfo(); | 424 | RegionInfo region = new RegionInfo(); |
424 | 425 | ||
425 | region.RegionID = regionID; | 426 | region.RegionID = regionID; |
426 | region.RegionName = (string) requestData["region_name"]; | 427 | region.RegionName = (string) requestData["region_name"]; |
427 | region.RegionLocX = Convert.ToUInt32(requestData["region_x"]); | 428 | region.RegionLocX = Convert.ToUInt32(requestData["region_x"]); |
428 | region.RegionLocY = Convert.ToUInt32(requestData["region_y"]); | 429 | region.RegionLocY = Convert.ToUInt32(requestData["region_y"]); |
429 | 430 | ||
430 | // check for collisions: region name, region UUID, | 431 | // check for collisions: region name, region UUID, |
431 | // region location | 432 | // region location |
432 | if (m_app.SceneManager.TryGetScene(region.RegionName, out scene)) | 433 | if (m_app.SceneManager.TryGetScene(region.RegionName, out scene)) |
433 | throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", | 434 | throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", |
434 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | 435 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, |
435 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | 436 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); |
436 | 437 | ||
437 | if (m_app.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) | 438 | if (m_app.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) |
438 | throw new Exception(String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", | 439 | throw new Exception(String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", |
439 | region.RegionLocX, region.RegionLocY, | 440 | region.RegionLocX, region.RegionLocY, |
440 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | 441 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, |
441 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | 442 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); |
442 | 443 | ||
443 | region.InternalEndPoint = | 444 | region.InternalEndPoint = |
444 | new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); | 445 | new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); |
445 | 446 | ||
446 | region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]); | 447 | region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]); |
447 | if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); | 448 | if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); |
448 | if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) | 449 | if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) |
449 | throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", | 450 | throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", |
450 | region.InternalEndPoint.Address, | 451 | region.InternalEndPoint.Address, |
451 | region.InternalEndPoint.Port, | 452 | region.InternalEndPoint.Port, |
452 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | 453 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, |
453 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | 454 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); |
454 | 455 | ||
455 | 456 | ||
456 | region.ExternalHostName = (string)requestData["external_address"]; | 457 | region.ExternalHostName = (string)requestData["external_address"]; |
457 | 458 | ||
458 | string masterFirst = (string)requestData["region_master_first"]; | 459 | string masterFirst = (string)requestData["region_master_first"]; |
459 | string masterLast = (string)requestData["region_master_last"]; | 460 | string masterLast = (string)requestData["region_master_last"]; |
460 | string masterPassword = (string)requestData["region_master_password"]; | 461 | string masterPassword = (string)requestData["region_master_password"]; |
461 | 462 | ||
462 | UUID userID = UUID.Zero; | 463 | UUID userID = UUID.Zero; |
463 | if (requestData.ContainsKey("region_master_uuid")) | 464 | if (requestData.ContainsKey("region_master_uuid")) |
464 | { | ||
465 | // ok, client wants us to use an explicit UUID | ||
466 | // regardless of what the avatar name provided | ||
467 | userID = new UUID((string)requestData["region_master_uuid"]); | ||
468 | } | ||
469 | else | ||
470 | { | ||
471 | // no client supplied UUID: look it up... | ||
472 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(masterFirst, masterLast); | ||
473 | if (null == userProfile) | ||
474 | { | 465 | { |
475 | m_log.InfoFormat("master avatar does not exist, creating it"); | 466 | // ok, client wants us to use an explicit UUID |
476 | // ...or create new user | 467 | // regardless of what the avatar name provided |
477 | userID = m_app.CommunicationsManager.UserAdminService.AddUser( | 468 | userID = new UUID((string)requestData["region_master_uuid"]); |
478 | masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY); | ||
479 | |||
480 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | ||
481 | masterFirst, masterLast)); | ||
482 | } | 469 | } |
483 | else | 470 | else |
484 | { | 471 | { |
485 | userID = userProfile.ID; | 472 | // no client supplied UUID: look it up... |
473 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(masterFirst, masterLast); | ||
474 | if (null == userProfile) | ||
475 | { | ||
476 | m_log.InfoFormat("master avatar does not exist, creating it"); | ||
477 | // ...or create new user | ||
478 | userID = m_app.CommunicationsManager.UserAdminService.AddUser( | ||
479 | masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY); | ||
480 | |||
481 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | ||
482 | masterFirst, masterLast)); | ||
483 | } | ||
484 | else | ||
485 | { | ||
486 | userID = userProfile.ID; | ||
487 | } | ||
486 | } | 488 | } |
487 | } | ||
488 | 489 | ||
489 | region.MasterAvatarFirstName = masterFirst; | 490 | region.MasterAvatarFirstName = masterFirst; |
490 | region.MasterAvatarLastName = masterLast; | 491 | region.MasterAvatarLastName = masterLast; |
491 | region.MasterAvatarSandboxPassword = masterPassword; | 492 | region.MasterAvatarSandboxPassword = masterPassword; |
492 | region.MasterAvatarAssignedUUID = userID; | 493 | region.MasterAvatarAssignedUUID = userID; |
493 | 494 | ||
494 | bool persist = Convert.ToBoolean((string)requestData["persist"]); | 495 | bool persist = Convert.ToBoolean((string)requestData["persist"]); |
495 | if (persist) | 496 | if (persist) |
496 | { | ||
497 | // default place for region XML files is in the | ||
498 | // Regions directory of the config dir (aka /bin) | ||
499 | string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); | ||
500 | try | ||
501 | { | ||
502 | // OpenSim.ini can specify a different regions dir | ||
503 | IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; | ||
504 | regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); | ||
505 | } | ||
506 | catch (Exception) | ||
507 | { | 497 | { |
508 | // No INI setting recorded. | 498 | // default place for region XML files is in the |
499 | // Regions directory of the config dir (aka /bin) | ||
500 | string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); | ||
501 | try | ||
502 | { | ||
503 | // OpenSim.ini can specify a different regions dir | ||
504 | IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; | ||
505 | regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); | ||
506 | } | ||
507 | catch (Exception) | ||
508 | { | ||
509 | // No INI setting recorded. | ||
510 | } | ||
511 | string regionXmlPath = Path.Combine(regionConfigPath, | ||
512 | String.Format(m_config.GetString("region_file_template", "{0}x{1}-{2}.xml"), | ||
513 | region.RegionLocX.ToString(), | ||
514 | region.RegionLocY.ToString(), | ||
515 | regionID.ToString(), | ||
516 | region.InternalEndPoint.Port.ToString(), | ||
517 | region.RegionName.Replace(" ", "_").Replace(":", "_").Replace("/", "_"))); | ||
518 | m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", | ||
519 | region.RegionID, regionXmlPath); | ||
520 | region.SaveRegionToFile("dynamic region", regionXmlPath); | ||
509 | } | 521 | } |
510 | string regionXmlPath = Path.Combine(regionConfigPath, | ||
511 | String.Format(m_config.GetString("region_file_template", "{0}x{1}-{2}.xml"), | ||
512 | region.RegionLocX.ToString(), | ||
513 | region.RegionLocY.ToString(), | ||
514 | regionID.ToString(), | ||
515 | region.InternalEndPoint.Port.ToString(), | ||
516 | region.RegionName.Replace(" ", "_").Replace(":", "_").Replace("/", "_"))); | ||
517 | m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", | ||
518 | region.RegionID, regionXmlPath); | ||
519 | region.SaveRegionToFile("dynamic region", regionXmlPath); | ||
520 | } | ||
521 | 522 | ||
522 | m_app.CreateRegion(region); | 523 | m_app.CreateRegion(region); |
523 | 524 | ||
524 | responseData["success"] = "true"; | 525 | responseData["success"] = "true"; |
525 | responseData["region_name"] = region.RegionName; | 526 | responseData["region_name"] = region.RegionName; |
526 | responseData["region_uuid"] = region.RegionID.ToString(); | 527 | responseData["region_uuid"] = region.RegionID.ToString(); |
527 | 528 | ||
528 | response.Value = responseData; | 529 | response.Value = responseData; |
529 | } | 530 | } |
530 | catch (Exception e) | 531 | catch (Exception e) |
531 | { | 532 | { |
532 | m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message); | 533 | m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message); |
533 | m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString()); | 534 | m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString()); |
534 | 535 | ||
535 | responseData["success"] = "false"; | 536 | responseData["success"] = "false"; |
536 | responseData["error"] = e.Message; | 537 | responseData["error"] = e.Message; |
537 | 538 | ||
538 | response.Value = responseData; | 539 | response.Value = responseData; |
540 | } | ||
541 | return response; | ||
539 | } | 542 | } |
540 | |||
541 | return response; | ||
542 | } | 543 | } |
543 | 544 | ||
544 | /// <summary> | 545 | /// <summary> |
@@ -573,34 +574,37 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
573 | XmlRpcResponse response = new XmlRpcResponse(); | 574 | XmlRpcResponse response = new XmlRpcResponse(); |
574 | Hashtable responseData = new Hashtable(); | 575 | Hashtable responseData = new Hashtable(); |
575 | 576 | ||
576 | try { | 577 | lock(this) { |
577 | Hashtable requestData = (Hashtable) request.Params[0]; | 578 | try { |
578 | checkStringParameters(request, new string[] {"password", "region_name"}); | 579 | Hashtable requestData = (Hashtable) request.Params[0]; |
580 | checkStringParameters(request, new string[] {"password", "region_name"}); | ||
579 | 581 | ||
580 | Scene scene = null; | 582 | Scene scene = null; |
581 | string regionName = (string)requestData["region_name"]; | 583 | string regionName = (string)requestData["region_name"]; |
582 | if (!m_app.SceneManager.TryGetScene(regionName, out scene)) | 584 | if (!m_app.SceneManager.TryGetScene(regionName, out scene)) |
583 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); | 585 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); |
584 | 586 | ||
585 | m_app.RemoveRegion(scene, true); | 587 | m_app.RemoveRegion(scene, true); |
586 | 588 | ||
587 | responseData["success"] = "true"; | 589 | responseData["success"] = "true"; |
588 | responseData["region_name"] = regionName; | 590 | responseData["region_name"] = regionName; |
589 | 591 | ||
590 | response.Value = responseData; | 592 | response.Value = responseData; |
591 | } | 593 | } |
592 | catch (Exception e) | 594 | catch (Exception e) |
593 | { | 595 | { |
594 | m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message); | 596 | m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message); |
595 | m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString()); | 597 | m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString()); |
596 | 598 | ||
597 | responseData["success"] = "false"; | 599 | responseData["success"] = "false"; |
598 | responseData["error"] = e.Message; | 600 | responseData["error"] = e.Message; |
599 | 601 | ||
600 | response.Value = responseData; | 602 | response.Value = responseData; |
601 | } | 603 | } |
602 | 604 | ||
603 | return response; | 605 | return response; |
606 | |||
607 | } | ||
604 | } | 608 | } |
605 | 609 | ||
606 | /// <summary> | 610 | /// <summary> |
@@ -645,58 +649,60 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
645 | XmlRpcResponse response = new XmlRpcResponse(); | 649 | XmlRpcResponse response = new XmlRpcResponse(); |
646 | Hashtable responseData = new Hashtable(); | 650 | Hashtable responseData = new Hashtable(); |
647 | 651 | ||
648 | try | 652 | lock(this) { |
649 | { | 653 | try |
650 | Hashtable requestData = (Hashtable) request.Params[0]; | 654 | { |
655 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
651 | 656 | ||
652 | // check completeness | 657 | // check completeness |
653 | checkStringParameters(request, new string[] { "password", "user_firstname", | 658 | checkStringParameters(request, new string[] { "password", "user_firstname", |
654 | "user_lastname", "user_password", }); | 659 | "user_lastname", "user_password", }); |
655 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); | 660 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); |
656 | 661 | ||
657 | // check password | 662 | // check password |
658 | if (!String.IsNullOrEmpty(requiredPassword) && | 663 | if (!String.IsNullOrEmpty(requiredPassword) && |
659 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | 664 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); |
660 | 665 | ||
661 | // do the job | 666 | // do the job |
662 | string firstname = (string) requestData["user_firstname"]; | 667 | string firstname = (string) requestData["user_firstname"]; |
663 | string lastname = (string) requestData["user_lastname"]; | 668 | string lastname = (string) requestData["user_lastname"]; |
664 | string passwd = (string) requestData["user_password"]; | 669 | string passwd = (string) requestData["user_password"]; |
665 | string email = ""; //Empty string for email | 670 | string email = ""; //Empty string for email |
666 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); | 671 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); |
667 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); | 672 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); |
668 | 673 | ||
669 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); | 674 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); |
670 | if (null != userProfile) | 675 | if (null != userProfile) |
671 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); | 676 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); |
672 | 677 | ||
673 | UUID userID | 678 | UUID userID |
674 | = m_app.CommunicationsManager.UserAdminService.AddUser( | 679 | = m_app.CommunicationsManager.UserAdminService.AddUser( |
675 | firstname, lastname, passwd, email, regX, regY); | 680 | firstname, lastname, passwd, email, regX, regY); |
676 | 681 | ||
677 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | 682 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", |
678 | firstname, lastname)); | 683 | firstname, lastname)); |
679 | 684 | ||
680 | responseData["success"] = "true"; | 685 | responseData["success"] = "true"; |
681 | responseData["avatar_uuid"] = userID.ToString(); | 686 | responseData["avatar_uuid"] = userID.ToString(); |
682 | 687 | ||
683 | response.Value = responseData; | 688 | response.Value = responseData; |
684 | 689 | ||
685 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); | 690 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); |
686 | } | 691 | } |
687 | catch (Exception e) | 692 | catch (Exception e) |
688 | { | 693 | { |
689 | m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); | 694 | m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); |
690 | m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); | 695 | m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); |
691 | 696 | ||
692 | responseData["success"] = "false"; | 697 | responseData["success"] = "false"; |
693 | responseData["avatar_uuid"] = UUID.Zero.ToString(); | 698 | responseData["avatar_uuid"] = UUID.Zero.ToString(); |
694 | responseData["error"] = e.Message; | 699 | responseData["error"] = e.Message; |
695 | 700 | ||
696 | response.Value = responseData; | 701 | response.Value = responseData; |
697 | } | 702 | } |
703 | return response; | ||
698 | 704 | ||
699 | return response; | 705 | } |
700 | } | 706 | } |
701 | 707 | ||
702 | /// <summary> | 708 | /// <summary> |
@@ -743,58 +749,60 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
743 | XmlRpcResponse response = new XmlRpcResponse(); | 749 | XmlRpcResponse response = new XmlRpcResponse(); |
744 | Hashtable responseData = new Hashtable(); | 750 | Hashtable responseData = new Hashtable(); |
745 | 751 | ||
746 | try | 752 | lock(this) { |
747 | { | 753 | try |
748 | Hashtable requestData = (Hashtable)request.Params[0]; | 754 | { |
755 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
749 | 756 | ||
750 | // check completeness | 757 | // check completeness |
751 | checkStringParameters(request, new string[] { "password", "user_firstname", | 758 | checkStringParameters(request, new string[] { "password", "user_firstname", |
752 | "user_lastname", "user_password", "user_email" }); | 759 | "user_lastname", "user_password", "user_email" }); |
753 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); | 760 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); |
754 | 761 | ||
755 | // check password | 762 | // check password |
756 | if (!String.IsNullOrEmpty(requiredPassword) && | 763 | if (!String.IsNullOrEmpty(requiredPassword) && |
757 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | 764 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); |
758 | 765 | ||
759 | // do the job | 766 | // do the job |
760 | string firstname = (string)requestData["user_firstname"]; | 767 | string firstname = (string)requestData["user_firstname"]; |
761 | string lastname = (string)requestData["user_lastname"]; | 768 | string lastname = (string)requestData["user_lastname"]; |
762 | string passwd = (string)requestData["user_password"]; | 769 | string passwd = (string)requestData["user_password"]; |
763 | string email = (string)requestData["user_email"]; | 770 | string email = (string)requestData["user_email"]; |
764 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); | 771 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); |
765 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); | 772 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); |
766 | 773 | ||
767 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); | 774 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); |
768 | if (null != userProfile) | 775 | if (null != userProfile) |
769 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); | 776 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); |
770 | 777 | ||
771 | UUID userID | 778 | UUID userID |
772 | = m_app.CommunicationsManager.UserAdminService.AddUser( | 779 | = m_app.CommunicationsManager.UserAdminService.AddUser( |
773 | firstname, lastname, passwd, email, regX, regY); | 780 | firstname, lastname, passwd, email, regX, regY); |
774 | 781 | ||
775 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | 782 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", |
776 | firstname, lastname)); | 783 | firstname, lastname)); |
777 | 784 | ||
778 | responseData["success"] = "true"; | 785 | responseData["success"] = "true"; |
779 | responseData["avatar_uuid"] = userID.ToString(); | 786 | responseData["avatar_uuid"] = userID.ToString(); |
780 | 787 | ||
781 | response.Value = responseData; | 788 | response.Value = responseData; |
782 | 789 | ||
783 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); | 790 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); |
784 | } | 791 | } |
785 | catch (Exception e) | 792 | catch (Exception e) |
786 | { | 793 | { |
787 | m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); | 794 | m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); |
788 | m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); | 795 | m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); |
789 | 796 | ||
790 | responseData["success"] = "false"; | 797 | responseData["success"] = "false"; |
791 | responseData["avatar_uuid"] = UUID.Zero.ToString(); | 798 | responseData["avatar_uuid"] = UUID.Zero.ToString(); |
792 | responseData["error"] = e.Message; | 799 | responseData["error"] = e.Message; |
793 | 800 | ||
794 | response.Value = responseData; | 801 | response.Value = responseData; |
795 | } | 802 | } |
803 | return response; | ||
796 | 804 | ||
797 | return response; | 805 | } |
798 | } | 806 | } |
799 | 807 | ||
800 | /// <summary> | 808 | /// <summary> |
@@ -909,87 +917,89 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
909 | XmlRpcResponse response = new XmlRpcResponse(); | 917 | XmlRpcResponse response = new XmlRpcResponse(); |
910 | Hashtable responseData = new Hashtable(); | 918 | Hashtable responseData = new Hashtable(); |
911 | 919 | ||
912 | try | 920 | lock(this) { |
913 | { | 921 | try |
914 | Hashtable requestData = (Hashtable) request.Params[0]; | 922 | { |
923 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
915 | 924 | ||
916 | // check completeness | 925 | // check completeness |
917 | checkStringParameters(request, new string[] { "password", "user_firstname", | 926 | checkStringParameters(request, new string[] { "password", "user_firstname", |
918 | "user_lastname" }); | 927 | "user_lastname" }); |
919 | 928 | ||
920 | // check password | 929 | // check password |
921 | if (!String.IsNullOrEmpty(requiredPassword) && | 930 | if (!String.IsNullOrEmpty(requiredPassword) && |
922 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | 931 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); |
923 | 932 | ||
924 | // do the job | 933 | // do the job |
925 | string firstname = (string) requestData["user_firstname"]; | 934 | string firstname = (string) requestData["user_firstname"]; |
926 | string lastname = (string) requestData["user_lastname"]; | 935 | string lastname = (string) requestData["user_lastname"]; |
927 | 936 | ||
928 | 937 | ||
929 | string passwd = String.Empty; | 938 | string passwd = String.Empty; |
930 | uint? regX = null; | 939 | uint? regX = null; |
931 | uint? regY = null; | 940 | uint? regY = null; |
932 | uint? ulaX = null; | 941 | uint? ulaX = null; |
933 | uint? ulaY = null; | 942 | uint? ulaY = null; |
934 | uint? ulaZ = null; | 943 | uint? ulaZ = null; |
935 | uint? usaX = null; | 944 | uint? usaX = null; |
936 | uint? usaY = null; | 945 | uint? usaY = null; |
937 | uint? usaZ = null; | 946 | uint? usaZ = null; |
938 | 947 | ||
939 | 948 | ||
940 | if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; | 949 | if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; |
941 | if (requestData.ContainsKey("start_region_x")) regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); | 950 | if (requestData.ContainsKey("start_region_x")) regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); |
942 | if (requestData.ContainsKey("start_region_y")) regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); | 951 | if (requestData.ContainsKey("start_region_y")) regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); |
943 | 952 | ||
944 | if (requestData.ContainsKey("start_lookat_x")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_x"]); | 953 | if (requestData.ContainsKey("start_lookat_x")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_x"]); |
945 | if (requestData.ContainsKey("start_lookat_y")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_y"]); | 954 | if (requestData.ContainsKey("start_lookat_y")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_y"]); |
946 | if (requestData.ContainsKey("start_lookat_z")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_z"]); | 955 | if (requestData.ContainsKey("start_lookat_z")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_z"]); |
947 | 956 | ||
948 | if (requestData.ContainsKey("start_standat_x")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_x"]); | 957 | if (requestData.ContainsKey("start_standat_x")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_x"]); |
949 | if (requestData.ContainsKey("start_standat_y")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_y"]); | 958 | if (requestData.ContainsKey("start_standat_y")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_y"]); |
950 | if (requestData.ContainsKey("start_standat_z")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_z"]); | 959 | if (requestData.ContainsKey("start_standat_z")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_z"]); |
951 | 960 | ||
952 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); | 961 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); |
953 | 962 | ||
954 | if (null == userProfile) | 963 | if (null == userProfile) |
955 | throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); | 964 | throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); |
956 | 965 | ||
957 | if (null != passwd) | 966 | if (null != passwd) |
958 | { | 967 | { |
959 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty); | 968 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty); |
960 | userProfile.PasswordHash = md5PasswdHash; | 969 | userProfile.PasswordHash = md5PasswdHash; |
961 | } | 970 | } |
962 | 971 | ||
963 | if (null != regX) userProfile.HomeRegionX = (uint)regX; | 972 | if (null != regX) userProfile.HomeRegionX = (uint)regX; |
964 | if (null != regY) userProfile.HomeRegionY = (uint)regY; | 973 | if (null != regY) userProfile.HomeRegionY = (uint)regY; |
965 | 974 | ||
966 | if (null != usaX) userProfile.HomeLocationX = (uint)usaX; | 975 | if (null != usaX) userProfile.HomeLocationX = (uint)usaX; |
967 | if (null != usaY) userProfile.HomeLocationY = (uint)usaY; | 976 | if (null != usaY) userProfile.HomeLocationY = (uint)usaY; |
968 | if (null != usaZ) userProfile.HomeLocationZ = (uint)usaZ; | 977 | if (null != usaZ) userProfile.HomeLocationZ = (uint)usaZ; |
969 | 978 | ||
970 | if (null != ulaX) userProfile.HomeLookAtX = (uint)ulaX; | 979 | if (null != ulaX) userProfile.HomeLookAtX = (uint)ulaX; |
971 | if (null != ulaY) userProfile.HomeLookAtY = (uint)ulaY; | 980 | if (null != ulaY) userProfile.HomeLookAtY = (uint)ulaY; |
972 | if (null != ulaZ) userProfile.HomeLookAtZ = (uint)ulaZ; | 981 | if (null != ulaZ) userProfile.HomeLookAtZ = (uint)ulaZ; |
973 | 982 | ||
974 | if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) | 983 | if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) |
975 | throw new Exception("did not manage to update user profile"); | 984 | throw new Exception("did not manage to update user profile"); |
976 | 985 | ||
977 | responseData["success"] = "true"; | 986 | responseData["success"] = "true"; |
978 | 987 | ||
979 | response.Value = responseData; | 988 | response.Value = responseData; |
980 | 989 | ||
981 | m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname, | 990 | m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname, |
982 | userProfile.ID); | 991 | userProfile.ID); |
983 | } | 992 | } |
984 | catch (Exception e) | 993 | catch (Exception e) |
985 | { | 994 | { |
986 | m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); | 995 | m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); |
987 | m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); | 996 | m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); |
988 | 997 | ||
989 | responseData["success"] = "false"; | 998 | responseData["success"] = "false"; |
990 | responseData["error"] = e.Message; | 999 | responseData["error"] = e.Message; |
991 | 1000 | ||
992 | response.Value = responseData; | 1001 | response.Value = responseData; |
1002 | } | ||
993 | } | 1003 | } |
994 | 1004 | ||
995 | return response; | 1005 | return response; |
@@ -1033,56 +1043,58 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1033 | XmlRpcResponse response = new XmlRpcResponse(); | 1043 | XmlRpcResponse response = new XmlRpcResponse(); |
1034 | Hashtable responseData = new Hashtable(); | 1044 | Hashtable responseData = new Hashtable(); |
1035 | 1045 | ||
1036 | try | 1046 | lock(this) { |
1037 | { | 1047 | try |
1038 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1039 | |||
1040 | // check completeness | ||
1041 | foreach (string p in new string[] { "password", "filename" }) | ||
1042 | { | 1048 | { |
1043 | if (!requestData.Contains(p)) | 1049 | Hashtable requestData = (Hashtable) request.Params[0]; |
1044 | throw new Exception(String.Format("missing parameter {0}", p)); | ||
1045 | if (String.IsNullOrEmpty((string)requestData[p])) | ||
1046 | throw new Exception(String.Format("parameter {0} is empty")); | ||
1047 | } | ||
1048 | 1050 | ||
1049 | // check password | 1051 | // check completeness |
1050 | if (!String.IsNullOrEmpty(requiredPassword) && | 1052 | foreach (string p in new string[] { "password", "filename" }) |
1051 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | 1053 | { |
1054 | if (!requestData.Contains(p)) | ||
1055 | throw new Exception(String.Format("missing parameter {0}", p)); | ||
1056 | if (String.IsNullOrEmpty((string)requestData[p])) | ||
1057 | throw new Exception(String.Format("parameter {0} is empty")); | ||
1058 | } | ||
1052 | 1059 | ||
1053 | string filename = (string)requestData["filename"]; | 1060 | // check password |
1054 | Scene scene = null; | 1061 | if (!String.IsNullOrEmpty(requiredPassword) && |
1055 | if (requestData.Contains("region_uuid")) | 1062 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); |
1056 | { | 1063 | |
1057 | UUID region_uuid = (UUID)(string)requestData["region_uuid"]; | 1064 | string filename = (string)requestData["filename"]; |
1058 | if (!m_app.SceneManager.TryGetScene(region_uuid, out scene)) | 1065 | Scene scene = null; |
1059 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | 1066 | if (requestData.Contains("region_uuid")) |
1067 | { | ||
1068 | UUID region_uuid = (UUID)(string)requestData["region_uuid"]; | ||
1069 | if (!m_app.SceneManager.TryGetScene(region_uuid, out scene)) | ||
1070 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1071 | } | ||
1072 | else if (requestData.Contains("region_name")) | ||
1073 | { | ||
1074 | string region_name = (string)requestData["region_name"]; | ||
1075 | if (!m_app.SceneManager.TryGetScene(region_name, out scene)) | ||
1076 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1077 | } | ||
1078 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1079 | |||
1080 | new ArchiveReadRequest(scene, filename); | ||
1081 | responseData["loaded"] = "true"; | ||
1082 | |||
1083 | response.Value = responseData; | ||
1060 | } | 1084 | } |
1061 | else if (requestData.Contains("region_name")) | 1085 | catch (Exception e) |
1062 | { | 1086 | { |
1063 | string region_name = (string)requestData["region_name"]; | 1087 | m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message); |
1064 | if (!m_app.SceneManager.TryGetScene(region_name, out scene)) | 1088 | m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString()); |
1065 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1066 | } | ||
1067 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1068 | 1089 | ||
1069 | new ArchiveReadRequest(scene, filename); | 1090 | responseData["loaded"] = "false"; |
1070 | responseData["loaded"] = "true"; | 1091 | responseData["error"] = e.Message; |
1071 | 1092 | ||
1072 | response.Value = responseData; | 1093 | response.Value = responseData; |
1073 | } | 1094 | } |
1074 | catch (Exception e) | ||
1075 | { | ||
1076 | m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message); | ||
1077 | m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString()); | ||
1078 | |||
1079 | responseData["loaded"] = "false"; | ||
1080 | responseData["error"] = e.Message; | ||
1081 | 1095 | ||
1082 | response.Value = responseData; | 1096 | return response; |
1083 | } | 1097 | } |
1084 | |||
1085 | return response; | ||
1086 | } | 1098 | } |
1087 | 1099 | ||
1088 | /// <summary> | 1100 | /// <summary> |
@@ -1181,79 +1193,82 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1181 | m_log.Info("[RADMIN]: Received Load XML Administrator Request"); | 1193 | m_log.Info("[RADMIN]: Received Load XML Administrator Request"); |
1182 | XmlRpcResponse response = new XmlRpcResponse(); | 1194 | XmlRpcResponse response = new XmlRpcResponse(); |
1183 | Hashtable responseData = new Hashtable(); | 1195 | Hashtable responseData = new Hashtable(); |
1196 | |||
1197 | lock(this) { | ||
1184 | 1198 | ||
1185 | try | 1199 | try |
1186 | { | ||
1187 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1188 | |||
1189 | // check completeness | ||
1190 | foreach (string p in new string[] { "password", "filename" }) | ||
1191 | { | 1200 | { |
1192 | if (!requestData.Contains(p)) | 1201 | Hashtable requestData = (Hashtable) request.Params[0]; |
1193 | throw new Exception(String.Format("missing parameter {0}", p)); | ||
1194 | if (String.IsNullOrEmpty((string)requestData[p])) | ||
1195 | throw new Exception(String.Format("parameter {0} is empty")); | ||
1196 | } | ||
1197 | 1202 | ||
1198 | // check password | 1203 | // check completeness |
1199 | if (!String.IsNullOrEmpty(requiredPassword) && | 1204 | foreach (string p in new string[] { "password", "filename" }) |
1200 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | 1205 | { |
1206 | if (!requestData.Contains(p)) | ||
1207 | throw new Exception(String.Format("missing parameter {0}", p)); | ||
1208 | if (String.IsNullOrEmpty((string)requestData[p])) | ||
1209 | throw new Exception(String.Format("parameter {0} is empty")); | ||
1210 | } | ||
1201 | 1211 | ||
1202 | string filename = (string)requestData["filename"]; | 1212 | // check password |
1203 | if (requestData.Contains("region_uuid")) | 1213 | if (!String.IsNullOrEmpty(requiredPassword) && |
1204 | { | 1214 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); |
1205 | UUID region_uuid = (UUID)(string)requestData["region_uuid"]; | ||
1206 | if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1207 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1208 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); | ||
1209 | } | ||
1210 | else if (requestData.Contains("region_name")) | ||
1211 | { | ||
1212 | string region_name = (string)requestData["region_name"]; | ||
1213 | if (!m_app.SceneManager.TrySetCurrentScene(region_name)) | ||
1214 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1215 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); | ||
1216 | } | ||
1217 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1218 | 1215 | ||
1219 | responseData["switched"] = "true"; | 1216 | string filename = (string)requestData["filename"]; |
1217 | if (requestData.Contains("region_uuid")) | ||
1218 | { | ||
1219 | UUID region_uuid = (UUID)(string)requestData["region_uuid"]; | ||
1220 | if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1221 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1222 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); | ||
1223 | } | ||
1224 | else if (requestData.Contains("region_name")) | ||
1225 | { | ||
1226 | string region_name = (string)requestData["region_name"]; | ||
1227 | if (!m_app.SceneManager.TrySetCurrentScene(region_name)) | ||
1228 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1229 | m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); | ||
1230 | } | ||
1231 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1220 | 1232 | ||
1221 | string xml_version = "1"; | 1233 | responseData["switched"] = "true"; |
1222 | if (requestData.Contains("xml_version")) | ||
1223 | { | ||
1224 | xml_version = (string)requestData["xml_version"]; | ||
1225 | } | ||
1226 | 1234 | ||
1227 | switch (xml_version) | 1235 | string xml_version = "1"; |
1228 | { | 1236 | if (requestData.Contains("xml_version")) |
1229 | case "1": | 1237 | { |
1230 | m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new Vector3(0, 0, 0)); | 1238 | xml_version = (string)requestData["xml_version"]; |
1231 | break; | 1239 | } |
1232 | 1240 | ||
1233 | case "2": | 1241 | switch (xml_version) |
1234 | m_app.SceneManager.LoadCurrentSceneFromXml2(filename); | 1242 | { |
1235 | break; | 1243 | case "1": |
1244 | m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new Vector3(0, 0, 0)); | ||
1245 | break; | ||
1236 | 1246 | ||
1237 | default: | 1247 | case "2": |
1238 | throw new Exception(String.Format("unknown Xml{0} format", xml_version)); | 1248 | m_app.SceneManager.LoadCurrentSceneFromXml2(filename); |
1249 | break; | ||
1250 | |||
1251 | default: | ||
1252 | throw new Exception(String.Format("unknown Xml{0} format", xml_version)); | ||
1253 | } | ||
1254 | |||
1255 | responseData["loaded"] = "true"; | ||
1256 | response.Value = responseData; | ||
1239 | } | 1257 | } |
1258 | catch (Exception e) | ||
1259 | { | ||
1260 | m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message); | ||
1261 | m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString()); | ||
1240 | 1262 | ||
1241 | responseData["loaded"] = "true"; | 1263 | responseData["loaded"] = "false"; |
1242 | response.Value = responseData; | 1264 | responseData["switched"] = "false"; |
1243 | } | 1265 | responseData["error"] = e.Message; |
1244 | catch (Exception e) | ||
1245 | { | ||
1246 | m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message); | ||
1247 | m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString()); | ||
1248 | 1266 | ||
1249 | responseData["loaded"] = "false"; | 1267 | response.Value = responseData; |
1250 | responseData["switched"] = "false"; | 1268 | } |
1251 | responseData["error"] = e.Message; | ||
1252 | 1269 | ||
1253 | response.Value = responseData; | 1270 | return response; |
1254 | } | 1271 | } |
1255 | |||
1256 | return response; | ||
1257 | } | 1272 | } |
1258 | 1273 | ||
1259 | 1274 | ||