aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs (renamed from OpenSim/Grid/AssetServer/RestService.cs)251
-rw-r--r--OpenSim/Framework/Servers/PostAssetStreamHandler.cs45
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs1
-rw-r--r--prebuild.xml5
4 files changed, 141 insertions, 161 deletions
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
index 1e01c44..d278a05 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
@@ -1,156 +1,95 @@
1/* 1using System;
2 * Copyright (c) Contributors, http://opensimulator.org/ 2using System.IO;
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3using System.Reflection;
4 * 4using System.Text;
5 * Redistribution and use in source and binary forms, with or without 5using System.Xml;
6 * modification, are permitted provided that the following conditions are met: 6using System.Xml.Serialization;
7 * * Redistributions of source code must retain the above copyright 7using log4net;
8 * notice, this list of conditions and the following disclaimer. 8using OpenMetaverse;
9 * * Redistributions in binary form must reproduce the above copyright 9using OpenSim.Data;
10 * notice, this list of conditions and the following disclaimer in the 10using OpenSim.Framework;
11 * documentation and/or other materials provided with the distribution. 11using OpenSim.Framework.Servers;
12 * * Neither the name of the OpenSim Project nor the 12using OpenSim.Framework.Statistics;
13 * names of its contributors may be used to endorse or promote products 13
14 * derived from this software without specific prior written permission. 14namespace OpenSim.Framework.Servers
15 * 15{
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 public class GetAssetStreamHandler : BaseStreamHandler
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 {
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 // private OpenAsset_Main m_assetManager;
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 private IAssetDataPlugin m_assetProvider;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 /// <summary>
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 /// Constructor.
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 /// </summary>
26 */ 26 /// <param name="assetManager"></param>
27 27 /// <param name="assetProvider"></param>
28using System; 28 public GetAssetStreamHandler(IAssetDataPlugin assetProvider)
29using System.IO; 29 : base("GET", "/assets")
30using System.Reflection; 30 {
31using System.Text; 31 m_log.Info("[REST]: In Get Request");
32using System.Xml; 32 // m_assetManager = assetManager;
33using System.Xml.Serialization; 33 m_assetProvider = assetProvider;
34using log4net; 34 }
35using OpenMetaverse; 35
36using OpenSim.Data; 36 public override byte[] Handle(string path, Stream request,
37using OpenSim.Framework; 37 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
38using OpenSim.Framework.Servers; 38 {
39using OpenSim.Framework.Statistics; 39 string param = GetParam(path);
40 40 byte[] result = new byte[] {};
41namespace OpenSim.Grid.AssetServer 41
42{ 42 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
43 public class GetAssetStreamHandler : BaseStreamHandler 43
44 { 44 if (p.Length > 0)
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 {
46 46 UUID assetID = UUID.Zero;
47 // private OpenAsset_Main m_assetManager; 47
48 private IAssetDataPlugin m_assetProvider; 48 if (!UUID.TryParse(p[0], out assetID))
49 49 {
50 /// <summary> 50 m_log.InfoFormat(
51 /// Constructor. 51 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
52 /// </summary> 52 return result;
53 /// <param name="assetManager"></param> 53 }
54 /// <param name="assetProvider"></param> 54
55 public GetAssetStreamHandler(IAssetDataPlugin assetProvider) 55 if (StatsManager.AssetStats != null)
56 : base("GET", "/assets") 56 StatsManager.AssetStats.AddRequest();
57 { 57
58 m_log.Info("[REST]: In Get Request"); 58 AssetBase asset = m_assetProvider.FetchAsset(assetID);
59 // m_assetManager = assetManager; 59 if (asset != null)
60 m_assetProvider = assetProvider; 60 {
61 } 61 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
62 62 MemoryStream ms = new MemoryStream();
63 public override byte[] Handle(string path, Stream request, 63 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
64 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 64 xw.Formatting = Formatting.Indented;
65 { 65 xs.Serialize(xw, asset);
66 string param = GetParam(path); 66 xw.Flush();
67 byte[] result = new byte[] {}; 67
68 68 ms.Seek(0, SeekOrigin.Begin);
69 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 69 //StreamReader sr = new StreamReader(ms);
70 70
71 if (p.Length > 0) 71 result = ms.GetBuffer();
72 { 72
73 UUID assetID = UUID.Zero; 73//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there
74 74//are multiple messages in a second and that is usually (in my experience) meaning
75 if (!UUID.TryParse(p[0], out assetID)) 75//the logging itself is slowing down the program. Leaving the unsuccesful message
76 { 76//as we need to know about that path.
77 m_log.InfoFormat( 77// m_log.InfoFormat(
78 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); 78// "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
79 return result; 79// assetID, asset.Name, result.Length);
80 } 80
81 81 Array.Resize<byte>(ref result, (int) ms.Length);
82 if (StatsManager.AssetStats != null) 82 }
83 StatsManager.AssetStats.AddRequest(); 83 else
84 84 {
85 AssetBase asset = m_assetProvider.FetchAsset(assetID); 85 if (StatsManager.AssetStats != null)
86 if (asset != null) 86 StatsManager.AssetStats.AddNotFoundRequest();
87 { 87
88 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 88 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
89 MemoryStream ms = new MemoryStream(); 89 }
90 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 90 }
91 xw.Formatting = Formatting.Indented; 91
92 xs.Serialize(xw, asset); 92 return result;
93 xw.Flush(); 93 }
94 94 }
95 ms.Seek(0, SeekOrigin.Begin); 95} \ No newline at end of file
96 //StreamReader sr = new StreamReader(ms);
97
98 result = ms.GetBuffer();
99
100//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there
101//are multiple messages in a second and that is usually (in my experience) meaning
102//the logging itself is slowing down the program. Leaving the unsuccesful message
103//as we need to know about that path.
104// m_log.InfoFormat(
105// "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
106// assetID, asset.Name, result.Length);
107
108 Array.Resize<byte>(ref result, (int) ms.Length);
109 }
110 else
111 {
112 if (StatsManager.AssetStats != null)
113 StatsManager.AssetStats.AddNotFoundRequest();
114
115 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
116 }
117 }
118
119 return result;
120 }
121 }
122
123 public class PostAssetStreamHandler : BaseStreamHandler
124 {
125 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
126
127 // private OpenAsset_Main m_assetManager;
128 private IAssetDataPlugin m_assetProvider;
129
130 public override byte[] Handle(string path, Stream request,
131 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
132 {
133 string param = GetParam(path);
134
135 UUID assetId;
136 if (param.Length > 0)
137 UUID.TryParse(param, out assetId);
138 // byte[] txBuffer = new byte[4096];
139
140 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
141 AssetBase asset = (AssetBase) xs.Deserialize(request);
142
143 m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID);
144 m_assetProvider.CreateAsset(asset);
145
146 return new byte[] {};
147 }
148
149 public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
150 : base("POST", "/assets")
151 {
152 // m_assetManager = assetManager;
153 m_assetProvider = assetProvider;
154 }
155 }
156}
diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
new file mode 100644
index 0000000..6e96361
--- /dev/null
+++ b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
@@ -0,0 +1,45 @@
1using System.IO;
2using System.Reflection;
3using System.Xml.Serialization;
4using log4net;
5using OpenMetaverse;
6using OpenSim.Data;
7using OpenSim.Framework;
8using OpenSim.Framework.Servers;
9
10namespace OpenSim.Framework.Servers
11{
12 public class PostAssetStreamHandler : BaseStreamHandler
13 {
14 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
15
16 // private OpenAsset_Main m_assetManager;
17 private IAssetDataPlugin m_assetProvider;
18
19 public override byte[] Handle(string path, Stream request,
20 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
21 {
22 string param = GetParam(path);
23
24 UUID assetId;
25 if (param.Length > 0)
26 UUID.TryParse(param, out assetId);
27 // byte[] txBuffer = new byte[4096];
28
29 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
30 AssetBase asset = (AssetBase) xs.Deserialize(request);
31
32 m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID);
33 m_assetProvider.CreateAsset(asset);
34
35 return new byte[] {};
36 }
37
38 public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
39 : base("POST", "/assets")
40 {
41 // m_assetManager = assetManager;
42 m_assetProvider = assetProvider;
43 }
44 }
45} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
index 7caa786..f8c7c79 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
@@ -35,7 +35,6 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Grid.AssetServer;
39using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
41 40
diff --git a/prebuild.xml b/prebuild.xml
index 2dd241d..13d4c33 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -300,6 +300,7 @@
300 <ReferencePath>../../../bin/</ReferencePath> 300 <ReferencePath>../../../bin/</ReferencePath>
301 <Reference name="System"/> 301 <Reference name="System"/>
302 <Reference name="System.Xml"/> 302 <Reference name="System.Xml"/>
303 <Reference name="OpenSim.Data"/>
303 <Reference name="OpenSim.Framework"/> 304 <Reference name="OpenSim.Framework"/>
304 <Reference name="OpenSim.Framework.Console"/> 305 <Reference name="OpenSim.Framework.Console"/>
305 <Reference name="OpenSim.Framework.Statistics"/> 306 <Reference name="OpenSim.Framework.Statistics"/>
@@ -572,7 +573,6 @@
572 <Reference name="OpenSim.Framework.Servers"/> 573 <Reference name="OpenSim.Framework.Servers"/>
573 <Reference name="OpenSim.Framework.Statistics"/> 574 <Reference name="OpenSim.Framework.Statistics"/>
574 <Reference name="OpenSim.Region.Physics.Manager"/> 575 <Reference name="OpenSim.Region.Physics.Manager"/>
575 <Reference name="OpenSim.Grid.AssetServer"/>
576 576
577 <!-- For scripting in funny languages by default --> 577 <!-- For scripting in funny languages by default -->
578 <Reference name="Microsoft.JScript"/> 578 <Reference name="Microsoft.JScript"/>
@@ -986,7 +986,6 @@
986 <Reference name="OpenSim.Framework.Servers"/> 986 <Reference name="OpenSim.Framework.Servers"/>
987 <Reference name="OpenSim.Framework.Statistics"/> 987 <Reference name="OpenSim.Framework.Statistics"/>
988 <Reference name="OpenSim.Region.Physics.Manager"/> 988 <Reference name="OpenSim.Region.Physics.Manager"/>
989 <Reference name="OpenSim.Grid.AssetServer"/>
990 989
991 <!-- For scripting in funny languages by default --> 990 <!-- For scripting in funny languages by default -->
992 <Reference name="Microsoft.JScript"/> 991 <Reference name="Microsoft.JScript"/>
@@ -1060,7 +1059,6 @@
1060 <Reference name="OpenSim.Framework.Servers"/> 1059 <Reference name="OpenSim.Framework.Servers"/>
1061 <Reference name="OpenSim.Framework.Statistics"/> 1060 <Reference name="OpenSim.Framework.Statistics"/>
1062 <Reference name="OpenSim.Region.Physics.Manager"/> 1061 <Reference name="OpenSim.Region.Physics.Manager"/>
1063 <Reference name="OpenSim.Grid.AssetServer"/>
1064 1062
1065 <!-- For scripting in funny languages by default --> 1063 <!-- For scripting in funny languages by default -->
1066 <Reference name="Microsoft.JScript"/> 1064 <Reference name="Microsoft.JScript"/>
@@ -2338,7 +2336,6 @@
2338 <Reference name="OpenSim.Framework.Servers"/> 2336 <Reference name="OpenSim.Framework.Servers"/>
2339 <Reference name="OpenSim.Framework.Statistics"/> 2337 <Reference name="OpenSim.Framework.Statistics"/>
2340 <Reference name="OpenSim.Region.Physics.Manager"/> 2338 <Reference name="OpenSim.Region.Physics.Manager"/>
2341 <Reference name="OpenSim.Grid.AssetServer"/>
2342 <Reference name="Mono.Data.SqliteClient"/> 2339 <Reference name="Mono.Data.SqliteClient"/>
2343 2340
2344 <!-- For scripting in funny languages by default --> 2341 <!-- For scripting in funny languages by default -->