aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer/RestService.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 18:04:42 +0000
committerAdam Frisby2008-05-01 18:04:42 +0000
commit20a9bf08f51351e1e0a9de94f184ff56cd572665 (patch)
tree52da64dab26353b903c8e4befed0178fa72a188b /OpenSim/Grid/AssetServer/RestService.cs
parentMore config cleanup in LaunchSLClient. (diff)
downloadopensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.zip
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.gz
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.bz2
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.xz
* Rolled back a few changes.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs42
1 files changed, 21 insertions, 21 deletions
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs
index 93f86b8..ece826e 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -43,8 +43,8 @@ namespace OpenSim.Grid.AssetServer
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private readonly IAssetProvider m_assetProvider;
47 private OpenAsset_Main m_assetManager; 46 private OpenAsset_Main m_assetManager;
47 private IAssetProvider m_assetProvider;
48 48
49 /// <summary> 49 /// <summary>
50 /// Constructor. 50 /// Constructor.
@@ -58,28 +58,28 @@ namespace OpenSim.Grid.AssetServer
58 m_assetManager = assetManager; 58 m_assetManager = assetManager;
59 m_assetProvider = assetProvider; 59 m_assetProvider = assetProvider;
60 } 60 }
61 61
62 public override byte[] Handle(string path, Stream request) 62 public override byte[] Handle(string path, Stream request)
63 { 63 {
64 string param = GetParam(path); 64 string param = GetParam(path);
65 byte[] result = new byte[] {}; 65 byte[] result = new byte[] {};
66 66
67 string[] p = param.Split(new[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 67 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
68 68
69 if (p.Length > 0) 69 if (p.Length > 0)
70 { 70 {
71 LLUUID assetID = null; 71 LLUUID assetID = null;
72 72
73 if (!LLUUID.TryParse(p[0], out assetID)) 73 if (!LLUUID.TryParse(p[0], out assetID))
74 { 74 {
75 m_log.InfoFormat( 75 m_log.InfoFormat(
76 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); 76 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
77 return result; 77 return result;
78 } 78 }
79 79
80 if (StatsManager.AssetStats != null) 80 if (StatsManager.AssetStats != null)
81 StatsManager.AssetStats.AddRequest(); 81 StatsManager.AssetStats.AddRequest();
82 82
83 AssetBase asset = m_assetProvider.FetchAsset(assetID); 83 AssetBase asset = m_assetProvider.FetchAsset(assetID);
84 if (asset != null) 84 if (asset != null)
85 { 85 {
@@ -94,39 +94,32 @@ namespace OpenSim.Grid.AssetServer
94 //StreamReader sr = new StreamReader(ms); 94 //StreamReader sr = new StreamReader(ms);
95 95
96 result = ms.GetBuffer(); 96 result = ms.GetBuffer();
97 97
98 m_log.InfoFormat( 98 m_log.InfoFormat(
99 "[REST]: GET:/asset found {0} with name {1}, size {2} bytes", 99 "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
100 assetID, asset.Name, result.Length); 100 assetID, asset.Name, result.Length);
101 101
102 Array.Resize(ref result, (int) ms.Length); 102 Array.Resize<byte>(ref result, (int) ms.Length);
103 } 103 }
104 else 104 else
105 { 105 {
106 if (StatsManager.AssetStats != null) 106 if (StatsManager.AssetStats != null)
107 StatsManager.AssetStats.AddNotFoundRequest(); 107 StatsManager.AssetStats.AddNotFoundRequest();
108 108
109 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID); 109 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
110 } 110 }
111 } 111 }
112 112
113 return result; 113 return result;
114 } 114 }
115 } 115 }
116 116
117 public class PostAssetStreamHandler : BaseStreamHandler 117 public class PostAssetStreamHandler : BaseStreamHandler
118 { 118 {
119 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 119 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
120 120
121 private readonly IAssetProvider m_assetProvider;
122 private OpenAsset_Main m_assetManager; 121 private OpenAsset_Main m_assetManager;
123 122 private IAssetProvider m_assetProvider;
124 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
125 : base("POST", "/assets")
126 {
127 m_assetManager = assetManager;
128 m_assetProvider = assetProvider;
129 }
130 123
131 public override byte[] Handle(string path, Stream request) 124 public override byte[] Handle(string path, Stream request)
132 { 125 {
@@ -146,5 +139,12 @@ namespace OpenSim.Grid.AssetServer
146 139
147 return new byte[] {}; 140 return new byte[] {};
148 } 141 }
142
143 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
144 : base("POST", "/assets")
145 {
146 m_assetManager = assetManager;
147 m_assetProvider = assetProvider;
148 }
149 } 149 }
150} \ No newline at end of file 150}