diff options
author | Melanie Thielker | 2009-05-09 04:03:32 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-09 04:03:32 +0000 |
commit | b3d29aaeb3816fdb963a038a2df840a69ccd21e8 (patch) | |
tree | 2c1f84543a40fc1be7925b2dcc9e5fc3589a38a1 /OpenSim/Region/CoreModules | |
parent | Plumb the remote asset hookup, all but the actual requests (diff) | |
download | opensim-SC_OLD-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.zip opensim-SC_OLD-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.tar.gz opensim-SC_OLD-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.tar.bz2 opensim-SC_OLD-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.tar.xz |
Make remote assets work through the new server system
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs index 715cf6e..2cc2962 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs | |||
@@ -27,12 +27,15 @@ | |||
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using System; | 29 | using System; |
30 | using System.IO; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Framework.Communications; | ||
36 | 39 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset |
38 | { | 41 | { |
@@ -76,6 +79,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
76 | } | 79 | } |
77 | m_Enabled = true; | 80 | m_Enabled = true; |
78 | m_ServerURI = serviceURI; | 81 | m_ServerURI = serviceURI; |
82 | |||
83 | m_log.Info("[ASSET CONNECTOR]: Remote assets enabled"); | ||
79 | } | 84 | } |
80 | } | 85 | } |
81 | } | 86 | } |
@@ -106,31 +111,74 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
106 | 111 | ||
107 | public AssetBase Get(string id) | 112 | public AssetBase Get(string id) |
108 | { | 113 | { |
109 | return null; | 114 | string uri = m_ServerURI + "/assets/" + id; |
115 | |||
116 | AssetBase asset = SynchronousRestObjectPoster. | ||
117 | BeginPostObject<int, AssetBase>("GET", uri, 0); | ||
118 | return asset; | ||
110 | } | 119 | } |
111 | 120 | ||
112 | public AssetMetadata GetMetadata(string id) | 121 | public AssetMetadata GetMetadata(string id) |
113 | { | 122 | { |
114 | return null; | 123 | string uri = m_ServerURI + "/assets/" + id + "/metadata"; |
124 | |||
125 | AssetMetadata asset = SynchronousRestObjectPoster. | ||
126 | BeginPostObject<int, AssetMetadata>("GET", uri, 0); | ||
127 | return asset; | ||
115 | } | 128 | } |
116 | 129 | ||
117 | public byte[] GetData(string id) | 130 | public byte[] GetData(string id) |
118 | { | 131 | { |
119 | return new byte[0]; | 132 | RestClient rc = new RestClient(m_ServerURI); |
133 | rc.AddResourcePath("assets"); | ||
134 | rc.AddResourcePath(id); | ||
135 | rc.AddResourcePath("data"); | ||
136 | |||
137 | rc.RequestMethod = "GET"; | ||
138 | |||
139 | Stream s = rc.Request(); | ||
140 | |||
141 | if (s == null) | ||
142 | return null; | ||
143 | |||
144 | if (s.Length > 0) | ||
145 | { | ||
146 | byte[] ret = new byte[s.Length]; | ||
147 | s.Read(ret, 0, (int)s.Length); | ||
148 | |||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | return null; | ||
120 | } | 153 | } |
121 | 154 | ||
122 | public string Store(AssetBase asset) | 155 | public string Store(AssetBase asset) |
123 | { | 156 | { |
124 | return String.Empty; | 157 | string uri = m_ServerURI + "/assets/"; |
158 | |||
159 | string newID = SynchronousRestObjectPoster. | ||
160 | BeginPostObject<AssetBase, string>("POST", uri, asset); | ||
161 | return newID; | ||
125 | } | 162 | } |
126 | 163 | ||
127 | public bool UpdateContent(string id, byte[] data) | 164 | public bool UpdateContent(string id, byte[] data) |
128 | { | 165 | { |
129 | return false; | 166 | AssetBase asset = new AssetBase(); |
167 | asset.ID = id; | ||
168 | asset.Data = data; | ||
169 | |||
170 | string uri = m_ServerURI + "/assets/" + id; | ||
171 | |||
172 | return SynchronousRestObjectPoster. | ||
173 | BeginPostObject<AssetBase, bool>("POST", uri, asset); | ||
130 | } | 174 | } |
131 | 175 | ||
132 | public bool Delete(string id) | 176 | public bool Delete(string id) |
133 | { | 177 | { |
178 | string uri = m_ServerURI + "/assets/" + id; | ||
179 | |||
180 | return SynchronousRestObjectPoster. | ||
181 | BeginPostObject<int, bool>("DELETE", uri, 0); | ||
134 | return false; | 182 | return false; |
135 | } | 183 | } |
136 | } | 184 | } |