aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/InventoryService/HGInventoryService.cs
diff options
context:
space:
mode:
authordiva2009-06-15 23:29:00 +0000
committerdiva2009-06-15 23:29:00 +0000
commite1fd76ace627dcef3798ca20f330397c93e13151 (patch)
tree8444597dd5c6dc6078e41872149bd5f9606336cb /OpenSim/Services/InventoryService/HGInventoryService.cs
parentRenamed two of the in connector modules, to make things consistent. (diff)
downloadopensim-SC_OLD-e1fd76ace627dcef3798ca20f330397c93e13151.zip
opensim-SC_OLD-e1fd76ace627dcef3798ca20f330397c93e13151.tar.gz
opensim-SC_OLD-e1fd76ace627dcef3798ca20f330397c93e13151.tar.bz2
opensim-SC_OLD-e1fd76ace627dcef3798ca20f330397c93e13151.tar.xz
Moving these nice HG connectors to their homes.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs (renamed from OpenSim/Services/InventoryService/HGInventoryService.cs)483
1 files changed, 241 insertions, 242 deletions
diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
index 0db80d0..e943ae4 100644
--- a/OpenSim/Services/InventoryService/HGInventoryService.cs
+++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
@@ -1,242 +1,241 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using log4net; 28using log4net;
29using Nini.Config; 29using Nini.Config;
30using System; 30using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors; 35using OpenMetaverse;
36using OpenMetaverse; 36
37 37namespace OpenSim.Services.Connectors.Inventory
38namespace OpenSim.Services.InventoryService 38{
39{ 39 public class HGInventoryServiceConnector : ISessionAuthInventoryService
40 public class HGInventoryService : ISessionAuthInventoryService 40 {
41 { 41 private static readonly ILog m_log =
42 private static readonly ILog m_log = 42 LogManager.GetLogger(
43 LogManager.GetLogger( 43 MethodBase.GetCurrentMethod().DeclaringType);
44 MethodBase.GetCurrentMethod().DeclaringType); 44
45 45 private Dictionary<string, InventoryServicesConnector> m_connectors = new Dictionary<string, InventoryServicesConnector>();
46 private Dictionary<string, InventoryServicesConnector> m_connectors = new Dictionary<string, InventoryServicesConnector>(); 46
47 47 public HGInventoryServiceConnector(IConfigSource source)
48 public HGInventoryService(IConfigSource source) 48 {
49 { 49 IConfig moduleConfig = source.Configs["Modules"];
50 IConfig moduleConfig = source.Configs["Modules"]; 50 if (moduleConfig != null)
51 if (moduleConfig != null) 51 {
52 { 52
53 53 IConfig inventoryConfig = source.Configs["InventoryService"];
54 IConfig assetConfig = source.Configs["InventoryService"]; 54 if (inventoryConfig == null)
55 if (assetConfig == null) 55 {
56 { 56 m_log.Error("[HG INVENTORY SERVICE]: InventoryService missing from OpenSim.ini");
57 m_log.Error("[HG INVENTORY SERVICE]: InventoryService missing from OpenSim.ini"); 57 return;
58 return; 58 }
59 } 59
60 60 m_log.Info("[HG INVENTORY SERVICE]: HG inventory service enabled");
61 m_log.Info("[HG INVENTORY SERVICE]: HG inventory service enabled"); 61 }
62 } 62 }
63 } 63
64 64 private bool StringToUrlAndUserID(string id, out string url, out string userID)
65 private bool StringToUrlAndUserID(string id, out string url, out string userID) 65 {
66 { 66 url = String.Empty;
67 url = String.Empty; 67 userID = String.Empty;
68 userID = String.Empty; 68
69 69 Uri assetUri;
70 Uri assetUri; 70
71 71 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
72 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) && 72 assetUri.Scheme == Uri.UriSchemeHttp)
73 assetUri.Scheme == Uri.UriSchemeHttp) 73 {
74 { 74 url = "http://" + assetUri.Authority;
75 url = "http://" + assetUri.Authority; 75 userID = assetUri.LocalPath.Trim(new char[] { '/' });
76 userID = assetUri.LocalPath.Trim(new char[] { '/' }); 76 return true;
77 return true; 77 }
78 } 78
79 79 return false;
80 return false; 80 }
81 } 81 private ISessionAuthInventoryService GetConnector(string url)
82 private ISessionAuthInventoryService GetConnector(string url) 82 {
83 { 83 InventoryServicesConnector connector = null;
84 InventoryServicesConnector connector = null; 84 lock (m_connectors)
85 lock (m_connectors) 85 {
86 { 86 if (m_connectors.ContainsKey(url))
87 if (m_connectors.ContainsKey(url)) 87 {
88 { 88 connector = m_connectors[url];
89 connector = m_connectors[url]; 89 }
90 } 90 else
91 else 91 {
92 { 92 // We're instantiating this class explicitly, but this won't
93 // We're instantiating this class explicitly, but this won't 93 // work in general, because the remote grid may be running
94 // work in general, because the remote grid may be running 94 // an inventory server that has a different protocol.
95 // an inventory server that has a different protocol. 95 // Eventually we will want a piece of protocol asking
96 // Eventually we will want a piece of protocol asking 96 // the remote server about its kind. Definitely cool thing to do!
97 // the remote server about its kind. Definitely cool thing to do! 97 connector = new InventoryServicesConnector(url);
98 connector = new InventoryServicesConnector(url); 98 m_connectors.Add(url, connector);
99 m_connectors.Add(url, connector); 99 }
100 } 100 }
101 } 101 return connector;
102 return connector; 102 }
103 } 103
104 104 public string Host
105 public string Host 105 {
106 { 106 get { return string.Empty; }
107 get { return string.Empty; } 107 }
108 } 108
109 109 public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback)
110 public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback) 110 {
111 { 111 m_log.Debug("[HGInventory]: GetUserInventory " + id);
112 m_log.Debug("[HGInventory]: GetUserInventory " + id); 112 string url = string.Empty;
113 string url = string.Empty; 113 string userID = string.Empty;
114 string userID = string.Empty; 114
115 115 if (StringToUrlAndUserID(id, out url, out userID))
116 if (StringToUrlAndUserID(id, out url, out userID)) 116 {
117 { 117 ISessionAuthInventoryService connector = GetConnector(url);
118 ISessionAuthInventoryService connector = GetConnector(url); 118 connector.GetUserInventory(userID, sessionID, callback);
119 connector.GetUserInventory(userID, sessionID, callback); 119 }
120 } 120
121 121 }
122 } 122
123 123 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID)
124 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) 124 {
125 { 125 string url = string.Empty;
126 string url = string.Empty; 126 string userID = string.Empty;
127 string userID = string.Empty; 127
128 128 if (StringToUrlAndUserID(id, out url, out userID))
129 if (StringToUrlAndUserID(id, out url, out userID)) 129 {
130 { 130 ISessionAuthInventoryService connector = GetConnector(url);
131 ISessionAuthInventoryService connector = GetConnector(url); 131 return connector.AddFolder(userID, folder, sessionID);
132 return connector.AddFolder(userID, folder, sessionID); 132 }
133 } 133 return false;
134 return false; 134 }
135 } 135
136 136 public bool UpdateFolder(string id, InventoryFolderBase folder, UUID sessionID)
137 public bool UpdateFolder(string id, InventoryFolderBase folder, UUID sessionID) 137 {
138 { 138 string url = string.Empty;
139 string url = string.Empty; 139 string userID = string.Empty;
140 string userID = string.Empty; 140
141 141 if (StringToUrlAndUserID(id, out url, out userID))
142 if (StringToUrlAndUserID(id, out url, out userID)) 142 {
143 { 143 ISessionAuthInventoryService connector = GetConnector(url);
144 ISessionAuthInventoryService connector = GetConnector(url); 144 return connector.UpdateFolder(userID, folder, sessionID);
145 return connector.UpdateFolder(userID, folder, sessionID); 145 }
146 } 146 return false;
147 return false; 147 }
148 } 148
149 149 public bool MoveFolder(string id, InventoryFolderBase folder, UUID sessionID)
150 public bool MoveFolder(string id, InventoryFolderBase folder, UUID sessionID) 150 {
151 { 151 string url = string.Empty;
152 string url = string.Empty; 152 string userID = string.Empty;
153 string userID = string.Empty; 153
154 154 if (StringToUrlAndUserID(id, out url, out userID))
155 if (StringToUrlAndUserID(id, out url, out userID)) 155 {
156 { 156 ISessionAuthInventoryService connector = GetConnector(url);
157 ISessionAuthInventoryService connector = GetConnector(url); 157 return connector.MoveFolder(userID, folder, sessionID);
158 return connector.MoveFolder(userID, folder, sessionID); 158 }
159 } 159 return false;
160 return false; 160 }
161 } 161
162 162 public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID)
163 public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID) 163 {
164 { 164 string url = string.Empty;
165 string url = string.Empty; 165 string userID = string.Empty;
166 string userID = string.Empty; 166
167 167 if (StringToUrlAndUserID(id, out url, out userID))
168 if (StringToUrlAndUserID(id, out url, out userID)) 168 {
169 { 169 ISessionAuthInventoryService connector = GetConnector(url);
170 ISessionAuthInventoryService connector = GetConnector(url); 170 return connector.PurgeFolder(userID, folder, sessionID);
171 return connector.PurgeFolder(userID, folder, sessionID); 171 }
172 } 172 return false;
173 return false; 173 }
174 } 174
175 175 public bool AddItem(string id, InventoryItemBase item, UUID sessionID)
176 public bool AddItem(string id, InventoryItemBase item, UUID sessionID) 176 {
177 { 177 string url = string.Empty;
178 string url = string.Empty; 178 string userID = string.Empty;
179 string userID = string.Empty; 179
180 180 if (StringToUrlAndUserID(id, out url, out userID))
181 if (StringToUrlAndUserID(id, out url, out userID)) 181 {
182 { 182 ISessionAuthInventoryService connector = GetConnector(url);
183 ISessionAuthInventoryService connector = GetConnector(url); 183 return connector.AddItem(userID, item, sessionID);
184 return connector.AddItem(userID, item, sessionID); 184 }
185 } 185 return false;
186 return false; 186 }
187 } 187
188 188 public bool UpdateItem(string id, InventoryItemBase item, UUID sessionID)
189 public bool UpdateItem(string id, InventoryItemBase item, UUID sessionID) 189 {
190 { 190 string url = string.Empty;
191 string url = string.Empty; 191 string userID = string.Empty;
192 string userID = string.Empty; 192
193 193 if (StringToUrlAndUserID(id, out url, out userID))
194 if (StringToUrlAndUserID(id, out url, out userID)) 194 {
195 { 195 ISessionAuthInventoryService connector = GetConnector(url);
196 ISessionAuthInventoryService connector = GetConnector(url); 196 return connector.UpdateItem(userID, item, sessionID);
197 return connector.UpdateItem(userID, item, sessionID); 197 }
198 } 198 return false;
199 return false; 199 }
200 } 200
201 201 public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID)
202 public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) 202 {
203 { 203 string url = string.Empty;
204 string url = string.Empty; 204 string userID = string.Empty;
205 string userID = string.Empty; 205
206 206 if (StringToUrlAndUserID(id, out url, out userID))
207 if (StringToUrlAndUserID(id, out url, out userID)) 207 {
208 { 208 ISessionAuthInventoryService connector = GetConnector(url);
209 ISessionAuthInventoryService connector = GetConnector(url); 209 return connector.UpdateItem(userID, item, sessionID);
210 return connector.UpdateItem(userID, item, sessionID); 210 }
211 } 211 return false;
212 return false; 212 }
213 } 213
214 214 public InventoryItemBase QueryItem(string id, InventoryItemBase item, UUID sessionID)
215 public InventoryItemBase QueryItem(string id, InventoryItemBase item, UUID sessionID) 215 {
216 { 216 string url = string.Empty;
217 string url = string.Empty; 217 string userID = string.Empty;
218 string userID = string.Empty; 218
219 219 if (StringToUrlAndUserID(id, out url, out userID))
220 if (StringToUrlAndUserID(id, out url, out userID)) 220 {
221 { 221 ISessionAuthInventoryService connector = GetConnector(url);
222 ISessionAuthInventoryService connector = GetConnector(url); 222 return connector.QueryItem(userID, item, sessionID);
223 return connector.QueryItem(userID, item, sessionID); 223 }
224 } 224 return null;
225 return null; 225 }
226 } 226
227 227 public InventoryFolderBase QueryFolder(string id, InventoryFolderBase folder, UUID sessionID)
228 public InventoryFolderBase QueryFolder(string id, InventoryFolderBase folder, UUID sessionID) 228 {
229 { 229 string url = string.Empty;
230 string url = string.Empty; 230 string userID = string.Empty;
231 string userID = string.Empty; 231
232 232 if (StringToUrlAndUserID(id, out url, out userID))
233 if (StringToUrlAndUserID(id, out url, out userID)) 233 {
234 { 234 ISessionAuthInventoryService connector = GetConnector(url);
235 ISessionAuthInventoryService connector = GetConnector(url); 235 return connector.QueryFolder(userID, folder, sessionID);
236 return connector.QueryFolder(userID, folder, sessionID); 236 }
237 } 237 return null;
238 return null; 238 }
239 } 239
240 240 }
241 } 241}
242}