aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs74
1 files changed, 70 insertions, 4 deletions
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
index 4907015..5d94eac 100644
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
@@ -163,20 +163,47 @@ namespace OpenSim.Services.Connectors
163 /// <returns></returns> 163 /// <returns></returns>
164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID) 164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
165 { 165 {
166 List<InventoryFolderBase> folders = null;
167 Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>();
166 try 168 try
167 { 169 {
168 List<InventoryFolderBase> folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( 170 folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
169 "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); 171 "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
170 172
171 Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>();
172 foreach (InventoryFolderBase f in folders) 173 foreach (InventoryFolderBase f in folders)
173 dFolders[(AssetType)f.Type] = f; 174 dFolders[(AssetType)f.Type] = f;
175
174 return dFolders; 176 return dFolders;
175 } 177 }
176 catch (Exception e) 178 catch (Exception e)
177 { 179 {
178 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}", 180 // Maybe we're talking to an old inventory server. Try this other thing.
181 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}. Trying RootFolders.",
179 e.Source, e.Message); 182 e.Source, e.Message);
183
184 try
185 {
186 folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
187 "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
188 }
189 catch (Exception ex)
190 {
191 m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.",
192 e.Source, ex.Message);
193 }
194
195 if ((folders != null) && (folders.Count > 0))
196 {
197 dFolders[AssetType.Folder] = folders[0]; // Root folder is the first one
198 folders.RemoveAt(0);
199 foreach (InventoryFolderBase f in folders)
200 {
201 if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown))
202 dFolders[(AssetType)f.Type] = f;
203 }
204
205 return dFolders;
206 }
180 } 207 }
181 208
182 return new Dictionary<AssetType, InventoryFolderBase>(); 209 return new Dictionary<AssetType, InventoryFolderBase>();
@@ -192,13 +219,52 @@ namespace OpenSim.Services.Connectors
192 { 219 {
193 try 220 try
194 { 221 {
222 // normal case
195 return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject( 223 return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
196 "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString()); 224 "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString());
197 } 225 }
198 catch (Exception e) 226 catch (Exception e)
199 { 227 {
200 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}", 228 // Maybe we're talking to an old inventory server. Try this other thing.
229 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}. Trying RootFolders and GetItems.",
201 e.Source, e.Message); 230 e.Source, e.Message);
231
232 List<InventoryFolderBase> folders = null;
233 try
234 {
235 folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
236 "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
237 }
238 catch (Exception ex)
239 {
240 m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.",
241 e.Source, ex.Message);
242 }
243
244 if ((folders != null) && (folders.Count > 0))
245 {
246 folders = folders.FindAll(delegate (InventoryFolderBase f) { return f.ParentID == folderID ; });
247
248 try
249 {
250 List<InventoryItemBase> items = SynchronousRestSessionObjectPoster<Guid, List<InventoryItemBase>>.BeginPostObject(
251 "POST", m_ServerURI + "/GetItems/", folderID.Guid, sessionID.ToString(), userID.ToString());
252
253 if (items != null)
254 {
255 InventoryCollection result = new InventoryCollection();
256 result.Folders = folders;
257 result.Items = items;
258 result.UserID = new UUID(userID);
259 return result;
260 }
261 }
262 catch (Exception ex)
263 {
264 m_log.ErrorFormat("[INVENTORY CONNECTOR]: QueryFolder and GetItems operation failed, {0} {1}. Give up.",
265 e.Source, ex.Message);
266 }
267 }
202 } 268 }
203 269
204 return null; 270 return null;