aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMike Mazur2009-02-16 02:27:25 +0000
committerMike Mazur2009-02-16 02:27:25 +0000
commitf8ea2740909cbe33c7729be0333260f0567e7867 (patch)
tree19559d7130b5200c8bcc7f0639f2dadaac77d47a /OpenSim
parentAssetInventoryServer now compiles while using the standard OpenSim (diff)
downloadopensim-SC_OLD-f8ea2740909cbe33c7729be0333260f0567e7867.zip
opensim-SC_OLD-f8ea2740909cbe33c7729be0333260f0567e7867.tar.gz
opensim-SC_OLD-f8ea2740909cbe33c7729be0333260f0567e7867.tar.bz2
opensim-SC_OLD-f8ea2740909cbe33c7729be0333260f0567e7867.tar.xz
- asset server functionality works with OpenSim's HttpServer
- start of removal of AssetInventoryServer.Metadata class
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Interfaces.cs2
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs97
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs23
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs16
4 files changed, 34 insertions, 104 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs
index 19298c5..d934b14 100644
--- a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Grid.AssetInventoryServer
77 { 77 {
78 BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata); 78 BackendResponse TryFetchMetadata(UUID assetID, out Metadata metadata);
79 BackendResponse TryFetchData(UUID assetID, out byte[] assetData); 79 BackendResponse TryFetchData(UUID assetID, out byte[] assetData);
80 BackendResponse TryFetchDataMetadata(UUID assetID, out Metadata metadata, out byte[] assetData); 80 BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset);
81 BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData); 81 BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData);
82 BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData, out UUID assetID); 82 BackendResponse TryCreateAsset(Metadata metadata, byte[] assetData, out UUID assetID);
83 int ForEach(Action<Metadata> action, int start, int count); 83 int ForEach(Action<Metadata> action, int start, int count);
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs
index 3431ff3..b8f48cb 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
43{ 43{
44 public class OpenSimAssetFrontendPlugin : IAssetInventoryServerPlugin 44 public class OpenSimAssetFrontendPlugin : IAssetInventoryServerPlugin
45 { 45 {
46 private AssetInventoryServer server; 46 private AssetInventoryServer m_server;
47 47
48 public OpenSimAssetFrontendPlugin() 48 public OpenSimAssetFrontendPlugin()
49 { 49 {
@@ -53,13 +53,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
53 53
54 public void Initialise(AssetInventoryServer server) 54 public void Initialise(AssetInventoryServer server)
55 { 55 {
56 this.server = server; 56 m_server = server;
57 57
58 // Asset request 58 // Asset request
59 server.HttpServer.AddStreamHandler(new AssetRequestHandler(server)); 59 m_server.HttpServer.AddStreamHandler(new AssetRequestHandler(server));
60 60
61 // Asset creation 61 // Asset creation
62 server.HttpServer.AddStreamHandler(new AssetPostHandler(server)); 62 m_server.HttpServer.AddStreamHandler(new AssetPostHandler(server));
63 63
64 Logger.Log.Info("[ASSET] OpenSim Asset Frontend loaded."); 64 Logger.Log.Info("[ASSET] OpenSim Asset Frontend loaded.");
65 } 65 }
@@ -90,63 +90,31 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
90 90
91 #endregion IPlugin implementation 91 #endregion IPlugin implementation
92 92
93 public class AssetRequestHandler : IStreamedRequestHandler 93 public class AssetRequestHandler : BaseStreamHandler
94 { 94 {
95 AssetInventoryServer m_server; 95 AssetInventoryServer m_server;
96 string m_contentType;
97 string m_httpMethod;
98 string m_path;
99 96
100 public AssetRequestHandler(AssetInventoryServer server) 97 //public AssetRequestHandler(AssetInventoryServer server) : base("GET", "^/assets")
98 public AssetRequestHandler(AssetInventoryServer server) : base("GET", "/assets")
101 { 99 {
100 Logger.Log.Info("[REST]: In Get Request");
102 m_server = server; 101 m_server = server;
103 m_contentType = null;
104 m_httpMethod = "GET";
105 m_path = @"^/assets/";
106 } 102 }
107 103
108 #region IStreamedRequestHandler implementation 104 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
109
110 public string ContentType
111 {
112 get { return m_contentType; }
113 }
114
115 public string HttpMethod
116 {
117 get { return m_httpMethod; }
118 }
119
120 public string Path
121 {
122 get { return m_path; }
123 }
124
125 public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
126 { 105 {
127 byte[] buffer = null; 106 byte[] buffer = new byte[] {};
128 UUID assetID; 107 UUID assetID;
129 // Split the URL up to get the asset ID out 108 // Split the URL up to get the asset ID out
130 string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/'); 109 string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/');
131 110
132 if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 && UUID.TryParse(rawUrl[2].Substring(0, 36), out assetID)) 111 if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 && UUID.TryParse(rawUrl[2].Substring(0, 36), out assetID))
133 { 112 {
134 Metadata metadata;
135 byte[] assetData;
136 BackendResponse dataResponse; 113 BackendResponse dataResponse;
137 114
138 if ((dataResponse = m_server.StorageProvider.TryFetchDataMetadata(assetID, out metadata, out assetData)) == BackendResponse.Success) 115 AssetBase asset = new AssetBase();
116 if ((dataResponse = m_server.StorageProvider.TryFetchDataMetadata(assetID, out asset)) == BackendResponse.Success)
139 { 117 {
140 AssetBase asset = new AssetBase();
141 asset.Data = assetData;
142 asset.Metadata.FullID = metadata.ID;
143 asset.Metadata.Name = metadata.Name;
144 asset.Metadata.Description = metadata.Description;
145 asset.Metadata.CreationDate = metadata.CreationDate;
146 asset.Metadata.Type = (sbyte) Utils.ContentTypeToSLAssetType(metadata.ContentType);
147 asset.Metadata.Local = false;
148 asset.Metadata.Temporary = metadata.Temporary;
149
150 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 118 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
151 MemoryStream ms = new MemoryStream(); 119 MemoryStream ms = new MemoryStream();
152 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 120 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
@@ -155,12 +123,8 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
155 123
156 ms.Seek(0, SeekOrigin.Begin); 124 ms.Seek(0, SeekOrigin.Begin);
157 buffer = ms.GetBuffer(); 125 buffer = ms.GetBuffer();
158 126 Array.Resize<byte>(ref buffer, (int) ms.Length);
159 httpResponse.StatusCode = (int) HttpStatusCode.OK; 127 httpResponse.StatusCode = (int) HttpStatusCode.OK;
160 httpResponse.ContentType = "application/xml";
161 httpResponse.ContentLength = ms.Length;
162 httpResponse.Body.Write(buffer, 0, (int) ms.Length);
163 httpResponse.Body.Flush();
164 } 128 }
165 else 129 else
166 { 130 {
@@ -175,44 +139,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
175 139
176 return buffer; 140 return buffer;
177 } 141 }
178
179 #endregion IStreamedRequestHandler implementation
180 } 142 }
181 143
182 public class AssetPostHandler : IStreamedRequestHandler 144 public class AssetPostHandler : BaseStreamHandler
183 { 145 {
184 AssetInventoryServer m_server; 146 AssetInventoryServer m_server;
185 string m_contentType;
186 string m_httpMethod;
187 string m_path;
188 147
189 public AssetPostHandler(AssetInventoryServer server) 148 //public AssetPostHandler(AssetInventoryServer server) : base("POST", "/^assets")
149 public AssetPostHandler(AssetInventoryServer server) : base("POST", "/assets")
190 { 150 {
191 m_server = server; 151 m_server = server;
192 m_contentType = null;
193 m_httpMethod = "POST";
194 m_path = @"^/assets/";
195 }
196
197 #region IStreamedRequestHandler implementation
198
199 public string ContentType
200 {
201 get { return m_contentType; }
202 }
203
204 public string HttpMethod
205 {
206 get { return m_httpMethod; }
207 }
208
209 public string Path
210 {
211 get { return m_path; }
212 } 152 }
213 153
214 public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) 154 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
215 //bool AssetPostHandler(IHttpClientContext client, IHttpRequest request, IHttpResponse response)
216 { 155 {
217 Metadata metadata = new Metadata(); 156 Metadata metadata = new Metadata();
218 157
@@ -254,8 +193,6 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
254 193
255 return null; 194 return null;
256 } 195 }
257
258 #endregion IStreamedRequestHandler implementation
259 } 196 }
260 } 197 }
261} 198}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
index b5bc70e..e35092b 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
@@ -137,28 +137,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
137 return ret; 137 return ret;
138 } 138 }
139 139
140 public BackendResponse TryFetchDataMetadata(UUID assetID, out Metadata metadata, out byte[] assetData) 140 public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset)
141 { 141 {
142 metadata = null; 142 asset = m_assetProvider.FetchAsset(assetID);
143 assetData = null;
144 //BackendResponse ret;
145
146 AssetBase asset = m_assetProvider.FetchAsset(assetID);
147 143
148 if (asset != null) 144 if (asset == null) return BackendResponse.NotFound;
149 {
150 metadata = new Metadata();
151 metadata.ID = asset.Metadata.FullID;
152 metadata.CreationDate = OpenMetaverse.Utils.Epoch;
153 metadata.SHA1 = null;
154 metadata.Name = asset.Metadata.Name;
155 metadata.Description = asset.Metadata.Description;
156 metadata.ContentType = Utils.SLAssetTypeToContentType(asset.Metadata.Type);
157 metadata.Temporary = asset.Metadata.Temporary;
158
159 assetData = asset.Data;
160 }
161 else return BackendResponse.NotFound;
162 145
163 return BackendResponse.Success; 146 return BackendResponse.Success;
164 } 147 }
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs
index 301a55f..5a718f2 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs
@@ -95,10 +95,10 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
95 return ret; 95 return ret;
96 } 96 }
97 97
98 public BackendResponse TryFetchDataMetadata(UUID assetID, out Metadata metadata, out byte[] assetData) 98 public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset)
99 { 99 {
100 metadata = null; 100 Metadata metadata = null;
101 assetData = null; 101 byte[] assetData = null;
102 string filename; 102 string filename;
103 BackendResponse ret; 103 BackendResponse ret;
104 104
@@ -121,6 +121,16 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
121 ret = BackendResponse.NotFound; 121 ret = BackendResponse.NotFound;
122 } 122 }
123 123
124 asset = new AssetBase();
125 asset.Data = assetData;
126 asset.Metadata.FullID = metadata.ID;
127 asset.Metadata.Name = metadata.Name;
128 asset.Metadata.Description = metadata.Description;
129 asset.Metadata.CreationDate = metadata.CreationDate;
130 asset.Metadata.Type = (sbyte) Utils.ContentTypeToSLAssetType(metadata.ContentType);
131 asset.Metadata.Local = false;
132 asset.Metadata.Temporary = metadata.Temporary;
133
124 server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); 134 server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now);
125 server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); 135 server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now);
126 return ret; 136 return ret;