aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs302
1 files changed, 150 insertions, 152 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
index b70a511..4369216 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
@@ -39,8 +39,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
39 39
40 public class RestAppearanceServices : IRest 40 public class RestAppearanceServices : IRest
41 { 41 {
42 42// private static readonly int PARM_USERID = 0;
43 private static readonly int PARM_USERID = 0;
44 43
45 // private static readonly int PARM_PATH = 1; 44 // private static readonly int PARM_PATH = 1;
46 45
@@ -64,6 +63,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
64 { 63 {
65 Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId); 64 Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId);
66 qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix); 65 qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
66 qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
67 Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix); 67 Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix);
68 } 68 }
69 69
@@ -294,31 +294,31 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
294 /// </summary> 294 /// </summary>
295 /// <param name=rdata>HTTP service request work area</param> 295 /// <param name=rdata>HTTP service request work area</param>
296 296
297 private void DoGet(AppearanceRequestData rdata) 297// private void DoGet(AppearanceRequestData rdata)
298 { 298// {
299 AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID); 299// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
300 300//
301 if (adata == null) 301// if (adata == null)
302 { 302// {
303 rdata.Fail(Rest.HttpStatusCodeNoContent, 303// rdata.Fail(Rest.HttpStatusCodeNoContent,
304 String.Format("appearance data not found for user {0} {1}", 304// String.Format("appearance data not found for user {0} {1}",
305 rdata.userProfile.FirstName, rdata.userProfile.SurName)); 305// rdata.userProfile.FirstName, rdata.userProfile.SurName));
306 } 306// }
307 rdata.userAppearance = adata.ToAvatarAppearance(rdata.userProfile.ID); 307// rdata.userAppearance = adata.ToAvatarAppearance(rdata.userProfile.ID);
308 308//
309 rdata.initXmlWriter(); 309// rdata.initXmlWriter();
310 310//
311 FormatUserAppearance(rdata); 311// FormatUserAppearance(rdata);
312 312//
313 // Indicate a successful request 313// // Indicate a successful request
314 314//
315 rdata.Complete(); 315// rdata.Complete();
316 316//
317 // Send the response to the user. The body will be implicitly 317// // Send the response to the user. The body will be implicitly
318 // constructed from the result of the XML writer. 318// // constructed from the result of the XML writer.
319 319//
320 rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method)); 320// rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method));
321 } 321// }
322 322
323 /// <summary> 323 /// <summary>
324 /// POST adds NEW information to the user profile database. 324 /// POST adds NEW information to the user profile database.
@@ -326,112 +326,112 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
326 /// characteristics supplied in the request. 326 /// characteristics supplied in the request.
327 /// </summary> 327 /// </summary>
328 328
329 private void DoExtend(AppearanceRequestData rdata) 329// private void DoExtend(AppearanceRequestData rdata)
330 { 330// {
331 331//
332 bool created = false; 332// bool created = false;
333 bool modified = false; 333// bool modified = false;
334 string newnode = String.Empty; 334// string newnode = String.Empty;
335 335//
336 Rest.Log.DebugFormat("{0} POST ENTRY", MsgId); 336// Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
337 337//
338 //AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); 338// //AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
339 339//
340 rdata.userAppearance = new AvatarAppearance(); 340// rdata.userAppearance = new AvatarAppearance();
341 341//
342 // Although the following behavior is admitted by HTTP I am becoming 342// // Although the following behavior is admitted by HTTP I am becoming
343 // increasingly doubtful that it is appropriate for REST. If I attempt to 343// // increasingly doubtful that it is appropriate for REST. If I attempt to
344 // add a new record, and it already exists, then it seems to me that the 344// // add a new record, and it already exists, then it seems to me that the
345 // attempt should fail, rather than update the existing record. 345// // attempt should fail, rather than update the existing record.
346 AvatarData adata = null; 346// AvatarData adata = null;
347 if (GetUserAppearance(rdata)) 347// if (GetUserAppearance(rdata))
348 { 348// {
349 modified = rdata.userAppearance != null; 349// modified = rdata.userAppearance != null;
350 created = !modified; 350// created = !modified;
351 adata = new AvatarData(rdata.userAppearance); 351// adata = new AvatarData(rdata.userAppearance);
352 Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); 352// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
353 // Rest.UserServices.UpdateUserProfile(rdata.userProfile); 353// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
354 } 354// }
355 else 355// else
356 { 356// {
357 created = true; 357// created = true;
358 adata = new AvatarData(rdata.userAppearance); 358// adata = new AvatarData(rdata.userAppearance);
359 Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); 359// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
360 // Rest.UserServices.UpdateUserProfile(rdata.userProfile); 360// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
361 } 361// }
362 362//
363 if (created) 363// if (created)
364 { 364// {
365 newnode = String.Format("{0} {1}", rdata.userProfile.FirstName, 365// newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
366 rdata.userProfile.SurName); 366// rdata.userProfile.SurName);
367 // Must include a location header with a URI that identifies the new resource. 367// // Must include a location header with a URI that identifies the new resource.
368 368//
369 rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}", 369// rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
370 rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode)); 370// rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
371 rdata.Complete(Rest.HttpStatusCodeCreated); 371// rdata.Complete(Rest.HttpStatusCodeCreated);
372 372//
373 } 373// }
374 else 374// else
375 { 375// {
376 if (modified) 376// if (modified)
377 { 377// {
378 rdata.Complete(Rest.HttpStatusCodeOK); 378// rdata.Complete(Rest.HttpStatusCodeOK);
379 } 379// }
380 else 380// else
381 { 381// {
382 rdata.Complete(Rest.HttpStatusCodeNoContent); 382// rdata.Complete(Rest.HttpStatusCodeNoContent);
383 } 383// }
384 } 384// }
385 385//
386 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 386// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
387 387//
388 } 388// }
389 389
390 /// <summary> 390 /// <summary>
391 /// This updates the user's appearance. not all aspects need to be provided, 391 /// This updates the user's appearance. not all aspects need to be provided,
392 /// only those supplied will be changed. 392 /// only those supplied will be changed.
393 /// </summary> 393 /// </summary>
394 394
395 private void DoUpdate(AppearanceRequestData rdata) 395// private void DoUpdate(AppearanceRequestData rdata)
396 { 396// {
397 397//
398 // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7 398// // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7
399 399//
400 //bool created = false; 400// //bool created = false;
401 //bool modified = false; 401// //bool modified = false;
402 402//
403 403//
404 //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); 404// //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
405 405//
406 //// If the user exists then this is considered a modification regardless 406// //// If the user exists then this is considered a modification regardless
407 //// of what may, or may not be, specified in the payload. 407// //// of what may, or may not be, specified in the payload.
408 408//
409 //if (rdata.userAppearance != null) 409// //if (rdata.userAppearance != null)
410 //{ 410// //{
411 // modified = true; 411// // modified = true;
412 // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); 412// // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
413 // Rest.UserServices.UpdateUserProfile(rdata.userProfile); 413// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
414 //} 414// //}
415 415//
416 //if (created) 416// //if (created)
417 //{ 417// //{
418 // rdata.Complete(Rest.HttpStatusCodeCreated); 418// // rdata.Complete(Rest.HttpStatusCodeCreated);
419 //} 419// //}
420 //else 420// //else
421 //{ 421// //{
422 // if (modified) 422// // if (modified)
423 // { 423// // {
424 // rdata.Complete(Rest.HttpStatusCodeOK); 424// // rdata.Complete(Rest.HttpStatusCodeOK);
425 // } 425// // }
426 // else 426// // else
427 // { 427// // {
428 // rdata.Complete(Rest.HttpStatusCodeNoContent); 428// // rdata.Complete(Rest.HttpStatusCodeNoContent);
429 // } 429// // }
430 //} 430// //}
431 431//
432 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 432// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
433 433//
434 } 434// }
435 435
436 /// <summary> 436 /// <summary>
437 /// Delete the specified user's appearance. This actually performs a reset 437 /// Delete the specified user's appearance. This actually performs a reset
@@ -439,31 +439,29 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
439 /// Existing ownership is preserved. All prior updates are lost and can not 439 /// Existing ownership is preserved. All prior updates are lost and can not
440 /// be recovered. 440 /// be recovered.
441 /// </summary> 441 /// </summary>
442 442// private void DoDelete(AppearanceRequestData rdata)
443 private void DoDelete(AppearanceRequestData rdata) 443// {
444 { 444// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
445 AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID); 445//
446 446// if (adata != null)
447 if (adata != null) 447// {
448 { 448// AvatarAppearance old = adata.ToAvatarAppearance(rdata.userProfile.ID);
449 AvatarAppearance old = adata.ToAvatarAppearance(rdata.userProfile.ID); 449// rdata.userAppearance = new AvatarAppearance();
450 rdata.userAppearance = new AvatarAppearance(); 450// rdata.userAppearance.Owner = old.Owner;
451 rdata.userAppearance.Owner = old.Owner; 451// adata = new AvatarData(rdata.userAppearance);
452 adata = new AvatarData(rdata.userAppearance); 452//
453 453// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
454 Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); 454//
455 455// rdata.Complete();
456 rdata.Complete(); 456// }
457 } 457// else
458 else 458// {
459 { 459//
460 460// rdata.Complete(Rest.HttpStatusCodeNoContent);
461 rdata.Complete(Rest.HttpStatusCodeNoContent); 461// }
462 } 462//
463 463// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
464 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 464// }
465
466 }
467 465
468#endregion method-specific processing 466#endregion method-specific processing
469 467