aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/AssetServer')
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs81
-rw-r--r--OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs42
3 files changed, 64 insertions, 61 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index 26f4bc8..c26c506 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -46,14 +46,48 @@ namespace OpenSim.Grid.AssetServer
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 public AssetConfig m_config; 49 public static OpenAsset_Main assetserver;
50 50
51 public static OpenAsset_Main assetserver;
52
53 // Temporarily hardcoded - should be a plugin 51 // Temporarily hardcoded - should be a plugin
54 protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); 52 protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
55 53
56 private IAssetProvider m_assetProvider; 54 private IAssetProvider m_assetProvider;
55 public AssetConfig m_config;
56
57 public OpenAsset_Main()
58 {
59 m_console = new ConsoleBase("OpenAsset", this);
60
61 MainConsole.Instance = m_console;
62 }
63
64 #region conscmd_callback Members
65
66 public override void RunCmd(string cmd, string[] cmdparams)
67 {
68 base.RunCmd(cmd, cmdparams);
69
70 switch (cmd)
71 {
72 case "help":
73 m_console.Notice(
74 @"shutdown - shutdown this asset server (USE CAUTION!)
75 stats - statistical information for this server");
76
77 break;
78
79 case "stats":
80 m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report());
81 break;
82
83 case "shutdown":
84 m_console.Close();
85 Environment.Exit(0);
86 break;
87 }
88 }
89
90 #endregion
57 91
58 [STAThread] 92 [STAThread]
59 public static void Main(string[] args) 93 public static void Main(string[] args)
@@ -78,13 +112,6 @@ namespace OpenSim.Grid.AssetServer
78 } 112 }
79 } 113 }
80 114
81 public OpenAsset_Main()
82 {
83 m_console = new ConsoleBase("OpenAsset", this);
84
85 MainConsole.Instance = m_console;
86 }
87
88 public void Startup() 115 public void Startup()
89 { 116 {
90 m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); 117 m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml")));
@@ -160,42 +187,18 @@ namespace OpenSim.Grid.AssetServer
160 catch (Exception e) 187 catch (Exception e)
161 { 188 {
162 m_log.Warn("[ASSET]: setupDB() - Exception occured"); 189 m_log.Warn("[ASSET]: setupDB() - Exception occured");
163 m_log.Warn("[ASSET]: " + e.ToString()); 190 m_log.Warn("[ASSET]: " + e);
164 } 191 }
165 } 192 }
166 193
167 public void LoadDefaultAssets() 194 public void LoadDefaultAssets()
168 { 195 {
169 assetLoader.ForEachDefaultXmlAsset(StoreAsset); 196 assetLoader.ForEachDefaultXmlAsset(StoreAsset);
170 } 197 }
171 198
172 protected void StoreAsset(AssetBase asset) 199 protected void StoreAsset(AssetBase asset)
173 { 200 {
174 m_assetProvider.CreateAsset(asset); 201 m_assetProvider.CreateAsset(asset);
175 } 202 }
176
177 public override void RunCmd(string cmd, string[] cmdparams)
178 {
179 base.RunCmd(cmd, cmdparams);
180
181 switch (cmd)
182 {
183 case "help":
184 m_console.Notice(
185 @"shutdown - shutdown this asset server (USE CAUTION!)
186 stats - statistical information for this server");
187
188 break;
189
190 case "stats":
191 m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report());
192 break;
193
194 case "shutdown":
195 m_console.Close();
196 Environment.Exit(0);
197 break;
198 }
199 }
200 } 203 }
201} 204} \ No newline at end of file
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
index 6f219a6..3bae064 100644
--- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
@@ -60,4 +60,4 @@ using System.Runtime.InteropServices;
60// 60//
61 61
62[assembly : AssemblyVersion("1.0.0.0")] 62[assembly : AssemblyVersion("1.0.0.0")]
63[assembly : AssemblyFileVersion("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 ece826e..93f86b8 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;
46 private OpenAsset_Main m_assetManager; 47 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 char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 67 string[] p = param.Split(new[] {'/', '?', '&'}, 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,32 +94,39 @@ 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<byte>(ref result, (int) ms.Length); 102 Array.Resize(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;
121 private OpenAsset_Main m_assetManager; 122 private OpenAsset_Main m_assetManager;
122 private IAssetProvider m_assetProvider; 123
124 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
125 : base("POST", "/assets")
126 {
127 m_assetManager = assetManager;
128 m_assetProvider = assetProvider;
129 }
123 130
124 public override byte[] Handle(string path, Stream request) 131 public override byte[] Handle(string path, Stream request)
125 { 132 {
@@ -139,12 +146,5 @@ namespace OpenSim.Grid.AssetServer
139 146
140 return new byte[] {}; 147 return new byte[] {};
141 } 148 }
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} 150} \ No newline at end of file