diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index dcf25ad31b..9e0a23011d 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -54,8 +54,6 @@ namespace OpenSim.Services.Connectors
private string m_ServerURI = String.Empty;
- private int m_maxRetries = 0;
-
///
/// Timeout for remote requests.
///
@@ -110,7 +108,6 @@ namespace OpenSim.Services.Connectors
m_ServerURI = serviceURI;
m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs);
- m_maxRetries = config.GetInt("MaxRetries", m_maxRetries);
StatsManager.RegisterStat(
new Stat(
@@ -152,8 +149,9 @@ namespace OpenSim.Services.Connectors
public bool CreateUserInventory(UUID principalID)
{
- Dictionary ret = MakeRequest("CREATEUSERINVENTORY",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "CREATEUSERINVENTORY"},
{ "PRINCIPAL", principalID.ToString() }
});
@@ -162,8 +160,9 @@ namespace OpenSim.Services.Connectors
public List GetInventorySkeleton(UUID principalID)
{
- Dictionary ret = MakeRequest("GETINVENTORYSKELETON",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETINVENTORYSKELETON"},
{ "PRINCIPAL", principalID.ToString() }
});
@@ -189,8 +188,9 @@ namespace OpenSim.Services.Connectors
public InventoryFolderBase GetRootFolder(UUID principalID)
{
- Dictionary ret = MakeRequest("GETROOTFOLDER",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETROOTFOLDER"},
{ "PRINCIPAL", principalID.ToString() }
});
@@ -202,8 +202,9 @@ namespace OpenSim.Services.Connectors
public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
{
- Dictionary ret = MakeRequest("GETFOLDERFORTYPE",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETFOLDERFORTYPE"},
{ "PRINCIPAL", principalID.ToString() },
{ "TYPE", ((int)type).ToString() }
});
@@ -223,8 +224,9 @@ namespace OpenSim.Services.Connectors
try
{
- Dictionary ret = MakeRequest("GETFOLDERCONTENT",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETFOLDERCONTENT"},
{ "PRINCIPAL", principalID.ToString() },
{ "FOLDER", folderID.ToString() }
});
@@ -258,8 +260,9 @@ namespace OpenSim.Services.Connectors
// m_log.DebugFormat("[XXX]: In GetMultipleFoldersContent {0}", String.Join(",", folderIDs));
try
{
- Dictionary resultSet = MakeRequest("GETMULTIPLEFOLDERSCONTENT",
+ Dictionary resultSet = MakeRequest(
new Dictionary {
+ { "METHOD", "GETMULTIPLEFOLDERSCONTENT"},
{ "PRINCIPAL", principalID.ToString() },
{ "FOLDERS", String.Join(",", folderIDs) },
{ "COUNT", folderIDs.Length.ToString() }
@@ -298,20 +301,23 @@ namespace OpenSim.Services.Connectors
//m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID);
- Dictionary folders =
- (Dictionary)ret["FOLDERS"];
- Dictionary items =
- (Dictionary)ret["ITEMS"];
-
- foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
+ if (ret.TryGetValue("FOLDERS", out object ofolders) && ofolders is Dictionary)
{
- inventory.Folders.Add(BuildFolder((Dictionary)o));
- }
- foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
- {
- inventory.Items.Add(BuildItem((Dictionary)o));
+ var folders = ofolders as Dictionary;
+ foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
+ {
+ inventory.Folders.Add(BuildFolder((Dictionary)o));
+ }
}
+ if (ret.TryGetValue("ITEMS", out object oitems) && oitems is Dictionary)
+ {
+ var items = oitems as Dictionary;
+ foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
+ {
+ inventory.Items.Add(BuildItem((Dictionary)o));
+ }
+ }
inventoryArr[i] = inventory;
}
else
@@ -335,8 +341,9 @@ namespace OpenSim.Services.Connectors
public List GetFolderItems(UUID principalID, UUID folderID)
{
- Dictionary ret = MakeRequest("GETFOLDERITEMS",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETFOLDERITEMS"},
{ "PRINCIPAL", principalID.ToString() },
{ "FOLDER", folderID.ToString() }
});
@@ -354,8 +361,9 @@ namespace OpenSim.Services.Connectors
public bool AddFolder(InventoryFolderBase folder)
{
- Dictionary ret = MakeRequest("ADDFOLDER",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "ADDFOLDER"},
{ "ParentID", folder.ParentID.ToString() },
{ "Type", folder.Type.ToString() },
{ "Version", folder.Version.ToString() },
@@ -369,8 +377,9 @@ namespace OpenSim.Services.Connectors
public bool UpdateFolder(InventoryFolderBase folder)
{
- Dictionary ret = MakeRequest("UPDATEFOLDER",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "UPDATEFOLDER"},
{ "ParentID", folder.ParentID.ToString() },
{ "Type", folder.Type.ToString() },
{ "Version", folder.Version.ToString() },
@@ -384,8 +393,9 @@ namespace OpenSim.Services.Connectors
public bool MoveFolder(InventoryFolderBase folder)
{
- Dictionary ret = MakeRequest("MOVEFOLDER",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "MOVEFOLDER"},
{ "ParentID", folder.ParentID.ToString() },
{ "ID", folder.ID.ToString() },
{ "PRINCIPAL", folder.Owner.ToString() }
@@ -401,8 +411,9 @@ namespace OpenSim.Services.Connectors
foreach (UUID f in folderIDs)
slist.Add(f.ToString());
- Dictionary ret = MakeRequest("DELETEFOLDERS",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "DELETEFOLDERS"},
{ "PRINCIPAL", principalID.ToString() },
{ "FOLDERS", slist }
});
@@ -412,8 +423,9 @@ namespace OpenSim.Services.Connectors
public bool PurgeFolder(InventoryFolderBase folder)
{
- Dictionary ret = MakeRequest("PURGEFOLDER",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "PURGEFOLDER"},
{ "ID", folder.ID.ToString() }
});
@@ -428,8 +440,9 @@ namespace OpenSim.Services.Connectors
item.CreatorData = String.Empty;
if (item.CreatorId == null)
item.CreatorId = String.Empty;
- Dictionary ret = MakeRequest("ADDITEM",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "ADDITEM"},
{ "AssetID", item.AssetID.ToString() },
{ "AssetType", item.AssetType.ToString() },
{ "Name", item.Name.ToString() },
@@ -460,8 +473,9 @@ namespace OpenSim.Services.Connectors
{
if (item.CreatorData == null)
item.CreatorData = String.Empty;
- Dictionary ret = MakeRequest("UPDATEITEM",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "UPDATEITEM"},
{ "AssetID", item.AssetID.ToString() },
{ "AssetType", item.AssetType.ToString() },
{ "Name", item.Name.ToString() },
@@ -505,8 +519,9 @@ namespace OpenSim.Services.Connectors
destlist.Add(item.Folder.ToString());
}
- Dictionary ret = MakeRequest("MOVEITEMS",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "MOVEITEMS"},
{ "PRINCIPAL", principalID.ToString() },
{ "IDLIST", idlist },
{ "DESTLIST", destlist }
@@ -522,8 +537,9 @@ namespace OpenSim.Services.Connectors
foreach (UUID f in itemIDs)
slist.Add(f.ToString());
- Dictionary ret = MakeRequest("DELETEITEMS",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "DELETEITEMS"},
{ "PRINCIPAL", principalID.ToString() },
{ "ITEMS", slist }
});
@@ -541,8 +557,9 @@ namespace OpenSim.Services.Connectors
try
{
- Dictionary ret = MakeRequest("GETITEM",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETITEM"},
{ "ID", itemID.ToString() },
{ "PRINCIPAL", principalID.ToString() }
});
@@ -585,8 +602,9 @@ namespace OpenSim.Services.Connectors
try
{
- Dictionary resultSet = MakeRequest("GETMULTIPLEITEMS",
+ Dictionary resultSet = MakeRequest(
new Dictionary {
+ { "METHOD", "GETMULTIPLEITEMS"},
{ "PRINCIPAL", principalID.ToString() },
{ "ITEMS", String.Join(",", pending.ToArray()) },
{ "COUNT", pending.Count.ToString() }
@@ -629,8 +647,9 @@ namespace OpenSim.Services.Connectors
{
try
{
- Dictionary ret = MakeRequest("GETFOLDER",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETFOLDER"},
{ "ID", folderID.ToString() },
{ "PRINCIPAL", principalID.ToString() }
});
@@ -650,8 +669,9 @@ namespace OpenSim.Services.Connectors
public List GetActiveGestures(UUID principalID)
{
- Dictionary ret = MakeRequest("GETACTIVEGESTURES",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETACTIVEGESTURES"},
{ "PRINCIPAL", principalID.ToString() }
});
@@ -668,8 +688,9 @@ namespace OpenSim.Services.Connectors
public int GetAssetPermissions(UUID principalID, UUID assetID)
{
- Dictionary ret = MakeRequest("GETASSETPERMISSIONS",
+ Dictionary ret = MakeRequest(
new Dictionary {
+ { "METHOD", "GETASSETPERMISSIONS"},
{ "PRINCIPAL", principalID.ToString() },
{ "ASSET", assetID.ToString() }
});
@@ -699,35 +720,20 @@ namespace OpenSim.Services.Connectors
// Helpers
//
- private Dictionary MakeRequest(string method,
- Dictionary sendData)
+ private Dictionary MakeRequest(Dictionary sendData)
{
- // Add "METHOD" as the first key in the dictionary. This ensures that it will be
- // visible even when using partial logging ("debug http all 5").
- Dictionary temp = sendData;
- sendData = new Dictionary{ { "METHOD", method } };
- foreach (KeyValuePair kvp in temp)
- sendData.Add(kvp.Key, kvp.Value);
-
RequestsMade++;
string reply = String.Empty;
- int retries = 0;
+
+ reply = SynchronousRestFormsRequester.MakePostRequest(
+ m_ServerURI + "/xinventory",
+ ServerUtils.BuildQueryString(sendData), m_Auth, m_requestTimeoutSecs);
- do
- {
- reply = SynchronousRestFormsRequester.MakeRequest(
- "POST", m_ServerURI + "/xinventory",
- ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth);
+ if(string.IsNullOrWhiteSpace(reply))
+ return new Dictionary();
- if (reply != String.Empty)
- break;
-
- retries++;
- } while (retries <= m_maxRetries);
-
- Dictionary replyData = ServerUtils.ParseXmlResponse(
- reply);
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
return replyData;
}
@@ -769,8 +775,6 @@ namespace OpenSim.Services.Connectors
item.CreatorId = data["CreatorId"].ToString();
if (data.ContainsKey("CreatorData"))
item.CreatorData = data["CreatorData"].ToString();
- else
- item.CreatorData = String.Empty;
item.Description = data["Description"].ToString();
item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());