@@ -143,7 +138,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void DoInventory(RequestData hdata)
{
-
InventoryRequestData rdata = (InventoryRequestData) hdata;
Rest.Log.DebugFormat("{0} DoInventory ENTRY", MsgId);
@@ -155,7 +149,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
return;
}
- // Now that we know this is a serious attempt to
+ // Now that we know this is a serious attempt to
// access inventory data, we should find out who
// is asking, and make sure they are authorized
// to do so. We need to validate the caller's
@@ -166,9 +160,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// With the present HTTP server we can't use the
// builtin authentication mechanisms because they
// would be enforced for all in-bound requests.
- // Instead we look at the headers ourselves and
+ // Instead we look at the headers ourselves and
// handle authentication directly.
-
+
try
{
if (!rdata.IsAuthenticated)
@@ -205,7 +199,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
//
// Indicating that this is an inventory request for
// an avatar named Arthur Dent. This is ALL that is
- // required to designate a GET for an entire
+ // required to designate a GET for an entire
// inventory.
//
// Do we have at least a user agent name?
@@ -247,7 +241,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (rdata.userProfile != null)
{
- Rest.Log.DebugFormat("{0} Profile obtained for agent {1} {2}",
+ Rest.Log.DebugFormat("{0} Profile obtained for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
}
else
@@ -269,18 +263,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// response is not recieved in a timely fashion.
rdata.uuid = rdata.userProfile.ID;
-
+
if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
{
-
rdata.root = Rest.InventoryServices.RequestRootFolder(rdata.uuid);
- Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
+ Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
Rest.InventoryServices.RequestInventoryForUser(rdata.uuid, rdata.GetUserInventory);
- Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}",
+ Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
lock (rdata)
@@ -293,7 +286,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (rdata.root == null)
{
- Rest.Log.WarnFormat("{0} Inventory is not available [1] for agent {1} {2}",
+ Rest.Log.WarnFormat("{0} Inventory is not available [1] for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
rdata.Fail(Rest.HttpStatusCodeServerError, "inventory retrieval failed");
}
@@ -301,7 +294,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
else
{
- Rest.Log.WarnFormat("{0} Inventory is not locally available for agent {1} {2}",
+ Rest.Log.WarnFormat("{0} Inventory is not locally available for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
rdata.Fail(Rest.HttpStatusCodeNotFound, "no local inventory for user");
}
@@ -311,7 +304,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
switch (rdata.method)
{
-
case Rest.HEAD : // Do the processing, set the status code, suppress entity
DoGet(rdata);
rdata.buffer = null;
@@ -334,12 +326,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
break;
default :
- Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
+ Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
MsgId, rdata.method, rdata.path);
rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, rdata.method+" not supported");
- break;
+ break;
}
-
}
#endregion Interface
@@ -355,18 +346,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void DoGet(InventoryRequestData rdata)
{
-
rdata.initXmlWriter();
rdata.writer.WriteStartElement(String.Empty,"Inventory",String.Empty);
// If there are additional parameters, then these represent
// a path relative to the root of the inventory. This path
- // must be traversed before we format the sub-tree thus
+ // must be traversed before we format the sub-tree thus
// identified.
traverse(rdata, rdata.root, PARM_PATH);
-
+
// Close all open elements
rdata.writer.WriteFullEndElement();
@@ -379,9 +369,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// constructed from the result of the XML writer.
rdata.Respond(String.Format("Inventory {0} Normal completion", rdata.method));
-
}
-
+
///
/// In the case of the inventory, and probably in general,
/// the distinction between PUT and POST is not always
@@ -392,7 +381,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
/// consistency across different implementations.
///
/// For OpenSim PUT is an update and POST is an addition. This
- /// is the behavior required by the HTTP specification and
+ /// is the behavior required by the HTTP specification and
/// therefore as required by REST.
///
/// The best way to explain the distinction is to
@@ -401,53 +390,51 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
/// actual entity to be modified or replaced, i.e. the
/// enclosed entity.
///
- /// If the operation is POST,then the URI describes the
+ /// If the operation is POST,then the URI describes the
/// context into which the new entity will be added.
///
/// As an example, suppose the URI contains:
/// /admin/inventory/Clothing
///
/// A PUT request will normally result in some modification of
- /// the folder or item named "Clothing". Whereas a POST
- /// request will normally add some new information into the
+ /// the folder or item named "Clothing". Whereas a POST
+ /// request will normally add some new information into the
/// content identified by Clothing. It follows from this
/// that for POST, the element identified by the URI MUST
/// be a folder.
///
///
- /// POST adds new information to the inventory in the
+ /// POST adds new information to the inventory in the
/// context identified by the URI.
///
/// HTTP service request work area
private void DoExtend(InventoryRequestData rdata)
{
-
bool created = false;
bool modified = false;
string newnode = String.Empty;
// Resolve the context node specified in the URI. Entity
// data will be ADDED beneath this node. rdata already contains
- // information about the current content of the user's
+ // information about the current content of the user's
// inventory.
Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, Rest.Fill);
// Processing depends upon the type of inventory node
// identified in the URI. This is the CONTEXT for the
- // change. We either got a context or we threw an
+ // change. We either got a context or we threw an
// exception.
// It follows that we can only add information if the URI
- // has identified a folder. So only a type of folder is supported
+ // has identified a folder. So only a type of folder is supported
// in this case.
if (typeof(InventoryFolderBase) == InventoryNode.GetType() ||
typeof(InventoryFolderImpl) == InventoryNode.GetType())
{
-
// Cast the context node appropriately.
InventoryFolderBase context = (InventoryFolderBase) InventoryNode;
@@ -466,12 +453,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
XmlInventoryCollection entity = ReconstituteEntity(rdata);
// Inlined assets can be included in entity. These must be incorporated into
- // the asset database before we attempt to update the inventory. If anything
+ // the asset database before we attempt to update the inventory. If anything
// fails, return a failure to requestor.
if (entity.Assets.Count > 0)
{
-
Rest.Log.DebugFormat("{0} Adding {1} assets to server",
MsgId, entity.Assets.Count);
@@ -489,9 +475,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
Rest.Dump(asset.Data);
}
-
}
-
}
// Modify the context using the collection of folders and items
@@ -499,7 +483,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
foreach (InventoryFolderBase folder in entity.Folders)
{
-
InventoryFolderBase found;
// If the parentID is zero, then this folder is going
@@ -544,7 +527,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
modified = true;
rdata.appendStatus(String.Format(" Created folder {0}, UUID {1}
",
- folder.Name, folder.ID));
+ folder.Name, folder.ID));
}
else
{
@@ -553,10 +536,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
created = true;
rdata.appendStatus(String.Format("
Modified folder {0}, UUID {1}
",
- folder.Name, folder.ID));
-
+ folder.Name, folder.ID));
}
-
}
// Now we repeat a similar process for the items included
@@ -564,7 +545,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
foreach (InventoryItemBase item in entity.Items)
{
-
InventoryItemBase found = null;
// If the parentID is zero, then this is going
@@ -575,7 +555,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
item.Folder = context.ID;
}
- // Determine whether this is a new item or a
+ // Determine whether this is a new item or a
// replacement definition.
foreach (InventoryItemBase xi in rdata.items)
@@ -604,7 +584,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
created = true;
rdata.appendStatus(String.Format("
Created item {2}, UUID {3}
", item.Name, item.ID));
}
-
}
if (created)
@@ -627,7 +606,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
rdata.Respond("Inventory " + rdata.method + ": Normal completion");
-
}
else
{
@@ -635,35 +613,33 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
MsgId, rdata.method, rdata.path, InventoryNode.GetType());
rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid resource context");
}
-
}
///
/// PUT updates the URI-identified element in the inventory. This
/// is actually far more flexible than it might at first sound. For
/// PUT the URI serves two purposes:
- /// [1] It identifies the user whose inventory is to be
+ /// [1] It identifies the user whose inventory is to be
/// processed.
/// [2] It optionally specifies a subtree of the inventory
- /// that is to be used to resolve any relative subtree
+ /// that is to be used to resolve any relative subtree
/// specifications in the entity. If nothing is specified
/// then the whole of the private inventory is implied.
/// Please note that the subtree specified by the URI is only relevant
/// to an entity containing a URI relative specification, i.e. one or
- /// more elements do not specify parent folder information. These
+ /// more elements do not specify parent folder information. These
/// elements will be implicitly referenced within the context identified
/// by the URI.
/// If an element in the entity specifies an explicit parent folder, then
/// that parent is effective, regardless of any value specified in the
/// URI. If the parent does not exist, then the element, and any dependent
- /// elements, are ignored. This case is actually detected and handled
+ /// elements, are ignored. This case is actually detected and handled
/// during the reconstitution process.
///
/// HTTP service request work area
private void DoUpdate(InventoryRequestData rdata)
{
-
int count = 0;
bool created = false;
bool modified = false;
@@ -675,8 +651,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, Rest.Fill);
// As long as we have a node, then we have something
- // meaningful to do, unlike POST. So we reconstitute the
- // subtree before doing anything else. Note that we
+ // meaningful to do, unlike POST. So we reconstitute the
+ // subtree before doing anything else. Note that we
// etiher got a valid node or we threw an exception.
XmlInventoryCollection entity = ReconstituteEntity(rdata);
@@ -705,33 +681,31 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
Rest.Dump(asset.Data);
}
-
}
}
// The URI specifies either a folder or an item to be updated.
//
// The root node in the entity will replace the node identified
- // by the URI. This means the parent will remain the same, but
+ // by the URI. This means the parent will remain the same, but
// any or all attributes associated with the named element
// will change.
//
// If the inventory collection contains an element with a zero
- // parent ID, then this is taken to be the replacement for the
- // named node. The collection MAY also specify an explicit
+ // parent ID, then this is taken to be the replacement for the
+ // named node. The collection MAY also specify an explicit
// parent ID, in this case it MAY identify the same parent as
- // the current node, or it MAY specify a different parent,
+ // the current node, or it MAY specify a different parent,
// indicating that the folder is being moved in addition to any
// other modifications being made.
if (typeof(InventoryFolderBase) == InventoryNode.GetType() ||
typeof(InventoryFolderImpl) == InventoryNode.GetType())
{
-
bool rfound = false;
InventoryFolderBase uri = (InventoryFolderBase) InventoryNode;
InventoryFolderBase xml = null;
-
+
// If the entity to be replaced resolved to be the root
// directory itself (My Inventory), then make sure that
// the supplied data include as appropriately typed and
@@ -741,7 +715,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (uri == rdata.root)
{
-
foreach (InventoryFolderBase folder in entity.Folders)
{
if ((rfound = (folder.Name == PRIVATE_ROOT_NAME)))
@@ -757,7 +730,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
MsgId, rdata.method, rdata.path);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid inventory structure");
}
-
}
// Scan the set of folders in the entity collection for an
@@ -768,7 +740,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// ambiguity in this case because this is POST and we are
// supposed to be modifying a specific node.
// We assign any element IDs required as an economy; we don't
- // want to iterate over the fodler set again if it can be
+ // want to iterate over the fodler set again if it can be
// helped.
foreach (InventoryFolderBase folder in entity.Folders)
@@ -795,13 +767,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// Exactly one entry means we ARE replacing the node
// identified by the URI. So we delete the old folder
// by moving it to the trash and then purging it.
- // We then add all of the folders and items we
+ // We then add all of the folders and items we
// included in the entity. The subtree has been
// modified.
if (count == 1)
{
-
InventoryFolderBase TrashCan = GetTrashCan(rdata);
// All went well, so we generate a UUID is one is
@@ -816,10 +787,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.InventoryServices.MoveFolder(uri);
Rest.InventoryServices.PurgeFolder(TrashCan);
modified = true;
-
}
- // Now, regardelss of what they represent, we
+ // Now, regardelss of what they represent, we
// integrate all of the elements in the entity.
foreach (InventoryFolderBase f in entity.Folders)
@@ -833,7 +803,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
rdata.appendStatus(String.Format("
Storing item {0} UUID {1}
", it.Name, it.ID));
Rest.InventoryServices.AddItem(it);
}
-
}
///
@@ -846,7 +815,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
else
{
-
InventoryItemBase uri = (InventoryItemBase) InventoryNode;
InventoryItemBase xml = null;
@@ -865,7 +833,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
xml = entity.Items[0];
-
+
if (xml.ID == LLUUID.Zero)
{
xml.ID = LLUUID.Random();
@@ -884,7 +852,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.InventoryServices.AddItem(xml);
rdata.appendStatus(String.Format("Storing item {0} UUID {1}
", xml.Name, xml.ID));
-
}
if (created)
@@ -904,7 +871,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
rdata.Respond("Inventory " + rdata.method + ": Normal completion");
-
}
///
@@ -917,7 +883,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
///
/// Folders are deleted by moving them to another folder and then
/// purging that folder. We'll do that by creating a temporary
- /// sub-folder in the TrashCan and purging that folder's
+ /// sub-folder in the TrashCan and purging that folder's
/// contents. If we can't can it, we don't delete it...
/// So, if no trashcan is available, the request does nothing.
/// Items are summarily deleted.
@@ -930,13 +896,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void DoDelete(InventoryRequestData rdata)
{
-
Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, false);
if (typeof(InventoryFolderBase) == InventoryNode.GetType() ||
typeof(InventoryFolderImpl) == InventoryNode.GetType())
{
-
InventoryFolderBase TrashCan = GetTrashCan(rdata);
InventoryFolderBase folder = (InventoryFolderBase) InventoryNode;
@@ -947,7 +911,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.InventoryServices.PurgeFolder(TrashCan);
rdata.appendStatus(String.Format("Deleted folder {0} UUID {1}
", folder.Name, folder.ID));
-
}
// Deleting items is much more straight forward.
@@ -963,7 +926,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
rdata.Complete();
rdata.Respond("Inventory " + rdata.method + ": Normal completion");
-
}
#endregion method-specific processing
@@ -971,10 +933,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
///
/// This method is called to obtain the OpenSim inventory object identified
/// by the supplied URI. This may be either an Item or a Folder, so a suitably
- /// ambiguous return type is employed (Object). This method recurses as
+ /// ambiguous return type is employed (Object). This method recurses as
/// necessary to process the designated hierarchy.
- ///
- /// If we reach the end of the URI then we return the contextual folder to
+ ///
+ /// If we reach the end of the URI then we return the contextual folder to
/// our caller.
///
/// If we are not yet at the end of the URI we attempt to find a child folder
@@ -1000,7 +962,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
InventoryFolderBase folder,
int pi, bool fill)
{
-
InventoryFolderBase foundf = null;
int fk = 0;
@@ -1013,18 +974,19 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
return folder;
}
- // There are more names in the parameter sequence,
- // look for the folder named by param[pi] as a
+ // There are more names in the parameter sequence,
+ // look for the folder named by param[pi] as a
// child of the folder supplied as an argument.
// Note that a UUID may have been supplied as the
// identifier (it is the ONLY guaranteed unambiguous
- // option.
+ // option.
if (rdata.folders != null)
+ {
foreach (InventoryFolderBase f in rdata.folders)
{
// Look for the present node in the directory list
- if (f.ParentID == folder.ID &&
+ if (f.ParentID == folder.ID &&
(f.Name == rdata.Parameters[pi] ||
f.ID.ToString() == rdata.Parameters[pi]))
{
@@ -1032,7 +994,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
fk++;
}
}
-
+ }
+
// If more than one node matched, then the path, as specified
// is ambiguous.
@@ -1063,7 +1026,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
InventoryItemBase li = null;
foreach (InventoryItemBase i in rdata.items)
{
- if (i.Folder == folder.ID &&
+ if (i.Folder == folder.ID &&
(i.Name == rdata.Parameters[pi] ||
i.ID.ToString() == rdata.Parameters[pi]))
{
@@ -1099,11 +1062,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
rdata.Fail(Rest.HttpStatusCodeNotFound, "resource "+rdata.path+" not found");
return null; /* Never reached */
-
}
///
- /// This routine traverse the inventory's structure until the end-point identified
+ /// This routine traverse the inventory's structure until the end-point identified
/// in the URI is reached, the remainder of the inventory (if any) is then formatted
/// and returned to the requestor.
///
@@ -1119,13 +1081,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void traverse(InventoryRequestData rdata, InventoryFolderBase folder, int pi)
{
-
Rest.Log.DebugFormat("{0} Traverse[initial] : {1} {2} [{3}]", MsgId, folder.ID, folder.Name, pi);
if (rdata.folders != null)
{
-
- // If there was only one parameter (avatar name), then the entire
+ // If there was only one parameter (avatar name), then the entire
// inventory is being requested.
if (rdata.Parameters.Length == 1)
@@ -1159,18 +1119,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
return;
-
}
}
///
- /// This is the recursive method. I've separated them in this way so that
+ /// This is the recursive method. I've separated them in this way so that
/// we do not have to waste cycles on any first-case-only processing.
///
private void traverseInventory(InventoryRequestData rdata, InventoryFolderBase folder, int pi)
{
-
int fk = 0;
InventoryFolderBase ffound = null;
InventoryItemBase ifound = null;
@@ -1179,7 +1137,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
foreach (InventoryFolderBase f in rdata.folders)
{
- if (f.ParentID == folder.ID &&
+ if (f.ParentID == folder.ID &&
(f.Name == rdata.Parameters[pi] ||
f.ID.ToString() == rdata.Parameters[pi]))
{
@@ -1194,14 +1152,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (pi == rdata.Parameters.Length-1)
{
-
// Only if there are any items, and there pretty much always are.
if (rdata.items != null)
{
foreach (InventoryItemBase i in rdata.items)
{
- if (i.Folder == folder.ID &&
+ if (i.Folder == folder.ID &&
(i.Name == rdata.Parameters[pi] ||
i.ID.ToString() == rdata.Parameters[pi]))
{
@@ -1230,7 +1187,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
// Fetching an Item has a special significance. In this
// case we also want to fetch the associated asset.
- // To make it interesting, we'll d this via redirection.
+ // To make it interesting, we'll d this via redirection.
string asseturl = "http://" + rdata.hostname + ":" + rdata.port +
"/admin/assets" + Rest.UrlPathSeparator + ifound.AssetID.ToString();
rdata.Redirect(asseturl,Rest.PERMANENT);
@@ -1240,14 +1197,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
else if (fk > 1)
{
rdata.Fail(Rest.HttpStatusCodeConflict,
- String.Format("ambiguous element ({0}) in path specified: <{1}>",
- pi, rdata.path));
+ String.Format("ambiguous element ({0}) in path specified: <{1}>",
+ pi, rdata.path));
}
- Rest.Log.DebugFormat("{0} Inventory does not contain item/folder: <{1}>",
+ Rest.Log.DebugFormat("{0} Inventory does not contain item/folder: <{1}>",
MsgId, rdata.path);
rdata.Fail(Rest.HttpStatusCodeNotFound,String.Format("no such item/folder : {0}",
- rdata.Parameters[pi]));
+ rdata.Parameters[pi]));
}
@@ -1264,10 +1221,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void formatInventory(InventoryRequestData rdata, InventoryFolderBase folder, string indent)
{
-
if (Rest.DEBUG)
{
- Rest.Log.DebugFormat("{0} Folder : {1} {2} {3} type = {4}",
+ Rest.Log.DebugFormat("{0} Folder : {1} {2} {3} type = {4}",
MsgId, folder.ID, indent, folder.Name, folder.Type);
indent += "\t";
}
@@ -1307,7 +1263,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// End folder item
rdata.writer.WriteEndElement();
-
}
///
@@ -1319,8 +1274,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void formatItem(InventoryRequestData rdata, InventoryItemBase i, string indent)
{
-
- Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}",
+ Rest.Log.DebugFormat("{0} Item : {1} {2} {3} Type = {4}, AssetType = {5}",
MsgId, i.ID, indent, i.Name, i.InvType, i.AssetType);
rdata.writer.WriteStartElement(String.Empty,"Item",String.Empty);
@@ -1350,11 +1304,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
rdata.writer.WriteElementString("Asset",i.AssetID.ToString());
rdata.writer.WriteEndElement();
-
}
///
- /// This method creates a "trashcan" folder to support folder and item
+ /// This method creates a "trashcan" folder to support folder and item
/// deletions by this interface. The xisting trash folder is found and
/// this folder is created within it. It is called "tmp" to indicate to
/// the client that it is OK to delete this folder. The REST interface
@@ -1366,7 +1319,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private InventoryFolderBase GetTrashCan(InventoryRequestData rdata)
{
-
InventoryFolderBase TrashCan = null;
foreach (InventoryFolderBase f in rdata.folders)
@@ -1393,7 +1345,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
}
}
-
+
if (TrashCan == null)
{
Rest.Log.DebugFormat("{0} No Trash Can available", MsgId);
@@ -1401,7 +1353,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
return TrashCan;
-
}
///
@@ -1413,11 +1364,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private bool FolderHasChanged(InventoryFolderBase newf, InventoryFolderBase oldf)
{
- return ( newf.Name != oldf.Name
- || newf.ParentID != oldf.ParentID
- || newf.Owner != oldf.Owner
- || newf.Type != oldf.Type
- || newf.Version != oldf.Version
+ return (newf.Name != oldf.Name
+ || newf.ParentID != oldf.ParentID
+ || newf.Owner != oldf.Owner
+ || newf.Type != oldf.Type
+ || newf.Version != oldf.Version
);
}
@@ -1430,24 +1381,24 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private bool ItemHasChanged(InventoryItemBase newf, InventoryItemBase oldf)
{
- return ( newf.Name != oldf.Name
- || newf.Folder != oldf.Description
- || newf.Description != oldf.Description
- || newf.Owner != oldf.Owner
- || newf.Creator != oldf.Creator
- || newf.AssetID != oldf.AssetID
- || newf.GroupID != oldf.GroupID
- || newf.GroupOwned != oldf.GroupOwned
- || newf.InvType != oldf.InvType
- || newf.AssetType != oldf.AssetType
+ return (newf.Name != oldf.Name
+ || newf.Folder != oldf.Description
+ || newf.Description != oldf.Description
+ || newf.Owner != oldf.Owner
+ || newf.Creator != oldf.Creator
+ || newf.AssetID != oldf.AssetID
+ || newf.GroupID != oldf.GroupID
+ || newf.GroupOwned != oldf.GroupOwned
+ || newf.InvType != oldf.InvType
+ || newf.AssetType != oldf.AssetType
);
}
///
/// This method is called by PUT and POST to create an XmlInventoryCollection
/// instance that reflects the content of the entity supplied on the request.
- /// Any elements in the completed collection whose UUID is zero, are
- /// considered to be located relative to the end-point identified int he
+ /// Any elements in the completed collection whose UUID is zero, are
+ /// considered to be located relative to the end-point identified int he
/// URI. In this way, an entire sub-tree can be conveyed in a single REST
/// PUT or POST request.
///
@@ -1455,27 +1406,25 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
/// has an entity, it is more completely initialized. thus, if no entity was
/// provided the collection is valid, but empty.
///
- /// The entity is then scanned and each tag is processed to produce the
+ /// The entity is then scanned and each tag is processed to produce the
/// appropriate inventory elements. At the end f the scan, teh XmlInventoryCollection
/// will reflect the subtree described by the entity.
///
/// This is a very flexible mechanism, the entity may contain arbitrary,
/// discontiguous tree fragments, or may contain single element. The caller is
- /// responsible for integrating this collection (and ensuring that any
+ /// responsible for integrating this collection (and ensuring that any
/// missing parent IDs are resolved).
///
/// HTTP service request work area
internal XmlInventoryCollection ReconstituteEntity(InventoryRequestData rdata)
{
-
Rest.Log.DebugFormat("{0} Reconstituting entity", MsgId);
XmlInventoryCollection ic = new XmlInventoryCollection();
if (rdata.request.HasEntityBody)
{
-
Rest.Log.DebugFormat("{0} Entity present", MsgId);
ic.init(rdata);
@@ -1571,7 +1520,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.Log.WarnFormat("{0} Unexpected XML parsing error: {1}", MsgId, e.Message);
throw e;
}
-
}
else
{
@@ -1587,14 +1535,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
return ic;
-
}
///
/// This method creates an inventory Folder from the
/// information supplied in the request's entity.
- /// A folder instance is created and initialized to reflect
- /// default values. These values are then overridden
+ /// A folder instance is created and initialized to reflect
+ /// default values. These values are then overridden
/// by information supplied in the entity.
/// If context was not explicitly provided, then the
/// appropriate ID values are determined.
@@ -1602,7 +1549,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void CollectFolder(XmlInventoryCollection ic)
{
-
Rest.Log.DebugFormat("{0} Interpret folder element", MsgId);
InventoryFolderBase result = new InventoryFolderBase();
@@ -1614,7 +1560,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
result.Owner = ic.UserID;
result.ParentID = LLUUID.Zero; // Context
result.Type = (short) AssetType.Folder;
- result.Version = 1;
+ result.Version = 1;
if (ic.xml.HasAttributes)
{
@@ -1642,7 +1588,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
result.Version = UInt16.Parse(ic.xml.Value);
break;
default :
- Rest.Log.DebugFormat("{0} Folder: unrecognized attribute: {1}:{2}",
+ Rest.Log.DebugFormat("{0} Folder: unrecognized attribute: {1}:{2}",
MsgId, ic.xml.Name, ic.xml.Value);
ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute <{0}>",
ic.xml.Name));
@@ -1664,7 +1610,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
else
{
-
bool found = false;
foreach (InventoryFolderBase parent in ic.rdata.folders)
@@ -1678,11 +1623,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (!found)
{
- Rest.Log.ErrorFormat("{0} Invalid parent ID ({1}) in folder {2}",
+ Rest.Log.ErrorFormat("{0} Invalid parent ID ({1}) in folder {2}",
MsgId, ic.Item.Folder, result.ID);
ic.Fail(Rest.HttpStatusCodeBadRequest, "invalid parent");
}
-
}
// This is a new folder, so no existing UUID is available
@@ -1697,15 +1641,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// obsolete as a consequence.
ic.Push(result);
-
}
///
/// This method is called to handle the construction of an Item
- /// instance from the supplied request entity. It is called
+ /// instance from the supplied request entity. It is called
/// whenever an Item start tag is detected.
/// An instance of an Item is created and initialized to default
- /// values. These values are then overridden from values supplied
+ /// values. These values are then overridden from values supplied
/// as attributes to the Item element.
/// This item is then stored in the XmlInventoryCollection and
/// will be verified by Validate.
@@ -1715,7 +1658,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void CollectItem(XmlInventoryCollection ic)
{
-
Rest.Log.DebugFormat("{0} Interpret item element", MsgId);
InventoryItemBase result = new InventoryItemBase();
@@ -1736,7 +1678,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
for (int i = 0; i < ic.xml.AttributeCount; i++)
{
-
ic.xml.MoveToAttribute(i);
switch (ic.xml.Name)
@@ -1785,37 +1726,36 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
break;
default :
- Rest.Log.DebugFormat("{0} Item: Unrecognized attribute: {1}:{2}",
+ Rest.Log.DebugFormat("{0} Item: Unrecognized attribute: {1}:{2}",
MsgId, ic.xml.Name, ic.xml.Value);
ic.Fail(Rest.HttpStatusCodeBadRequest, String.Format("unrecognized attribute",
ic.xml.Name));
break;
}
}
- }
-
+ }
+
ic.xml.MoveToElement();
ic.Push(result);
-
}
///
- /// This method assembles an asset instance from the
- /// information supplied in the request's entity. It is
- /// called as a result of detecting a start tag for a
+ /// This method assembles an asset instance from the
+ /// information supplied in the request's entity. It is
+ /// called as a result of detecting a start tag for a
/// type of Asset.
/// The information is collected locally, and an asset
/// instance is created only if the basic XML parsing
/// completes successfully.
- /// Default values for all parts of the asset are
+ /// Default values for all parts of the asset are
/// established before overriding them from the supplied
/// XML.
/// If an asset has inline=true as an attribute, then
/// the element contains the data representing the
/// asset. This is saved as the data component.
/// inline=false means that the element's payload is
- /// simply the UUID of the asset referenced by the
+ /// simply the UUID of the asset referenced by the
/// item being constructed.
/// An asset, if created is stored in the
/// XmlInventoryCollection
@@ -1876,9 +1816,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
break;
default :
- Rest.Log.DebugFormat("{0} Asset: Unrecognized attribute: {1}:{2}",
+ Rest.Log.DebugFormat("{0} Asset: Unrecognized attribute: {1}:{2}",
MsgId, ic.xml.Name, ic.xml.Value);
- ic.Fail(Rest.HttpStatusCodeBadRequest,
+ ic.Fail(Rest.HttpStatusCodeBadRequest,
String.Format("unrecognized attribute <{0}>", ic.xml.Name));
break;
}
@@ -1889,7 +1829,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// If this is a reference to an existing asset, just store the
// asset ID into the item.
-
+
if (!inline)
{
if (ic.Item != null)
@@ -1904,13 +1844,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
}
- // Otherwise, generate an asset ID, store that into the item, and
+ // Otherwise, generate an asset ID, store that into the item, and
// create an entry in the asset list for the inlined asset. But
// only if the size is non-zero.
else
{
-
string b64string = null;
// Generate a UUID of none were given, and generally none should
@@ -1923,17 +1862,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// Create AssetBase entity to hold the inlined asset
- asset = new AssetBase(uuid, name);
+ asset = new AssetBase(uuid, name);
asset.Description = desc;
asset.Type = type; // type == 0 == texture
asset.Local = local;
asset.Temporary = temp;
-
+
b64string = ic.xml.ReadElementContentAsString();
Rest.Log.DebugFormat("{0} Data length is {1}", MsgId, b64string.Length);
- Rest.Log.DebugFormat("{0} Data content starts with: \n\t<{1}>", MsgId,
+ Rest.Log.DebugFormat("{0} Data content starts with: \n\t<{1}>", MsgId,
b64string.Substring(0, b64string.Length > 132 ? 132 : b64string.Length));
asset.Data = Convert.FromBase64String(b64string);
@@ -1952,7 +1891,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
ic.Item.AssetID = uuid;
}
-
}
ic.Push(asset);
@@ -1961,13 +1899,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
///
/// Store any permissions information provided by the request.
- /// This overrides the default permissions set when the
+ /// This overrides the default permissions set when the
/// XmlInventoryCollection object was created.
///
private void CollectPermissions(XmlInventoryCollection ic)
{
-
if (ic.xml.HasAttributes)
{
for (int i = 0; i < ic.xml.AttributeCount; i++)
@@ -1990,7 +1927,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
default :
Rest.Log.DebugFormat("{0} Permissions: invalid attribute {1}:{2}",
MsgId,ic.xml.Name, ic.xml.Value);
- ic.Fail(Rest.HttpStatusCodeBadRequest,
+ ic.Fail(Rest.HttpStatusCodeBadRequest,
String.Format("invalid attribute <{0}>", ic.xml.Name));
break;
}
@@ -1998,7 +1935,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
ic.xml.MoveToElement();
-
}
///
@@ -2013,7 +1949,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void Validate(XmlInventoryCollection ic)
{
-
// There really should be an item present if we've
// called validate. So fail if there is not.
@@ -2022,7 +1957,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.Log.ErrorFormat("{0} Unable to parse request", MsgId);
ic.Fail(Rest.HttpStatusCodeBadRequest, "request parse error");
}
-
+
// Every item is required to have a name (via REST anyway)
if (ic.Item.Name == String.Empty)
@@ -2030,18 +1965,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.Log.ErrorFormat("{0} An item name MUST be specified", MsgId);
ic.Fail(Rest.HttpStatusCodeBadRequest, "item name required");
}
-
- // An item MUST have an asset ID. AssetID should never be zero
+
+ // An item MUST have an asset ID. AssetID should never be zero
// here. It should always get set from the information stored
// when the Asset element was processed.
if (ic.Item.AssetID == LLUUID.Zero)
{
-
Rest.Log.ErrorFormat("{0} Unable to complete request", MsgId);
Rest.Log.InfoFormat("{0} Asset information is missing", MsgId);
ic.Fail(Rest.HttpStatusCodeBadRequest, "asset information required");
-
}
// If the item is new, then assign it an ID
@@ -2054,14 +1987,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// If the context is being implied, obtain the current
// folder item's ID. If it was specified explicitly, make
// sure that theparent folder exists.
-
+
if (ic.Item.Folder == LLUUID.Zero)
{
ic.Item.Folder = ic.Parent();
}
else
{
-
bool found = false;
foreach (InventoryFolderBase parent in ic.rdata.folders)
@@ -2075,11 +2007,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (!found)
{
- Rest.Log.ErrorFormat("{0} Invalid parent ID ({1}) in item {2}",
+ Rest.Log.ErrorFormat("{0} Invalid parent ID ({1}) in item {2}",
MsgId, ic.Item.Folder, ic.Item.ID);
ic.Fail(Rest.HttpStatusCodeBadRequest, "parent information required");
}
-
}
// If this is an inline asset being constructed in the context
@@ -2101,13 +2032,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
ic.Item.NextPermissions = ic.NextPermissions;
// If no type was specified for this item, we can attempt to
- // infer something from the file type maybe. This is NOT as
+ // infer something from the file type maybe. This is NOT as
// good as having type be specified in the XML.
if (ic.Item.AssetType == (int) AssetType.Unknown ||
ic.Item.InvType == (int) AssetType.Unknown)
{
-
Rest.Log.DebugFormat("{0} Attempting to infer item type", MsgId);
string[] parts = ic.Item.Name.Split(Rest.CA_PERIOD);
@@ -2127,7 +2057,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (parts.Length > 1)
{
- Rest.Log.DebugFormat("{0} File type is {1}",
+ Rest.Log.DebugFormat("{0} File type is {1}",
MsgId, parts[parts.Length - 1]);
switch (parts[parts.Length - 1])
{
@@ -2135,7 +2065,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
case "jpeg-2000" :
case "jpg2000" :
case "jpg-2000" :
- Rest.Log.DebugFormat("{0} Type {1} inferred",
+ Rest.Log.DebugFormat("{0} Type {1} inferred",
MsgId, parts[parts.Length-1]);
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageJPEG;
@@ -2144,7 +2074,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
break;
case "jpg" :
case "jpeg" :
- Rest.Log.DebugFormat("{0} Type {1} inferred",
+ Rest.Log.DebugFormat("{0} Type {1} inferred",
MsgId, parts[parts.Length - 1]);
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageJPEG;
@@ -2168,7 +2098,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
break;
default :
- Rest.Log.DebugFormat("{0} Asset/Inventory type could not be inferred for {1}",
+ Rest.Log.DebugFormat("{0} Asset/Inventory type could not be inferred for {1}",
MsgId,ic.Item.Name);
break;
}
@@ -2186,16 +2116,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
temp = OpenJPEGNet.LoadTGAClass.LoadTGA(tgadata);
ic.Asset.Data = OpenJPEGNet.OpenJPEG.EncodeFromImage(temp, true);
}
-
- ic.reset();
+ ic.reset();
}
#region Inventory RequestData extension
internal class InventoryRequestData : RequestData
{
-
///
/// These are the inventory specific request/response state
/// extensions.
@@ -2214,7 +2142,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
}
///
- /// This is the callback method required by inventory services. The
+ /// This is the callback method required by inventory services. The
/// requestor issues an inventory request and then blocks until this
/// method signals the monitor.
///
@@ -2230,7 +2158,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Monitor.Pulse(this);
}
}
-
}
#endregion Inventory RequestData extension
@@ -2243,7 +2170,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
internal class XmlInventoryCollection : InventoryCollection
{
-
internal InventoryRequestData rdata;
private Stack stk;
@@ -2336,7 +2262,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
rdata.Fail(code, addendum);
}
-
}
}
}
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs
index c50a945..1cbe38f 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs
@@ -23,7 +23,6 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
*/
using libsecondlife;
@@ -41,10 +40,8 @@ using OpenSim.Framework.Communications.Cache;
namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
{
-
public class Remote : ITest
{
-
private static readonly int PARM_TESTID = 0;
private static readonly int PARM_COMMAND = 1;
@@ -72,7 +69,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
}
// Called by the plug-in to halt REST processing. Local processing is
- // disabled, and control blocks until all current processing has
+ // disabled, and control blocks until all current processing has
// completed. No new processing will be started
public void Close()
@@ -91,11 +88,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
// Remote Handler
// Key information of interest here is the Parameters array, each
// entry represents an element of the URI, with element zero being
- // the
+ // the
public void Execute(RequestData rdata)
{
-
if (!enabled) return;
// If we can't relate to what's there, leave it for others.
@@ -125,7 +121,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
{
DoHelp(rdata);
}
- }
+ }
private void DoHelp(RequestData rdata)
{
@@ -138,7 +134,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
{
if (rdata.Parameters.Length >= 6)
{
-
string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE);
ScenePresence avatar = null;
Scene scene = null;
@@ -149,7 +144,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
String.Format("invalid avatar name: <{0}>",rdata.Parameters[PARM_MOVE_AVATAR]));
}
- Rest.Log.WarnFormat("{0} '{1}' command received for {2} {3}",
+ Rest.Log.WarnFormat("{0} '{1}' command received for {2} {3}",
MsgId, rdata.Parameters[0], names[0], names[1]);
// The first parameter should be an avatar name, look for the
@@ -171,8 +166,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
if (avatar != null)
{
-
- Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}",
+ Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}",
MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName);
try
@@ -185,16 +179,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
}
catch (Exception e)
{
- rdata.Fail(Rest.HttpStatusCodeBadRequest,
- String.Format("invalid parameters: {0}", e.Message));
+ rdata.Fail(Rest.HttpStatusCodeBadRequest,
+ String.Format("invalid parameters: {0}", e.Message));
}
}
else
{
- rdata.Fail(Rest.HttpStatusCodeBadRequest,
+ rdata.Fail(Rest.HttpStatusCodeBadRequest,
String.Format("avatar {0} not present", rdata.Parameters[PARM_MOVE_AVATAR]));
- }
+ }
rdata.Complete();
rdata.Respond("OK");
@@ -205,7 +199,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
}
-
}
private static readonly string Help =
@@ -220,6 +213,5 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
+ "