aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer
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
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')
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs27
-rw-r--r--OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs29
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs44
3 files changed, 49 insertions, 51 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index e7e5d27..61427fa 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -29,17 +29,10 @@
29using System; 29using System;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32
33using libsecondlife; 32using libsecondlife;
34using Nini.Config; 33using Nini.Config;
35
36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Framework; 34using OpenSim.Framework;
39using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Servers;
42using OpenSim.Framework;
43using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
44 37
45namespace OpenSim.Grid.AssetServer 38namespace OpenSim.Grid.AssetServer
@@ -79,11 +72,12 @@ namespace OpenSim.Grid.AssetServer
79 72
80 private OpenAsset_Main() 73 private OpenAsset_Main()
81 { 74 {
82 if(!Directory.Exists(Util.logDir())) 75 if (!Directory.Exists(Util.logDir()))
83 { 76 {
84 Directory.CreateDirectory(Util.logDir()); 77 Directory.CreateDirectory(Util.logDir());
85 } 78 }
86 m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-AssetServer-console.log")), "OpenAsset", this, true); 79 m_console =
80 new LogBase((Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), "OpenAsset", this, true);
87 MainLog.Instance = m_console; 81 MainLog.Instance = m_console;
88 } 82 }
89 83
@@ -96,9 +90,9 @@ namespace OpenSim.Grid.AssetServer
96 90
97 m_console.Verbose("ASSET", "Loading default asset set.."); 91 m_console.Verbose("ASSET", "Loading default asset set..");
98 LoadDefaultAssets(); 92 LoadDefaultAssets();
99 93
100 m_console.Verbose("ASSET", "Starting HTTP process"); 94 m_console.Verbose("ASSET", "Starting HTTP process");
101 BaseHttpServer httpServer = new BaseHttpServer((int)m_config.HttpPort); 95 BaseHttpServer httpServer = new BaseHttpServer((int) m_config.HttpPort);
102 96
103 httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider)); 97 httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider));
104 httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider)); 98 httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider));
@@ -125,7 +119,8 @@ namespace OpenSim.Grid.AssetServer
125 119
126 if (typeInterface != null) 120 if (typeInterface != null)
127 { 121 {
128 IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 122 IAssetProvider plug =
123 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
129 assetPlugin = plug; 124 assetPlugin = plug;
130 assetPlugin.Initialise(); 125 assetPlugin.Initialise();
131 126
@@ -174,7 +169,7 @@ namespace OpenSim.Grid.AssetServer
174 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); 169 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
175 byte[] idata = new byte[numBytes]; 170 byte[] idata = new byte[numBytes];
176 BinaryReader br = new BinaryReader(fStream); 171 BinaryReader br = new BinaryReader(fStream);
177 idata = br.ReadBytes((int)numBytes); 172 idata = br.ReadBytes((int) numBytes);
178 br.Close(); 173 br.Close();
179 fStream.Close(); 174 fStream.Close();
180 info.Data = idata; 175 info.Data = idata;
@@ -213,8 +208,8 @@ namespace OpenSim.Grid.AssetServer
213 { 208 {
214 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); 209 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated());
215 string name = source.Configs[i].GetString("name", ""); 210 string name = source.Configs[i].GetString("name", "");
216 sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); 211 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
217 sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); 212 sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
218 string fileName = source.Configs[i].GetString("fileName", ""); 213 string fileName = source.Configs[i].GetString("fileName", "");
219 214
220 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); 215 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
@@ -247,4 +242,4 @@ namespace OpenSim.Grid.AssetServer
247 { 242 {
248 } 243 }
249 } 244 }
250} 245} \ No newline at end of file
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
index 63213f6..87a7f67 100644
--- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
@@ -27,25 +27,29 @@
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30
30// General Information about an assembly is controlled through the following 31// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information 32// set of attributes. Change these attribute values to modify the information
32// associated with an assembly. 33// associated with an assembly.
33[assembly: AssemblyTitle("OGS-AssetServer")] 34
34[assembly: AssemblyDescription("")] 35[assembly : AssemblyTitle("OGS-AssetServer")]
35[assembly: AssemblyConfiguration("")] 36[assembly : AssemblyDescription("")]
36[assembly: AssemblyCompany("")] 37[assembly : AssemblyConfiguration("")]
37[assembly: AssemblyProduct("OGS-AssetServer")] 38[assembly : AssemblyCompany("")]
38[assembly: AssemblyCopyright("Copyright © 2007")] 39[assembly : AssemblyProduct("OGS-AssetServer")]
39[assembly: AssemblyTrademark("")] 40[assembly : AssemblyCopyright("Copyright © 2007")]
40[assembly: AssemblyCulture("")] 41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
41 43
42// Setting ComVisible to false makes the types in this assembly not visible 44// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from 45// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type. 46// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)] 47
48[assembly : ComVisible(false)]
46 49
47// The following GUID is for the ID of the typelib if this project is exposed to COM 50// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] 51
52[assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")]
49 53
50// Version information for an assembly consists of the following four values: 54// Version information for an assembly consists of the following four values:
51// 55//
@@ -54,5 +58,6 @@ using System.Runtime.InteropServices;
54// Build Number 58// Build Number
55// Revision 59// Revision
56// 60//
57[assembly: AssemblyVersion("1.0.0.0")] 61
58[assembly: AssemblyFileVersion("1.0.0.0")] 62[assembly : AssemblyVersion("1.0.0.0")]
63[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
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