Some refactoring of the RestObjectPoster (and related classes).

afrisby
MW 2007-12-05 19:02:57 +00:00
parent 4b77821275
commit d2736437d4
5 changed files with 17 additions and 7 deletions

View File

@ -10,11 +10,16 @@ namespace OpenSim.Framework.Servers
public class RestObjectPoster
{
public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
{
BeginPostObject("POST", requestUrl, obj);
}
public static void BeginPostObject<TRequest>(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();

View File

@ -14,11 +14,16 @@ namespace OpenSim.Framework.Servers
public ReturnResponse<TResponse> ResponseCallback;
public void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
{
BeginPostObject("POST", requestUrl, obj);
}
public void BeginPostObject<TRequest>(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();

View File

@ -9,12 +9,12 @@ namespace OpenSim.Framework.Servers
{
public class SynchronousRestObjectPoster
{
public static TResponse BeginPostObject<TRequest, TResponse>(string requestUrl, TRequest obj)
public static TResponse BeginPostObject<TRequest, TResponse>(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();

View File

@ -157,7 +157,7 @@ namespace OpenSim.Grid.UserServer
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
// requester.ReturnResponseVal = TestResponse;
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject< LLUUID, List<InventoryFolderBase>>("POST",m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
break;
}
}

View File

@ -197,12 +197,12 @@ namespace OpenSim.Grid.UserServer
protected override InventoryData CreateInventoryData(LLUUID userID)
{
List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_config.InventoryUrl + "RootFolders/", userID);
List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", m_config.InventoryUrl + "RootFolders/", userID);
if (folders ==null | folders.Count == 0)
{
RestObjectPoster.BeginPostObject<LLUUID>(m_config.InventoryUrl + "CreateInventory/", userID);
Thread.Sleep(1000);
folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_config.InventoryUrl + "RootFolders/", userID);
folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", m_config.InventoryUrl + "RootFolders/", userID);
}
if(folders.Count >0)