Interfaces.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. using OpenSim.Framework;
  31. namespace OpenSim.Grid.AssetInventoryServer
  32. {
  33. /// <summary>
  34. /// Response from a call to a backend provider
  35. /// </summary>
  36. public enum BackendResponse
  37. {
  38. /// <summary>The call succeeded</summary>
  39. Success,
  40. /// <summary>The resource requested was not found</summary>
  41. NotFound,
  42. /// <summary>A server failure prevented the call from
  43. /// completing</summary>
  44. Failure
  45. }
  46. public class AssetInventoryServerPluginInitialiser : PluginInitialiserBase
  47. {
  48. private AssetInventoryServer server;
  49. public AssetInventoryServerPluginInitialiser(AssetInventoryServer server)
  50. {
  51. this.server = server;
  52. }
  53. public override void Initialise(IPlugin plugin)
  54. {
  55. IAssetInventoryServerPlugin p = plugin as IAssetInventoryServerPlugin;
  56. p.Initialise (server);
  57. }
  58. }
  59. #region Interfaces
  60. public interface IAssetInventoryServerPlugin : IPlugin
  61. {
  62. void Initialise(AssetInventoryServer server);
  63. }
  64. public interface IAssetStorageProvider : IAssetInventoryServerPlugin
  65. {
  66. BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata);
  67. BackendResponse TryFetchData(UUID assetID, out byte[] assetData);
  68. BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset);
  69. BackendResponse TryCreateAsset(AssetBase asset);
  70. BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID);
  71. int ForEach(Action<AssetMetadata> action, int start, int count);
  72. }
  73. public interface IInventoryStorageProvider : IAssetInventoryServerPlugin
  74. {
  75. BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item);
  76. BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder);
  77. BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents);
  78. BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders);
  79. BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory);
  80. BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures);
  81. BackendResponse TryCreateItem(Uri owner, InventoryItemBase item);
  82. BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder);
  83. BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder);
  84. BackendResponse TryDeleteItem(Uri owner, UUID itemID);
  85. BackendResponse TryDeleteFolder(Uri owner, UUID folderID);
  86. BackendResponse TryPurgeFolder(Uri owner, UUID folderID);
  87. }
  88. public interface IAuthenticationProvider : IAssetInventoryServerPlugin
  89. {
  90. void AddIdentifier(UUID authToken, Uri identifier);
  91. bool RemoveIdentifier(UUID authToken);
  92. bool TryGetIdentifier(UUID authToken, out Uri identifier);
  93. }
  94. public interface IAuthorizationProvider : IAssetInventoryServerPlugin
  95. {
  96. bool IsMetadataAuthorized(UUID authToken, UUID assetID);
  97. /// <summary>
  98. /// Authorizes access to the data for an asset. Access to asset data
  99. /// also implies access to the metadata for that asset
  100. /// </summary>
  101. /// <param name="authToken">Authentication token to check for access</param>
  102. /// <param name="assetID">ID of the requested asset</param>
  103. /// <returns>True if access is granted, otherwise false</returns>
  104. bool IsDataAuthorized(UUID authToken, UUID assetID);
  105. bool IsCreateAuthorized(UUID authToken);
  106. bool IsInventoryReadAuthorized(UUID authToken, Uri owner);
  107. bool IsInventoryWriteAuthorized(UUID authToken, Uri owner);
  108. }
  109. public interface IMetricsProvider : IAssetInventoryServerPlugin
  110. {
  111. void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time);
  112. void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time);
  113. void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time);
  114. void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time);
  115. void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time);
  116. void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time);
  117. void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time);
  118. void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time);
  119. void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time);
  120. void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time);
  121. void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time);
  122. void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time);
  123. }
  124. #endregion Interfaces
  125. }