C# Class OpenSim.ApplicationPlugins.Rest.Inventory.RestInventoryServices

Inheritance: IRest
Show file Open project: openmetaversefoundation/fortis-opensim

Private Properties

Property Type Description
Allocate RequestData
CollectAsset void
CollectFolder void
CollectItem void
CollectPermissions void
DoInventory void
FolderHasChanged bool
GetTrashCan InventoryFolderBase
ItemHasChanged bool
ReconstituteEntity XmlInventoryCollection
Validate void
formatInventory void
formatItem void
getInventoryNode Object
traverse void
traverseInventory void

Public Methods

Method Description
Close ( ) : void

Called by the plug-in to halt service processing. Local processing is disabled.

Initialize ( ) : void

Post-construction, pre-enabled initialization opportunity Not currently exploited.

RestInventoryServices ( ) : System

The constructor makes sure that the service prefix is absolute and the registers the service handler and the allocator.

Private Methods

Method Description
Allocate ( OpenSim.Framework.Servers.HttpServer.OSHttpRequest request, OpenSim.Framework.Servers.HttpServer.OSHttpResponse response, string prefix ) : RequestData

The plugin (RestHandler) calls this method to allocate the request state carrier for a new request. It is destroyed when the request completes. All request-instance specific state is kept here. This is registered when this service provider is registered.

CollectAsset ( XmlInventoryCollection ic ) : void

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 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 item being constructed. An asset, if created is stored in the XmlInventoryCollection

CollectFolder ( XmlInventoryCollection ic ) : void

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 by information supplied in the entity. If context was not explicitly provided, then the appropriate ID values are determined.

CollectItem ( XmlInventoryCollection ic ) : void

This method is called to handle the construction of an Item 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 as attributes to the Item element. This item is then stored in the XmlInventoryCollection and will be verified by Validate. All context is reset whenever the effective folder changes or an item is successfully validated.

CollectPermissions ( XmlInventoryCollection ic ) : void

Store any permissions information provided by the request. This overrides the default permissions set when the XmlInventoryCollection object was created.

DoInventory ( RequestData hdata ) : void

This method is registered with the handler when this service provider is initialized. It is called whenever the plug-in identifies this service provider as the best match for a given request. It handles all aspects of inventory REST processing, i.e. /admin/inventory

FolderHasChanged ( OpenSim.Framework.InventoryFolderBase newf, OpenSim.Framework.InventoryFolderBase oldf ) : bool

Make sure that an unchanged folder is not unnecessarily processed.

GetTrashCan ( InventoryRequestData rdata ) : InventoryFolderBase

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 will recreate the folder on an as-required basis. If the trash can cannot be created, then by implication the request that required it cannot be completed, and it fails accordingly.

ItemHasChanged ( InventoryItemBase newf, InventoryItemBase oldf ) : bool

Make sure that an unchanged item is not unnecessarily processed.

ReconstituteEntity ( InventoryRequestData rdata ) : XmlInventoryCollection

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 URI. In this way, an entire sub-tree can be conveyed in a single REST PUT or POST request. A new instance of XmlInventoryCollection is created and, if the request 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 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 missing parent IDs are resolved).

Validate ( XmlInventoryCollection ic ) : void

This method is called whenever an Item has been successfully reconstituted from the request's entity. It uses the information curren tin the XmlInventoryCollection to complete the item's specification, including any implied context and asset associations. It fails the request if any necessary item or asset information is missing.

formatInventory ( InventoryRequestData rdata, InventoryFolderBase folder, string indent ) : void

This method generates XML that describes an instance of InventoryFolderBase. It recurses as necessary to reflect a folder hierarchy, and calls formatItem to generate XML for any items encountered along the way. The indentation parameter is solely for the benefit of trace record formatting.

formatItem ( InventoryRequestData rdata, InventoryItemBase i, string indent ) : void

This method generates XML that describes an instance of InventoryItemBase.

getInventoryNode ( InventoryRequestData rdata, InventoryFolderBase folder, int pi, bool fill ) : Object

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 necessary to process the designated hierarchy. 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 and if we succeed we recurse. If this is the last node, then we look to see if this is an item. If it is, we return that item. If we reach the end of an inventory path and the URI si not yet exhausted, then if 'fill' is specified, we create the intermediate nodes. Otherwise we fail the request on the ground of an invalid URI. An ambiguous request causes the request to fail.

traverse ( InventoryRequestData rdata, InventoryFolderBase folder, int pi ) : void

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. Note that this method is only interested in those folder that match elements of the URI supplied by the requestor, so once a match is fund, the processing does not need to consider any further elements. Only the last element in the URI should identify an item.

traverseInventory ( InventoryRequestData rdata, InventoryFolderBase folder, int pi ) : void

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.

Method Details

Close() public method

Called by the plug-in to halt service processing. Local processing is disabled.
public Close ( ) : void
return void

Initialize() public method

Post-construction, pre-enabled initialization opportunity Not currently exploited.
public Initialize ( ) : void
return void

RestInventoryServices() public method

The constructor makes sure that the service prefix is absolute and the registers the service handler and the allocator.
public RestInventoryServices ( ) : System
return System