aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
diff options
context:
space:
mode:
authorTleiades Hax2007-10-26 11:46:27 +0000
committerTleiades Hax2007-10-26 11:46:27 +0000
commit5e7dba726896fcb84882b53952651742926e6efb (patch)
treea396337e721912fd954e8a66e26d16c375d7bab4 /OpenSim/Framework/Communications/Cache/GridAssetClient.cs
parentadd my set-eol-style script. Can be run on Linux (diff)
downloadopensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.zip
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.gz
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.bz2
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.xz
Very early first implementation of grid based assets.
Run this on a major grid, and weep
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/GridAssetClient.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs160
1 files changed, 160 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
new file mode 100644
index 0000000..fc77431
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -0,0 +1,160 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.IO;
30using System.Threading;
31using System.Reflection;
32using System.Xml.Serialization;
33
34using libsecondlife;
35
36using Nini.Config;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types;
40using OpenSim.Framework.Utilities;
41using OpenSim.Framework.Communications;
42
43namespace OpenSim.Framework.Communications.Cache
44{
45 public class GridAssetClient : IAssetServer
46 {
47 private string _assetServerUrl;
48 private IAssetReceiver _receiver;
49
50 public GridAssetClient(string serverUrl)
51 {
52 _assetServerUrl = serverUrl;
53 }
54
55 #region IAssetServer Members
56
57 public void SetReceiver(IAssetReceiver receiver)
58 {
59 _receiver = receiver;
60 }
61
62 public void FetchAsset(LLUUID assetID, bool isTexture)
63 {
64 Stream s = null;
65 try
66 {
67
68 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString());
69
70 RestClient rc = new RestClient(_assetServerUrl);
71 rc.AddResourcePath("assets");
72 rc.AddResourcePath(assetID.ToString());
73 if (isTexture)
74 rc.AddQueryParameter("texture");
75
76 rc.RequestMethod = "GET";
77 s = rc.Request();
78
79 if (s.Length > 0)
80 {
81 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
82 AssetBase asset = (AssetBase)xs.Deserialize(s);
83
84 _receiver.AssetReceived(asset, isTexture);
85 }
86 else
87 {
88 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString());
89 _receiver.AssetNotFound(assetID);
90 }
91 }
92 catch (Exception e)
93 {
94 MainLog.Instance.Error("ASSETCACHE", e.Message);
95 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
96 }
97 }
98
99 public void UpdateAsset(AssetBase asset)
100 {
101 throw new Exception("The method or operation is not implemented.");
102 }
103
104 public void StoreAndCommitAsset(AssetBase asset)
105 {
106 try
107 {
108 MemoryStream s = new MemoryStream();
109
110 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
111 xs.Serialize(s, asset);
112 RestClient rc = new RestClient(_assetServerUrl);
113 rc.AddResourcePath("assets");
114 rc.RequestMethod = "POST";
115 rc.Request(s);
116 }
117 catch (Exception e)
118 {
119 MainLog.Instance.Error("ASSETS", e.Message);
120 }
121 }
122
123 public void Close()
124 {
125 throw new Exception("The method or operation is not implemented.");
126 }
127
128 public void LoadAsset(AssetBase info, bool image, string filename)
129 {
130 throw new Exception("The method or operation is not implemented.");
131 }
132
133 public System.Collections.Generic.List<AssetBase> GetDefaultAssets()
134 {
135 throw new Exception("The method or operation is not implemented.");
136 }
137
138 public AssetBase CreateImageAsset(string assetIdStr, string name, string filename)
139 {
140 throw new Exception("The method or operation is not implemented.");
141 }
142
143 public void ForEachDefaultAsset(Action<AssetBase> action)
144 {
145 throw new Exception("The method or operation is not implemented.");
146 }
147
148 public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage)
149 {
150 throw new Exception("The method or operation is not implemented.");
151 }
152
153 public void ForEachXmlAsset(Action<AssetBase> action)
154 {
155 throw new Exception("The method or operation is not implemented.");
156 }
157
158 #endregion
159 }
160}