diff options
author | Mike Mazur | 2009-02-16 02:28:34 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-16 02:28:34 +0000 |
commit | ab5e3328323a66028bfd47562d9d515dbec433be (patch) | |
tree | d81184cd1f8788c20b4600649195be66e03f48c3 | |
parent | We need to return a zero-length byte array from the Handle() routine. (diff) | |
download | opensim-SC-ab5e3328323a66028bfd47562d9d515dbec433be.zip opensim-SC-ab5e3328323a66028bfd47562d9d515dbec433be.tar.gz opensim-SC-ab5e3328323a66028bfd47562d9d515dbec433be.tar.bz2 opensim-SC-ab5e3328323a66028bfd47562d9d515dbec433be.tar.xz |
- removed OpenSim.Grid.AssetInventoryServer.Metadata class in favor of
OpenSim.Framework.AssetMetadata and related updates in AssetInventory
server
- removed dependency on MySql.Data.MySqlClient
- commented out the bulk of OpenSimInventoryStorage due to missing
MySql.Data dependency
- refactor asset creation in OpenSimAssetFrontend
- commented out ForEach implementation, which also depended on
MySql.Data, until it's supported by OpenSim backends
- commented out some handlers in BrowseFrontend and ReferenceFrontend as
they relied on either ForEach or the removed Metadata class
9 files changed, 1074 insertions, 1251 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs index 29428d4..053cacf 100644 --- a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs +++ b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs | |||
@@ -73,12 +73,12 @@ namespace OpenSim.Grid.AssetInventoryServer | |||
73 | 73 | ||
74 | public interface IAssetStorageProvider : IAssetInventoryServerPlugin | 74 | public interface IAssetStorageProvider : IAssetInventoryServerPlugin |
75 | { | 75 | { |
76 | BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata); | 76 | BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata); |
77 | BackendResponse TryFetchData(UUID assetID, out byte[] assetData); | 77 | BackendResponse TryFetchData(UUID assetID, out byte[] assetData); |
78 | BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset); | 78 | BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset); |
79 | BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData); | 79 | BackendResponse TryCreateAsset(AssetBase asset); |
80 | BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData, out UUID assetID); | 80 | BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID); |
81 | int ForEach(Action<Metadata> action, int start, int count); | 81 | int ForEach(Action<AssetMetadata> action, int start, int count); |
82 | } | 82 | } |
83 | 83 | ||
84 | public interface IInventoryStorageProvider : IAssetInventoryServerPlugin | 84 | public interface IInventoryStorageProvider : IAssetInventoryServerPlugin |
diff --git a/OpenSim/Grid/AssetInventoryServer/Metadata.cs b/OpenSim/Grid/AssetInventoryServer/Metadata.cs deleted file mode 100644 index ebd379d..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Metadata.cs +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using OpenMetaverse; | ||
4 | using OpenMetaverse.StructuredData; | ||
5 | |||
6 | namespace OpenSim.Grid.AssetInventoryServer | ||
7 | { | ||
8 | public class Metadata | ||
9 | { | ||
10 | public UUID ID; | ||
11 | public string Name; | ||
12 | public string Description; | ||
13 | public DateTime CreationDate; | ||
14 | public string ContentType; | ||
15 | public byte[] SHA1; | ||
16 | public bool Temporary; | ||
17 | public Dictionary<string, Uri> Methods = new Dictionary<string, Uri>(); | ||
18 | public OSDMap ExtraData; | ||
19 | |||
20 | public OSDMap SerializeToOSD() | ||
21 | { | ||
22 | OSDMap osdata = new OSDMap(); | ||
23 | |||
24 | if (ID != UUID.Zero) osdata["id"] = OSD.FromUUID(ID); | ||
25 | osdata["name"] = OSD.FromString(Name); | ||
26 | osdata["description"] = OSD.FromString(Description); | ||
27 | osdata["creation_date"] = OSD.FromDate(CreationDate); | ||
28 | osdata["type"] = OSD.FromString(ContentType); | ||
29 | osdata["sha1"] = OSD.FromBinary(SHA1); | ||
30 | osdata["temporary"] = OSD.FromBoolean(Temporary); | ||
31 | |||
32 | OSDMap methods = new OSDMap(Methods.Count); | ||
33 | foreach (KeyValuePair<string, Uri> kvp in Methods) | ||
34 | methods.Add(kvp.Key, OSD.FromUri(kvp.Value)); | ||
35 | osdata["methods"] = methods; | ||
36 | |||
37 | if (ExtraData != null) osdata["extra_data"] = ExtraData; | ||
38 | |||
39 | return osdata; | ||
40 | } | ||
41 | |||
42 | public byte[] SerializeToBytes() | ||
43 | { | ||
44 | LitJson.JsonData jsonData = OSDParser.SerializeJson(SerializeToOSD()); | ||
45 | return System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson()); | ||
46 | } | ||
47 | |||
48 | public void Deserialize(byte[] data) | ||
49 | { | ||
50 | OSD osdata = OSDParser.DeserializeJson(System.Text.Encoding.UTF8.GetString(data)); | ||
51 | Deserialize(osdata); | ||
52 | } | ||
53 | |||
54 | public void Deserialize(string data) | ||
55 | { | ||
56 | OSD osdata = OSDParser.DeserializeJson(data); | ||
57 | Deserialize(osdata); | ||
58 | } | ||
59 | |||
60 | public void Deserialize(OSD osdata) | ||
61 | { | ||
62 | if (osdata.Type == OSDType.Map) | ||
63 | { | ||
64 | OSDMap map = (OSDMap)osdata; | ||
65 | ID = map["id"].AsUUID(); | ||
66 | Name = map["name"].AsString(); | ||
67 | Description = map["description"].AsString(); | ||
68 | CreationDate = map["creation_date"].AsDate(); | ||
69 | ContentType = map["type"].AsString(); | ||
70 | SHA1 = map["sha1"].AsBinary(); | ||
71 | Temporary = map["temporary"].AsBoolean(); | ||
72 | |||
73 | OSDMap methods = map["methods"] as OSDMap; | ||
74 | if (methods != null) | ||
75 | { | ||
76 | foreach (KeyValuePair<string, OSD> kvp in methods) | ||
77 | Methods.Add(kvp.Key, kvp.Value.AsUri()); | ||
78 | } | ||
79 | |||
80 | ExtraData = map["extra_data"] as OSDMap; | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs index 6afda79..3b6e99e 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs | |||
@@ -57,8 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
57 | m_server = server; | 57 | m_server = server; |
58 | 58 | ||
59 | // Request for / or /?... | 59 | // Request for / or /?... |
60 | //server.HttpServer.AddHandler("get", null, @"(^/$)|(^/\?.*)", BrowseRequestHandler); | 60 | //m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); |
61 | m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); | ||
62 | 61 | ||
63 | m_log.Info("[ASSET] Browser Frontend loaded."); | 62 | m_log.Info("[ASSET] Browser Frontend loaded."); |
64 | } | 63 | } |
@@ -89,102 +88,102 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
89 | 88 | ||
90 | #endregion IPlugin implementation | 89 | #endregion IPlugin implementation |
91 | 90 | ||
92 | public class BrowseRequestHandler : IStreamedRequestHandler | 91 | //public class BrowseRequestHandler : IStreamedRequestHandler |
93 | { | 92 | //{ |
94 | AssetInventoryServer m_server; | 93 | // AssetInventoryServer m_server; |
95 | string m_contentType; | 94 | // string m_contentType; |
96 | string m_httpMethod; | 95 | // string m_httpMethod; |
97 | string m_path; | 96 | // string m_path; |
98 | 97 | ||
99 | public BrowseRequestHandler(AssetInventoryServer server) | 98 | // public BrowseRequestHandler(AssetInventoryServer server) |
100 | { | 99 | // { |
101 | m_server = server; | 100 | // m_server = server; |
102 | m_contentType = null; | 101 | // m_contentType = null; |
103 | m_httpMethod = "GET"; | 102 | // m_httpMethod = "GET"; |
104 | m_path = @"(^/$)|(^/\?.*)"; | 103 | // m_path = @"(^/$)|(^/\?.*)"; |
105 | } | 104 | // } |
106 | 105 | ||
107 | #region IStreamedRequestHandler implementation | 106 | // #region IStreamedRequestHandler implementation |
108 | 107 | ||
109 | public string ContentType | 108 | // public string ContentType |
110 | { | 109 | // { |
111 | get { return m_contentType; } | 110 | // get { return m_contentType; } |
112 | } | 111 | // } |
113 | 112 | ||
114 | public string HttpMethod | 113 | // public string HttpMethod |
115 | { | 114 | // { |
116 | get { return m_httpMethod; } | 115 | // get { return m_httpMethod; } |
117 | } | 116 | // } |
118 | 117 | ||
119 | public string Path | 118 | // public string Path |
120 | { | 119 | // { |
121 | get { return m_path; } | 120 | // get { return m_path; } |
122 | } | 121 | // } |
123 | 122 | ||
124 | public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 123 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
125 | { | 124 | // { |
126 | const int ASSETS_PER_PAGE = 25; | 125 | // const int ASSETS_PER_PAGE = 25; |
127 | const string HEADER = "<html><head><title>Asset Server</title></head><body>"; | 126 | // const string HEADER = "<html><head><title>Asset Server</title></head><body>"; |
128 | const string TABLE_HEADER = | 127 | // const string TABLE_HEADER = |
129 | "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; | 128 | // "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>"; |
130 | const string TABLE_FOOTER = "</table>"; | 129 | // const string TABLE_FOOTER = "</table>"; |
131 | const string FOOTER = "</body></html>"; | 130 | // const string FOOTER = "</body></html>"; |
132 | 131 | ||
133 | UUID authToken = Utils.GetAuthToken(httpRequest); | 132 | // UUID authToken = Utils.GetAuthToken(httpRequest); |
134 | 133 | ||
135 | StringBuilder html = new StringBuilder(); | 134 | // StringBuilder html = new StringBuilder(); |
136 | int start = 0; | 135 | // int start = 0; |
137 | uint page = 0; | 136 | // uint page = 0; |
138 | 137 | ||
139 | if (!String.IsNullOrEmpty(httpRequest.Url.Query)) | 138 | // if (!String.IsNullOrEmpty(httpRequest.Url.Query)) |
140 | { | 139 | // { |
141 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | 140 | // NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); |
142 | if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) | 141 | // if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page)) |
143 | start = (int)page * ASSETS_PER_PAGE; | 142 | // start = (int)page * ASSETS_PER_PAGE; |
144 | } | 143 | // } |
145 | 144 | ||
146 | html.AppendLine(HEADER); | 145 | // html.AppendLine(HEADER); |
147 | 146 | ||
148 | html.AppendLine("<p>"); | 147 | // html.AppendLine("<p>"); |
149 | if (page > 0) | 148 | // if (page > 0) |
150 | html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); | 149 | // html.AppendFormat("<a href=\"{0}?page={1}\">< Previous Page</a> | ", httpRequest.RawUrl, page - 1); |
151 | html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); | 150 | // html.AppendFormat("<a href=\"{0}?page={1}\">Next Page ></a>", httpRequest.RawUrl, page + 1); |
152 | html.AppendLine("</p>"); | 151 | // html.AppendLine("</p>"); |
153 | 152 | ||
154 | html.AppendLine(TABLE_HEADER); | 153 | // html.AppendLine(TABLE_HEADER); |
155 | 154 | ||
156 | m_server.StorageProvider.ForEach( | 155 | // m_server.StorageProvider.ForEach( |
157 | delegate(Metadata data) | 156 | // delegate(Metadata data) |
158 | { | 157 | // { |
159 | if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) | 158 | // if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.ID)) |
160 | { | 159 | // { |
161 | html.AppendLine(String.Format( | 160 | // html.AppendLine(String.Format( |
162 | "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", | 161 | // "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>", |
163 | data.Name, data.Description, data.ContentType, data.ID, data.Temporary, | 162 | // data.Name, data.Description, data.ContentType, data.ID, data.Temporary, |
164 | BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); | 163 | // BitConverter.ToString(data.SHA1).Replace("-", String.Empty))); |
165 | } | 164 | // } |
166 | else | 165 | // else |
167 | { | 166 | // { |
168 | html.AppendLine(String.Format( | 167 | // html.AppendLine(String.Format( |
169 | "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", | 168 | // "<tr><td>[Protected Asset]</td><td> </td><td> </td><td>{0}</td><td>{1}</td><td> </td></tr>", |
170 | data.ID, data.Temporary)); | 169 | // data.ID, data.Temporary)); |
171 | } | 170 | // } |
172 | }, start, ASSETS_PER_PAGE | 171 | // }, start, ASSETS_PER_PAGE |
173 | ); | 172 | // ); |
174 | 173 | ||
175 | html.AppendLine(TABLE_FOOTER); | 174 | // html.AppendLine(TABLE_FOOTER); |
176 | 175 | ||
177 | html.AppendLine(FOOTER); | 176 | // html.AppendLine(FOOTER); |
178 | 177 | ||
179 | byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); | 178 | // byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString()); |
180 | 179 | ||
181 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | 180 | // httpResponse.StatusCode = (int) HttpStatusCode.OK; |
182 | httpResponse.Body.Write(responseData, 0, responseData.Length); | 181 | // httpResponse.Body.Write(responseData, 0, responseData.Length); |
183 | httpResponse.Body.Flush(); | 182 | // httpResponse.Body.Flush(); |
184 | return responseData; | 183 | // return responseData; |
185 | } | 184 | // } |
186 | 185 | ||
187 | #endregion IStreamedRequestHandler implementation | 186 | // #endregion IStreamedRequestHandler implementation |
188 | } | 187 | //} |
189 | } | 188 | } |
190 | } | 189 | } |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs index afb836d..f8f4cce 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs | |||
@@ -153,37 +153,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
153 | 153 | ||
154 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 154 | public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
155 | { | 155 | { |
156 | Metadata metadata = new Metadata(); | 156 | AssetBase asset = null; |
157 | 157 | ||
158 | try | 158 | try |
159 | { | 159 | { |
160 | AssetBase asset = (AssetBase) new XmlSerializer(typeof (AssetBase)).Deserialize(httpRequest.InputStream); | 160 | asset = (AssetBase) new XmlSerializer(typeof (AssetBase)).Deserialize(httpRequest.InputStream); |
161 | |||
162 | if (asset.Data != null && asset.Data.Length > 0) | ||
163 | { | ||
164 | metadata.ID = asset.Metadata.FullID; | ||
165 | metadata.ContentType = Utils.SLAssetTypeToContentType((int) asset.Metadata.Type); | ||
166 | metadata.Name = asset.Metadata.Name; | ||
167 | metadata.Description = asset.Metadata.Description; | ||
168 | metadata.Temporary = asset.Metadata.Temporary; | ||
169 | |||
170 | metadata.SHA1 = OpenMetaverse.Utils.SHA1(asset.Data); | ||
171 | metadata.CreationDate = DateTime.Now; | ||
172 | |||
173 | BackendResponse storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, asset.Data); | ||
174 | |||
175 | if (storageResponse == BackendResponse.Success) | ||
176 | httpResponse.StatusCode = (int) HttpStatusCode.Created; | ||
177 | else if (storageResponse == BackendResponse.NotFound) | ||
178 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
179 | else | ||
180 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
181 | } | ||
182 | else | ||
183 | { | ||
184 | m_log.Warn("AssetPostHandler called with no asset data"); | ||
185 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
186 | } | ||
187 | } | 161 | } |
188 | catch (Exception ex) | 162 | catch (Exception ex) |
189 | { | 163 | { |
@@ -191,6 +165,23 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
191 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | 165 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; |
192 | } | 166 | } |
193 | 167 | ||
168 | if (asset != null && asset.Data != null && asset.Data.Length > 0) | ||
169 | { | ||
170 | BackendResponse storageResponse = m_server.StorageProvider.TryCreateAsset(asset); | ||
171 | |||
172 | if (storageResponse == BackendResponse.Success) | ||
173 | httpResponse.StatusCode = (int) HttpStatusCode.Created; | ||
174 | else if (storageResponse == BackendResponse.NotFound) | ||
175 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | ||
176 | else | ||
177 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | m_log.Warn("AssetPostHandler called with no asset data"); | ||
182 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | ||
183 | } | ||
184 | |||
194 | return new byte[] {}; | 185 | return new byte[] {}; |
195 | } | 186 | } |
196 | } | 187 | } |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs index bcd1900..fccf50d 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | |||
@@ -30,7 +30,6 @@ | |||
30 | using System; | 30 | using System; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Data; | 32 | using System.Data; |
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Data; | 35 | using OpenSim.Data; |
@@ -54,46 +53,18 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
54 | 53 | ||
55 | #region IAssetStorageProvider implementation | 54 | #region IAssetStorageProvider implementation |
56 | 55 | ||
57 | public BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata) | 56 | public BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata) |
58 | { | 57 | { |
59 | metadata = null; | 58 | metadata = null; |
60 | BackendResponse ret; | 59 | BackendResponse ret; |
61 | 60 | ||
62 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect"))) | 61 | AssetBase asset = m_assetProvider.FetchAsset(assetID); |
63 | { | ||
64 | IDataReader reader; | ||
65 | 62 | ||
66 | try | 63 | if (asset == null) ret = BackendResponse.NotFound; |
67 | { | 64 | else |
68 | dbConnection.Open(); | 65 | { |
69 | 66 | metadata = asset.Metadata; | |
70 | IDbCommand command = dbConnection.CreateCommand(); | 67 | ret = BackendResponse.Success; |
71 | command.CommandText = String.Format("SELECT name,description,assetType,temporary FROM assets WHERE id='{0}'", assetID.ToString()); | ||
72 | reader = command.ExecuteReader(); | ||
73 | |||
74 | if (reader.Read()) | ||
75 | { | ||
76 | metadata = new Metadata(); | ||
77 | metadata.CreationDate = OpenMetaverse.Utils.Epoch; | ||
78 | metadata.SHA1 = null; | ||
79 | metadata.ID = assetID; | ||
80 | metadata.Name = reader.GetString(0); | ||
81 | metadata.Description = reader.GetString(1); | ||
82 | metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); | ||
83 | metadata.Temporary = reader.GetBoolean(3); | ||
84 | |||
85 | ret = BackendResponse.Success; | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | ret = BackendResponse.NotFound; | ||
90 | } | ||
91 | } | ||
92 | catch (MySqlException ex) | ||
93 | { | ||
94 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | ||
95 | ret = BackendResponse.Failure; | ||
96 | } | ||
97 | } | 68 | } |
98 | 69 | ||
99 | m_server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); | 70 | m_server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); |
@@ -105,33 +76,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
105 | assetData = null; | 76 | assetData = null; |
106 | BackendResponse ret; | 77 | BackendResponse ret; |
107 | 78 | ||
108 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect"))) | 79 | AssetBase asset = m_assetProvider.FetchAsset(assetID); |
109 | { | ||
110 | IDataReader reader; | ||
111 | 80 | ||
112 | try | 81 | if (asset == null) ret = BackendResponse.NotFound; |
113 | { | 82 | else |
114 | dbConnection.Open(); | 83 | { |
115 | 84 | assetData = asset.Data; | |
116 | IDbCommand command = dbConnection.CreateCommand(); | 85 | ret = BackendResponse.Success; |
117 | command.CommandText = String.Format("SELECT data FROM assets WHERE id='{0}'", assetID.ToString()); | ||
118 | reader = command.ExecuteReader(); | ||
119 | |||
120 | if (reader.Read()) | ||
121 | { | ||
122 | assetData = (byte[])reader.GetValue(0); | ||
123 | ret = BackendResponse.Success; | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | ret = BackendResponse.NotFound; | ||
128 | } | ||
129 | } | ||
130 | catch (MySqlException ex) | ||
131 | { | ||
132 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | ||
133 | ret = BackendResponse.Failure; | ||
134 | } | ||
135 | } | 86 | } |
136 | 87 | ||
137 | m_server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); | 88 | m_server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); |
@@ -147,101 +98,63 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
147 | return BackendResponse.Success; | 98 | return BackendResponse.Success; |
148 | } | 99 | } |
149 | 100 | ||
150 | public BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData, out UUID assetID) | 101 | public BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID) |
151 | { | 102 | { |
152 | assetID = metadata.ID = UUID.Random(); | 103 | assetID = asset.FullID = UUID.Random(); |
153 | return TryCreateAsset(metadata, assetData); | 104 | return TryCreateAsset(asset); |
154 | } | 105 | } |
155 | 106 | ||
156 | public BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData) | 107 | public BackendResponse TryCreateAsset(AssetBase asset) |
157 | { | 108 | { |
158 | BackendResponse ret; | 109 | BackendResponse ret; |
159 | 110 | ||
160 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect"))) | 111 | m_assetProvider.CreateAsset(asset); |
161 | { | 112 | ret = BackendResponse.Success; |
162 | try | ||
163 | { | ||
164 | dbConnection.Open(); | ||
165 | |||
166 | MySqlCommand command = new MySqlCommand( | ||
167 | "REPLACE INTO assets (name,description,assetType,local,temporary,data,id) VALUES " + | ||
168 | "(?name,?description,?assetType,?local,?temporary,?data,?id)", dbConnection); | ||
169 | |||
170 | command.Parameters.AddWithValue("?name", metadata.Name); | ||
171 | command.Parameters.AddWithValue("?description", metadata.Description); | ||
172 | command.Parameters.AddWithValue("?assetType", Utils.ContentTypeToSLAssetType(metadata.ContentType)); | ||
173 | command.Parameters.AddWithValue("?local", 0); | ||
174 | command.Parameters.AddWithValue("?temporary", metadata.Temporary); | ||
175 | command.Parameters.AddWithValue("?data", assetData); | ||
176 | command.Parameters.AddWithValue("?id", metadata.ID.ToString()); | ||
177 | |||
178 | int rowsAffected = command.ExecuteNonQuery(); | ||
179 | if (rowsAffected == 1) | ||
180 | { | ||
181 | ret = BackendResponse.Success; | ||
182 | } | ||
183 | else if (rowsAffected == 2) | ||
184 | { | ||
185 | m_log.Info("Replaced asset " + metadata.ID.ToString()); | ||
186 | ret = BackendResponse.Success; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); | ||
191 | ret = BackendResponse.Failure; | ||
192 | } | ||
193 | } | ||
194 | catch (MySqlException ex) | ||
195 | { | ||
196 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | ||
197 | ret = BackendResponse.Failure; | ||
198 | } | ||
199 | } | ||
200 | 113 | ||
201 | m_server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, metadata.ID, assetData.Length, DateTime.Now); | 114 | m_server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now); |
202 | return ret; | 115 | return ret; |
203 | } | 116 | } |
204 | 117 | ||
205 | public int ForEach(Action<Metadata> action, int start, int count) | 118 | public int ForEach(Action<AssetMetadata> action, int start, int count) |
206 | { | 119 | { |
207 | int rowCount = 0; | 120 | int rowCount = 0; |
208 | 121 | ||
209 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect"))) | 122 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect"))) |
210 | { | 123 | //{ |
211 | MySqlDataReader reader; | 124 | // MySqlDataReader reader; |
212 | 125 | ||
213 | try | 126 | // try |
214 | { | 127 | // { |
215 | dbConnection.Open(); | 128 | // dbConnection.Open(); |
216 | 129 | ||
217 | MySqlCommand command = dbConnection.CreateCommand(); | 130 | // MySqlCommand command = dbConnection.CreateCommand(); |
218 | command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}", | 131 | // command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}", |
219 | start, count); | 132 | // start, count); |
220 | reader = command.ExecuteReader(); | 133 | // reader = command.ExecuteReader(); |
221 | } | 134 | // } |
222 | catch (MySqlException ex) | 135 | // catch (MySqlException ex) |
223 | { | 136 | // { |
224 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 137 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
225 | return 0; | 138 | // return 0; |
226 | } | 139 | // } |
227 | 140 | ||
228 | while (reader.Read()) | 141 | // while (reader.Read()) |
229 | { | 142 | // { |
230 | Metadata metadata = new Metadata(); | 143 | // Metadata metadata = new Metadata(); |
231 | metadata.CreationDate = OpenMetaverse.Utils.Epoch; | 144 | // metadata.CreationDate = OpenMetaverse.Utils.Epoch; |
232 | metadata.Description = reader.GetString(1); | 145 | // metadata.Description = reader.GetString(1); |
233 | metadata.ID = UUID.Parse(reader.GetString(5)); | 146 | // metadata.ID = UUID.Parse(reader.GetString(5)); |
234 | metadata.Name = reader.GetString(0); | 147 | // metadata.Name = reader.GetString(0); |
235 | metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4)); | 148 | // metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4)); |
236 | metadata.Temporary = reader.GetBoolean(3); | 149 | // metadata.Temporary = reader.GetBoolean(3); |
237 | metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); | 150 | // metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); |
238 | 151 | ||
239 | action(metadata); | 152 | // action(metadata); |
240 | ++rowCount; | 153 | // ++rowCount; |
241 | } | 154 | // } |
242 | 155 | ||
243 | reader.Close(); | 156 | // reader.Close(); |
244 | } | 157 | //} |
245 | 158 | ||
246 | return rowCount; | 159 | return rowCount; |
247 | } | 160 | } |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs index 86cf1de..69b8497 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs | |||
@@ -31,7 +31,6 @@ using System; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Data; | 33 | using System.Data; |
34 | using MySql.Data.MySqlClient; | ||
35 | using OpenMetaverse; | 34 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
37 | using OpenSim.Data; | 36 | using OpenSim.Data; |
@@ -45,7 +44,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting | 45 | const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting |
47 | 46 | ||
48 | private AssetInventoryServer m_server; | 47 | //private AssetInventoryServer m_server; |
49 | private IInventoryDataPlugin m_inventoryProvider; | 48 | private IInventoryDataPlugin m_inventoryProvider; |
50 | private IConfig m_openSimConfig; | 49 | private IConfig m_openSimConfig; |
51 | 50 | ||
@@ -58,529 +57,537 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
58 | public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item) | 57 | public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item) |
59 | { | 58 | { |
60 | item = null; | 59 | item = null; |
61 | BackendResponse ret; | 60 | //BackendResponse ret; |
62 | 61 | ||
63 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 62 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
64 | { | 63 | //{ |
65 | IDataReader reader; | 64 | // IDataReader reader; |
66 | 65 | ||
67 | try | 66 | // try |
68 | { | 67 | // { |
69 | dbConnection.Open(); | 68 | // dbConnection.Open(); |
70 | 69 | ||
71 | IDbCommand command = dbConnection.CreateCommand(); | 70 | // IDbCommand command = dbConnection.CreateCommand(); |
72 | command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | 71 | // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + |
73 | "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | 72 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + |
74 | "creationDate,groupID,groupOwned,flags,avatarID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE inventoryID='{0}'", | 73 | // "creationDate,groupID,groupOwned,flags,avatarID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE inventoryID='{0}'", |
75 | itemID.ToString()); | 74 | // itemID.ToString()); |
76 | reader = command.ExecuteReader(); | 75 | // reader = command.ExecuteReader(); |
77 | 76 | ||
78 | if (reader.Read()) | 77 | // if (reader.Read()) |
79 | { | 78 | // { |
80 | item = new InventoryItem(); | 79 | // item = new InventoryItem(); |
81 | item.ID = itemID; | 80 | // item.ID = itemID; |
82 | item.AssetID = UUID.Parse(reader.GetString(0)); | 81 | // item.AssetID = UUID.Parse(reader.GetString(0)); |
83 | item.AssetType = reader.GetInt32(1); | 82 | // item.AssetType = reader.GetInt32(1); |
84 | item.Name = reader.GetString(2); | 83 | // item.Name = reader.GetString(2); |
85 | item.Description = reader.GetString(3); | 84 | // item.Description = reader.GetString(3); |
86 | item.NextPermissions = (uint)reader.GetInt32(4); | 85 | // item.NextPermissions = (uint)reader.GetInt32(4); |
87 | item.CurrentPermissions = (uint)reader.GetInt32(5); | 86 | // item.CurrentPermissions = (uint)reader.GetInt32(5); |
88 | item.InvType = reader.GetInt32(6); | 87 | // item.InvType = reader.GetInt32(6); |
89 | item.Creator = UUID.Parse(reader.GetString(7)); | 88 | // item.Creator = UUID.Parse(reader.GetString(7)); |
90 | item.BasePermissions = (uint)reader.GetInt32(8); | 89 | // item.BasePermissions = (uint)reader.GetInt32(8); |
91 | item.EveryOnePermissions = (uint)reader.GetInt32(9); | 90 | // item.EveryOnePermissions = (uint)reader.GetInt32(9); |
92 | item.SalePrice = reader.GetInt32(10); | 91 | // item.SalePrice = reader.GetInt32(10); |
93 | item.SaleType = reader.GetByte(11); | 92 | // item.SaleType = reader.GetByte(11); |
94 | item.CreationDate = reader.GetInt32(12); | 93 | // item.CreationDate = reader.GetInt32(12); |
95 | item.GroupID = UUID.Parse(reader.GetString(13)); | 94 | // item.GroupID = UUID.Parse(reader.GetString(13)); |
96 | item.GroupOwned = reader.GetBoolean(14); | 95 | // item.GroupOwned = reader.GetBoolean(14); |
97 | item.Flags = (uint)reader.GetInt32(15); | 96 | // item.Flags = (uint)reader.GetInt32(15); |
98 | item.Owner = UUID.Parse(reader.GetString(16)); | 97 | // item.Owner = UUID.Parse(reader.GetString(16)); |
99 | item.Folder = UUID.Parse(reader.GetString(17)); | 98 | // item.Folder = UUID.Parse(reader.GetString(17)); |
100 | item.GroupPermissions = (uint)reader.GetInt32(18); | 99 | // item.GroupPermissions = (uint)reader.GetInt32(18); |
101 | 100 | ||
102 | ret = BackendResponse.Success; | 101 | // ret = BackendResponse.Success; |
103 | } | 102 | // } |
104 | else | 103 | // else |
105 | { | 104 | // { |
106 | ret = BackendResponse.NotFound; | 105 | // ret = BackendResponse.NotFound; |
107 | } | 106 | // } |
108 | } | 107 | // } |
109 | catch (MySqlException ex) | 108 | // catch (MySqlException ex) |
110 | { | 109 | // { |
111 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 110 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
112 | ret = BackendResponse.Failure; | 111 | // ret = BackendResponse.Failure; |
113 | } | 112 | // } |
114 | } | 113 | //} |
115 | 114 | ||
116 | m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | 115 | //m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); |
117 | return ret; | 116 | //return ret; |
117 | return BackendResponse.Success; | ||
118 | } | 118 | } |
119 | 119 | ||
120 | public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder) | 120 | public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder) |
121 | { | 121 | { |
122 | folder = null; | 122 | folder = null; |
123 | BackendResponse ret; | 123 | //BackendResponse ret; |
124 | 124 | ||
125 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 125 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
126 | { | 126 | //{ |
127 | IDataReader reader; | 127 | // IDataReader reader; |
128 | 128 | ||
129 | try | 129 | // try |
130 | { | 130 | // { |
131 | dbConnection.Open(); | 131 | // dbConnection.Open(); |
132 | 132 | ||
133 | IDbCommand command = dbConnection.CreateCommand(); | 133 | // IDbCommand command = dbConnection.CreateCommand(); |
134 | command.CommandText = String.Format("SELECT folderName,type,version,agentID,parentFolderID FROM inventoryfolders WHERE folderID='{0}'", | 134 | // command.CommandText = String.Format("SELECT folderName,type,version,agentID,parentFolderID FROM inventoryfolders WHERE folderID='{0}'", |
135 | folderID.ToString()); | 135 | // folderID.ToString()); |
136 | reader = command.ExecuteReader(); | 136 | // reader = command.ExecuteReader(); |
137 | 137 | ||
138 | if (reader.Read()) | 138 | // if (reader.Read()) |
139 | { | 139 | // { |
140 | folder = new InventoryFolder(); | 140 | // folder = new InventoryFolder(); |
141 | folder.Children = null; // This call only returns data for the folder itself, no children data | 141 | // folder.Children = null; // This call only returns data for the folder itself, no children data |
142 | folder.ID = folderID; | 142 | // folder.ID = folderID; |
143 | folder.Name = reader.GetString(0); | 143 | // folder.Name = reader.GetString(0); |
144 | folder.Type = reader.GetInt16(1); | 144 | // folder.Type = reader.GetInt16(1); |
145 | folder.Version = (ushort)reader.GetInt16(2); | 145 | // folder.Version = (ushort)reader.GetInt16(2); |
146 | folder.Owner = UUID.Parse(reader.GetString(3)); | 146 | // folder.Owner = UUID.Parse(reader.GetString(3)); |
147 | folder.ParentID = UUID.Parse(reader.GetString(4)); | 147 | // folder.ParentID = UUID.Parse(reader.GetString(4)); |
148 | 148 | ||
149 | ret = BackendResponse.Success; | 149 | // ret = BackendResponse.Success; |
150 | } | 150 | // } |
151 | else | 151 | // else |
152 | { | 152 | // { |
153 | ret = BackendResponse.NotFound; | 153 | // ret = BackendResponse.NotFound; |
154 | } | 154 | // } |
155 | } | 155 | // } |
156 | catch (MySqlException ex) | 156 | // catch (MySqlException ex) |
157 | { | 157 | // { |
158 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 158 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
159 | ret = BackendResponse.Failure; | 159 | // ret = BackendResponse.Failure; |
160 | } | 160 | // } |
161 | } | 161 | //} |
162 | 162 | ||
163 | m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | 163 | //m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); |
164 | return ret; | 164 | //return ret; |
165 | return BackendResponse.Success; | ||
165 | } | 166 | } |
166 | 167 | ||
167 | public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents) | 168 | public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents) |
168 | { | 169 | { |
169 | contents = null; | 170 | contents = null; |
170 | BackendResponse ret; | 171 | //BackendResponse ret; |
171 | 172 | ||
172 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 173 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
173 | { | 174 | //{ |
174 | IDataReader reader; | 175 | // IDataReader reader; |
175 | 176 | ||
176 | try | 177 | // try |
177 | { | 178 | // { |
178 | dbConnection.Open(); | 179 | // dbConnection.Open(); |
179 | 180 | ||
180 | contents = new InventoryCollection(); | 181 | // contents = new InventoryCollection(); |
181 | 182 | ||
182 | #region Folder retrieval | 183 | // #region Folder retrieval |
183 | 184 | ||
184 | IDbCommand command = dbConnection.CreateCommand(); | 185 | // IDbCommand command = dbConnection.CreateCommand(); |
185 | command.CommandText = String.Format("SELECT folderName,type,version,agentID,folderID FROM inventoryfolders WHERE parentFolderID='{0}'", | 186 | // command.CommandText = String.Format("SELECT folderName,type,version,agentID,folderID FROM inventoryfolders WHERE parentFolderID='{0}'", |
186 | folderID.ToString()); | 187 | // folderID.ToString()); |
187 | reader = command.ExecuteReader(); | 188 | // reader = command.ExecuteReader(); |
188 | 189 | ||
189 | contents.Folders = new Dictionary<UUID, InventoryFolder>(); | 190 | // contents.Folders = new Dictionary<UUID, InventoryFolder>(); |
190 | 191 | ||
191 | while (reader.Read()) | 192 | // while (reader.Read()) |
192 | { | 193 | // { |
193 | InventoryFolder folder = new InventoryFolder(); | 194 | // InventoryFolder folder = new InventoryFolder(); |
194 | folder.ParentID = folderID; | 195 | // folder.ParentID = folderID; |
195 | folder.Children = null; // This call doesn't do recursion | 196 | // folder.Children = null; // This call doesn't do recursion |
196 | folder.Name = reader.GetString(0); | 197 | // folder.Name = reader.GetString(0); |
197 | folder.Type = reader.GetInt16(1); | 198 | // folder.Type = reader.GetInt16(1); |
198 | folder.Version = (ushort)reader.GetInt16(2); | 199 | // folder.Version = (ushort)reader.GetInt16(2); |
199 | folder.Owner = UUID.Parse(reader.GetString(3)); | 200 | // folder.Owner = UUID.Parse(reader.GetString(3)); |
200 | folder.ID = UUID.Parse(reader.GetString(4)); | 201 | // folder.ID = UUID.Parse(reader.GetString(4)); |
201 | 202 | ||
202 | contents.Folders.Add(folder.ID, folder); | 203 | // contents.Folders.Add(folder.ID, folder); |
203 | contents.UserID = folder.Owner; | 204 | // contents.UserID = folder.Owner; |
204 | } | 205 | // } |
205 | 206 | ||
206 | reader.Close(); | 207 | // reader.Close(); |
207 | 208 | ||
208 | #endregion Folder retrieval | 209 | // #endregion Folder retrieval |
209 | 210 | ||
210 | #region Item retrieval | 211 | // #region Item retrieval |
211 | 212 | ||
212 | command = dbConnection.CreateCommand(); | 213 | // command = dbConnection.CreateCommand(); |
213 | command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | 214 | // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + |
214 | "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | 215 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + |
215 | "creationDate,groupID,groupOwned,flags,avatarID,inventoryID,inventoryGroupPermissions FROM inventoryitems WHERE parentFolderID='{0}'", | 216 | // "creationDate,groupID,groupOwned,flags,avatarID,inventoryID,inventoryGroupPermissions FROM inventoryitems WHERE parentFolderID='{0}'", |
216 | folderID.ToString()); | 217 | // folderID.ToString()); |
217 | reader = command.ExecuteReader(); | 218 | // reader = command.ExecuteReader(); |
218 | 219 | ||
219 | contents.Items = new Dictionary<UUID, InventoryItem>(); | 220 | // contents.Items = new Dictionary<UUID, InventoryItem>(); |
220 | 221 | ||
221 | while (reader.Read()) | 222 | // while (reader.Read()) |
222 | { | 223 | // { |
223 | InventoryItem item = new InventoryItem(); | 224 | // InventoryItem item = new InventoryItem(); |
224 | item.Folder = folderID; | 225 | // item.Folder = folderID; |
225 | item.AssetID = UUID.Parse(reader.GetString(0)); | 226 | // item.AssetID = UUID.Parse(reader.GetString(0)); |
226 | item.AssetType = reader.GetInt32(1); | 227 | // item.AssetType = reader.GetInt32(1); |
227 | item.Name = reader.GetString(2); | 228 | // item.Name = reader.GetString(2); |
228 | item.Description = reader.GetString(3); | 229 | // item.Description = reader.GetString(3); |
229 | item.NextPermissions = (uint)reader.GetInt32(4); | 230 | // item.NextPermissions = (uint)reader.GetInt32(4); |
230 | item.CurrentPermissions = (uint)reader.GetInt32(5); | 231 | // item.CurrentPermissions = (uint)reader.GetInt32(5); |
231 | item.InvType = reader.GetInt32(6); | 232 | // item.InvType = reader.GetInt32(6); |
232 | item.Creator = UUID.Parse(reader.GetString(7)); | 233 | // item.Creator = UUID.Parse(reader.GetString(7)); |
233 | item.BasePermissions = (uint)reader.GetInt32(8); | 234 | // item.BasePermissions = (uint)reader.GetInt32(8); |
234 | item.EveryOnePermissions = (uint)reader.GetInt32(9); | 235 | // item.EveryOnePermissions = (uint)reader.GetInt32(9); |
235 | item.SalePrice = reader.GetInt32(10); | 236 | // item.SalePrice = reader.GetInt32(10); |
236 | item.SaleType = reader.GetByte(11); | 237 | // item.SaleType = reader.GetByte(11); |
237 | item.CreationDate = reader.GetInt32(12); | 238 | // item.CreationDate = reader.GetInt32(12); |
238 | item.GroupID = UUID.Parse(reader.GetString(13)); | 239 | // item.GroupID = UUID.Parse(reader.GetString(13)); |
239 | item.GroupOwned = reader.GetBoolean(14); | 240 | // item.GroupOwned = reader.GetBoolean(14); |
240 | item.Flags = (uint)reader.GetInt32(15); | 241 | // item.Flags = (uint)reader.GetInt32(15); |
241 | item.Owner = UUID.Parse(reader.GetString(16)); | 242 | // item.Owner = UUID.Parse(reader.GetString(16)); |
242 | item.ID = UUID.Parse(reader.GetString(17)); | 243 | // item.ID = UUID.Parse(reader.GetString(17)); |
243 | item.GroupPermissions = (uint)reader.GetInt32(18); | 244 | // item.GroupPermissions = (uint)reader.GetInt32(18); |
244 | 245 | ||
245 | contents.Items.Add(item.ID, item); | 246 | // contents.Items.Add(item.ID, item); |
246 | contents.UserID = item.Owner; | 247 | // contents.UserID = item.Owner; |
247 | } | 248 | // } |
248 | 249 | ||
249 | #endregion Item retrieval | 250 | // #endregion Item retrieval |
250 | 251 | ||
251 | ret = BackendResponse.Success; | 252 | // ret = BackendResponse.Success; |
252 | } | 253 | // } |
253 | catch (MySqlException ex) | 254 | // catch (MySqlException ex) |
254 | { | 255 | // { |
255 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 256 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
256 | ret = BackendResponse.Failure; | 257 | // ret = BackendResponse.Failure; |
257 | } | 258 | // } |
258 | } | 259 | //} |
259 | 260 | ||
260 | m_server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); | 261 | //m_server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); |
261 | return ret; | 262 | //return ret; |
263 | return BackendResponse.Success; | ||
262 | } | 264 | } |
263 | 265 | ||
264 | public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders) | 266 | public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders) |
265 | { | 267 | { |
266 | folders = null; | 268 | folders = null; |
267 | BackendResponse ret; | 269 | //BackendResponse ret; |
268 | UUID ownerID; | 270 | //UUID ownerID; |
269 | 271 | ||
270 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 272 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
271 | { | 273 | //{ |
272 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 274 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
273 | { | 275 | // { |
274 | IDataReader reader; | 276 | // IDataReader reader; |
275 | 277 | ||
276 | try | 278 | // try |
277 | { | 279 | // { |
278 | dbConnection.Open(); | 280 | // dbConnection.Open(); |
279 | folders = new List<InventoryFolder>(); | 281 | // folders = new List<InventoryFolder>(); |
280 | 282 | ||
281 | IDbCommand command = dbConnection.CreateCommand(); | 283 | // IDbCommand command = dbConnection.CreateCommand(); |
282 | command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'", | 284 | // command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'", |
283 | ownerID.ToString()); | 285 | // ownerID.ToString()); |
284 | reader = command.ExecuteReader(); | 286 | // reader = command.ExecuteReader(); |
285 | 287 | ||
286 | while (reader.Read()) | 288 | // while (reader.Read()) |
287 | { | 289 | // { |
288 | InventoryFolder folder = new InventoryFolder(); | 290 | // InventoryFolder folder = new InventoryFolder(); |
289 | folder.Owner = ownerID; | 291 | // folder.Owner = ownerID; |
290 | folder.Children = null; // This call does not create a folder hierarchy | 292 | // folder.Children = null; // This call does not create a folder hierarchy |
291 | folder.Name = reader.GetString(0); | 293 | // folder.Name = reader.GetString(0); |
292 | folder.Type = reader.GetInt16(1); | 294 | // folder.Type = reader.GetInt16(1); |
293 | folder.Version = (ushort)reader.GetInt16(2); | 295 | // folder.Version = (ushort)reader.GetInt16(2); |
294 | folder.ID = UUID.Parse(reader.GetString(3)); | 296 | // folder.ID = UUID.Parse(reader.GetString(3)); |
295 | folder.ParentID = UUID.Parse(reader.GetString(4)); | 297 | // folder.ParentID = UUID.Parse(reader.GetString(4)); |
296 | 298 | ||
297 | folders.Add(folder); | 299 | // folders.Add(folder); |
298 | } | 300 | // } |
299 | 301 | ||
300 | ret = BackendResponse.Success; | 302 | // ret = BackendResponse.Success; |
301 | } | 303 | // } |
302 | catch (MySqlException ex) | 304 | // catch (MySqlException ex) |
303 | { | 305 | // { |
304 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 306 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
305 | ret = BackendResponse.Failure; | 307 | // ret = BackendResponse.Failure; |
306 | } | 308 | // } |
307 | } | 309 | // } |
308 | } | 310 | //} |
309 | else | 311 | //else |
310 | { | 312 | //{ |
311 | ret = BackendResponse.NotFound; | 313 | // ret = BackendResponse.NotFound; |
312 | } | 314 | //} |
313 | 315 | ||
314 | m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); | 316 | //m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); |
315 | return ret; | 317 | //return ret; |
318 | return BackendResponse.Success; | ||
316 | } | 319 | } |
317 | 320 | ||
318 | public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory) | 321 | public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory) |
319 | { | 322 | { |
320 | inventory = null; | 323 | inventory = null; |
321 | BackendResponse ret; | 324 | //BackendResponse ret; |
322 | List<InventoryFolder> folders; | 325 | //List<InventoryFolder> folders; |
323 | UUID ownerID; | 326 | //UUID ownerID; |
324 | 327 | ||
325 | ret = TryFetchFolderList(owner, out folders); | 328 | //ret = TryFetchFolderList(owner, out folders); |
326 | 329 | ||
327 | if (ret == BackendResponse.Success) | 330 | //if (ret == BackendResponse.Success) |
328 | { | 331 | //{ |
329 | // Add the retrieved folders to the inventory collection | 332 | // // Add the retrieved folders to the inventory collection |
330 | inventory = new InventoryCollection(); | 333 | // inventory = new InventoryCollection(); |
331 | inventory.Folders = new Dictionary<UUID, InventoryFolder>(folders.Count); | 334 | // inventory.Folders = new Dictionary<UUID, InventoryFolder>(folders.Count); |
332 | foreach (InventoryFolder folder in folders) | 335 | // foreach (InventoryFolder folder in folders) |
333 | inventory.Folders[folder.ID] = folder; | 336 | // inventory.Folders[folder.ID] = folder; |
334 | 337 | ||
335 | // Fetch inventory items | 338 | // // Fetch inventory items |
336 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 339 | // if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
337 | { | 340 | // { |
338 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 341 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
339 | { | 342 | // { |
340 | IDataReader reader; | 343 | // IDataReader reader; |
341 | 344 | ||
342 | try | 345 | // try |
343 | { | 346 | // { |
344 | dbConnection.Open(); | 347 | // dbConnection.Open(); |
345 | 348 | ||
346 | IDbCommand command = dbConnection.CreateCommand(); | 349 | // IDbCommand command = dbConnection.CreateCommand(); |
347 | command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | 350 | // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + |
348 | "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | 351 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + |
349 | "creationDate,groupID,groupOwned,flags,inventoryID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE " + | 352 | // "creationDate,groupID,groupOwned,flags,inventoryID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE " + |
350 | "avatarID='{0}'", ownerID.ToString()); | 353 | // "avatarID='{0}'", ownerID.ToString()); |
351 | reader = command.ExecuteReader(); | 354 | // reader = command.ExecuteReader(); |
352 | 355 | ||
353 | inventory.UserID = ownerID; | 356 | // inventory.UserID = ownerID; |
354 | inventory.Items = new Dictionary<UUID, InventoryItem>(); | 357 | // inventory.Items = new Dictionary<UUID, InventoryItem>(); |
355 | 358 | ||
356 | while (reader.Read()) | 359 | // while (reader.Read()) |
357 | { | 360 | // { |
358 | InventoryItem item = new InventoryItem(); | 361 | // InventoryItem item = new InventoryItem(); |
359 | item.Owner = ownerID; | 362 | // item.Owner = ownerID; |
360 | item.AssetID = UUID.Parse(reader.GetString(0)); | 363 | // item.AssetID = UUID.Parse(reader.GetString(0)); |
361 | item.AssetType = reader.GetInt32(1); | 364 | // item.AssetType = reader.GetInt32(1); |
362 | item.Name = reader.GetString(2); | 365 | // item.Name = reader.GetString(2); |
363 | item.Description = reader.GetString(3); | 366 | // item.Description = reader.GetString(3); |
364 | item.NextPermissions = (uint)reader.GetInt32(4); | 367 | // item.NextPermissions = (uint)reader.GetInt32(4); |
365 | item.CurrentPermissions = (uint)reader.GetInt32(5); | 368 | // item.CurrentPermissions = (uint)reader.GetInt32(5); |
366 | item.InvType = reader.GetInt32(6); | 369 | // item.InvType = reader.GetInt32(6); |
367 | item.Creator = UUID.Parse(reader.GetString(7)); | 370 | // item.Creator = UUID.Parse(reader.GetString(7)); |
368 | item.BasePermissions = (uint)reader.GetInt32(8); | 371 | // item.BasePermissions = (uint)reader.GetInt32(8); |
369 | item.EveryOnePermissions = (uint)reader.GetInt32(9); | 372 | // item.EveryOnePermissions = (uint)reader.GetInt32(9); |
370 | item.SalePrice = reader.GetInt32(10); | 373 | // item.SalePrice = reader.GetInt32(10); |
371 | item.SaleType = reader.GetByte(11); | 374 | // item.SaleType = reader.GetByte(11); |
372 | item.CreationDate = reader.GetInt32(12); | 375 | // item.CreationDate = reader.GetInt32(12); |
373 | item.GroupID = UUID.Parse(reader.GetString(13)); | 376 | // item.GroupID = UUID.Parse(reader.GetString(13)); |
374 | item.GroupOwned = reader.GetBoolean(14); | 377 | // item.GroupOwned = reader.GetBoolean(14); |
375 | item.Flags = (uint)reader.GetInt32(15); | 378 | // item.Flags = (uint)reader.GetInt32(15); |
376 | item.ID = UUID.Parse(reader.GetString(16)); | 379 | // item.ID = UUID.Parse(reader.GetString(16)); |
377 | item.Folder = UUID.Parse(reader.GetString(17)); | 380 | // item.Folder = UUID.Parse(reader.GetString(17)); |
378 | item.GroupPermissions = (uint)reader.GetInt32(18); | 381 | // item.GroupPermissions = (uint)reader.GetInt32(18); |
379 | 382 | ||
380 | inventory.Items.Add(item.ID, item); | 383 | // inventory.Items.Add(item.ID, item); |
381 | } | 384 | // } |
382 | 385 | ||
383 | ret = BackendResponse.Success; | 386 | // ret = BackendResponse.Success; |
384 | } | 387 | // } |
385 | catch (MySqlException ex) | 388 | // catch (MySqlException ex) |
386 | { | 389 | // { |
387 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 390 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
388 | ret = BackendResponse.Failure; | 391 | // ret = BackendResponse.Failure; |
389 | } | 392 | // } |
390 | } | 393 | // } |
391 | } | 394 | // } |
392 | else | 395 | // else |
393 | { | 396 | // { |
394 | ret = BackendResponse.NotFound; | 397 | // ret = BackendResponse.NotFound; |
395 | } | 398 | // } |
396 | } | 399 | //} |
397 | 400 | ||
398 | m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); | 401 | //m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); |
399 | return ret; | 402 | //return ret; |
403 | return BackendResponse.Success; | ||
400 | } | 404 | } |
401 | 405 | ||
402 | public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures) | 406 | public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures) |
403 | { | 407 | { |
404 | gestures = null; | 408 | gestures = null; |
405 | BackendResponse ret; | 409 | //BackendResponse ret; |
406 | UUID ownerID; | 410 | //UUID ownerID; |
407 | 411 | ||
408 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 412 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
409 | { | 413 | //{ |
410 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 414 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
411 | { | 415 | // { |
412 | IDataReader reader; | 416 | // IDataReader reader; |
413 | 417 | ||
414 | try | 418 | // try |
415 | { | 419 | // { |
416 | dbConnection.Open(); | 420 | // dbConnection.Open(); |
417 | 421 | ||
418 | MySqlCommand command = new MySqlCommand("SELECT assetID,inventoryName,inventoryDescription,inventoryNextPermissions," + | 422 | // MySqlCommand command = new MySqlCommand("SELECT assetID,inventoryName,inventoryDescription,inventoryNextPermissions," + |
419 | "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | 423 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + |
420 | "creationDate,groupID,groupOwned,inventoryID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE " + | 424 | // "creationDate,groupID,groupOwned,inventoryID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE " + |
421 | "avatarId=?uuid AND assetType=?type AND flags=1", dbConnection); | 425 | // "avatarId=?uuid AND assetType=?type AND flags=1", dbConnection); |
422 | command.Parameters.AddWithValue("?uuid", ownerID.ToString()); | 426 | // command.Parameters.AddWithValue("?uuid", ownerID.ToString()); |
423 | command.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | 427 | // command.Parameters.AddWithValue("?type", (int)AssetType.Gesture); |
424 | reader = command.ExecuteReader(); | 428 | // reader = command.ExecuteReader(); |
425 | 429 | ||
426 | while (reader.Read()) | 430 | // while (reader.Read()) |
427 | { | 431 | // { |
428 | InventoryItem item = new InventoryItem(); | 432 | // InventoryItem item = new InventoryItem(); |
429 | item.Owner = ownerID; | 433 | // item.Owner = ownerID; |
430 | item.AssetType = (int)AssetType.Gesture; | 434 | // item.AssetType = (int)AssetType.Gesture; |
431 | item.Flags = (uint)1; | 435 | // item.Flags = (uint)1; |
432 | item.AssetID = UUID.Parse(reader.GetString(0)); | 436 | // item.AssetID = UUID.Parse(reader.GetString(0)); |
433 | item.Name = reader.GetString(1); | 437 | // item.Name = reader.GetString(1); |
434 | item.Description = reader.GetString(2); | 438 | // item.Description = reader.GetString(2); |
435 | item.NextPermissions = (uint)reader.GetInt32(3); | 439 | // item.NextPermissions = (uint)reader.GetInt32(3); |
436 | item.CurrentPermissions = (uint)reader.GetInt32(4); | 440 | // item.CurrentPermissions = (uint)reader.GetInt32(4); |
437 | item.InvType = reader.GetInt32(5); | 441 | // item.InvType = reader.GetInt32(5); |
438 | item.Creator = UUID.Parse(reader.GetString(6)); | 442 | // item.Creator = UUID.Parse(reader.GetString(6)); |
439 | item.BasePermissions = (uint)reader.GetInt32(7); | 443 | // item.BasePermissions = (uint)reader.GetInt32(7); |
440 | item.EveryOnePermissions = (uint)reader.GetInt32(8); | 444 | // item.EveryOnePermissions = (uint)reader.GetInt32(8); |
441 | item.SalePrice = reader.GetInt32(9); | 445 | // item.SalePrice = reader.GetInt32(9); |
442 | item.SaleType = reader.GetByte(10); | 446 | // item.SaleType = reader.GetByte(10); |
443 | item.CreationDate = reader.GetInt32(11); | 447 | // item.CreationDate = reader.GetInt32(11); |
444 | item.GroupID = UUID.Parse(reader.GetString(12)); | 448 | // item.GroupID = UUID.Parse(reader.GetString(12)); |
445 | item.GroupOwned = reader.GetBoolean(13); | 449 | // item.GroupOwned = reader.GetBoolean(13); |
446 | item.ID = UUID.Parse(reader.GetString(14)); | 450 | // item.ID = UUID.Parse(reader.GetString(14)); |
447 | item.Folder = UUID.Parse(reader.GetString(15)); | 451 | // item.Folder = UUID.Parse(reader.GetString(15)); |
448 | item.GroupPermissions = (uint)reader.GetInt32(16); | 452 | // item.GroupPermissions = (uint)reader.GetInt32(16); |
449 | 453 | ||
450 | gestures.Add(item); | 454 | // gestures.Add(item); |
451 | } | 455 | // } |
452 | 456 | ||
453 | ret = BackendResponse.Success; | 457 | // ret = BackendResponse.Success; |
454 | } | 458 | // } |
455 | catch (MySqlException ex) | 459 | // catch (MySqlException ex) |
456 | { | 460 | // { |
457 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 461 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
458 | ret = BackendResponse.Failure; | 462 | // ret = BackendResponse.Failure; |
459 | } | 463 | // } |
460 | } | 464 | // } |
461 | } | 465 | //} |
462 | else | 466 | //else |
463 | { | 467 | //{ |
464 | ret = BackendResponse.NotFound; | 468 | // ret = BackendResponse.NotFound; |
465 | } | 469 | //} |
466 | 470 | ||
467 | m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); | 471 | //m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); |
468 | return ret; | 472 | //return ret; |
473 | return BackendResponse.Success; | ||
469 | } | 474 | } |
470 | 475 | ||
471 | public BackendResponse TryCreateItem(Uri owner, InventoryItem item) | 476 | public BackendResponse TryCreateItem(Uri owner, InventoryItem item) |
472 | { | 477 | { |
473 | BackendResponse ret; | 478 | //BackendResponse ret; |
474 | 479 | ||
475 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 480 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
476 | { | 481 | //{ |
477 | try | 482 | // try |
478 | { | 483 | // { |
479 | dbConnection.Open(); | 484 | // dbConnection.Open(); |
480 | 485 | ||
481 | MySqlCommand command = new MySqlCommand( | 486 | // MySqlCommand command = new MySqlCommand( |
482 | "REPLACE INTO inventoryitems (assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + | 487 | // "REPLACE INTO inventoryitems (assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + |
483 | "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + | 488 | // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," + |
484 | "creationDate,groupID,groupOwned,flags,inventoryID,avatarID,parentFolderID,inventoryGroupPermissions) VALUES " + | 489 | // "creationDate,groupID,groupOwned,flags,inventoryID,avatarID,parentFolderID,inventoryGroupPermissions) VALUES " + |
485 | 490 | ||
486 | "(?assetID,?assetType,?inventoryName,?inventoryDescription,?inventoryNextPermissions,?inventoryCurrentPermissions,?invType," + | 491 | // "(?assetID,?assetType,?inventoryName,?inventoryDescription,?inventoryNextPermissions,?inventoryCurrentPermissions,?invType," + |
487 | "?creatorID,?inventoryBasePermissions,?inventoryEveryOnePermissions,?salePrice,?saleType,?creationDate,?groupID,?groupOwned," + | 492 | // "?creatorID,?inventoryBasePermissions,?inventoryEveryOnePermissions,?salePrice,?saleType,?creationDate,?groupID,?groupOwned," + |
488 | "?flags,?inventoryID,?avatarID,?parentFolderID,?inventoryGroupPermissions)", dbConnection); | 493 | // "?flags,?inventoryID,?avatarID,?parentFolderID,?inventoryGroupPermissions)", dbConnection); |
489 | 494 | ||
490 | command.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | 495 | // command.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); |
491 | command.Parameters.AddWithValue("?assetType", item.AssetType); | 496 | // command.Parameters.AddWithValue("?assetType", item.AssetType); |
492 | command.Parameters.AddWithValue("?inventoryName", item.Name); | 497 | // command.Parameters.AddWithValue("?inventoryName", item.Name); |
493 | command.Parameters.AddWithValue("?inventoryDescription", item.Description); | 498 | // command.Parameters.AddWithValue("?inventoryDescription", item.Description); |
494 | command.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions); | 499 | // command.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions); |
495 | command.Parameters.AddWithValue("?inventoryCurrentPermissions", item.CurrentPermissions); | 500 | // command.Parameters.AddWithValue("?inventoryCurrentPermissions", item.CurrentPermissions); |
496 | command.Parameters.AddWithValue("?invType", item.InvType); | 501 | // command.Parameters.AddWithValue("?invType", item.InvType); |
497 | command.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); | 502 | // command.Parameters.AddWithValue("?creatorID", item.Creator.ToString()); |
498 | command.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | 503 | // command.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); |
499 | command.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | 504 | // command.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); |
500 | command.Parameters.AddWithValue("?salePrice", item.SalePrice); | 505 | // command.Parameters.AddWithValue("?salePrice", item.SalePrice); |
501 | command.Parameters.AddWithValue("?saleType", item.SaleType); | 506 | // command.Parameters.AddWithValue("?saleType", item.SaleType); |
502 | command.Parameters.AddWithValue("?creationDate", item.CreationDate); | 507 | // command.Parameters.AddWithValue("?creationDate", item.CreationDate); |
503 | command.Parameters.AddWithValue("?groupID", item.GroupID.ToString()); | 508 | // command.Parameters.AddWithValue("?groupID", item.GroupID.ToString()); |
504 | command.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | 509 | // command.Parameters.AddWithValue("?groupOwned", item.GroupOwned); |
505 | command.Parameters.AddWithValue("?flags", item.Flags); | 510 | // command.Parameters.AddWithValue("?flags", item.Flags); |
506 | command.Parameters.AddWithValue("?inventoryID", item.ID); | 511 | // command.Parameters.AddWithValue("?inventoryID", item.ID); |
507 | command.Parameters.AddWithValue("?avatarID", item.Owner); | 512 | // command.Parameters.AddWithValue("?avatarID", item.Owner); |
508 | command.Parameters.AddWithValue("?parentFolderID", item.Folder); | 513 | // command.Parameters.AddWithValue("?parentFolderID", item.Folder); |
509 | command.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | 514 | // command.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); |
510 | 515 | ||
511 | int rowsAffected = command.ExecuteNonQuery(); | 516 | // int rowsAffected = command.ExecuteNonQuery(); |
512 | if (rowsAffected == 1) | 517 | // if (rowsAffected == 1) |
513 | { | 518 | // { |
514 | ret = BackendResponse.Success; | 519 | // ret = BackendResponse.Success; |
515 | } | 520 | // } |
516 | else if (rowsAffected == 2) | 521 | // else if (rowsAffected == 2) |
517 | { | 522 | // { |
518 | m_log.Info("Replaced inventory item " + item.ID.ToString()); | 523 | // m_log.Info("Replaced inventory item " + item.ID.ToString()); |
519 | ret = BackendResponse.Success; | 524 | // ret = BackendResponse.Success; |
520 | } | 525 | // } |
521 | else | 526 | // else |
522 | { | 527 | // { |
523 | m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); | 528 | // m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); |
524 | ret = BackendResponse.Failure; | 529 | // ret = BackendResponse.Failure; |
525 | } | 530 | // } |
526 | } | 531 | // } |
527 | catch (MySqlException ex) | 532 | // catch (MySqlException ex) |
528 | { | 533 | // { |
529 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 534 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
530 | ret = BackendResponse.Failure; | 535 | // ret = BackendResponse.Failure; |
531 | } | 536 | // } |
532 | } | 537 | //} |
533 | 538 | ||
534 | m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now); | 539 | //m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now); |
535 | return ret; | 540 | //return ret; |
541 | return BackendResponse.Success; | ||
536 | } | 542 | } |
537 | 543 | ||
538 | public BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder) | 544 | public BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder) |
539 | { | 545 | { |
540 | BackendResponse ret; | 546 | //BackendResponse ret; |
541 | 547 | ||
542 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 548 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
543 | { | 549 | //{ |
544 | try | 550 | // try |
545 | { | 551 | // { |
546 | dbConnection.Open(); | 552 | // dbConnection.Open(); |
547 | 553 | ||
548 | MySqlCommand command = new MySqlCommand( | 554 | // MySqlCommand command = new MySqlCommand( |
549 | "REPLACE INTO inventoryfolders (folderName,type,version,folderID,agentID,parentFolderID) VALUES " + | 555 | // "REPLACE INTO inventoryfolders (folderName,type,version,folderID,agentID,parentFolderID) VALUES " + |
550 | "(?folderName,?type,?version,?folderID,?agentID,?parentFolderID)", dbConnection); | 556 | // "(?folderName,?type,?version,?folderID,?agentID,?parentFolderID)", dbConnection); |
551 | 557 | ||
552 | command.Parameters.AddWithValue("?folderName", folder.Name); | 558 | // command.Parameters.AddWithValue("?folderName", folder.Name); |
553 | command.Parameters.AddWithValue("?type", folder.Type); | 559 | // command.Parameters.AddWithValue("?type", folder.Type); |
554 | command.Parameters.AddWithValue("?version", folder.Version); | 560 | // command.Parameters.AddWithValue("?version", folder.Version); |
555 | command.Parameters.AddWithValue("?folderID", folder.ID); | 561 | // command.Parameters.AddWithValue("?folderID", folder.ID); |
556 | command.Parameters.AddWithValue("?agentID", folder.Owner); | 562 | // command.Parameters.AddWithValue("?agentID", folder.Owner); |
557 | command.Parameters.AddWithValue("?parentFolderID", folder.ParentID); | 563 | // command.Parameters.AddWithValue("?parentFolderID", folder.ParentID); |
558 | 564 | ||
559 | int rowsAffected = command.ExecuteNonQuery(); | 565 | // int rowsAffected = command.ExecuteNonQuery(); |
560 | if (rowsAffected == 1) | 566 | // if (rowsAffected == 1) |
561 | { | 567 | // { |
562 | ret = BackendResponse.Success; | 568 | // ret = BackendResponse.Success; |
563 | } | 569 | // } |
564 | else if (rowsAffected == 2) | 570 | // else if (rowsAffected == 2) |
565 | { | 571 | // { |
566 | m_log.Info("Replaced inventory folder " + folder.ID.ToString()); | 572 | // m_log.Info("Replaced inventory folder " + folder.ID.ToString()); |
567 | ret = BackendResponse.Success; | 573 | // ret = BackendResponse.Success; |
568 | } | 574 | // } |
569 | else | 575 | // else |
570 | { | 576 | // { |
571 | m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); | 577 | // m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); |
572 | ret = BackendResponse.Failure; | 578 | // ret = BackendResponse.Failure; |
573 | } | 579 | // } |
574 | } | 580 | // } |
575 | catch (MySqlException ex) | 581 | // catch (MySqlException ex) |
576 | { | 582 | // { |
577 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 583 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
578 | ret = BackendResponse.Failure; | 584 | // ret = BackendResponse.Failure; |
579 | } | 585 | // } |
580 | } | 586 | //} |
581 | 587 | ||
582 | m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); | 588 | //m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); |
583 | return ret; | 589 | //return ret; |
590 | return BackendResponse.Success; | ||
584 | } | 591 | } |
585 | 592 | ||
586 | public BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder) | 593 | public BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder) |
@@ -590,193 +597,196 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
590 | 597 | ||
591 | public BackendResponse TryDeleteItem(Uri owner, UUID itemID) | 598 | public BackendResponse TryDeleteItem(Uri owner, UUID itemID) |
592 | { | 599 | { |
593 | BackendResponse ret; | 600 | //BackendResponse ret; |
594 | UUID ownerID; | 601 | //UUID ownerID; |
595 | 602 | ||
596 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 603 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
597 | { | 604 | //{ |
598 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 605 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
599 | { | 606 | // { |
600 | try | 607 | // try |
601 | { | 608 | // { |
602 | dbConnection.Open(); | 609 | // dbConnection.Open(); |
603 | 610 | ||
604 | MySqlCommand command = new MySqlCommand( | 611 | // MySqlCommand command = new MySqlCommand( |
605 | "DELETE FROM inventoryitems WHERE inventoryID=?inventoryID AND avatarID=?avatarID", dbConnection); | 612 | // "DELETE FROM inventoryitems WHERE inventoryID=?inventoryID AND avatarID=?avatarID", dbConnection); |
606 | 613 | ||
607 | command.Parameters.AddWithValue("?inventoryID", itemID.ToString()); | 614 | // command.Parameters.AddWithValue("?inventoryID", itemID.ToString()); |
608 | command.Parameters.AddWithValue("?avatarID", ownerID.ToString()); | 615 | // command.Parameters.AddWithValue("?avatarID", ownerID.ToString()); |
609 | 616 | ||
610 | int rowsAffected = command.ExecuteNonQuery(); | 617 | // int rowsAffected = command.ExecuteNonQuery(); |
611 | if (rowsAffected == 1) | 618 | // if (rowsAffected == 1) |
612 | { | 619 | // { |
613 | ret = BackendResponse.Success; | 620 | // ret = BackendResponse.Success; |
614 | } | 621 | // } |
615 | else | 622 | // else |
616 | { | 623 | // { |
617 | m_log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected); | 624 | // m_log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected); |
618 | ret = BackendResponse.NotFound; | 625 | // ret = BackendResponse.NotFound; |
619 | } | 626 | // } |
620 | } | 627 | // } |
621 | catch (MySqlException ex) | 628 | // catch (MySqlException ex) |
622 | { | 629 | // { |
623 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 630 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
624 | ret = BackendResponse.Failure; | 631 | // ret = BackendResponse.Failure; |
625 | } | 632 | // } |
626 | } | 633 | // } |
627 | } | 634 | //} |
628 | else | 635 | //else |
629 | { | 636 | //{ |
630 | ret = BackendResponse.NotFound; | 637 | // ret = BackendResponse.NotFound; |
631 | } | 638 | //} |
632 | 639 | ||
633 | m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); | 640 | //m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); |
634 | return ret; | 641 | //return ret; |
642 | return BackendResponse.Success; | ||
635 | } | 643 | } |
636 | 644 | ||
637 | public BackendResponse TryDeleteFolder(Uri owner, UUID folderID) | 645 | public BackendResponse TryDeleteFolder(Uri owner, UUID folderID) |
638 | { | 646 | { |
639 | BackendResponse ret; | 647 | //BackendResponse ret; |
640 | UUID ownerID; | 648 | //UUID ownerID; |
641 | 649 | ||
642 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 650 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
643 | { | 651 | //{ |
644 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 652 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
645 | { | 653 | // { |
646 | try | 654 | // try |
647 | { | 655 | // { |
648 | dbConnection.Open(); | 656 | // dbConnection.Open(); |
649 | 657 | ||
650 | MySqlCommand command = new MySqlCommand( | 658 | // MySqlCommand command = new MySqlCommand( |
651 | "DELETE FROM inventoryfolders WHERE folderID=?folderID AND agentID=?agentID", dbConnection); | 659 | // "DELETE FROM inventoryfolders WHERE folderID=?folderID AND agentID=?agentID", dbConnection); |
652 | 660 | ||
653 | command.Parameters.AddWithValue("?folderID", folderID.ToString()); | 661 | // command.Parameters.AddWithValue("?folderID", folderID.ToString()); |
654 | command.Parameters.AddWithValue("?agentID", ownerID.ToString()); | 662 | // command.Parameters.AddWithValue("?agentID", ownerID.ToString()); |
655 | 663 | ||
656 | int rowsAffected = command.ExecuteNonQuery(); | 664 | // int rowsAffected = command.ExecuteNonQuery(); |
657 | if (rowsAffected == 1) | 665 | // if (rowsAffected == 1) |
658 | { | 666 | // { |
659 | ret = BackendResponse.Success; | 667 | // ret = BackendResponse.Success; |
660 | } | 668 | // } |
661 | else | 669 | // else |
662 | { | 670 | // { |
663 | m_log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected); | 671 | // m_log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected); |
664 | ret = BackendResponse.NotFound; | 672 | // ret = BackendResponse.NotFound; |
665 | } | 673 | // } |
666 | } | 674 | // } |
667 | catch (MySqlException ex) | 675 | // catch (MySqlException ex) |
668 | { | 676 | // { |
669 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 677 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
670 | ret = BackendResponse.Failure; | 678 | // ret = BackendResponse.Failure; |
671 | } | 679 | // } |
672 | } | 680 | // } |
673 | } | 681 | //} |
674 | else | 682 | //else |
675 | { | 683 | //{ |
676 | ret = BackendResponse.NotFound; | 684 | // ret = BackendResponse.NotFound; |
677 | } | 685 | //} |
678 | 686 | ||
679 | m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); | 687 | //m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); |
680 | return ret; | 688 | //return ret; |
689 | return BackendResponse.Success; | ||
681 | } | 690 | } |
682 | 691 | ||
683 | public BackendResponse TryPurgeFolder(Uri owner, UUID folderID) | 692 | public BackendResponse TryPurgeFolder(Uri owner, UUID folderID) |
684 | { | 693 | { |
685 | BackendResponse ret; | 694 | //BackendResponse ret; |
686 | UUID ownerID; | 695 | //UUID ownerID; |
687 | 696 | ||
688 | if (Utils.TryGetOpenSimUUID(owner, out ownerID)) | 697 | //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) |
689 | { | 698 | //{ |
690 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 699 | // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
691 | { | 700 | // { |
692 | try | 701 | // try |
693 | { | 702 | // { |
694 | dbConnection.Open(); | 703 | // dbConnection.Open(); |
695 | 704 | ||
696 | #region Delete items | 705 | // #region Delete items |
697 | 706 | ||
698 | MySqlCommand command = new MySqlCommand( | 707 | // MySqlCommand command = new MySqlCommand( |
699 | "DELETE FROM inventoryitems WHERE parentFolderID=?parentFolderID AND avatarID=?avatarID", dbConnection); | 708 | // "DELETE FROM inventoryitems WHERE parentFolderID=?parentFolderID AND avatarID=?avatarID", dbConnection); |
700 | 709 | ||
701 | command.Parameters.AddWithValue("?parentFolderID", folderID.ToString()); | 710 | // command.Parameters.AddWithValue("?parentFolderID", folderID.ToString()); |
702 | command.Parameters.AddWithValue("?avatarID", ownerID.ToString()); | 711 | // command.Parameters.AddWithValue("?avatarID", ownerID.ToString()); |
703 | 712 | ||
704 | int rowsAffected = command.ExecuteNonQuery(); | 713 | // int rowsAffected = command.ExecuteNonQuery(); |
705 | 714 | ||
706 | #endregion Delete items | 715 | // #endregion Delete items |
707 | 716 | ||
708 | #region Delete folders | 717 | // #region Delete folders |
709 | 718 | ||
710 | command = new MySqlCommand( | 719 | // command = new MySqlCommand( |
711 | "DELETE FROM inventoryfolders WHERE parentFolderID=?parentFolderID AND agentID=?agentID", dbConnection); | 720 | // "DELETE FROM inventoryfolders WHERE parentFolderID=?parentFolderID AND agentID=?agentID", dbConnection); |
712 | 721 | ||
713 | command.Parameters.AddWithValue("?parentFolderID", folderID.ToString()); | 722 | // command.Parameters.AddWithValue("?parentFolderID", folderID.ToString()); |
714 | command.Parameters.AddWithValue("?agentID", ownerID.ToString()); | 723 | // command.Parameters.AddWithValue("?agentID", ownerID.ToString()); |
715 | 724 | ||
716 | rowsAffected += command.ExecuteNonQuery(); | 725 | // rowsAffected += command.ExecuteNonQuery(); |
717 | 726 | ||
718 | #endregion Delete folders | 727 | // #endregion Delete folders |
719 | 728 | ||
720 | m_log.DebugFormat("Deleted {0} inventory objects from MySQL in a folder purge", rowsAffected); | 729 | // m_log.DebugFormat("Deleted {0} inventory objects from MySQL in a folder purge", rowsAffected); |
721 | 730 | ||
722 | ret = BackendResponse.Success; | 731 | // ret = BackendResponse.Success; |
723 | } | 732 | // } |
724 | catch (MySqlException ex) | 733 | // catch (MySqlException ex) |
725 | { | 734 | // { |
726 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 735 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
727 | ret = BackendResponse.Failure; | 736 | // ret = BackendResponse.Failure; |
728 | } | 737 | // } |
729 | } | 738 | // } |
730 | } | 739 | //} |
731 | else | 740 | //else |
732 | { | 741 | //{ |
733 | ret = BackendResponse.NotFound; | 742 | // ret = BackendResponse.NotFound; |
734 | } | 743 | //} |
735 | 744 | ||
736 | m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); | 745 | //m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); |
737 | return ret; | 746 | //return ret; |
747 | return BackendResponse.Success; | ||
738 | } | 748 | } |
739 | 749 | ||
740 | public int ForEach(Action<Metadata> action, int start, int count) | 750 | public int ForEach(Action<AssetMetadata> action, int start, int count) |
741 | { | 751 | { |
742 | int rowCount = 0; | 752 | int rowCount = 0; |
743 | 753 | ||
744 | using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) | 754 | //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) |
745 | { | 755 | //{ |
746 | MySqlDataReader reader; | 756 | // MySqlDataReader reader; |
747 | 757 | ||
748 | try | 758 | // try |
749 | { | 759 | // { |
750 | dbConnection.Open(); | 760 | // dbConnection.Open(); |
751 | 761 | ||
752 | MySqlCommand command = dbConnection.CreateCommand(); | 762 | // MySqlCommand command = dbConnection.CreateCommand(); |
753 | command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}", | 763 | // command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}", |
754 | start, count); | 764 | // start, count); |
755 | reader = command.ExecuteReader(); | 765 | // reader = command.ExecuteReader(); |
756 | } | 766 | // } |
757 | catch (MySqlException ex) | 767 | // catch (MySqlException ex) |
758 | { | 768 | // { |
759 | m_log.Error("Connection to MySQL backend failed: " + ex.Message); | 769 | // m_log.Error("Connection to MySQL backend failed: " + ex.Message); |
760 | return 0; | 770 | // return 0; |
761 | } | 771 | // } |
762 | 772 | ||
763 | while (reader.Read()) | 773 | // while (reader.Read()) |
764 | { | 774 | // { |
765 | Metadata metadata = new Metadata(); | 775 | // Metadata metadata = new Metadata(); |
766 | metadata.CreationDate = OpenMetaverse.Utils.Epoch; | 776 | // metadata.CreationDate = OpenMetaverse.Utils.Epoch; |
767 | metadata.Description = reader.GetString(1); | 777 | // metadata.Description = reader.GetString(1); |
768 | metadata.ID = UUID.Parse(reader.GetString(5)); | 778 | // metadata.ID = UUID.Parse(reader.GetString(5)); |
769 | metadata.Name = reader.GetString(0); | 779 | // metadata.Name = reader.GetString(0); |
770 | metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4)); | 780 | // metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4)); |
771 | metadata.Temporary = reader.GetBoolean(3); | 781 | // metadata.Temporary = reader.GetBoolean(3); |
772 | metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); | 782 | // metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2)); |
773 | 783 | ||
774 | action(metadata); | 784 | // action(metadata); |
775 | ++rowCount; | 785 | // ++rowCount; |
776 | } | 786 | // } |
777 | 787 | ||
778 | reader.Close(); | 788 | // reader.Close(); |
779 | } | 789 | //} |
780 | 790 | ||
781 | return rowCount; | 791 | return rowCount; |
782 | } | 792 | } |
@@ -787,7 +797,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim | |||
787 | 797 | ||
788 | public void Initialise(AssetInventoryServer server) | 798 | public void Initialise(AssetInventoryServer server) |
789 | { | 799 | { |
790 | m_server = server; | 800 | //m_server = server; |
791 | m_openSimConfig = server.ConfigFile.Configs["OpenSim"]; | 801 | m_openSimConfig = server.ConfigFile.Configs["OpenSim"]; |
792 | 802 | ||
793 | try | 803 | try |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs index 7ff5dfa..f19be08 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs | |||
@@ -55,13 +55,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
55 | m_server = server; | 55 | m_server = server; |
56 | 56 | ||
57 | // Asset metadata request | 57 | // Asset metadata request |
58 | m_server.HttpServer.AddStreamHandler(new MetadataRequestHandler(server)); | 58 | //m_server.HttpServer.AddStreamHandler(new MetadataRequestHandler(server)); |
59 | 59 | ||
60 | // Asset data request | 60 | // Asset data request |
61 | m_server.HttpServer.AddStreamHandler(new DataRequestHandler(server)); | 61 | m_server.HttpServer.AddStreamHandler(new DataRequestHandler(server)); |
62 | 62 | ||
63 | // Asset creation | 63 | // Asset creation |
64 | m_server.HttpServer.AddStreamHandler(new CreateRequestHandler(server)); | 64 | //m_server.HttpServer.AddStreamHandler(new CreateRequestHandler(server)); |
65 | 65 | ||
66 | m_log.Info("[ASSET] Reference Frontend loaded."); | 66 | m_log.Info("[ASSET] Reference Frontend loaded."); |
67 | } | 67 | } |
@@ -92,95 +92,95 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
92 | 92 | ||
93 | #endregion IPlugin implementation | 93 | #endregion IPlugin implementation |
94 | 94 | ||
95 | public class MetadataRequestHandler : IStreamedRequestHandler | 95 | //public class MetadataRequestHandler : IStreamedRequestHandler |
96 | { | 96 | //{ |
97 | AssetInventoryServer m_server; | 97 | // AssetInventoryServer m_server; |
98 | string m_contentType; | 98 | // string m_contentType; |
99 | string m_httpMethod; | 99 | // string m_httpMethod; |
100 | string m_path; | 100 | // string m_path; |
101 | 101 | ||
102 | public MetadataRequestHandler(AssetInventoryServer server) | 102 | // public MetadataRequestHandler(AssetInventoryServer server) |
103 | { | 103 | // { |
104 | m_server = server; | 104 | // m_server = server; |
105 | m_contentType = null; | 105 | // m_contentType = null; |
106 | m_httpMethod = "GET"; | 106 | // m_httpMethod = "GET"; |
107 | m_path = @"^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/metadata"; | 107 | // m_path = @"^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/metadata"; |
108 | } | 108 | // } |
109 | 109 | ||
110 | #region IStreamedRequestHandler implementation | 110 | // #region IStreamedRequestHandler implementation |
111 | 111 | ||
112 | public string ContentType | 112 | // public string ContentType |
113 | { | 113 | // { |
114 | get { return m_contentType; } | 114 | // get { return m_contentType; } |
115 | } | 115 | // } |
116 | 116 | ||
117 | public string HttpMethod | 117 | // public string HttpMethod |
118 | { | 118 | // { |
119 | get { return m_httpMethod; } | 119 | // get { return m_httpMethod; } |
120 | } | 120 | // } |
121 | 121 | ||
122 | public string Path | 122 | // public string Path |
123 | { | 123 | // { |
124 | get { return m_path; } | 124 | // get { return m_path; } |
125 | } | 125 | // } |
126 | 126 | ||
127 | public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 127 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
128 | { | 128 | // { |
129 | byte[] serializedData = null; | 129 | // byte[] serializedData = null; |
130 | UUID assetID; | 130 | // UUID assetID; |
131 | // Split the URL up into an AssetID and a method | 131 | // // Split the URL up into an AssetID and a method |
132 | string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); | 132 | // string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); |
133 | 133 | ||
134 | if (rawUrl.Length >= 3 && UUID.TryParse(rawUrl[1], out assetID)) | 134 | // if (rawUrl.Length >= 3 && UUID.TryParse(rawUrl[1], out assetID)) |
135 | { | 135 | // { |
136 | UUID authToken = Utils.GetAuthToken(httpRequest); | 136 | // UUID authToken = Utils.GetAuthToken(httpRequest); |
137 | 137 | ||
138 | if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, assetID)) | 138 | // if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, assetID)) |
139 | { | 139 | // { |
140 | Metadata metadata; | 140 | // AssetMetadata metadata; |
141 | BackendResponse storageResponse = m_server.StorageProvider.TryFetchMetadata(assetID, out metadata); | 141 | // BackendResponse storageResponse = m_server.StorageProvider.TryFetchMetadata(assetID, out metadata); |
142 | 142 | ||
143 | if (storageResponse == BackendResponse.Success) | 143 | // if (storageResponse == BackendResponse.Success) |
144 | { | 144 | // { |
145 | // If the asset data location wasn't specified in the metadata, specify it | 145 | // // If the asset data location wasn't specified in the metadata, specify it |
146 | // manually here by pointing back to this asset server | 146 | // // manually here by pointing back to this asset server |
147 | if (!metadata.Methods.ContainsKey("data")) | 147 | // if (!metadata.Methods.ContainsKey("data")) |
148 | { | 148 | // { |
149 | metadata.Methods["data"] = new Uri(String.Format("{0}://{1}/{2}/data", | 149 | // metadata.Methods["data"] = new Uri(String.Format("{0}://{1}/{2}/data", |
150 | httpRequest.Url.Scheme, httpRequest.Url.Authority, assetID)); | 150 | // httpRequest.Url.Scheme, httpRequest.Url.Authority, assetID)); |
151 | } | 151 | // } |
152 | 152 | ||
153 | serializedData = metadata.SerializeToBytes(); | 153 | // serializedData = metadata.SerializeToBytes(); |
154 | 154 | ||
155 | httpResponse.StatusCode = (int) HttpStatusCode.OK; | 155 | // httpResponse.StatusCode = (int) HttpStatusCode.OK; |
156 | httpResponse.ContentType = "application/json"; | 156 | // httpResponse.ContentType = "application/json"; |
157 | httpResponse.ContentLength = serializedData.Length; | 157 | // httpResponse.ContentLength = serializedData.Length; |
158 | httpResponse.Body.Write(serializedData, 0, serializedData.Length); | 158 | // httpResponse.Body.Write(serializedData, 0, serializedData.Length); |
159 | } | 159 | // } |
160 | else if (storageResponse == BackendResponse.NotFound) | 160 | // else if (storageResponse == BackendResponse.NotFound) |
161 | { | 161 | // { |
162 | m_log.Warn("Could not find metadata for asset " + assetID.ToString()); | 162 | // m_log.Warn("Could not find metadata for asset " + assetID.ToString()); |
163 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | 163 | // httpResponse.StatusCode = (int) HttpStatusCode.NotFound; |
164 | } | 164 | // } |
165 | else | 165 | // else |
166 | { | 166 | // { |
167 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | 167 | // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; |
168 | } | 168 | // } |
169 | } | 169 | // } |
170 | else | 170 | // else |
171 | { | 171 | // { |
172 | httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; | 172 | // httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; |
173 | } | 173 | // } |
174 | 174 | ||
175 | return serializedData; | 175 | // return serializedData; |
176 | } | 176 | // } |
177 | 177 | ||
178 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | 178 | // httpResponse.StatusCode = (int) HttpStatusCode.NotFound; |
179 | return serializedData; | 179 | // return serializedData; |
180 | } | 180 | // } |
181 | 181 | ||
182 | #endregion IStreamedRequestHandler implementation | 182 | // #endregion IStreamedRequestHandler implementation |
183 | } | 183 | //} |
184 | 184 | ||
185 | public class DataRequestHandler : IStreamedRequestHandler | 185 | public class DataRequestHandler : IStreamedRequestHandler |
186 | { | 186 | { |
@@ -261,110 +261,110 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
261 | #endregion IStreamedRequestHandler implementation | 261 | #endregion IStreamedRequestHandler implementation |
262 | } | 262 | } |
263 | 263 | ||
264 | public class CreateRequestHandler : IStreamedRequestHandler | 264 | //public class CreateRequestHandler : IStreamedRequestHandler |
265 | { | 265 | //{ |
266 | AssetInventoryServer m_server; | 266 | // AssetInventoryServer m_server; |
267 | string m_contentType; | 267 | // string m_contentType; |
268 | string m_httpMethod; | 268 | // string m_httpMethod; |
269 | string m_path; | 269 | // string m_path; |
270 | 270 | ||
271 | public CreateRequestHandler(AssetInventoryServer server) | 271 | // public CreateRequestHandler(AssetInventoryServer server) |
272 | { | 272 | // { |
273 | m_server = server; | 273 | // m_server = server; |
274 | m_contentType = null; | 274 | // m_contentType = null; |
275 | m_httpMethod = "POST"; | 275 | // m_httpMethod = "POST"; |
276 | m_path = "^/createasset"; | 276 | // m_path = "^/createasset"; |
277 | } | 277 | // } |
278 | 278 | ||
279 | #region IStreamedRequestHandler implementation | 279 | // #region IStreamedRequestHandler implementation |
280 | 280 | ||
281 | public string ContentType | 281 | // public string ContentType |
282 | { | 282 | // { |
283 | get { return m_contentType; } | 283 | // get { return m_contentType; } |
284 | } | 284 | // } |
285 | 285 | ||
286 | public string HttpMethod | 286 | // public string HttpMethod |
287 | { | 287 | // { |
288 | get { return m_httpMethod; } | 288 | // get { return m_httpMethod; } |
289 | } | 289 | // } |
290 | 290 | ||
291 | public string Path | 291 | // public string Path |
292 | { | 292 | // { |
293 | get { return m_path; } | 293 | // get { return m_path; } |
294 | } | 294 | // } |
295 | 295 | ||
296 | public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 296 | // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
297 | { | 297 | // { |
298 | byte[] responseData = null; | 298 | // byte[] responseData = null; |
299 | UUID authToken = Utils.GetAuthToken(httpRequest); | 299 | // UUID authToken = Utils.GetAuthToken(httpRequest); |
300 | 300 | ||
301 | if (m_server.AuthorizationProvider.IsCreateAuthorized(authToken)) | 301 | // if (m_server.AuthorizationProvider.IsCreateAuthorized(authToken)) |
302 | { | 302 | // { |
303 | try | 303 | // try |
304 | { | 304 | // { |
305 | OSD osdata = OSDParser.DeserializeJson(new StreamReader(httpRequest.InputStream).ReadToEnd()); | 305 | // OSD osdata = OSDParser.DeserializeJson(new StreamReader(httpRequest.InputStream).ReadToEnd()); |
306 | 306 | ||
307 | if (osdata.Type == OSDType.Map) | 307 | // if (osdata.Type == OSDType.Map) |
308 | { | 308 | // { |
309 | OSDMap map = (OSDMap)osdata; | 309 | // OSDMap map = (OSDMap)osdata; |
310 | Metadata metadata = new Metadata(); | 310 | // Metadata metadata = new Metadata(); |
311 | metadata.Deserialize(map); | 311 | // metadata.Deserialize(map); |
312 | 312 | ||
313 | byte[] assetData = map["data"].AsBinary(); | 313 | // byte[] assetData = map["data"].AsBinary(); |
314 | 314 | ||
315 | if (assetData != null && assetData.Length > 0) | 315 | // if (assetData != null && assetData.Length > 0) |
316 | { | 316 | // { |
317 | BackendResponse storageResponse; | 317 | // BackendResponse storageResponse; |
318 | 318 | ||
319 | if (metadata.ID != UUID.Zero) | 319 | // if (metadata.ID != UUID.Zero) |
320 | storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData); | 320 | // storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData); |
321 | else | 321 | // else |
322 | storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData, out metadata.ID); | 322 | // storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData, out metadata.ID); |
323 | 323 | ||
324 | if (storageResponse == BackendResponse.Success) | 324 | // if (storageResponse == BackendResponse.Success) |
325 | { | 325 | // { |
326 | httpResponse.StatusCode = (int) HttpStatusCode.Created; | 326 | // httpResponse.StatusCode = (int) HttpStatusCode.Created; |
327 | OSDMap responseMap = new OSDMap(1); | 327 | // OSDMap responseMap = new OSDMap(1); |
328 | responseMap["id"] = OSD.FromUUID(metadata.ID); | 328 | // responseMap["id"] = OSD.FromUUID(metadata.ID); |
329 | LitJson.JsonData jsonData = OSDParser.SerializeJson(responseMap); | 329 | // LitJson.JsonData jsonData = OSDParser.SerializeJson(responseMap); |
330 | responseData = System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson()); | 330 | // responseData = System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson()); |
331 | httpResponse.Body.Write(responseData, 0, responseData.Length); | 331 | // httpResponse.Body.Write(responseData, 0, responseData.Length); |
332 | httpResponse.Body.Flush(); | 332 | // httpResponse.Body.Flush(); |
333 | } | 333 | // } |
334 | else if (storageResponse == BackendResponse.NotFound) | 334 | // else if (storageResponse == BackendResponse.NotFound) |
335 | { | 335 | // { |
336 | httpResponse.StatusCode = (int) HttpStatusCode.NotFound; | 336 | // httpResponse.StatusCode = (int) HttpStatusCode.NotFound; |
337 | } | 337 | // } |
338 | else | 338 | // else |
339 | { | 339 | // { |
340 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | 340 | // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; |
341 | } | 341 | // } |
342 | } | 342 | // } |
343 | else | 343 | // else |
344 | { | 344 | // { |
345 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | 345 | // httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; |
346 | } | 346 | // } |
347 | } | 347 | // } |
348 | else | 348 | // else |
349 | { | 349 | // { |
350 | httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; | 350 | // httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; |
351 | } | 351 | // } |
352 | } | 352 | // } |
353 | catch (Exception ex) | 353 | // catch (Exception ex) |
354 | { | 354 | // { |
355 | httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; | 355 | // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError; |
356 | httpResponse.StatusDescription = ex.Message; | 356 | // httpResponse.StatusDescription = ex.Message; |
357 | } | 357 | // } |
358 | } | 358 | // } |
359 | else | 359 | // else |
360 | { | 360 | // { |
361 | httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; | 361 | // httpResponse.StatusCode = (int) HttpStatusCode.Forbidden; |
362 | } | 362 | // } |
363 | 363 | ||
364 | return responseData; | 364 | // return responseData; |
365 | } | 365 | // } |
366 | 366 | ||
367 | #endregion IStreamedRequestHandler implementation | 367 | // #endregion IStreamedRequestHandler implementation |
368 | } | 368 | //} |
369 | } | 369 | } |
370 | } | 370 | } |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs index cd0a454..384f5f0 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
45 | 45 | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | AssetInventoryServer server; | 47 | AssetInventoryServer server; |
48 | Dictionary<UUID, Metadata> metadataStorage; | 48 | Dictionary<UUID, AssetMetadata> metadataStorage; |
49 | Dictionary<UUID, string> filenames; | 49 | Dictionary<UUID, string> filenames; |
50 | 50 | ||
51 | public SimpleAssetStoragePlugin() | 51 | public SimpleAssetStoragePlugin() |
@@ -54,7 +54,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
54 | 54 | ||
55 | #region Required Interfaces | 55 | #region Required Interfaces |
56 | 56 | ||
57 | public BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata) | 57 | public BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata) |
58 | { | 58 | { |
59 | metadata = null; | 59 | metadata = null; |
60 | BackendResponse ret; | 60 | BackendResponse ret; |
@@ -98,8 +98,9 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
98 | 98 | ||
99 | public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset) | 99 | public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset) |
100 | { | 100 | { |
101 | Metadata metadata = null; | 101 | asset = new AssetBase(); |
102 | byte[] assetData = null; | 102 | AssetMetadata metadata = asset.Metadata; |
103 | |||
103 | string filename; | 104 | string filename; |
104 | BackendResponse ret; | 105 | BackendResponse ret; |
105 | 106 | ||
@@ -108,7 +109,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
108 | { | 109 | { |
109 | try | 110 | try |
110 | { | 111 | { |
111 | assetData = File.ReadAllBytes(filename); | 112 | asset.Data = File.ReadAllBytes(filename); |
112 | ret = BackendResponse.Success; | 113 | ret = BackendResponse.Success; |
113 | } | 114 | } |
114 | catch (Exception ex) | 115 | catch (Exception ex) |
@@ -116,80 +117,74 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
116 | m_log.ErrorFormat("Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message); | 117 | m_log.ErrorFormat("Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message); |
117 | ret = BackendResponse.Failure; | 118 | ret = BackendResponse.Failure; |
118 | } | 119 | } |
120 | |||
121 | asset.Metadata.Type = (sbyte) Utils.ContentTypeToSLAssetType(asset.Metadata.ContentType); | ||
122 | asset.Metadata.Local = false; | ||
119 | } | 123 | } |
120 | else | 124 | else |
121 | { | 125 | { |
126 | asset = null; | ||
122 | ret = BackendResponse.NotFound; | 127 | ret = BackendResponse.NotFound; |
123 | } | 128 | } |
124 | 129 | ||
125 | asset = new AssetBase(); | ||
126 | asset.Data = assetData; | ||
127 | asset.Metadata.FullID = metadata.ID; | ||
128 | asset.Metadata.Name = metadata.Name; | ||
129 | asset.Metadata.Description = metadata.Description; | ||
130 | asset.Metadata.CreationDate = metadata.CreationDate; | ||
131 | asset.Metadata.Type = (sbyte) Utils.ContentTypeToSLAssetType(metadata.ContentType); | ||
132 | asset.Metadata.Local = false; | ||
133 | asset.Metadata.Temporary = metadata.Temporary; | ||
134 | |||
135 | server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); | 130 | server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); |
136 | server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); | 131 | server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (asset != null && asset.Data != null ? asset.Data.Length : 0), DateTime.Now); |
137 | return ret; | 132 | return ret; |
138 | } | 133 | } |
139 | 134 | ||
140 | public BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData, out UUID assetID) | 135 | public BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID) |
141 | { | 136 | { |
142 | assetID = metadata.ID = UUID.Random(); | 137 | assetID = asset.FullID = UUID.Random(); |
143 | return TryCreateAsset(metadata, assetData); | 138 | return TryCreateAsset(asset); |
144 | } | 139 | } |
145 | 140 | ||
146 | public BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData) | 141 | public BackendResponse TryCreateAsset(AssetBase asset) |
147 | { | 142 | { |
148 | BackendResponse ret; | 143 | BackendResponse ret; |
149 | 144 | ||
150 | string path; | 145 | string path; |
151 | string filename = String.Format("{0}.{1}", metadata.ID, Utils.ContentTypeToExtension(metadata.ContentType)); | 146 | string filename = String.Format("{0}.{1}", asset.FullID, Utils.ContentTypeToExtension(asset.Metadata.ContentType)); |
152 | 147 | ||
153 | if (metadata.Temporary) | 148 | if (asset.Metadata.Temporary) |
154 | path = Path.Combine(TEMP_DATA_DIR, filename); | 149 | path = Path.Combine(TEMP_DATA_DIR, filename); |
155 | else | 150 | else |
156 | path = Path.Combine(DEFAULT_DATA_DIR, filename); | 151 | path = Path.Combine(DEFAULT_DATA_DIR, filename); |
157 | 152 | ||
158 | try | 153 | try |
159 | { | 154 | { |
160 | File.WriteAllBytes(path, assetData); | 155 | File.WriteAllBytes(path, asset.Data); |
161 | lock (filenames) filenames[metadata.ID] = path; | 156 | lock (filenames) filenames[asset.FullID] = path; |
162 | 157 | ||
163 | // Set the creation date to right now | 158 | // Set the creation date to right now |
164 | metadata.CreationDate = DateTime.Now; | 159 | asset.Metadata.CreationDate = DateTime.Now; |
165 | 160 | ||
166 | lock (metadataStorage) | 161 | lock (metadataStorage) |
167 | metadataStorage[metadata.ID] = metadata; | 162 | metadataStorage[asset.FullID] = asset.Metadata; |
168 | 163 | ||
169 | ret = BackendResponse.Success; | 164 | ret = BackendResponse.Success; |
170 | } | 165 | } |
171 | catch (Exception ex) | 166 | catch (Exception ex) |
172 | { | 167 | { |
173 | m_log.ErrorFormat("Failed writing data for asset {0} to {1}: {2}", metadata.ID, filename, ex.Message); | 168 | m_log.ErrorFormat("Failed writing data for asset {0} to {1}: {2}", asset.FullID, filename, ex.Message); |
174 | ret = BackendResponse.Failure; | 169 | ret = BackendResponse.Failure; |
175 | } | 170 | } |
176 | 171 | ||
177 | server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, metadata.ID, assetData.Length, DateTime.Now); | 172 | server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now); |
178 | return ret; | 173 | return ret; |
179 | } | 174 | } |
180 | 175 | ||
181 | public int ForEach(Action<Metadata> action, int start, int count) | 176 | public int ForEach(Action<AssetMetadata> action, int start, int count) |
182 | { | 177 | { |
183 | int rowCount = 0; | 178 | int rowCount = 0; |
184 | 179 | ||
185 | lock (metadataStorage) | 180 | //lock (metadataStorage) |
186 | { | 181 | //{ |
187 | foreach (Metadata metadata in metadataStorage.Values) | 182 | // foreach (Metadata metadata in metadataStorage.Values) |
188 | { | 183 | // { |
189 | action(metadata); | 184 | // action(metadata); |
190 | ++rowCount; | 185 | // ++rowCount; |
191 | } | 186 | // } |
192 | } | 187 | //} |
193 | 188 | ||
194 | return rowCount; | 189 | return rowCount; |
195 | } | 190 | } |
@@ -202,7 +197,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
202 | { | 197 | { |
203 | this.server = server; | 198 | this.server = server; |
204 | 199 | ||
205 | metadataStorage = new Dictionary<UUID, Metadata>(); | 200 | metadataStorage = new Dictionary<UUID, AssetMetadata>(); |
206 | filenames = new Dictionary<UUID, string>(); | 201 | filenames = new Dictionary<UUID, string>(); |
207 | 202 | ||
208 | LoadFiles(DEFAULT_DATA_DIR, false); | 203 | LoadFiles(DEFAULT_DATA_DIR, false); |
@@ -272,18 +267,18 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple | |||
272 | string filename = assets[i]; | 267 | string filename = assets[i]; |
273 | byte[] data = File.ReadAllBytes(filename); | 268 | byte[] data = File.ReadAllBytes(filename); |
274 | 269 | ||
275 | Metadata metadata = new Metadata(); | 270 | AssetMetadata metadata = new AssetMetadata(); |
276 | metadata.CreationDate = File.GetCreationTime(filename); | 271 | metadata.CreationDate = File.GetCreationTime(filename); |
277 | metadata.Description = String.Empty; | 272 | metadata.Description = String.Empty; |
278 | metadata.ID = SimpleUtils.ParseUUIDFromFilename(filename); | 273 | metadata.FullID = SimpleUtils.ParseUUIDFromFilename(filename); |
279 | metadata.Name = SimpleUtils.ParseNameFromFilename(filename); | 274 | metadata.Name = SimpleUtils.ParseNameFromFilename(filename); |
280 | metadata.SHA1 = OpenMetaverse.Utils.SHA1(data); | 275 | metadata.SHA1 = OpenMetaverse.Utils.SHA1(data); |
281 | metadata.Temporary = false; | 276 | metadata.Temporary = false; |
282 | metadata.ContentType = Utils.ExtensionToContentType(Path.GetExtension(filename).TrimStart('.')); | 277 | metadata.ContentType = Utils.ExtensionToContentType(Path.GetExtension(filename).TrimStart('.')); |
283 | 278 | ||
284 | // Store the loaded data | 279 | // Store the loaded data |
285 | metadataStorage[metadata.ID] = metadata; | 280 | metadataStorage[metadata.FullID] = metadata; |
286 | filenames[metadata.ID] = filename; | 281 | filenames[metadata.FullID] = filename; |
287 | } | 282 | } |
288 | } | 283 | } |
289 | catch (Exception ex) | 284 | catch (Exception ex) |
diff --git a/prebuild.xml b/prebuild.xml index a9af08e..30cb8c6 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -851,7 +851,6 @@ | |||
851 | <Reference name="OpenSim.Framework" /> | 851 | <Reference name="OpenSim.Framework" /> |
852 | <Reference name="OpenSim.Grid.AssetInventoryServer" /> | 852 | <Reference name="OpenSim.Grid.AssetInventoryServer" /> |
853 | <Reference name="OpenSim.Framework.Servers"/> | 853 | <Reference name="OpenSim.Framework.Servers"/> |
854 | <Reference name="MySql.Data"/> | ||
855 | <Reference name="log4net"/> | 854 | <Reference name="log4net"/> |
856 | <Reference name="Nini.dll" /> | 855 | <Reference name="Nini.dll" /> |
857 | 856 | ||