cleanups, fixing REST appearance services.
parent
a042302100
commit
201805172f
|
@ -1103,7 +1103,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
// Respond to the client's request, tag the response (for the
|
// Respond to the client's request, tag the response (for the
|
||||||
// benefit of trace) to indicate the reason.
|
// benefit of trace) to indicate the reason.
|
||||||
|
|
||||||
Respond(String.Format("Failure response: ({0}) : {1}",
|
Respond(String.Format("Failure response: ({0}) : {1} ",
|
||||||
code, Rest.HttpStatusDesc[code]));
|
code, Rest.HttpStatusDesc[code]));
|
||||||
|
|
||||||
// Finally initialize and the throw a RestException. All of the
|
// Finally initialize and the throw a RestException. All of the
|
||||||
|
|
|
@ -42,9 +42,12 @@ using Nini.Config;
|
||||||
|
|
||||||
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
{
|
{
|
||||||
|
|
||||||
public class RestAppearanceServices : IRest
|
public class RestAppearanceServices : IRest
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly int PARM_USERID = 0;
|
private static readonly int PARM_USERID = 0;
|
||||||
|
|
||||||
// private static readonly int PARM_PATH = 1;
|
// private static readonly int PARM_PATH = 1;
|
||||||
|
|
||||||
private bool enabled = false;
|
private bool enabled = false;
|
||||||
|
@ -139,6 +142,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
|
|
||||||
private void DoAppearance(RequestData hdata)
|
private void DoAppearance(RequestData hdata)
|
||||||
{
|
{
|
||||||
|
|
||||||
AppearanceRequestData rdata = (AppearanceRequestData) hdata;
|
AppearanceRequestData rdata = (AppearanceRequestData) hdata;
|
||||||
|
|
||||||
Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
|
Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
|
||||||
|
@ -207,7 +211,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
// inventory.
|
// inventory.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// Do we have at least a user agent name?
|
// Do we have at least a user agent name?
|
||||||
|
|
||||||
if (rdata.Parameters.Length < 1)
|
if (rdata.Parameters.Length < 1)
|
||||||
|
@ -306,7 +309,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
|
|
||||||
if (rdata.userAppearance == null)
|
if (rdata.userAppearance == null)
|
||||||
{
|
{
|
||||||
rdata.Fail(Rest.HttpStatusCodeNoContent,"appearance data not found");
|
rdata.Fail(Rest.HttpStatusCodeNoContent,
|
||||||
|
String.Format("appearance data not found for user {0} {1}",
|
||||||
|
rdata.userProfile.FirstName, rdata.userProfile.SurName));
|
||||||
}
|
}
|
||||||
|
|
||||||
rdata.initXmlWriter();
|
rdata.initXmlWriter();
|
||||||
|
@ -331,26 +336,34 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
|
|
||||||
private void DoExtend(AppearanceRequestData rdata)
|
private void DoExtend(AppearanceRequestData rdata)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool created = false;
|
bool created = false;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
string newnode = String.Empty;
|
string newnode = String.Empty;
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
|
||||||
|
|
||||||
AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
|
||||||
|
|
||||||
rdata.userAppearance = new AvatarAppearance();
|
rdata.userAppearance = new AvatarAppearance();
|
||||||
|
|
||||||
rdata.userAppearance.Owner = old.Owner;
|
// Although the following behavior is admitted by HTTP I am becoming
|
||||||
rdata.userAppearance.Serial = old.Serial;
|
// increasingly doubtful that it is appropriate for REST. If I attempt to
|
||||||
|
// add a new record, and it already exists, then it seems to me that the
|
||||||
|
// attempt should fail, rather than update the existing record.
|
||||||
|
|
||||||
if (GetUserAppearance(rdata))
|
if (GetUserAppearance(rdata))
|
||||||
{
|
{
|
||||||
modified = rdata.userAppearance != null;
|
modified = rdata.userAppearance != null;
|
||||||
created = !modified;
|
created = !modified;
|
||||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||||
|
// Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
created = true;
|
created = true;
|
||||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||||
|
// Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (created)
|
if (created)
|
||||||
|
@ -358,9 +371,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
|
newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
|
||||||
rdata.userProfile.SurName);
|
rdata.userProfile.SurName);
|
||||||
// Must include a location header with a URI that identifies the new resource.
|
// Must include a location header with a URI that identifies the new resource.
|
||||||
|
|
||||||
rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
|
rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
|
||||||
rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
|
rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
|
||||||
rdata.Complete(Rest.HttpStatusCodeCreated);
|
rdata.Complete(Rest.HttpStatusCodeCreated);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -399,6 +414,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
{
|
{
|
||||||
modified = true;
|
modified = true;
|
||||||
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
|
||||||
|
Rest.UserServices.UpdateUserProfile(rdata.userProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (created)
|
if (created)
|
||||||
|
@ -703,83 +719,64 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FormatPart(AppearanceRequestData rdata, string part, UUID item, UUID asset)
|
||||||
|
{
|
||||||
|
if(item != UUID.Zero || asset != UUID.Zero)
|
||||||
|
{
|
||||||
|
rdata.writer.WriteStartElement(part);
|
||||||
|
if(item != UUID.Zero)
|
||||||
|
{
|
||||||
|
rdata.writer.WriteAttributeString("Item",item.ToString());
|
||||||
|
}
|
||||||
|
if(asset != UUID.Zero)
|
||||||
|
{
|
||||||
|
rdata.writer.WriteAttributeString("Item",asset.ToString());
|
||||||
|
}
|
||||||
|
rdata.writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void FormatUserAppearance(AppearanceRequestData rdata)
|
private void FormatUserAppearance(AppearanceRequestData rdata)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance", MsgId);
|
||||||
|
|
||||||
|
if(rdata.userAppearance != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: appearance object exists", MsgId);
|
||||||
rdata.writer.WriteStartElement("Appearance");
|
rdata.writer.WriteStartElement("Appearance");
|
||||||
|
|
||||||
rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString());
|
rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString());
|
||||||
|
if(rdata.userAppearance.Owner != null)
|
||||||
rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
|
rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
|
||||||
rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString());
|
rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString());
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Body");
|
FormatPart(rdata, "Body", rdata.userAppearance.BodyItem, rdata.userAppearance.BodyAsset);
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.BodyItem.ToString());
|
FormatPart(rdata, "Skin", rdata.userAppearance.SkinItem, rdata.userAppearance.SkinAsset);
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.BodyAsset.ToString());
|
FormatPart(rdata, "Hair", rdata.userAppearance.HairItem, rdata.userAppearance.HairAsset);
|
||||||
rdata.writer.WriteEndElement();
|
FormatPart(rdata, "Eyes", rdata.userAppearance.EyesItem, rdata.userAppearance.EyesAsset);
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Skin");
|
FormatPart(rdata, "Shirt", rdata.userAppearance.ShirtItem, rdata.userAppearance.ShirtAsset);
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.SkinItem.ToString());
|
FormatPart(rdata, "Pants", rdata.userAppearance.PantsItem, rdata.userAppearance.PantsAsset);
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.SkinAsset.ToString());
|
FormatPart(rdata, "Skirt", rdata.userAppearance.SkirtItem, rdata.userAppearance.SkirtAsset);
|
||||||
rdata.writer.WriteEndElement();
|
FormatPart(rdata, "Shoes", rdata.userAppearance.ShoesItem, rdata.userAppearance.ShoesAsset);
|
||||||
|
FormatPart(rdata, "Socks", rdata.userAppearance.SocksItem, rdata.userAppearance.SocksAsset);
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Hair");
|
FormatPart(rdata, "Jacket", rdata.userAppearance.JacketItem, rdata.userAppearance.JacketAsset);
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.HairItem.ToString());
|
FormatPart(rdata, "Gloves", rdata.userAppearance.GlovesItem, rdata.userAppearance.GlovesAsset);
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.HairAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Eyes");
|
FormatPart(rdata, "UnderShirt", rdata.userAppearance.UnderShirtItem, rdata.userAppearance.UnderShirtAsset);
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.EyesItem.ToString());
|
FormatPart(rdata, "UnderPants", rdata.userAppearance.UnderPantsItem, rdata.userAppearance.UnderPantsAsset);
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.EyesAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Shirt");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.ShirtItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.ShirtAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Pants");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.PantsItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.PantsAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Shoes");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.ShoesItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.ShoesAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Socks");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.SocksItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.SocksAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Jacket");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.JacketItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.JacketAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Gloves");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.GlovesItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.GlovesAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("UnderShirt");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.UnderShirtItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.UnderShirtAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("UnderPants");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.UnderPantsItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.UnderPantsAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Skirt");
|
|
||||||
rdata.writer.WriteAttributeString("Item",rdata.userAppearance.SkirtItem.ToString());
|
|
||||||
rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.SkirtAsset.ToString());
|
|
||||||
rdata.writer.WriteEndElement();
|
|
||||||
|
|
||||||
Hashtable attachments = rdata.userAppearance.GetAttachments();
|
Hashtable attachments = rdata.userAppearance.GetAttachments();
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("Attachments");
|
if(attachments != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
|
||||||
|
|
||||||
|
rdata.writer.WriteStartElement("Attachments");
|
||||||
for (int i=0; i<attachments.Count;i++)
|
for (int i=0; i<attachments.Count;i++)
|
||||||
{
|
{
|
||||||
Hashtable attachment = attachments[i] as Hashtable;
|
Hashtable attachment = attachments[i] as Hashtable;
|
||||||
|
@ -789,35 +786,56 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
|
||||||
rdata.writer.WriteAttributeString("Asset", (string) attachment["asset"]);
|
rdata.writer.WriteAttributeString("Asset", (string) attachment["asset"]);
|
||||||
rdata.writer.WriteEndElement();
|
rdata.writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
rdata.writer.WriteEndElement();
|
rdata.writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
Primitive.TextureEntry texture = rdata.userAppearance.Texture;
|
Primitive.TextureEntry texture = rdata.userAppearance.Texture;
|
||||||
|
|
||||||
if (texture != null)
|
if (texture != null && (texture.DefaultTexture != null || texture.FaceTextures != null))
|
||||||
{
|
{
|
||||||
rdata.writer.WriteStartElement("Texture");
|
|
||||||
rdata.writer.WriteAttributeString("Default",
|
|
||||||
rdata.userAppearance.Texture.DefaultTexture.TextureID.ToString());
|
|
||||||
|
|
||||||
for (int i=0; i<Primitive.TextureEntry.MAX_FACES;i++)
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting textures", MsgId);
|
||||||
|
|
||||||
|
rdata.writer.WriteStartElement("Texture");
|
||||||
|
|
||||||
|
if(texture.DefaultTexture != null)
|
||||||
|
{
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting default texture", MsgId);
|
||||||
|
rdata.writer.WriteAttributeString("Default",
|
||||||
|
texture.DefaultTexture.TextureID.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(texture.FaceTextures != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting face textures", MsgId);
|
||||||
|
|
||||||
|
for (int i=0; i<texture.FaceTextures.Length;i++)
|
||||||
|
{
|
||||||
|
if (texture.FaceTextures[i] != null)
|
||||||
{
|
{
|
||||||
rdata.writer.WriteStartElement("Face");
|
rdata.writer.WriteStartElement("Face");
|
||||||
rdata.writer.WriteAttributeString("Index", i.ToString());
|
rdata.writer.WriteAttributeString("Index", i.ToString());
|
||||||
rdata.writer.WriteAttributeString("Id",
|
rdata.writer.WriteAttributeString("Id",
|
||||||
rdata.userAppearance.Texture.FaceTextures[i].TextureID.ToString());
|
texture.FaceTextures[i].TextureID.ToString());
|
||||||
rdata.writer.WriteEndElement();
|
rdata.writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rdata.writer.WriteEndElement();
|
rdata.writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting visual parameters", MsgId);
|
||||||
|
|
||||||
rdata.writer.WriteStartElement("VisualParameters");
|
rdata.writer.WriteStartElement("VisualParameters");
|
||||||
rdata.writer.WriteBase64(rdata.userAppearance.VisualParams,0,
|
rdata.writer.WriteBase64(rdata.userAppearance.VisualParams,0,
|
||||||
rdata.userAppearance.VisualParams.Length);
|
rdata.userAppearance.VisualParams.Length);
|
||||||
rdata.writer.WriteEndElement();
|
rdata.writer.WriteEndElement();
|
||||||
rdata.writer.WriteFullEndElement();
|
rdata.writer.WriteFullEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
Rest.Log.DebugFormat("{0} FormatUserAppearance: completed", MsgId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5219,7 +5219,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketType.UpdateTaskInventory:
|
case PacketType.UpdateTaskInventory:
|
||||||
m_log.DebugFormat("[AMW] UpdateTaskInventory request");
|
|
||||||
UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
|
UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
|
||||||
if (OnUpdateTaskInventory != null)
|
if (OnUpdateTaskInventory != null)
|
||||||
{
|
{
|
||||||
|
@ -5286,7 +5285,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PacketType.RezScript:
|
case PacketType.RezScript:
|
||||||
m_log.DebugFormat("[AMW] RezScript");
|
|
||||||
//Console.WriteLine(Pack.ToString());
|
//Console.WriteLine(Pack.ToString());
|
||||||
RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
|
RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue