diff options
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 99e6983..8f601e8 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
81 | 81 | ||
82 | public SimianAssetServiceConnector(IConfigSource source) | 82 | public SimianAssetServiceConnector(IConfigSource source) |
83 | { | 83 | { |
84 | Initialise(source); | 84 | CommonInit(source); |
85 | } | 85 | } |
86 | 86 | ||
87 | public void Initialise(IConfigSource source) | 87 | public void Initialise(IConfigSource source) |
@@ -91,31 +91,40 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
91 | { | 91 | { |
92 | string name = moduleConfig.GetString("AssetServices", ""); | 92 | string name = moduleConfig.GetString("AssetServices", ""); |
93 | if (name == Name) | 93 | if (name == Name) |
94 | { | 94 | CommonInit(source); |
95 | IConfig gridConfig = source.Configs["AssetService"]; | 95 | } |
96 | if (gridConfig != null) | 96 | } |
97 | { | ||
98 | string serviceUrl = gridConfig.GetString("AssetServerURI"); | ||
99 | if (!String.IsNullOrEmpty(serviceUrl)) | ||
100 | { | ||
101 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) | ||
102 | serviceUrl = serviceUrl + '/'; | ||
103 | m_serverUrl = serviceUrl; | ||
104 | } | ||
105 | } | ||
106 | 97 | ||
107 | if (String.IsNullOrEmpty(m_serverUrl)) | 98 | private void CommonInit(IConfigSource source) |
108 | m_log.Info("[SIMIAN ASSET CONNECTOR]: No AssetServerURI specified, disabling connector"); | 99 | { |
109 | else | 100 | IConfig gridConfig = source.Configs["AssetService"]; |
110 | m_Enabled = true; | 101 | if (gridConfig != null) |
102 | { | ||
103 | string serviceUrl = gridConfig.GetString("AssetServerURI"); | ||
104 | if (!String.IsNullOrEmpty(serviceUrl)) | ||
105 | { | ||
106 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) | ||
107 | serviceUrl = serviceUrl + '/'; | ||
108 | m_serverUrl = serviceUrl; | ||
111 | } | 109 | } |
112 | } | 110 | } |
111 | |||
112 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
113 | m_log.Info("[SIMIAN ASSET CONNECTOR]: No AssetServerURI specified, disabling connector"); | ||
114 | else | ||
115 | m_Enabled = true; | ||
113 | } | 116 | } |
114 | 117 | ||
115 | #region IAssetService | 118 | #region IAssetService |
116 | 119 | ||
117 | public AssetBase Get(string id) | 120 | public AssetBase Get(string id) |
118 | { | 121 | { |
122 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
123 | { | ||
124 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
125 | throw new InvalidOperationException(); | ||
126 | } | ||
127 | |||
119 | // Cache fetch | 128 | // Cache fetch |
120 | if (m_cache != null) | 129 | if (m_cache != null) |
121 | { | 130 | { |
@@ -142,6 +151,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
142 | /// <returns></returns> | 151 | /// <returns></returns> |
143 | public AssetMetadata GetMetadata(string id) | 152 | public AssetMetadata GetMetadata(string id) |
144 | { | 153 | { |
154 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
155 | { | ||
156 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
157 | throw new InvalidOperationException(); | ||
158 | } | ||
159 | |||
145 | AssetMetadata metadata = null; | 160 | AssetMetadata metadata = null; |
146 | 161 | ||
147 | // Cache fetch | 162 | // Cache fetch |
@@ -213,6 +228,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
213 | /// <returns>True if the id was parseable, false otherwise</returns> | 228 | /// <returns>True if the id was parseable, false otherwise</returns> |
214 | public bool Get(string id, Object sender, AssetRetrieved handler) | 229 | public bool Get(string id, Object sender, AssetRetrieved handler) |
215 | { | 230 | { |
231 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
232 | { | ||
233 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
234 | throw new InvalidOperationException(); | ||
235 | } | ||
236 | |||
216 | // Cache fetch | 237 | // Cache fetch |
217 | if (m_cache != null) | 238 | if (m_cache != null) |
218 | { | 239 | { |
@@ -243,6 +264,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
243 | /// <returns></returns> | 264 | /// <returns></returns> |
244 | public string Store(AssetBase asset) | 265 | public string Store(AssetBase asset) |
245 | { | 266 | { |
267 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
268 | { | ||
269 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
270 | throw new InvalidOperationException(); | ||
271 | } | ||
272 | |||
246 | bool storedInCache = false; | 273 | bool storedInCache = false; |
247 | string errorMessage = null; | 274 | string errorMessage = null; |
248 | 275 | ||
@@ -375,6 +402,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
375 | /// <returns></returns> | 402 | /// <returns></returns> |
376 | public bool Delete(string id) | 403 | public bool Delete(string id) |
377 | { | 404 | { |
405 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
406 | { | ||
407 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
408 | throw new InvalidOperationException(); | ||
409 | } | ||
410 | |||
378 | //string errorMessage = String.Empty; | 411 | //string errorMessage = String.Empty; |
379 | string url = m_serverUrl + id; | 412 | string url = m_serverUrl + id; |
380 | 413 | ||