From: Richard Alimi <ralimi@us.ibm.com>

The following patch allows an asset to be added via the REST interface.
0.6.0-stable
Dr Scofield 2008-08-15 07:45:23 +00:00
parent 08c5c71200
commit d96701a0e4
1 changed files with 44 additions and 0 deletions

View File

@ -168,6 +168,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
DoGet(rdata);
break;
case "put" :
DoPut(rdata);
break;
case "post" :
case "delete" :
default :
@ -240,6 +242,48 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
private void DoPut(AssetRequestData rdata)
{
Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method);
// The only parameter we accept is an LLUUID for
// the asset
if (rdata.parameters.Length == 1)
{
rdata.initXmlReader();
XmlReader xml = rdata.reader;
if (!xml.ReadToFollowing("Asset"))
{
Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path);
rdata.Fail(Rest.HttpStatusCodeBadRequest,
Rest.HttpStatusDescBadRequest);
}
AssetBase asset = new AssetBase();
asset.ID = rdata.parameters[0];
asset.Name = xml.GetAttribute("name");
asset.Description = xml.GetAttribute("desc");
asset.Type = SByte.Parse(xml.GetAttribute("type"));
asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0;
asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0;
asset.Data = (new System.Text.ASCIIEncoding()).GetBytes(Rest.Base64ToString(xml.ReadElementContentAsString("Asset", "")));
Rest.AssetServices.AddAsset(asset);
}
else
{
Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
rdata.Fail(Rest.HttpStatusCodeNotFound,
Rest.HttpStatusDescNotFound);
}
rdata.Complete();
rdata.Respond("Asset " + rdata.method + ": Normal completion");
}
internal class AssetRequestData : RequestData
{
internal AssetRequestData(OSHttpRequest request, OSHttpResponse response, string prefix)