From d2736437d42758ddefee4e50e23c465e514077be Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 5 Dec 2007 19:02:57 +0000 Subject: [PATCH] Some refactoring of the RestObjectPoster (and related classes). --- OpenSim/Framework/Servers/RestObjectPoster.cs | 7 ++++++- OpenSim/Framework/Servers/RestObjectPosterResponse.cs | 7 ++++++- OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs | 4 ++-- OpenSim/Grid/UserServer/Main.cs | 2 +- OpenSim/Grid/UserServer/UserLoginService.cs | 4 ++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs index 9bcfcca87e..991b1d5676 100644 --- a/OpenSim/Framework/Servers/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/RestObjectPoster.cs @@ -10,11 +10,16 @@ namespace OpenSim.Framework.Servers public class RestObjectPoster { public static void BeginPostObject(string requestUrl, TRequest obj) + { + BeginPostObject("POST", requestUrl, obj); + } + + public static void BeginPostObject(string verb, string requestUrl, TRequest obj) { Type type = typeof(TRequest); WebRequest request = WebRequest.Create(requestUrl); - request.Method = "POST"; + request.Method = verb; request.ContentType = "text/xml"; MemoryStream buffer = new MemoryStream(); diff --git a/OpenSim/Framework/Servers/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/RestObjectPosterResponse.cs index eeae285a84..d91d5669bf 100644 --- a/OpenSim/Framework/Servers/RestObjectPosterResponse.cs +++ b/OpenSim/Framework/Servers/RestObjectPosterResponse.cs @@ -14,11 +14,16 @@ namespace OpenSim.Framework.Servers public ReturnResponse ResponseCallback; public void BeginPostObject(string requestUrl, TRequest obj) + { + BeginPostObject("POST", requestUrl, obj); + } + + public void BeginPostObject(string verb, string requestUrl, TRequest obj) { Type type = typeof(TRequest); WebRequest request = WebRequest.Create(requestUrl); - request.Method = "POST"; + request.Method = verb; request.ContentType = "text/xml"; MemoryStream buffer = new MemoryStream(); diff --git a/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs b/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs index dde4c02662..11a74b1cb5 100644 --- a/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs +++ b/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs @@ -9,12 +9,12 @@ namespace OpenSim.Framework.Servers { public class SynchronousRestObjectPoster { - public static TResponse BeginPostObject(string requestUrl, TRequest obj) + public static TResponse BeginPostObject(string verb, string requestUrl, TRequest obj) { Type type = typeof(TRequest); WebRequest request = WebRequest.Create(requestUrl); - request.Method = "POST"; + request.Method = verb; request.ContentType = "text/xml"; MemoryStream buffer = new MemoryStream(); diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 634698e367..d2ad6ae7a9 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -157,7 +157,7 @@ namespace OpenSim.Grid.UserServer // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); // requester.ReturnResponseVal = TestResponse; // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); - List folders = SynchronousRestObjectPoster.BeginPostObject>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + List folders = SynchronousRestObjectPoster.BeginPostObject< LLUUID, List>("POST",m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); break; } } diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 4d1328e7be..ccd35485ca 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -197,12 +197,12 @@ namespace OpenSim.Grid.UserServer protected override InventoryData CreateInventoryData(LLUUID userID) { - List folders = SynchronousRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); + List folders = SynchronousRestObjectPoster.BeginPostObject>("POST", m_config.InventoryUrl + "RootFolders/", userID); if (folders ==null | folders.Count == 0) { RestObjectPoster.BeginPostObject(m_config.InventoryUrl + "CreateInventory/", userID); Thread.Sleep(1000); - folders = SynchronousRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); + folders = SynchronousRestObjectPoster.BeginPostObject>("POST", m_config.InventoryUrl + "RootFolders/", userID); } if(folders.Count >0)