aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/GridAssetClient.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs140
1 files changed, 0 insertions, 140 deletions
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
deleted file mode 100644
index e070131..0000000
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ /dev/null
@@ -1,140 +0,0 @@
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 OpenSimulator 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.Reflection;
31using System.Xml.Serialization;
32using log4net;
33using OpenSim.Framework.Servers.HttpServer;
34
35namespace OpenSim.Framework.Communications.Cache
36{
37 public class GridAssetClient : AssetServerBase
38 {
39 #region IPlugin
40
41 public override string Name
42 {
43 get { return "Grid"; }
44 }
45
46 public override string Version
47 {
48 get { return "1.0"; }
49 }
50
51 public override void Initialise(ConfigSettings p_set, string p_url)
52 {
53 m_log.Debug("[GRID ASSET CLIENT]: Plugin configured initialisation");
54 Initialise(p_url);
55 }
56
57 #endregion
58
59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60
61 private string _assetServerUrl;
62
63 public GridAssetClient() {}
64
65 public GridAssetClient(string p_url)
66 {
67 m_log.Debug("[GRID ASSET CLIENT]: Direct constructor");
68 Initialise(p_url);
69 }
70
71 public void Initialise(string serverUrl)
72 {
73 _assetServerUrl = serverUrl;
74 }
75
76 #region IAssetServer Members
77
78 protected override AssetBase GetAsset(AssetRequest req)
79 {
80 #if DEBUG
81 //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString());
82 #endif
83
84 RestClient rc = new RestClient(_assetServerUrl);
85 rc.AddResourcePath("assets");
86 rc.AddResourcePath(req.AssetID.ToString());
87
88 rc.RequestMethod = "GET";
89
90 Stream s = rc.Request();
91
92 if (s == null)
93 return null;
94
95 if (s.Length > 0)
96 {
97 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
98
99 return (AssetBase) xs.Deserialize(s);
100 }
101
102 return null;
103 }
104
105 public override void UpdateAsset(AssetBase asset)
106 {
107 throw new Exception("The method or operation is not implemented.");
108 }
109
110 public override void StoreAsset(AssetBase asset)
111 {
112 try
113 {
114 // MemoryStream s = new MemoryStream();
115
116 // XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
117 // xs.Serialize(s, asset);
118 // RestClient rc = new RestClient(_assetServerUrl);
119
120 string assetUrl = _assetServerUrl + "/assets/";
121
122 //rc.AddResourcePath("assets");
123
124 // rc.RequestMethod = "POST";
125 // rc.Request(s);
126 //m_log.InfoFormat("[ASSET]: Stored {0}", rc);
127
128 m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID);
129
130 RestObjectPoster.BeginPostObject<AssetBase>(assetUrl, asset);
131 }
132 catch (Exception e)
133 {
134 m_log.ErrorFormat("[GRID ASSET CLIENT]: {0}", e);
135 }
136 }
137
138 #endregion
139 }
140}