Annotation of /trunk/AssetServer/Interfaces.cs
Parent Directory
|
Revision Log
Revision 51 - (view) (download)
| 1 : | jhurliman | 48 | /* |
| 2 : | * Copyright (c) 2008 Intel Corporation | ||
| 3 : | * All rights reserved. | ||
| 4 : | * Redistribution and use in source and binary forms, with or without | ||
| 5 : | * modification, are permitted provided that the following conditions | ||
| 6 : | * are met: | ||
| 7 : | * | ||
| 8 : | * -- Redistributions of source code must retain the above copyright | ||
| 9 : | * notice, this list of conditions and the following disclaimer. | ||
| 10 : | * -- Redistributions in binary form must reproduce the above copyright | ||
| 11 : | * notice, this list of conditions and the following disclaimer in the | ||
| 12 : | * documentation and/or other materials provided with the distribution. | ||
| 13 : | * -- Neither the name of the Intel Corporation nor the names of its | ||
| 14 : | * contributors may be used to endorse or promote products derived from | ||
| 15 : | * this software without specific prior written permission. | ||
| 16 : | * | ||
| 17 : | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 18 : | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 19 : | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
| 20 : | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS | ||
| 21 : | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| 22 : | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 23 : | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| 24 : | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 25 : | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 26 : | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 27 : | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 28 : | */ | ||
| 29 : | |||
| 30 : | using System; | ||
| 31 : | using System.Collections.Generic; | ||
| 32 : | using System.Net; | ||
| 33 : | using OpenMetaverse; | ||
| 34 : | using OpenMetaverse.StructuredData; | ||
| 35 : | |||
| 36 : | namespace AssetServer | ||
| 37 : | { | ||
| 38 : | /// <summary> | ||
| 39 : | /// Response from a call to a storage provider | ||
| 40 : | /// </summary> | ||
| 41 : | public enum StorageResponse | ||
| 42 : | { | ||
| 43 : | /// <summary>The storage call succeeded</summary> | ||
| 44 : | Success, | ||
| 45 : | /// <summary>The resource requested was not found</summary> | ||
| 46 : | NotFound, | ||
| 47 : | /// <summary>An authentication token was required and not provided, the | ||
| 48 : | /// authentication token provided was invalid, or the provided | ||
| 49 : | /// authentication was not authorized for the requested resource</summary> | ||
| 50 : | AuthNeeded, | ||
| 51 : | /// <summary>A server failure prevented the storage call from | ||
| 52 : | /// completing</summary> | ||
| 53 : | Failure | ||
| 54 : | } | ||
| 55 : | |||
| 56 : | #region Inventory Classes | ||
| 57 : | |||
| 58 : | public class InventoryBase | ||
| 59 : | { | ||
| 60 : | } | ||
| 61 : | |||
| 62 : | public class InventoryFolder : InventoryBase | ||
| 63 : | { | ||
| 64 : | public string Name; | ||
| 65 : | public UUID Owner; | ||
| 66 : | public UUID ParentID; | ||
| 67 : | public UUID ID; | ||
| 68 : | public short Type; | ||
| 69 : | public ushort Version; | ||
| 70 : | |||
| 71 : | [NonSerialized] | ||
| 72 : | public Dictionary<UUID, InventoryBase> Children = new Dictionary<UUID,InventoryBase>(); | ||
| 73 : | |||
| 74 : | public InventoryFolder() | ||
| 75 : | { | ||
| 76 : | } | ||
| 77 : | |||
| 78 : | public InventoryFolder(string name, UUID ownerID, UUID parentID, short assetType) | ||
| 79 : | { | ||
| 80 : | ID = UUID.Random(); | ||
| 81 : | Name = name; | ||
| 82 : | Owner = ownerID; | ||
| 83 : | ParentID = parentID; | ||
| 84 : | Type = assetType; | ||
| 85 : | Version = 1; | ||
| 86 : | } | ||
| 87 : | |||
| 88 : | public override string ToString() | ||
| 89 : | { | ||
| 90 : | return String.Format("{0} ({1})", Name, ID); | ||
| 91 : | } | ||
| 92 : | } | ||
| 93 : | |||
| 94 : | public class InventoryItem : InventoryBase | ||
| 95 : | { | ||
| 96 : | public UUID ID; | ||
| 97 : | public int InvType; | ||
| 98 : | public UUID Folder; | ||
| 99 : | public UUID Owner; | ||
| 100 : | public UUID Creator; | ||
| 101 : | public string Name; | ||
| 102 : | public string Description; | ||
| 103 : | public uint NextPermissions; | ||
| 104 : | public uint CurrentPermissions; | ||
| 105 : | public uint BasePermissions; | ||
| 106 : | public uint EveryOnePermissions; | ||
| 107 : | public uint GroupPermissions; | ||
| 108 : | public int AssetType; | ||
| 109 : | public UUID AssetID; | ||
| 110 : | public UUID GroupID; | ||
| 111 : | public bool GroupOwned; | ||
| 112 : | public int SalePrice; | ||
| 113 : | public byte SaleType; | ||
| 114 : | public uint Flags; | ||
| 115 : | public int CreationDate; | ||
| 116 : | |||
| 117 : | public override string ToString() | ||
| 118 : | { | ||
| 119 : | return String.Format("{0} ({1})", Name, ID); | ||
| 120 : | } | ||
| 121 : | } | ||
| 122 : | |||
| 123 : | public class InventoryCollection | ||
| 124 : | { | ||
| 125 : | public Dictionary<UUID, InventoryFolder> Folders; | ||
| 126 : | public Dictionary<UUID, InventoryItem> Items; | ||
| 127 : | public UUID UserID; | ||
| 128 : | } | ||
| 129 : | |||
| 130 : | #endregion Inventory Classes | ||
| 131 : | |||
| 132 : | #region Interfaces | ||
| 133 : | |||
| 134 : | public interface IStorageProvider | ||
| 135 : | { | ||
| 136 : | StorageResponse TryFetchMetadata(UUID assetID, UUID authToken, out Metadata metadata); | ||
| 137 : | StorageResponse TryFetchData(UUID assetID, UUID authToken, out byte[] assetData); | ||
| 138 : | StorageResponse TryFetchDataMetadata(UUID assetID, UUID authToken, out Metadata metadata, out byte[] assetData); | ||
| 139 : | StorageResponse TryCreateAsset(Metadata metadata, byte[] assetData, UUID authToken, out UUID assetID); | ||
| 140 : | StorageResponse TryCreateAsset(Metadata metadata, byte[] assetData, UUID authToken); | ||
| 141 : | int ForEach(Action<Metadata> action, int start, int count, UUID authToken); | ||
| 142 : | } | ||
| 143 : | |||
| 144 : | public interface IInventoryProvider | ||
| 145 : | { | ||
| 146 : | jhurliman | 51 | StorageResponse TryFetchItem(Uri owner, UUID itemID, UUID authToken, out InventoryItem item); |
| 147 : | StorageResponse TryFetchFolder(Uri owner, UUID folderID, UUID authToken, out InventoryFolder folder); | ||
| 148 : | StorageResponse TryFetchFolderContents(Uri owner, UUID folderID, UUID authToken, out InventoryCollection contents); | ||
| 149 : | StorageResponse TryFetchFolderList(Uri owner, UUID authToken, out List<InventoryFolder> folders); | ||
| 150 : | StorageResponse TryFetchInventory(Uri owner, UUID authToken, out InventoryCollection inventory); | ||
| 151 : | jhurliman | 48 | |
| 152 : | jhurliman | 51 | StorageResponse TryFetchActiveGestures(Uri owner, UUID authToken, out List<InventoryItem> gestures); |
| 153 : | jhurliman | 48 | |
| 154 : | StorageResponse TryCreateItem(InventoryItem item, UUID authToken); | ||
| 155 : | StorageResponse TryCreateFolder(InventoryFolder folder, UUID authToken); | ||
| 156 : | StorageResponse TryCreateInventory(InventoryFolder rootFolder, UUID authToken); | ||
| 157 : | |||
| 158 : | jhurliman | 51 | StorageResponse TryDeleteItem(Uri owner, UUID itemID, UUID authToken); |
| 159 : | StorageResponse TryDeleteFolder(Uri owner, UUID folderID, UUID authToken); | ||
| 160 : | StorageResponse TryPurgeFolder(Uri owner, UUID folderID, UUID authToken); | ||
| 161 : | jhurliman | 48 | } |
| 162 : | |||
| 163 : | public interface IAuthenticationProvider | ||
| 164 : | { | ||
| 165 : | void AddIdentifier(UUID authToken, Uri identifier); | ||
| 166 : | bool RemoveIdentifier(UUID authToken); | ||
| 167 : | bool TryGetIdentifier(UUID authToken, out Uri identifier); | ||
| 168 : | } | ||
| 169 : | |||
| 170 : | public interface IAuthorizationProvider | ||
| 171 : | { | ||
| 172 : | bool IsMetadataAuthorized(UUID authToken, UUID assetID); | ||
| 173 : | /// <summary> | ||
| 174 : | /// Authorizes access to the data for an asset. Access to asset data | ||
| 175 : | /// also implies access to the metadata for that asset | ||
| 176 : | /// </summary> | ||
| 177 : | /// <param name="authToken">Authentication token to check for access</param> | ||
| 178 : | /// <param name="assetID">ID of the requested asset</param> | ||
| 179 : | /// <returns>True if access is granted, otherwise false</returns> | ||
| 180 : | bool IsDataAuthorized(UUID authToken, UUID assetID); | ||
| 181 : | bool IsCreateAuthorized(UUID authToken); | ||
| 182 : | |||
| 183 : | jhurliman | 51 | bool IsInventoryReadAuthorized(UUID authToken, Uri owner); |
| 184 : | bool IsInventoryWriteAuthorized(UUID authToken, Uri owner); | ||
| 185 : | jhurliman | 48 | } |
| 186 : | |||
| 187 : | public interface IMetricsProvider | ||
| 188 : | { | ||
| 189 : | void LogAssetMetadataFetch(string extension, StorageResponse response, UUID assetID, UUID authToken, DateTime time); | ||
| 190 : | void LogAssetDataFetch(string extension, StorageResponse response, UUID assetID, int dataSize, UUID authToken, DateTime time); | ||
| 191 : | void LogAssetCreate(string extension, StorageResponse response, UUID assetID, int dataSize, UUID authToken, DateTime time); | ||
| 192 : | |||
| 193 : | jhurliman | 51 | void LogInventoryFetch(string extension, StorageResponse response, Uri owner, UUID objID, bool folder, UUID authToken, DateTime time); |
| 194 : | void LogInventoryFetchFolderContents(string extension, StorageResponse response, Uri owner, UUID folderID, UUID authToken, DateTime time); | ||
| 195 : | void LogInventoryFetchFolderList(string extension, StorageResponse response, Uri owner, UUID authToken, DateTime time); | ||
| 196 : | void LogInventoryFetchInventory(string extension, StorageResponse response, Uri owner, UUID authToken, DateTime time); | ||
| 197 : | void LogInventoryFetchActiveGestures(string extension, StorageResponse response, Uri owner, UUID authToken, DateTime time); | ||
| 198 : | void LogInventoryCreate(string extension, StorageResponse response, bool folder, UUID authToken, DateTime time); | ||
| 199 : | void LogInventoryCreateInventory(string extension, StorageResponse response, UUID authToken, DateTime time); | ||
| 200 : | void LogInventoryDelete(string extension, StorageResponse response, Uri owner, UUID objID, bool folder, UUID authToken, DateTime time); | ||
| 201 : | void LogInventoryPurgeFolder(string extension, StorageResponse response, Uri owner, UUID folderID, UUID authToken, DateTime time); | ||
| 202 : | jhurliman | 48 | } |
| 203 : | |||
| 204 : | #endregion Interfaces | ||
| 205 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

