aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer/RestService.cs
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Grid/AssetServer/RestService.cs
parent* Deleted .user file (diff)
downloadopensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Grid/AssetServer/RestService.cs')
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs44
1 files changed, 21 insertions, 23 deletions
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs
index 6993019..0cad643 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -1,29 +1,27 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Text;
3using System.Xml; 4using System.Xml;
4using System.Xml.Serialization; 5using System.Xml.Serialization;
5using System.Text;
6
7using libsecondlife; 6using libsecondlife;
8using OpenSim.Framework; 7using OpenSim.Framework;
9using OpenSim.Framework.Servers;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Console; 8using OpenSim.Framework.Console;
9using OpenSim.Framework.Servers;
12 10
13namespace OpenSim.Grid.AssetServer 11namespace OpenSim.Grid.AssetServer
14{ 12{
15 public class GetAssetStreamHandler : BaseStreamHandler 13 public class GetAssetStreamHandler : BaseStreamHandler
16 { 14 {
17 OpenAsset_Main m_assetManager; 15 private OpenAsset_Main m_assetManager;
18 IAssetProvider m_assetProvider; 16 private IAssetProvider m_assetProvider;
19 17
20 override public byte[] Handle(string path, Stream request) 18 public override byte[] Handle(string path, Stream request)
21 { 19 {
22 string param = GetParam(path); 20 string param = GetParam(path);
23 byte[] result = new byte[] { }; 21 byte[] result = new byte[] {};
24 try { 22 try
25 23 {
26 string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries); 24 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
27 25
28 if (p.Length > 0) 26 if (p.Length > 0)
29 { 27 {
@@ -42,7 +40,7 @@ namespace OpenSim.Grid.AssetServer
42 { 40 {
43 MainLog.Instance.Debug("REST", "GET:/asset found {0}, {1}", assetID, asset.Name); 41 MainLog.Instance.Debug("REST", "GET:/asset found {0}, {1}", assetID, asset.Name);
44 42
45 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 43 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
46 MemoryStream ms = new MemoryStream(); 44 MemoryStream ms = new MemoryStream();
47 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 45 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
48 xw.Formatting = Formatting.Indented; 46 xw.Formatting = Formatting.Indented;
@@ -53,7 +51,7 @@ namespace OpenSim.Grid.AssetServer
53 StreamReader sr = new StreamReader(ms); 51 StreamReader sr = new StreamReader(ms);
54 52
55 result = ms.GetBuffer(); 53 result = ms.GetBuffer();
56 Array.Resize<byte>(ref result, (int)ms.Length); 54 Array.Resize<byte>(ref result, (int) ms.Length);
57 } 55 }
58 else 56 else
59 { 57 {
@@ -69,7 +67,7 @@ namespace OpenSim.Grid.AssetServer
69 } 67 }
70 68
71 public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) 69 public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
72 : base("GET", "/assets" ) 70 : base("GET", "/assets")
73 { 71 {
74 m_assetManager = assetManager; 72 m_assetManager = assetManager;
75 m_assetProvider = assetProvider; 73 m_assetProvider = assetProvider;
@@ -78,25 +76,25 @@ namespace OpenSim.Grid.AssetServer
78 76
79 public class PostAssetStreamHandler : BaseStreamHandler 77 public class PostAssetStreamHandler : BaseStreamHandler
80 { 78 {
81 OpenAsset_Main m_assetManager; 79 private OpenAsset_Main m_assetManager;
82 IAssetProvider m_assetProvider; 80 private IAssetProvider m_assetProvider;
83 81
84 override public byte[] Handle(string path, Stream request) 82 public override byte[] Handle(string path, Stream request)
85 { 83 {
86 string param = GetParam(path); 84 string param = GetParam(path);
87 85
88 LLUUID assetId; 86 LLUUID assetId;
89 if(param.Length > 0) 87 if (param.Length > 0)
90 LLUUID.TryParse(param, out assetId); 88 LLUUID.TryParse(param, out assetId);
91 byte[] txBuffer = new byte[4096]; 89 byte[] txBuffer = new byte[4096];
92 90
93 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 91 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
94 AssetBase asset = (AssetBase)xs.Deserialize(request); 92 AssetBase asset = (AssetBase) xs.Deserialize(request);
95 93
96 MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID); 94 MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID);
97 m_assetProvider.CreateAsset(asset); 95 m_assetProvider.CreateAsset(asset);
98 96
99 return new byte[] { }; 97 return new byte[] {};
100 } 98 }
101 99
102 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) 100 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
@@ -106,4 +104,4 @@ namespace OpenSim.Grid.AssetServer
106 m_assetProvider = assetProvider; 104 m_assetProvider = assetProvider;
107 } 105 }
108 } 106 }
109} 107} \ No newline at end of file