aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer
diff options
context:
space:
mode:
authorJeff Ames2007-10-29 07:57:38 +0000
committerJeff Ames2007-10-29 07:57:38 +0000
commit7c6ef95f2f8a4fb06a1359e9625e80e4cb216a5d (patch)
treeae94989730f354f17619da74ca23eb2f1994f6b1 /OpenSim/Grid/AssetServer
parentshould help with ODE bounce on region cross (diff)
downloadopensim-SC_OLD-7c6ef95f2f8a4fb06a1359e9625e80e4cb216a5d.zip
opensim-SC_OLD-7c6ef95f2f8a4fb06a1359e9625e80e4cb216a5d.tar.gz
opensim-SC_OLD-7c6ef95f2f8a4fb06a1359e9625e80e4cb216a5d.tar.bz2
opensim-SC_OLD-7c6ef95f2f8a4fb06a1359e9625e80e4cb216a5d.tar.xz
normalized line endings
Diffstat (limited to 'OpenSim/Grid/AssetServer')
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs218
1 files changed, 109 insertions, 109 deletions
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs
index 88a1668..e4f770d 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -1,109 +1,109 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Xml; 3using System.Xml;
4using System.Xml.Serialization; 4using System.Xml.Serialization;
5using System.Text; 5using System.Text;
6 6
7using libsecondlife; 7using libsecondlife;
8using OpenSim.Framework.Types; 8using OpenSim.Framework.Types;
9using OpenSim.Framework.Servers; 9using OpenSim.Framework.Servers;
10using OpenSim.Framework.Interfaces; 10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Console; 11using OpenSim.Framework.Console;
12 12
13namespace OpenSim.Grid.AssetServer 13namespace OpenSim.Grid.AssetServer
14{ 14{
15 public class GetAssetStreamHandler : BaseStreamHandler 15 public class GetAssetStreamHandler : BaseStreamHandler
16 { 16 {
17 OpenAsset_Main m_assetManager; 17 OpenAsset_Main m_assetManager;
18 IAssetProvider m_assetProvider; 18 IAssetProvider m_assetProvider;
19 19
20 override public byte[] Handle(string path, Stream request) 20 override public byte[] Handle(string path, Stream request)
21 { 21 {
22 string param = GetParam(path); 22 string param = GetParam(path);
23 byte[] result = new byte[] { }; 23 byte[] result = new byte[] { };
24 try { 24 try {
25 25
26 string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries); 26 string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries);
27 27
28 if (p.Length > 0) 28 if (p.Length > 0)
29 { 29 {
30 LLUUID assetID; 30 LLUUID assetID;
31 bool isTexture = false; 31 bool isTexture = false;
32 LLUUID.TryParse(p[0], out assetID); 32 LLUUID.TryParse(p[0], out assetID);
33 if (p.Length > 1) 33 if (p.Length > 1)
34 { 34 {
35 if (string.Compare(p[1], "texture", true) == 0) 35 if (string.Compare(p[1], "texture", true) == 0)
36 isTexture = true; 36 isTexture = true;
37 } 37 }
38 38
39 39
40 AssetBase asset = m_assetProvider.FetchAsset(assetID); 40 AssetBase asset = m_assetProvider.FetchAsset(assetID);
41 if (asset != null) 41 if (asset != null)
42 { 42 {
43 MainLog.Instance.Debug("REST", "GET:/asset found {0}, {1}", assetID, asset.Name); 43 MainLog.Instance.Debug("REST", "GET:/asset found {0}, {1}", assetID, asset.Name);
44 44
45 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 45 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
46 MemoryStream ms = new MemoryStream(); 46 MemoryStream ms = new MemoryStream();
47 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 47 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
48 xw.Formatting = Formatting.Indented; 48 xw.Formatting = Formatting.Indented;
49 xs.Serialize(xw, asset); 49 xs.Serialize(xw, asset);
50 xw.Flush(); 50 xw.Flush();
51 51
52 ms.Seek(0, SeekOrigin.Begin); 52 ms.Seek(0, SeekOrigin.Begin);
53 StreamReader sr = new StreamReader(ms); 53 StreamReader sr = new StreamReader(ms);
54 54
55 result = ms.GetBuffer(); 55 result = ms.GetBuffer();
56 Array.Resize<byte>(ref result, (int)ms.Length); 56 Array.Resize<byte>(ref result, (int)ms.Length);
57 } 57 }
58 else 58 else
59 { 59 {
60 MainLog.Instance.Verbose("REST", "GET:/asset failed to find {0}", assetID); 60 MainLog.Instance.Verbose("REST", "GET:/asset failed to find {0}", assetID);
61 } 61 }
62 } 62 }
63 } 63 }
64 catch (Exception e) 64 catch (Exception e)
65 { 65 {
66 MainLog.Instance.Error(e.ToString()); 66 MainLog.Instance.Error(e.ToString());
67 } 67 }
68 return result; 68 return result;
69 } 69 }
70 70
71 public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) 71 public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
72 : base("GET", "/assets" ) 72 : base("GET", "/assets" )
73 { 73 {
74 m_assetManager = assetManager; 74 m_assetManager = assetManager;
75 m_assetProvider = assetProvider; 75 m_assetProvider = assetProvider;
76 } 76 }
77 } 77 }
78 78
79 public class PostAssetStreamHandler : BaseStreamHandler 79 public class PostAssetStreamHandler : BaseStreamHandler
80 { 80 {
81 OpenAsset_Main m_assetManager; 81 OpenAsset_Main m_assetManager;
82 IAssetProvider m_assetProvider; 82 IAssetProvider m_assetProvider;
83 83
84 override public byte[] Handle(string path, Stream request) 84 override public byte[] Handle(string path, Stream request)
85 { 85 {
86 string param = GetParam(path); 86 string param = GetParam(path);
87 87
88 LLUUID assetId; 88 LLUUID assetId;
89 if(param.Length > 0) 89 if(param.Length > 0)
90 LLUUID.TryParse(param, out assetId); 90 LLUUID.TryParse(param, out assetId);
91 byte[] txBuffer = new byte[4096]; 91 byte[] txBuffer = new byte[4096];
92 92
93 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 93 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
94 AssetBase asset = (AssetBase)xs.Deserialize(request); 94 AssetBase asset = (AssetBase)xs.Deserialize(request);
95 95
96 MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID); 96 MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID);
97 m_assetProvider.CreateAsset(asset); 97 m_assetProvider.CreateAsset(asset);
98 98
99 return new byte[] { }; 99 return new byte[] { };
100 } 100 }
101 101
102 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) 102 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
103 : base("POST", "/assets") 103 : base("POST", "/assets")
104 { 104 {
105 m_assetManager = assetManager; 105 m_assetManager = assetManager;
106 m_assetProvider = assetProvider; 106 m_assetProvider = assetProvider;
107 } 107 }
108 } 108 }
109} 109}