aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie Thielker2009-05-09 04:03:32 +0000
committerMelanie Thielker2009-05-09 04:03:32 +0000
commitb3d29aaeb3816fdb963a038a2df840a69ccd21e8 (patch)
tree2c1f84543a40fc1be7925b2dcc9e5fc3589a38a1 /OpenSim/Region/CoreModules
parentPlumb the remote asset hookup, all but the actual requests (diff)
downloadopensim-SC-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.zip
opensim-SC-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.tar.gz
opensim-SC-b3d29aaeb3816fdb963a038a2df840a69ccd21e8.tar.bz2
opensim-SC-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.cs58
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
28using log4net; 28using log4net;
29using System; 29using System;
30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using Nini.Config; 32using Nini.Config;
32using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenSim.Framework.Communications;
36 39
37namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset 40namespace 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 }