aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-08-25 16:13:02 -0400
committerTeravus Ovares (Dan Olivares)2009-08-25 16:13:02 -0400
commita7917b428a6bc3c9e33da64879b9e473516540a3 (patch)
tree2c38d9c33c4977a3d0356912915082a8bd568a23 /OpenSim
parentPatch from jhurliman to HttpServer (diff)
parentImplemented osPenCap, that sets EndCap and StartCap to Pen. This allows using... (diff)
downloadopensim-SC_OLD-a7917b428a6bc3c9e33da64879b9e473516540a3.zip
opensim-SC_OLD-a7917b428a6bc3c9e33da64879b9e473516540a3.tar.gz
opensim-SC_OLD-a7917b428a6bc3c9e33da64879b9e473516540a3.tar.bz2
opensim-SC_OLD-a7917b428a6bc3c9e33da64879b9e473516540a3.tar.xz
Merge branch 'master' of ssh://MyConnection/var/git/opensim
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs8
-rw-r--r--OpenSim/Data/AssetDataBase.cs10
-rw-r--r--OpenSim/Data/GridDataBase.cs3
-rw-r--r--OpenSim/Data/IAssetData.cs5
-rw-r--r--OpenSim/Data/IGridData.cs11
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs19
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGridData.cs27
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs17
-rw-r--r--OpenSim/Data/MySQL/MySQLGridData.cs13
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs24
-rw-r--r--OpenSim/Data/NHibernate/NHibernateGridData.cs14
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs47
-rw-r--r--OpenSim/Data/SQLite/SQLiteGridData.cs10
-rw-r--r--OpenSim/Data/SQLite/SQLiteInventoryStore.cs4
-rw-r--r--OpenSim/Data/Tests/BasicAssetTest.cs24
-rw-r--r--OpenSim/Data/Tests/BasicGridTest.cs8
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs9
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs2
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs4
-rw-r--r--OpenSim/Framework/Communications/Tests/LoginServiceTests.cs12
-rw-r--r--OpenSim/Framework/Console/CommandConsole.cs4
-rw-r--r--OpenSim/Framework/Console/ConsoleBase.cs4
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs6
-rw-r--r--OpenSim/Framework/GridConfig.cs16
-rw-r--r--OpenSim/Framework/IClientAPI.cs6
-rw-r--r--OpenSim/Framework/InventoryFolderBase.cs6
-rw-r--r--OpenSim/Framework/MessageServerConfig.cs16
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestSessionService.cs3
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs2
-rw-r--r--OpenSim/Framework/Servers/PostAssetStreamHandler.cs2
-rw-r--r--OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs2
-rw-r--r--OpenSim/Framework/UserConfig.cs14
-rw-r--r--OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs98
-rw-r--r--OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs216
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Interfaces.cs143
-rw-r--r--OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs139
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Main.cs62
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs105
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs173
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs211
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs151
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs198
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs189
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs867
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs547
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml27
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs369
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml28
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml16
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs290
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs625
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs71
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Utils.cs1031
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs2
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridDBService.cs6
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs30
-rw-r--r--OpenSim/Grid/GridServer/Program.cs14
-rw-r--r--OpenSim/Grid/InventoryServer/AuthedSessionCache.cs (renamed from OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs)2
-rw-r--r--OpenSim/Grid/InventoryServer/InventoryServiceBase.cs (renamed from OpenSim/Framework/Communications/InventoryServiceBase.cs)4
-rw-r--r--OpenSim/Grid/MessagingServer/Main.cs84
-rw-r--r--OpenSim/Grid/UserServer/Main.cs43
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs78
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs36
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs (renamed from OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs)32
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs125
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs64
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs21
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs45
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs109
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs74
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs9
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs148
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs82
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs43
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs28
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs50
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs (renamed from OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs)86
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs10
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs43
-rw-r--r--OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs16
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs175
-rw-r--r--OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs13
-rw-r--r--OpenSim/Services/Interfaces/IInventoryService.cs13
-rw-r--r--OpenSim/Services/InventoryService/InventoryService.cs54
-rw-r--r--OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs13
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryService.cs12
100 files changed, 1526 insertions, 6104 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index aec06be..59431bb 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -851,7 +851,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
851 851
852 // Delete the old item 852 // Delete the old item
853 853
854 Rest.InventoryServices.DeleteItem(uri); 854 List<UUID> uuids = new List<UUID>();
855 uuids.Add(uri.ID);
856 Rest.InventoryServices.DeleteItems(uri.Owner, uuids);
855 857
856 // Add the new item to the inventory 858 // Add the new item to the inventory
857 859
@@ -927,7 +929,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
927 InventoryItemBase item = (InventoryItemBase) InventoryNode; 929 InventoryItemBase item = (InventoryItemBase) InventoryNode;
928 Rest.Log.DebugFormat("{0} {1}: Item {2} will be deleted", 930 Rest.Log.DebugFormat("{0} {1}: Item {2} will be deleted",
929 MsgId, rdata.method, rdata.path); 931 MsgId, rdata.method, rdata.path);
930 Rest.InventoryServices.DeleteItem(item); 932 List<UUID> uuids = new List<UUID>();
933 uuids.Add(item.ID);
934 Rest.InventoryServices.DeleteItems(item.Owner, uuids);
931 rdata.appendStatus(String.Format("<p>Deleted item {0} UUID {1} <p>", item.Name, item.ID)); 935 rdata.appendStatus(String.Format("<p>Deleted item {0} UUID {1} <p>", item.Name, item.ID));
932 } 936 }
933 937
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs
index f723ebf..5deb44e 100644
--- a/OpenSim/Data/AssetDataBase.cs
+++ b/OpenSim/Data/AssetDataBase.cs
@@ -36,15 +36,9 @@ namespace OpenSim.Data
36{ 36{
37 public abstract class AssetDataBase : IAssetDataPlugin 37 public abstract class AssetDataBase : IAssetDataPlugin
38 { 38 {
39 public virtual AssetBase FetchAsset(UUID uuid) 39 public abstract AssetBase GetAsset(UUID uuid);
40 {
41 return FetchStoredAsset(uuid);
42 }
43
44 protected abstract AssetBase FetchStoredAsset(UUID uuid);
45 40
46 public abstract void CreateAsset(AssetBase asset); 41 public abstract void StoreAsset(AssetBase asset);
47 public abstract void UpdateAsset(AssetBase asset);
48 public abstract bool ExistsAsset(UUID uuid); 42 public abstract bool ExistsAsset(UUID uuid);
49 43
50 public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count); 44 public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs
index 5a30455..a03488b 100644
--- a/OpenSim/Data/GridDataBase.cs
+++ b/OpenSim/Data/GridDataBase.cs
@@ -38,9 +38,8 @@ namespace OpenSim.Data
38 public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); 38 public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
39 public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum); 39 public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
40 public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); 40 public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
41 public abstract DataResponse AddProfile(RegionProfileData profile); 41 public abstract DataResponse StoreProfile(RegionProfileData profile);
42 public abstract ReservationData GetReservationAtPoint(uint x, uint y); 42 public abstract ReservationData GetReservationAtPoint(uint x, uint y);
43 public abstract DataResponse UpdateProfile(RegionProfileData profile);
44 public abstract DataResponse DeleteProfile(string uuid); 43 public abstract DataResponse DeleteProfile(string uuid);
45 44
46 public abstract void Initialise(); 45 public abstract void Initialise();
diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs
index d13732b..2149bca 100644
--- a/OpenSim/Data/IAssetData.cs
+++ b/OpenSim/Data/IAssetData.cs
@@ -33,9 +33,8 @@ namespace OpenSim.Data
33{ 33{
34 public interface IAssetDataPlugin : IPlugin 34 public interface IAssetDataPlugin : IPlugin
35 { 35 {
36 AssetBase FetchAsset(UUID uuid); 36 AssetBase GetAsset(UUID uuid);
37 void CreateAsset(AssetBase asset); 37 void StoreAsset(AssetBase asset);
38 void UpdateAsset(AssetBase asset);
39 bool ExistsAsset(UUID uuid); 38 bool ExistsAsset(UUID uuid);
40 List<AssetMetadata> FetchAssetMetadataSet(int start, int count); 39 List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
41 void Initialise(string connect); 40 void Initialise(string connect);
diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs
index 4bf8646..8bd3811 100644
--- a/OpenSim/Data/IGridData.cs
+++ b/OpenSim/Data/IGridData.cs
@@ -99,18 +99,11 @@ namespace OpenSim.Data
99 bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); 99 bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
100 100
101 /// <summary> 101 /// <summary>
102 /// Adds a new profile to the database 102 /// Adds or updates a profile in the database
103 /// </summary> 103 /// </summary>
104 /// <param name="profile">The profile to add</param> 104 /// <param name="profile">The profile to add</param>
105 /// <returns>RESPONSE_OK if successful, error if not.</returns> 105 /// <returns>RESPONSE_OK if successful, error if not.</returns>
106 DataResponse AddProfile(RegionProfileData profile); 106 DataResponse StoreProfile(RegionProfileData profile);
107
108 /// <summary>
109 /// Updates a profile in the database
110 /// </summary>
111 /// <param name="profile"></param>
112 /// <returns></returns>
113 DataResponse UpdateProfile(RegionProfileData profile);
114 107
115 /// <summary> 108 /// <summary>
116 /// Remove a profile from the database 109 /// Remove a profile from the database
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index a542584..d193cf5 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Data.MSSQL
122 /// </summary> 122 /// </summary>
123 /// <param name="assetID">the asset UUID</param> 123 /// <param name="assetID">the asset UUID</param>
124 /// <returns></returns> 124 /// <returns></returns>
125 override protected AssetBase FetchStoredAsset(UUID assetID) 125 override public AssetBase GetAsset(UUID assetID)
126 { 126 {
127 string sql = "SELECT * FROM assets WHERE id = @id"; 127 string sql = "SELECT * FROM assets WHERE id = @id";
128 using (AutoClosingSqlCommand command = m_database.Query(sql)) 128 using (AutoClosingSqlCommand command = m_database.Query(sql))
@@ -152,7 +152,16 @@ namespace OpenSim.Data.MSSQL
152 /// Create asset in m_database 152 /// Create asset in m_database
153 /// </summary> 153 /// </summary>
154 /// <param name="asset">the asset</param> 154 /// <param name="asset">the asset</param>
155 override public void CreateAsset(AssetBase asset) 155 override public void StoreAsset(AssetBase asset)
156 {
157 if (ExistsAsset(asset.FullID))
158 UpdateAsset(asset);
159 else
160 InsertAsset(asset);
161 }
162
163
164 private void InsertAsset(AssetBase asset)
156 { 165 {
157 if (ExistsAsset(asset.FullID)) 166 if (ExistsAsset(asset.FullID))
158 { 167 {
@@ -208,7 +217,7 @@ namespace OpenSim.Data.MSSQL
208 /// Update asset in m_database 217 /// Update asset in m_database
209 /// </summary> 218 /// </summary>
210 /// <param name="asset">the asset</param> 219 /// <param name="asset">the asset</param>
211 override public void UpdateAsset(AssetBase asset) 220 private void UpdateAsset(AssetBase asset)
212 { 221 {
213 string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType, 222 string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType,
214 local = @local, temporary = @temporary, data = @data 223 local = @local, temporary = @temporary, data = @data
@@ -250,7 +259,7 @@ namespace OpenSim.Data.MSSQL
250 } 259 }
251 } 260 }
252 261
253// Commented out since currently unused - this probably should be called in FetchAsset() 262// Commented out since currently unused - this probably should be called in GetAsset()
254// private void UpdateAccessTime(AssetBase asset) 263// private void UpdateAccessTime(AssetBase asset)
255// { 264// {
256// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id")) 265// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
@@ -276,7 +285,7 @@ namespace OpenSim.Data.MSSQL
276 /// <returns>true if exist.</returns> 285 /// <returns>true if exist.</returns>
277 override public bool ExistsAsset(UUID uuid) 286 override public bool ExistsAsset(UUID uuid)
278 { 287 {
279 if (FetchAsset(uuid) != null) 288 if (GetAsset(uuid) != null)
280 { 289 {
281 return true; 290 return true;
282 } 291 }
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs
index 0ebbf4e..8a3d332 100644
--- a/OpenSim/Data/MSSQL/MSSQLGridData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs
@@ -272,26 +272,23 @@ namespace OpenSim.Data.MSSQL
272 /// </summary> 272 /// </summary>
273 /// <param name="profile">The profile to add</param> 273 /// <param name="profile">The profile to add</param>
274 /// <returns>A dataresponse enum indicating success</returns> 274 /// <returns>A dataresponse enum indicating success</returns>
275 override public DataResponse AddProfile(RegionProfileData profile) 275 override public DataResponse StoreProfile(RegionProfileData profile)
276 { 276 {
277 if (InsertRegionRow(profile)) 277 if (GetProfileByUUID(profile.UUID) == null)
278 { 278 {
279 return DataResponse.RESPONSE_OK; 279 if (InsertRegionRow(profile))
280 {
281 return DataResponse.RESPONSE_OK;
282 }
280 } 283 }
281 return DataResponse.RESPONSE_ERROR; 284 else
282 }
283
284 /// <summary>
285 /// Update the specified region in the database
286 /// </summary>
287 /// <param name="profile">The profile to update</param>
288 /// <returns>A dataresponse enum indicating success</returns>
289 override public DataResponse UpdateProfile(RegionProfileData profile)
290 {
291 if (UpdateRegionRow(profile))
292 { 285 {
293 return DataResponse.RESPONSE_OK; 286 if (UpdateRegionRow(profile))
287 {
288 return DataResponse.RESPONSE_OK;
289 }
294 } 290 }
291
295 return DataResponse.RESPONSE_ERROR; 292 return DataResponse.RESPONSE_ERROR;
296 } 293 }
297 294
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 0865083..66c34fe 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -135,7 +135,7 @@ namespace OpenSim.Data.MySQL
135 /// <param name="assetID">Asset UUID to fetch</param> 135 /// <param name="assetID">Asset UUID to fetch</param>
136 /// <returns>Return the asset</returns> 136 /// <returns>Return the asset</returns>
137 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks> 137 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks>
138 override protected AssetBase FetchStoredAsset(UUID assetID) 138 override public AssetBase GetAsset(UUID assetID)
139 { 139 {
140 AssetBase asset = null; 140 AssetBase asset = null;
141 lock (_dbConnection) 141 lock (_dbConnection)
@@ -168,7 +168,7 @@ namespace OpenSim.Data.MySQL
168 } 168 }
169 asset.Name = (string) dbReader["name"]; 169 asset.Name = (string) dbReader["name"];
170 asset.Type = (sbyte) dbReader["assetType"]; 170 asset.Type = (sbyte) dbReader["assetType"];
171 asset.Temporary = (bool)dbReader["temporary"]; 171 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
172 } 172 }
173 dbReader.Close(); 173 dbReader.Close();
174 cmd.Dispose(); 174 cmd.Dispose();
@@ -192,7 +192,7 @@ namespace OpenSim.Data.MySQL
192 /// </summary> 192 /// </summary>
193 /// <param name="asset">Asset UUID to create</param> 193 /// <param name="asset">Asset UUID to create</param>
194 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 194 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
195 override public void CreateAsset(AssetBase asset) 195 override public void StoreAsset(AssetBase asset)
196 { 196 {
197 lock (_dbConnection) 197 lock (_dbConnection)
198 { 198 {
@@ -285,15 +285,6 @@ namespace OpenSim.Data.MySQL
285 } 285 }
286 286
287 /// <summary> 287 /// <summary>
288 /// Update a asset in database, see <see cref="CreateAsset"/>
289 /// </summary>
290 /// <param name="asset">Asset UUID to update</param>
291 override public void UpdateAsset(AssetBase asset)
292 {
293 CreateAsset(asset);
294 }
295
296 /// <summary>
297 /// check if the asset UUID exist in database 288 /// check if the asset UUID exist in database
298 /// </summary> 289 /// </summary>
299 /// <param name="uuid">The asset UUID</param> 290 /// <param name="uuid">The asset UUID</param>
@@ -368,7 +359,7 @@ namespace OpenSim.Data.MySQL
368 metadata.Name = (string) dbReader["name"]; 359 metadata.Name = (string) dbReader["name"];
369 metadata.Description = (string) dbReader["description"]; 360 metadata.Description = (string) dbReader["description"];
370 metadata.Type = (sbyte) dbReader["assetType"]; 361 metadata.Type = (sbyte) dbReader["assetType"];
371 metadata.Temporary = (bool) dbReader["temporary"]; // Not sure if this is correct. 362 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
372 metadata.FullID = new UUID((string) dbReader["id"]); 363 metadata.FullID = new UUID((string) dbReader["id"]);
373 364
374 // Current SHA1s are not stored/computed. 365 // Current SHA1s are not stored/computed.
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs
index 0a5800b..1ec2609 100644
--- a/OpenSim/Data/MySQL/MySQLGridData.cs
+++ b/OpenSim/Data/MySQL/MySQLGridData.cs
@@ -391,7 +391,7 @@ namespace OpenSim.Data.MySQL
391 /// </summary> 391 /// </summary>
392 /// <param name="profile">The profile to add</param> 392 /// <param name="profile">The profile to add</param>
393 /// <returns>Successful?</returns> 393 /// <returns>Successful?</returns>
394 override public DataResponse AddProfile(RegionProfileData profile) 394 override public DataResponse StoreProfile(RegionProfileData profile)
395 { 395 {
396 MySQLSuperManager dbm = GetLockedConnection(); 396 MySQLSuperManager dbm = GetLockedConnection();
397 try { 397 try {
@@ -408,17 +408,6 @@ namespace OpenSim.Data.MySQL
408 } 408 }
409 409
410 /// <summary> 410 /// <summary>
411 /// Update a sim profile
412 /// </summary>
413 /// <param name="profile">The profile to update</param>
414 /// <returns>Sucessful?</returns>
415 /// <remarks>Same as AddProfile</remarks>
416 override public DataResponse UpdateProfile(RegionProfileData profile)
417 {
418 return AddProfile(profile);
419 }
420
421 /// <summary>
422 /// Deletes a sim profile from the database 411 /// Deletes a sim profile from the database
423 /// </summary> 412 /// </summary>
424 /// <param name="uuid">the sim UUID</param> 413 /// <param name="uuid">the sim UUID</param>
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index 9d8cec5..aaba15c 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -65,30 +65,24 @@ namespace OpenSim.Data.NHibernate
65 65
66 } 66 }
67 67
68 override protected AssetBase FetchStoredAsset(UUID uuid) 68 override public AssetBase GetAsset(UUID uuid)
69 { 69 {
70 return (AssetBase)manager.Get(typeof(AssetBase), uuid); 70 return (AssetBase)manager.Get(typeof(AssetBase), uuid);
71 } 71 }
72 72
73 private void Save(AssetBase asset) 73 override public void StoreAsset(AssetBase asset)
74 { 74 {
75 AssetBase temp = (AssetBase)manager.Get(typeof(AssetBase), asset.FullID); 75 AssetBase temp = (AssetBase)manager.Get(typeof(AssetBase), asset.FullID);
76 if (temp == null) 76 if (temp == null)
77 { 77 {
78 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
78 manager.Insert(asset); 79 manager.Insert(asset);
79 } 80 }
80 } 81 else
81 82 {
82 override public void CreateAsset(AssetBase asset) 83 m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID);
83 { 84 manager.Update(asset);
84 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID); 85 }
85 Save(asset);
86 }
87
88 override public void UpdateAsset(AssetBase asset)
89 {
90 m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID);
91 manager.Update(asset);
92 } 86 }
93 87
94 // private void LogAssetLoad(AssetBase asset) 88 // private void LogAssetLoad(AssetBase asset)
@@ -107,7 +101,7 @@ namespace OpenSim.Data.NHibernate
107 override public bool ExistsAsset(UUID uuid) 101 override public bool ExistsAsset(UUID uuid)
108 { 102 {
109 m_log.InfoFormat("[NHIBERNATE] ExistsAsset: {0}", uuid); 103 m_log.InfoFormat("[NHIBERNATE] ExistsAsset: {0}", uuid);
110 return (FetchAsset(uuid) != null); 104 return (GetAsset(uuid) != null);
111 } 105 }
112 106
113 /// <summary> 107 /// <summary>
diff --git a/OpenSim/Data/NHibernate/NHibernateGridData.cs b/OpenSim/Data/NHibernate/NHibernateGridData.cs
index fe8da59..018af62 100644
--- a/OpenSim/Data/NHibernate/NHibernateGridData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateGridData.cs
@@ -117,7 +117,7 @@ namespace OpenSim.Data.NHibernate
117 throw new NotImplementedException(); 117 throw new NotImplementedException();
118 } 118 }
119 119
120 public override DataResponse AddProfile(RegionProfileData profile) 120 public override DataResponse StoreProfile(RegionProfileData profile)
121 { 121 {
122 if (manager.Get(typeof(RegionProfileData), profile.Uuid) == null) 122 if (manager.Get(typeof(RegionProfileData), profile.Uuid) == null)
123 { 123 {
@@ -126,21 +126,9 @@ namespace OpenSim.Data.NHibernate
126 } 126 }
127 else 127 else
128 { 128 {
129 return DataResponse.RESPONSE_ERROR;
130 }
131 }
132
133 public override DataResponse UpdateProfile(RegionProfileData profile)
134 {
135 if (manager.Get(typeof(RegionProfileData), profile.Uuid) != null)
136 {
137 manager.Update(profile); 129 manager.Update(profile);
138 return DataResponse.RESPONSE_OK; 130 return DataResponse.RESPONSE_OK;
139 } 131 }
140 else
141 {
142 return DataResponse.RESPONSE_ERROR;
143 }
144 } 132 }
145 133
146 public override DataResponse DeleteProfile(string uuid) 134 public override DataResponse DeleteProfile(string uuid)
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index 72af7a0..3831467 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite
90 /// </summary> 90 /// </summary>
91 /// <param name="uuid">UUID of ... ?</param> 91 /// <param name="uuid">UUID of ... ?</param>
92 /// <returns>Asset base</returns> 92 /// <returns>Asset base</returns>
93 override protected AssetBase FetchStoredAsset(UUID uuid) 93 override public AssetBase GetAsset(UUID uuid)
94 { 94 {
95 lock (this) 95 lock (this)
96 { 96 {
@@ -119,18 +119,16 @@ namespace OpenSim.Data.SQLite
119 /// Create an asset 119 /// Create an asset
120 /// </summary> 120 /// </summary>
121 /// <param name="asset">Asset Base</param> 121 /// <param name="asset">Asset Base</param>
122 override public void CreateAsset(AssetBase asset) 122 override public void StoreAsset(AssetBase asset)
123 { 123 {
124 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); 124 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString());
125 if (ExistsAsset(asset.FullID)) 125 if (ExistsAsset(asset.FullID))
126 { 126 {
127 //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); 127 LogAssetLoad(asset);
128 } 128
129 else
130 {
131 lock (this) 129 lock (this)
132 { 130 {
133 using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) 131 using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn))
134 { 132 {
135 cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); 133 cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString()));
136 cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); 134 cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
@@ -144,29 +142,22 @@ namespace OpenSim.Data.SQLite
144 } 142 }
145 } 143 }
146 } 144 }
147 } 145 else
148
149 /// <summary>
150 /// Update an asset
151 /// </summary>
152 /// <param name="asset"></param>
153 override public void UpdateAsset(AssetBase asset)
154 {
155 LogAssetLoad(asset);
156
157 lock (this)
158 { 146 {
159 using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) 147 lock (this)
160 { 148 {
161 cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); 149 using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn))
162 cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); 150 {
163 cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); 151 cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString()));
164 cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); 152 cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
165 cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); 153 cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
166 cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); 154 cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
167 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); 155 cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
168 156 cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
169 cmd.ExecuteNonQuery(); 157 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
158
159 cmd.ExecuteNonQuery();
160 }
170 } 161 }
171 } 162 }
172 } 163 }
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs
index 4107594..18abb88 100644
--- a/OpenSim/Data/SQLite/SQLiteGridData.cs
+++ b/OpenSim/Data/SQLite/SQLiteGridData.cs
@@ -203,7 +203,7 @@ namespace OpenSim.Data.SQLite
203 /// </summary> 203 /// </summary>
204 /// <param name="profile">The profile to add</param> 204 /// <param name="profile">The profile to add</param>
205 /// <returns>A dataresponse enum indicating success</returns> 205 /// <returns>A dataresponse enum indicating success</returns>
206 override public DataResponse AddProfile(RegionProfileData profile) 206 override public DataResponse StoreProfile(RegionProfileData profile)
207 { 207 {
208 if (database.insertRow(profile)) 208 if (database.insertRow(profile))
209 { 209 {
@@ -215,17 +215,11 @@ namespace OpenSim.Data.SQLite
215 } 215 }
216 } 216 }
217 217
218 override public DataResponse UpdateProfile(RegionProfileData profile) 218 /// <summary>
219 {
220 return AddProfile(profile);
221 }
222
223 /// <summary>
224 /// Deletes a sim profile from the database 219 /// Deletes a sim profile from the database
225 /// </summary> 220 /// </summary>
226 /// <param name="uuid">the sim UUID</param> 221 /// <param name="uuid">the sim UUID</param>
227 /// <returns>Successful?</returns> 222 /// <returns>Successful?</returns>
228 //public DataResponse DeleteProfile(RegionProfileData profile)
229 override public DataResponse DeleteProfile(string uuid) 223 override public DataResponse DeleteProfile(string uuid)
230 { 224 {
231 Dictionary<string, string> param = new Dictionary<string, string>(); 225 Dictionary<string, string> param = new Dictionary<string, string>();
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index e5f7a50..64591fd 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -628,12 +628,12 @@ namespace OpenSim.Data.SQLite
628 628
629 public InventoryItemBase queryInventoryItem(UUID itemID) 629 public InventoryItemBase queryInventoryItem(UUID itemID)
630 { 630 {
631 return null; 631 return getInventoryItem(itemID);
632 } 632 }
633 633
634 public InventoryFolderBase queryInventoryFolder(UUID folderID) 634 public InventoryFolderBase queryInventoryFolder(UUID folderID)
635 { 635 {
636 return null; 636 return getInventoryFolder(folderID);
637 } 637 }
638 638
639 /// <summary> 639 /// <summary>
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
index 09131c1..1969d76 100644
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ b/OpenSim/Data/Tests/BasicAssetTest.cs
@@ -84,34 +84,34 @@ namespace OpenSim.Data.Tests
84 scrambler.Scramble(a2); 84 scrambler.Scramble(a2);
85 scrambler.Scramble(a3); 85 scrambler.Scramble(a3);
86 86
87 db.CreateAsset(a1); 87 db.StoreAsset(a1);
88 db.CreateAsset(a2); 88 db.StoreAsset(a2);
89 db.CreateAsset(a3); 89 db.StoreAsset(a3);
90 90
91 AssetBase a1a = db.FetchAsset(uuid1); 91 AssetBase a1a = db.GetAsset(uuid1);
92 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); 92 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
93 93
94 AssetBase a2a = db.FetchAsset(uuid2); 94 AssetBase a2a = db.GetAsset(uuid2);
95 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); 95 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
96 96
97 AssetBase a3a = db.FetchAsset(uuid3); 97 AssetBase a3a = db.GetAsset(uuid3);
98 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); 98 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
99 99
100 scrambler.Scramble(a1a); 100 scrambler.Scramble(a1a);
101 scrambler.Scramble(a2a); 101 scrambler.Scramble(a2a);
102 scrambler.Scramble(a3a); 102 scrambler.Scramble(a3a);
103 103
104 db.UpdateAsset(a1a); 104 db.StoreAsset(a1a);
105 db.UpdateAsset(a2a); 105 db.StoreAsset(a2a);
106 db.UpdateAsset(a3a); 106 db.StoreAsset(a3a);
107 107
108 AssetBase a1b = db.FetchAsset(uuid1); 108 AssetBase a1b = db.GetAsset(uuid1);
109 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); 109 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
110 110
111 AssetBase a2b = db.FetchAsset(uuid2); 111 AssetBase a2b = db.GetAsset(uuid2);
112 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); 112 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
113 113
114 AssetBase a3b = db.FetchAsset(uuid3); 114 AssetBase a3b = db.GetAsset(uuid3);
115 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); 115 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
116 116
117 Assert.That(db.ExistsAsset(uuid1), Is.True); 117 Assert.That(db.ExistsAsset(uuid1), Is.True);
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs
index de8fb48..df6c669 100644
--- a/OpenSim/Data/Tests/BasicGridTest.cs
+++ b/OpenSim/Data/Tests/BasicGridTest.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Data.Tests
70 reg.Uuid = regionUUID; 70 reg.Uuid = regionUUID;
71 reg.RegionName = regionName; 71 reg.RegionName = regionName;
72 72
73 db.AddProfile(reg); 73 db.StoreProfile(reg);
74 74
75 return reg; 75 return reg;
76 } 76 }
@@ -120,7 +120,7 @@ namespace OpenSim.Data.Tests
120 RegionProfileData retreg = db.GetProfileByUUID(region2); 120 RegionProfileData retreg = db.GetProfileByUUID(region2);
121 retreg.regionName = "Gotham City"; 121 retreg.regionName = "Gotham City";
122 122
123 db.UpdateProfile(retreg); 123 db.StoreProfile(retreg);
124 124
125 retreg = db.GetProfileByUUID(region2); 125 retreg = db.GetProfileByUUID(region2);
126 Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))"); 126 Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))");
@@ -135,13 +135,13 @@ namespace OpenSim.Data.Tests
135 retreg.RegionName = "Gotham Town"; 135 retreg.RegionName = "Gotham Town";
136 retreg.Uuid = region1; 136 retreg.Uuid = region1;
137 137
138 db.AddProfile(retreg); 138 db.StoreProfile(retreg);
139 139
140 retreg = db.GetProfileByUUID(region2); 140 retreg = db.GetProfileByUUID(region2);
141 retreg.RegionName = "Gothan Town"; 141 retreg.RegionName = "Gothan Town";
142 retreg.Uuid = region3; 142 retreg.Uuid = region3;
143 143
144 db.AddProfile(retreg); 144 db.StoreProfile(retreg);
145 145
146 List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10); 146 List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10);
147 147
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 7270f32..1fb01ba 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -503,7 +503,14 @@ namespace OpenSim.Framework
503 Owner = new UUID((string)h["owner"]); 503 Owner = new UUID((string)h["owner"]);
504 Serial = Convert.ToInt32((string)h["serial"]); 504 Serial = Convert.ToInt32((string)h["serial"]);
505 VisualParams = (byte[])h["visual_params"]; 505 VisualParams = (byte[])h["visual_params"];
506 Texture = new Primitive.TextureEntry((byte[])h["texture"], 0, ((byte[])h["texture"]).Length); 506
507 if (h.Contains("texture"))
508 {
509 byte[] te = h["texture"] as byte[];
510 if (te != null && te.Length > 0)
511 Texture = new Primitive.TextureEntry(te, 0, te.Length);
512 }
513
507 AvatarHeight = (float)Convert.ToDouble((string)h["avatar_height"]); 514 AvatarHeight = (float)Convert.ToDouble((string)h["avatar_height"]);
508 515
509 m_wearables = new AvatarWearable[MAX_WEARABLES]; 516 m_wearables = new AvatarWearable[MAX_WEARABLES];
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index ca641d0..238810a 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -653,7 +653,9 @@ namespace OpenSim.Framework.Communications.Cache
653 653
654 if (RootFolder.DeleteItem(item.ID)) 654 if (RootFolder.DeleteItem(item.ID))
655 { 655 {
656 return m_InventoryService.DeleteItem(item); 656 List<UUID> uuids = new List<UUID>();
657 uuids.Add(itemID);
658 return m_InventoryService.DeleteItems(this.UserProfile.ID, uuids);
657 } 659 }
658 } 660 }
659 else 661 else
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index c9f5236..7f1c7e9 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache
184 // Commented out for now. The implementation needs to be improved by protecting against race conditions, 184 // Commented out for now. The implementation needs to be improved by protecting against race conditions,
185 // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via 185 // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via
186 // returning a read only class from the cache). 186 // returning a read only class from the cache).
187// public bool UpdateProfile(UserProfileData userProfile) 187// public bool StoreProfile(UserProfileData userProfile)
188// { 188// {
189// lock (m_userProfilesById) 189// lock (m_userProfilesById)
190// { 190// {
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
index 670c9ff..933fa12 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
@@ -110,14 +110,14 @@ namespace OpenSim.Framework.Communications.Tests
110 IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; 110 IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin;
111 111
112 // Check that we can't update info before it exists 112 // Check that we can't update info before it exists
113 Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); 113 Assert.That(userCacheService.StoreProfile(newProfile), Is.False);
114 Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); 114 Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null);
115 115
116 // Check that we can update a profile once it exists 116 // Check that we can update a profile once it exists
117 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 117 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
118 lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); 118 lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId);
119 119
120 Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); 120 Assert.That(userCacheService.StoreProfile(newProfile), Is.True);
121 UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; 121 UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile;
122 Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); 122 Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName));
123 Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); 123 Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName));
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
index 22dcef9..57a908e 100644
--- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
@@ -532,6 +532,11 @@ namespace OpenSim.Framework.Communications.Tests
532 return false; 532 return false;
533 } 533 }
534 534
535 public bool DeleteFolders(UUID ownerID, List<UUID> ids)
536 {
537 return false;
538 }
539
535 public bool PurgeFolder(InventoryFolderBase folder) 540 public bool PurgeFolder(InventoryFolderBase folder)
536 { 541 {
537 return false; 542 return false;
@@ -547,7 +552,12 @@ namespace OpenSim.Framework.Communications.Tests
547 return false; 552 return false;
548 } 553 }
549 554
550 public bool DeleteItem(InventoryItemBase item) 555 public bool MoveItems(UUID owner, List<InventoryItemBase> items)
556 {
557 return false;
558 }
559
560 public bool DeleteItems(UUID owner, List<UUID> items)
551 { 561 {
552 return false; 562 return false;
553 } 563 }
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs
index 3387013..06136ff 100644
--- a/OpenSim/Framework/Console/CommandConsole.cs
+++ b/OpenSim/Framework/Console/CommandConsole.cs
@@ -576,7 +576,7 @@ namespace OpenSim.Framework.Console
576 576
577 public void Prompt() 577 public void Prompt()
578 { 578 {
579 string line = ReadLine(m_defaultPrompt, true, true); 579 string line = ReadLine(m_defaultPrompt + "# ", true, true);
580 580
581 if (line != String.Empty) 581 if (line != String.Empty)
582 { 582 {
@@ -592,7 +592,7 @@ namespace OpenSim.Framework.Console
592 592
593 public override string ReadLine(string p, bool isCommand, bool e) 593 public override string ReadLine(string p, bool isCommand, bool e)
594 { 594 {
595 System.Console.Write("{0}", prompt); 595 System.Console.Write("{0}", p);
596 string cmdinput = System.Console.ReadLine(); 596 string cmdinput = System.Console.ReadLine();
597 597
598 if (isCommand) 598 if (isCommand)
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 5e258ae..0a51266 100644
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Console
48 /// </summary> 48 /// </summary>
49 public string DefaultPrompt 49 public string DefaultPrompt
50 { 50 {
51 set { m_defaultPrompt = value + "# "; } 51 set { m_defaultPrompt = value; }
52 get { return m_defaultPrompt; } 52 get { return m_defaultPrompt; }
53 } 53 }
54 protected string m_defaultPrompt; 54 protected string m_defaultPrompt;
@@ -123,7 +123,7 @@ namespace OpenSim.Framework.Console
123 123
124 public virtual string ReadLine(string p, bool isCommand, bool e) 124 public virtual string ReadLine(string p, bool isCommand, bool e)
125 { 125 {
126 System.Console.Write("{0}", prompt); 126 System.Console.Write("{0}", p);
127 string cmdinput = System.Console.ReadLine(); 127 string cmdinput = System.Console.ReadLine();
128 128
129 return cmdinput; 129 return cmdinput;
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index da8556a..1810614 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -217,6 +217,12 @@ namespace OpenSim.Framework.Console
217 id.AppendChild(xmldoc.CreateTextNode(sessionID.ToString())); 217 id.AppendChild(xmldoc.CreateTextNode(sessionID.ToString()));
218 218
219 rootElement.AppendChild(id); 219 rootElement.AppendChild(id);
220
221 XmlElement prompt = xmldoc.CreateElement("", "Prompt", "");
222 prompt.AppendChild(xmldoc.CreateTextNode(DefaultPrompt));
223
224 rootElement.AppendChild(prompt);
225
220 rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc)); 226 rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc));
221 227
222 reply["str_response_string"] = xmldoc.InnerXml; 228 reply["str_response_string"] = xmldoc.InnerXml;
diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs
index a3c1032..9aa5d03 100644
--- a/OpenSim/Framework/GridConfig.cs
+++ b/OpenSim/Framework/GridConfig.cs
@@ -45,6 +45,8 @@ namespace OpenSim.Framework
45 public string SimSendKey = String.Empty; 45 public string SimSendKey = String.Empty;
46 public string UserRecvKey = String.Empty; 46 public string UserRecvKey = String.Empty;
47 public string UserSendKey = String.Empty; 47 public string UserSendKey = String.Empty;
48 public string ConsoleUser = String.Empty;
49 public string ConsolePass = String.Empty;
48 50
49 public GridConfig(string description, string filename) 51 public GridConfig(string description, string filename)
50 { 52 {
@@ -95,6 +97,12 @@ namespace OpenSim.Framework
95 "Allow regions to register immediately upon grid server startup? true/false", 97 "Allow regions to register immediately upon grid server startup? true/false",
96 "True", 98 "True",
97 false); 99 false);
100 m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
101 "Remote console access user name [Default: disabled]", "", false);
102
103 m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
104 "Remote console access password [Default: disabled]", "", false);
105
98 } 106 }
99 107
100 public bool handleIncomingConfiguration(string configuration_key, object configuration_result) 108 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@@ -140,9 +148,15 @@ namespace OpenSim.Framework
140 case "allow_region_registration": 148 case "allow_region_registration":
141 AllowRegionRegistration = (bool)configuration_result; 149 AllowRegionRegistration = (bool)configuration_result;
142 break; 150 break;
151 case "console_user":
152 ConsoleUser = (string)configuration_result;
153 break;
154 case "console_pass":
155 ConsolePass = (string)configuration_result;
156 break;
143 } 157 }
144 158
145 return true; 159 return true;
146 } 160 }
147 } 161 }
148} \ No newline at end of file 162}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index e451dd8..444adf9 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -254,13 +254,13 @@ namespace OpenSim.Framework
254 string newName); 254 string newName);
255 255
256 public delegate void MoveInventoryItem( 256 public delegate void MoveInventoryItem(
257 IClientAPI remoteClient, UUID folderID, UUID itemID, int length, string newName); 257 IClientAPI remoteClient, List<InventoryItemBase> items);
258 258
259 public delegate void RemoveInventoryItem( 259 public delegate void RemoveInventoryItem(
260 IClientAPI remoteClient, UUID itemID); 260 IClientAPI remoteClient, List<UUID> itemIDs);
261 261
262 public delegate void RemoveInventoryFolder( 262 public delegate void RemoveInventoryFolder(
263 IClientAPI remoteClient, UUID folderID); 263 IClientAPI remoteClient, List<UUID> folderIDs);
264 264
265 public delegate void RequestAsset(IClientAPI remoteClient, RequestAssetArgs transferRequest); 265 public delegate void RequestAsset(IClientAPI remoteClient, RequestAssetArgs transferRequest);
266 266
diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs
index 05f11a4..1869d48 100644
--- a/OpenSim/Framework/InventoryFolderBase.cs
+++ b/OpenSim/Framework/InventoryFolderBase.cs
@@ -78,6 +78,12 @@ namespace OpenSim.Framework
78 ID = id; 78 ID = id;
79 } 79 }
80 80
81 public InventoryFolderBase(UUID id, UUID owner)
82 {
83 ID = id;
84 Owner = owner;
85 }
86
81 public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) 87 public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version)
82 { 88 {
83 ID = id; 89 ID = id;
diff --git a/OpenSim/Framework/MessageServerConfig.cs b/OpenSim/Framework/MessageServerConfig.cs
index d0ceebc..884c0ea 100644
--- a/OpenSim/Framework/MessageServerConfig.cs
+++ b/OpenSim/Framework/MessageServerConfig.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Framework
46 public string UserRecvKey = String.Empty; 46 public string UserRecvKey = String.Empty;
47 public string UserSendKey = String.Empty; 47 public string UserSendKey = String.Empty;
48 public string UserServerURL = String.Empty; 48 public string UserServerURL = String.Empty;
49 public string ConsoleUser = String.Empty;
50 public string ConsolePass = String.Empty;
49 51
50 public MessageServerConfig(string description, string filename) 52 public MessageServerConfig(string description, string filename)
51 { 53 {
@@ -88,6 +90,12 @@ namespace OpenSim.Framework
88 "Use SSL? true/false", ConfigSettings.DefaultMessageServerHttpSSL.ToString(), false); 90 "Use SSL? true/false", ConfigSettings.DefaultMessageServerHttpSSL.ToString(), false);
89 m_configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING, 91 m_configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
90 "My Published IP Address", "127.0.0.1", false); 92 "My Published IP Address", "127.0.0.1", false);
93 m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
94 "Remote console access user name [Default: disabled]", "", false);
95
96 m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
97 "Remote console access password [Default: disabled]", "", false);
98
91 } 99 }
92 100
93 public bool handleIncomingConfiguration(string configuration_key, object configuration_result) 101 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@@ -130,9 +138,15 @@ namespace OpenSim.Framework
130 case "published_ip": 138 case "published_ip":
131 MessageServerIP = (string) configuration_result; 139 MessageServerIP = (string) configuration_result;
132 break; 140 break;
141 case "console_user":
142 ConsoleUser = (string)configuration_result;
143 break;
144 case "console_pass":
145 ConsolePass = (string)configuration_result;
146 break;
133 } 147 }
134 148
135 return true; 149 return true;
136 } 150 }
137 } 151 }
138} \ No newline at end of file 152}
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
index bc046cf..c6958de 100644
--- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
+++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Framework.Servers
57 57
58 protected override AssetBase GetAsset(UUID assetID) 58 protected override AssetBase GetAsset(UUID assetID)
59 { 59 {
60 return m_assetProvider.FetchAsset(assetID); 60 return m_assetProvider.GetAsset(assetID);
61 } 61 }
62 } 62 }
63} 63}
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
index ec2f9ec..2ef4a36 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Framework.Servers.HttpServer
75 WebRequest request = WebRequest.Create(requestUrl); 75 WebRequest request = WebRequest.Create(requestUrl);
76 request.Method = verb; 76 request.Method = verb;
77 request.ContentType = "text/xml"; 77 request.ContentType = "text/xml";
78 request.Timeout = 20000;
78 79
79 MemoryStream buffer = new MemoryStream(); 80 MemoryStream buffer = new MemoryStream();
80 81
@@ -98,7 +99,9 @@ namespace OpenSim.Framework.Servers.HttpServer
98 { 99 {
99 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 100 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
100 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); 101 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream());
102 resp.Close();
101 } 103 }
104 requestStream.Close();
102 return deserial; 105 return deserial;
103 } 106 }
104 } 107 }
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
index 09ef95b..ec9bd4f 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Framework.Servers.HttpServer
62 WebRequest request = WebRequest.Create(requestUrl); 62 WebRequest request = WebRequest.Create(requestUrl);
63 request.Method = verb; 63 request.Method = verb;
64 64
65 if (verb == "POST") 65 if ((verb == "POST") || (verb == "PUT"))
66 { 66 {
67 request.ContentType = "text/xml"; 67 request.ContentType = "text/xml";
68 68
diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
index 419b408..8bf406c 100644
--- a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
+++ b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Framework.Servers
57 AssetBase asset = (AssetBase) xs.Deserialize(request); 57 AssetBase asset = (AssetBase) xs.Deserialize(request);
58 58
59 m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID); 59 m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID);
60 m_assetProvider.CreateAsset(asset); 60 m_assetProvider.StoreAsset(asset);
61 61
62 return new byte[] {}; 62 return new byte[] {};
63 } 63 }
diff --git a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs
index 35da73f..be3f518 100644
--- a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs
+++ b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs
@@ -128,7 +128,7 @@ namespace OpenSim.Framework.Servers.Tests
128 IAssetDataPlugin assetDataPlugin = new TestAssetDataPlugin(); 128 IAssetDataPlugin assetDataPlugin = new TestAssetDataPlugin();
129 handler = new GetAssetStreamHandler(assetDataPlugin); 129 handler = new GetAssetStreamHandler(assetDataPlugin);
130 130
131 assetDataPlugin.CreateAsset(asset); 131 assetDataPlugin.StoreAsset(asset);
132 return asset; 132 return asset;
133 } 133 }
134 } 134 }
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs
index 31838ad..16f265c 100644
--- a/OpenSim/Framework/UserConfig.cs
+++ b/OpenSim/Framework/UserConfig.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Framework
46 public bool HttpSSL = ConfigSettings.DefaultUserServerHttpSSL; 46 public bool HttpSSL = ConfigSettings.DefaultUserServerHttpSSL;
47 public uint DefaultUserLevel = 0; 47 public uint DefaultUserLevel = 0;
48 public string LibraryXmlfile = ""; 48 public string LibraryXmlfile = "";
49 public string ConsoleUser = String.Empty;
50 public string ConsolePass = String.Empty;
49 51
50 private Uri m_inventoryUrl; 52 private Uri m_inventoryUrl;
51 53
@@ -155,6 +157,12 @@ namespace OpenSim.Framework
155 m_configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 157 m_configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
156 "Minimum Level a user should have to login [0 default]", "0", false); 158 "Minimum Level a user should have to login [0 default]", "0", false);
157 159
160 m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
161 "Remote console access user name [Default: disabled]", "", false);
162
163 m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
164 "Remote console access password [Default: disabled]", "", false);
165
158 } 166 }
159 167
160 public bool handleIncomingConfiguration(string configuration_key, object configuration_result) 168 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@@ -209,6 +217,12 @@ namespace OpenSim.Framework
209 case "library_location": 217 case "library_location":
210 LibraryXmlfile = (string)configuration_result; 218 LibraryXmlfile = (string)configuration_result;
211 break; 219 break;
220 case "console_user":
221 ConsoleUser = (string)configuration_result;
222 break;
223 case "console_pass":
224 ConsolePass = (string)configuration_result;
225 break;
212 } 226 }
213 227
214 return true; 228 return true;
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs
deleted file mode 100644
index 79b6c73..0000000
--- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryConfig.cs
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31using OpenSim.Framework;
32using log4net;
33using Nini.Config;
34
35namespace OpenSim.Grid.AssetInventoryServer
36{
37 public static class AssetInventoryConfig
38 {
39 public const string CONFIG_FILE = "AssetInventoryServer.ini";
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 public static IConfigSource LoadConfig()
43 {
44 IConfigSource configSource = new IniConfigSource();
45 configSource.AddConfig("Startup");
46 return LoadConfig(configSource);
47 }
48
49 public static IConfigSource LoadConfig(IConfigSource source)
50 {
51 string iniFileName = source.Configs["Startup"].GetString("inifile", CONFIG_FILE);
52 string iniFilePath = Path.Combine(Util.configDir(), iniFileName);
53
54 source.Merge(DefaultConfig());
55
56 if (!File.Exists(iniFilePath))
57 {
58 m_log.FatalFormat("[CONFIG]: File {0} not found, could not load any configuration.", iniFilePath);
59 m_log.FatalFormat("[CONFIG]: Did you copy the AssetInventoryServer.ini.example file to AssetInventoryServer.ini?");
60 Environment.Exit(1);
61 }
62
63 source.Merge(new IniConfigSource(iniFilePath));
64 return source;
65 }
66
67 private static IConfigSource DefaultConfig()
68 {
69 IConfigSource result = new IniConfigSource();
70
71 {
72 IConfig config = result.AddConfig("Config");
73 config.Set("listen_port", 8003);
74 config.Set("assetset_location", String.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar));
75 }
76
77 {
78 IConfig config = result.AddConfig("Plugins");
79 config.Set("asset_storage_provider", "OpenSimAssetStorage");
80 config.Set("inventory_storage_provider", "OpenSimInventoryStorage");
81 config.Set("authentication_provider", "NullAuthentication");
82 config.Set("authorization_provider", "AuthorizeAll");
83 config.Set("metrics_provider", "NullMetrics");
84 config.Set("frontends", "ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend");
85 }
86
87 {
88 IConfig config = result.AddConfig("OpenSim");
89 config.Set("asset_database_provider", "OpenSim.Data.MySQL.dll");
90 config.Set("inventory_database_provider", "OpenSim.Data.MySQL.dll");
91 config.Set("asset_database_connect", String.Empty);
92 config.Set("inventory_database_connect", String.Empty);
93 }
94
95 return result;
96 }
97 }
98}
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
deleted file mode 100644
index 16b9d9e..0000000
--- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
+++ /dev/null
@@ -1,216 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using OpenSim.Framework;
32using OpenSim.Framework.Servers;
33using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Framework.Console;
35using OpenSim.Framework.AssetLoader.Filesystem;
36using Nini.Config;
37using log4net;
38
39namespace OpenSim.Grid.AssetInventoryServer
40{
41 public class AssetInventoryServer : BaseOpenSimServer
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 public IConfigSource ConfigFile;
45
46 public IAssetStorageProvider StorageProvider;
47 public IInventoryStorageProvider InventoryProvider;
48 public IAuthenticationProvider AuthenticationProvider;
49 public IAuthorizationProvider AuthorizationProvider;
50 public IMetricsProvider MetricsProvider;
51
52 private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>();
53 private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>();
54
55 public AssetInventoryServer(IConfigSource config)
56 {
57 ConfigFile = config;
58
59 m_console = new LocalConsole("AssetInventory");
60 MainConsole.Instance = m_console;
61 }
62
63 public bool Start()
64 {
65 Startup();
66 m_log.Info("[ASSETINVENTORY]: Starting AssetInventory Server");
67
68 try
69 {
70 ConfigFile = AssetInventoryConfig.LoadConfig(ConfigFile);
71 }
72 catch (Exception)
73 {
74 m_log.Error("[ASSETINVENTORY]: Failed to load the config.");
75 return false;
76 }
77
78 StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AssetStorageProvider",
79 "asset_storage_provider", false) as IAssetStorageProvider;
80 m_backends.Add(StorageProvider);
81
82 InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryStorageProvider",
83 "inventory_storage_provider", false) as IInventoryStorageProvider;
84 m_backends.Add(InventoryProvider);
85
86 MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider",
87 "metrics_provider", false) as IMetricsProvider;
88 m_backends.Add(MetricsProvider);
89
90 try
91 {
92 InitHttpServer((uint) ConfigFile.Configs["Config"].GetInt("listen_port"));
93 }
94 catch (Exception ex)
95 {
96 m_log.Error("[ASSETINVENTORY]: Initializing the HTTP server failed, shutting down: " + ex.Message);
97 Shutdown();
98 return false;
99 }
100
101 LoadDefaultAssets();
102
103 AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider",
104 "authentication_provider", false) as IAuthenticationProvider;
105 m_backends.Add(AuthenticationProvider);
106
107 AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider",
108 "authorization_provider", false) as IAuthorizationProvider;
109 m_backends.Add(AuthorizationProvider);
110
111 m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", "frontends"));
112
113 // Inform the user if we don't have any frontends at this point.
114 if (m_frontends.Count == 0)
115 m_log.Info("[ASSETINVENTORY]: Starting with no frontends loaded, which isn't extremely useful. Did you set the 'frontends' configuration parameter?");
116
117 return true;
118 }
119
120 public void Work()
121 {
122 m_console.Output("Enter help for a list of commands");
123
124 while (true)
125 {
126 m_console.Prompt();
127 }
128 }
129
130 public override void ShutdownSpecific()
131 {
132 foreach (IAssetInventoryServerPlugin plugin in m_frontends)
133 {
134 m_log.Debug("[ASSETINVENTORY]: Disposing plugin " + plugin.Name);
135 try { plugin.Dispose(); }
136 catch (Exception ex)
137 { m_log.ErrorFormat("[ASSETINVENTORY]: Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
138 }
139
140 foreach (IAssetInventoryServerPlugin plugin in m_backends)
141 {
142 m_log.Debug("[ASSETINVENTORY]: Disposing plugin " + plugin.Name);
143 try { plugin.Dispose(); }
144 catch (Exception ex)
145 { m_log.ErrorFormat("[ASSETINVENTORY]: Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
146 }
147
148 if (HttpServer != null)
149 HttpServer.Stop();
150 }
151
152 void InitHttpServer(uint port)
153 {
154 m_httpServer = new BaseHttpServer(port);
155 m_httpServer.Start();
156
157 m_log.Info("[ASSETINVENTORY]: AssetInventory server is listening on port " + port);
158 }
159
160 private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string configParam, bool optional)
161 {
162 IAssetInventoryServerPlugin result = null;
163 List<IAssetInventoryServerPlugin> plugins = LoadAssetInventoryServerPlugins(addinPath, configParam);
164
165 if (plugins.Count == 1)
166 {
167 result = plugins[0];
168 }
169 else if (plugins.Count > 1)
170 {
171 m_log.ErrorFormat("[ASSETINVENTORY]: Only 1 plugin expected for extension point '{0}', {1} plugins loaded. Check the '{2}' parameter in the config file.",
172 addinPath, plugins.Count, configParam);
173 Shutdown();
174 Environment.Exit(0);
175 }
176 else if (!optional)
177 {
178 m_log.ErrorFormat("[ASSETINVENTORY]: The extension point '{0}' is not optional. Check the '{1}' parameter in the config file.", addinPath, configParam);
179 Shutdown();
180 Environment.Exit(0);
181 }
182
183 return result;
184 }
185
186 private List<IAssetInventoryServerPlugin> LoadAssetInventoryServerPlugins(string addinPath, string configParam)
187 {
188 PluginLoader<IAssetInventoryServerPlugin> loader = new PluginLoader<IAssetInventoryServerPlugin>(new AssetInventoryServerPluginInitialiser(this));
189 loader.Add(addinPath, new PluginIdFilter(ConfigFile.Configs["Plugins"].GetString(configParam)));
190
191 try
192 {
193 loader.Load();
194 }
195 catch (PluginNotInitialisedException e)
196 {
197 m_log.ErrorFormat("[ASSETINVENTORY]: Error initialising plugin '{0}' for extension point '{1}'.", e.Message, addinPath);
198 Shutdown();
199 Environment.Exit(0);
200 }
201
202 return loader.Plugins;
203 }
204
205 private void LoadDefaultAssets()
206 {
207 AssetLoaderFileSystem assetLoader = new AssetLoaderFileSystem();
208 assetLoader.ForEachDefaultXmlAsset(ConfigFile.Configs["Config"].GetString("assetset_location"), StoreAsset);
209 }
210
211 private void StoreAsset(AssetBase asset)
212 {
213 StorageProvider.TryCreateAsset(asset);
214 }
215 }
216}
diff --git a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs
deleted file mode 100644
index e808dd3..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs
+++ /dev/null
@@ -1,143 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Grid.AssetInventoryServer
34{
35 /// <summary>
36 /// Response from a call to a backend provider
37 /// </summary>
38 public enum BackendResponse
39 {
40 /// <summary>The call succeeded</summary>
41 Success,
42 /// <summary>The resource requested was not found</summary>
43 NotFound,
44 /// <summary>A server failure prevented the call from
45 /// completing</summary>
46 Failure
47 }
48
49 public class AssetInventoryServerPluginInitialiser : PluginInitialiserBase
50 {
51 private AssetInventoryServer server;
52
53 public AssetInventoryServerPluginInitialiser(AssetInventoryServer server)
54 {
55 this.server = server;
56 }
57
58 public override void Initialise(IPlugin plugin)
59 {
60 IAssetInventoryServerPlugin p = plugin as IAssetInventoryServerPlugin;
61 p.Initialise (server);
62 }
63 }
64
65 #region Interfaces
66
67 public interface IAssetInventoryServerPlugin : IPlugin
68 {
69 void Initialise(AssetInventoryServer server);
70 }
71
72 public interface IAssetStorageProvider : IAssetInventoryServerPlugin
73 {
74 BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata);
75 BackendResponse TryFetchData(UUID assetID, out byte[] assetData);
76 BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset);
77 BackendResponse TryCreateAsset(AssetBase asset);
78 BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID);
79 int ForEach(Action<AssetMetadata> action, int start, int count);
80 }
81
82 public interface IInventoryStorageProvider : IAssetInventoryServerPlugin
83 {
84 BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item);
85 BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder);
86 BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents);
87 BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders);
88 BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory);
89
90 BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures);
91
92 BackendResponse TryCreateItem(Uri owner, InventoryItemBase item);
93 BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder);
94 BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder);
95
96 BackendResponse TryDeleteItem(Uri owner, UUID itemID);
97 BackendResponse TryDeleteFolder(Uri owner, UUID folderID);
98 BackendResponse TryPurgeFolder(Uri owner, UUID folderID);
99 }
100
101 public interface IAuthenticationProvider : IAssetInventoryServerPlugin
102 {
103 void AddIdentifier(UUID authToken, Uri identifier);
104 bool RemoveIdentifier(UUID authToken);
105 bool TryGetIdentifier(UUID authToken, out Uri identifier);
106 }
107
108 public interface IAuthorizationProvider : IAssetInventoryServerPlugin
109 {
110 bool IsMetadataAuthorized(UUID authToken, UUID assetID);
111 /// <summary>
112 /// Authorizes access to the data for an asset. Access to asset data
113 /// also implies access to the metadata for that asset
114 /// </summary>
115 /// <param name="authToken">Authentication token to check for access</param>
116 /// <param name="assetID">ID of the requested asset</param>
117 /// <returns>True if access is granted, otherwise false</returns>
118 bool IsDataAuthorized(UUID authToken, UUID assetID);
119 bool IsCreateAuthorized(UUID authToken);
120
121 bool IsInventoryReadAuthorized(UUID authToken, Uri owner);
122 bool IsInventoryWriteAuthorized(UUID authToken, Uri owner);
123 }
124
125 public interface IMetricsProvider : IAssetInventoryServerPlugin
126 {
127 void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time);
128 void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time);
129 void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time);
130
131 void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time);
132 void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time);
133 void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time);
134 void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time);
135 void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time);
136 void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time);
137 void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time);
138 void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time);
139 void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time);
140 }
141
142 #endregion Interfaces
143}
diff --git a/OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs b/OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs
deleted file mode 100644
index 4f42a20..0000000
--- a/OpenSim/Grid/AssetInventoryServer/InventoryObjects.cs
+++ /dev/null
@@ -1,139 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Grid.AssetInventoryServer
34{
35 //public class InventoryBase
36 //{
37 //}
38
39 //public class InventoryFolder : InventoryBase
40 //{
41 // public string Name;
42 // public UUID Owner;
43 // public UUID ParentID;
44 // public UUID ID;
45 // public short Type;
46 // public ushort Version;
47
48 // [NonSerialized]
49 // public Dictionary<UUID, InventoryBase> Children = new Dictionary<UUID, InventoryBase>();
50
51 // public InventoryFolder()
52 // {
53 // }
54
55 // public InventoryFolder(string name, UUID ownerID, UUID parentID, short assetType)
56 // {
57 // ID = UUID.Random();
58 // Name = name;
59 // Owner = ownerID;
60 // ParentID = parentID;
61 // Type = assetType;
62 // Version = 1;
63 // }
64
65 // public override string ToString()
66 // {
67 // return String.Format("{0} ({1})", Name, ID);
68 // }
69 //}
70
71 //public class InventoryItem : InventoryBase
72 //{
73 // public UUID ID;
74 // public int InvType;
75 // public UUID Folder;
76 // public UUID Owner;
77 // public UUID Creator;
78 // public string Name;
79 // public string Description;
80 // public uint NextPermissions;
81 // public uint CurrentPermissions;
82 // public uint BasePermissions;
83 // public uint EveryOnePermissions;
84 // public uint GroupPermissions;
85 // public int AssetType;
86 // public UUID AssetID;
87 // public UUID GroupID;
88 // public bool GroupOwned;
89 // public int SalePrice;
90 // public byte SaleType;
91 // public uint Flags;
92 // public int CreationDate;
93
94 // public override string ToString()
95 // {
96 // return String.Format("{0} ({1})", Name, ID);
97 // }
98 //}
99
100 public class InventoryFolderWithChildren : InventoryFolderBase
101 {
102 public InventoryFolderWithChildren()
103 {
104 }
105
106 public InventoryFolderWithChildren(InventoryFolderBase folder)
107 {
108 // from InventoryNodeBase
109 Name = folder.Name;
110 ID = folder.ID;
111 Owner = folder.Owner;
112
113 // from InventoryFolderBase
114 ParentID = folder.ParentID;
115 Type = folder.Type;
116 Version = folder.Version;
117 }
118
119 public InventoryFolderWithChildren(string name, UUID ownerID, UUID parentID, short assetType)
120 {
121 ID = UUID.Random();
122 Name = name;
123 Owner = ownerID;
124 ParentID = parentID;
125 Type = assetType;
126 Version = 1;
127 }
128
129 [NonSerialized]
130 public Dictionary<UUID, InventoryNodeBase> Children = new Dictionary<UUID, InventoryNodeBase>();
131 }
132
133 public class InventoryCollection
134 {
135 public Dictionary<UUID, InventoryFolderWithChildren> Folders;
136 public Dictionary<UUID, InventoryItemBase> Items;
137 public UUID UserID;
138 }
139}
diff --git a/OpenSim/Grid/AssetInventoryServer/Main.cs b/OpenSim/Grid/AssetInventoryServer/Main.cs
deleted file mode 100644
index 598b754..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Main.cs
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using Nini.Config;
30using log4net.Config;
31using log4net;
32using System.Reflection;
33
34namespace OpenSim.Grid.AssetInventoryServer
35{
36 class MainEntry
37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 static void Main(string[] args)
41 {
42 XmlConfigurator.Configure();
43
44 ArgvConfigSource configSource = new ArgvConfigSource(args);
45 configSource.AddSwitch("Startup", "inifile");
46
47 AssetInventoryServer server = new AssetInventoryServer(configSource);
48 if (server.Start())
49 {
50 Console.CancelKeyPress +=
51 delegate(object sender, ConsoleCancelEventArgs e)
52 {
53 m_log.Info("AssetInventory server is shutting down...");
54 server.Shutdown();
55 Environment.Exit(0);
56 };
57
58 server.Work();
59 }
60 }
61 }
62}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs
deleted file mode 100644
index 3d0a283..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/AuthorizeAllPlugin.cs
+++ /dev/null
@@ -1,105 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using OpenMetaverse;
31using OpenSim.Framework;
32using log4net;
33
34namespace OpenSim.Grid.AssetInventoryServer.Plugins
35{
36 public class AuthorizeAllPlugin : IAuthorizationProvider
37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39 //private AssetInventoryServer m_server;
40
41 public AuthorizeAllPlugin()
42 {
43 }
44
45 #region IPlugin implementation
46
47 public void Initialise(AssetInventoryServer server)
48 {
49 //m_server = server;
50
51 m_log.Info("[AUTHORIZEALL]: Authorize All loaded.");
52 }
53
54 /// <summary>
55 /// <para>Initialises asset interface</para>
56 /// </summary>
57 public void Initialise()
58 {
59 m_log.InfoFormat("[AUTHORIZEALL]: {0} cannot be default-initialized!", Name);
60 throw new PluginNotInitialisedException(Name);
61 }
62
63 public void Dispose()
64 {
65 }
66
67 public string Version
68 {
69 // TODO: this should be something meaningful and not hardcoded?
70 get { return "0.1"; }
71 }
72
73 public string Name
74 {
75 get { return "AuthorizeAll"; }
76 }
77
78 #endregion IPlugin implementation
79
80 public bool IsMetadataAuthorized(UUID authToken, UUID assetID)
81 {
82 return true;
83 }
84
85 public bool IsDataAuthorized(UUID authToken, UUID assetID)
86 {
87 return true;
88 }
89
90 public bool IsCreateAuthorized(UUID authToken)
91 {
92 return true;
93 }
94
95 public bool IsInventoryReadAuthorized(UUID authToken, Uri owner)
96 {
97 return true;
98 }
99
100 public bool IsInventoryWriteAuthorized(UUID authToken, Uri owner)
101 {
102 return true;
103 }
104 }
105}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
deleted file mode 100644
index 90ea2e0..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/BrowseFrontendPlugin.cs
+++ /dev/null
@@ -1,173 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31using System.Collections.Specialized;
32using System.Net;
33using System.Text;
34using System.Web;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer;
39using log4net;
40
41namespace OpenSim.Grid.AssetInventoryServer.Plugins
42{
43 public class BrowseFrontendPlugin : IAssetInventoryServerPlugin
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private AssetInventoryServer m_server;
47
48 public BrowseFrontendPlugin()
49 {
50 }
51
52 #region IPlugin implementation
53
54 public void Initialise(AssetInventoryServer server)
55 {
56 m_server = server;
57
58 // Request for / or /?...
59 m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server));
60
61 m_log.Info("[BROWSEFRONTEND]: Browser Frontend loaded.");
62 }
63
64 /// <summary>
65 /// <para>Initialises asset interface</para>
66 /// </summary>
67 public void Initialise()
68 {
69 m_log.InfoFormat("[BROWSEFRONTEND]: {0} cannot be default-initialized!", Name);
70 throw new PluginNotInitialisedException(Name);
71 }
72
73 public void Dispose()
74 {
75 }
76
77 public string Version
78 {
79 // TODO: this should be something meaningful and not hardcoded?
80 get { return "0.1"; }
81 }
82
83 public string Name
84 {
85 get { return "BrowseFrontend"; }
86 }
87
88 #endregion IPlugin implementation
89
90 public class BrowseRequestHandler : BaseStreamHandler
91 {
92 AssetInventoryServer m_server;
93
94 //public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "(^/$|(^/\?.*)")
95 public BrowseRequestHandler(AssetInventoryServer server) : base("GET", "/")
96 {
97 m_server = server;
98 }
99
100 public override string ContentType
101 {
102 get { return "text/html"; }
103 }
104
105 #region IStreamedRequestHandler implementation
106
107 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
108 {
109 const int ASSETS_PER_PAGE = 25;
110 const string HEADER = "<html><head><title>Asset Server</title></head><body>";
111 const string TABLE_HEADER =
112 "<table><tr><th>Name</th><th>Description</th><th>Type</th><th>ID</th><th>Temporary</th><th>SHA-1</th></tr>";
113 const string TABLE_FOOTER = "</table>";
114 const string FOOTER = "</body></html>";
115
116 UUID authToken = Utils.GetAuthToken(httpRequest);
117
118 StringBuilder html = new StringBuilder();
119 int start = 0;
120 uint page = 0;
121
122 if (!String.IsNullOrEmpty(httpRequest.Url.Query))
123 {
124 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
125 if (!String.IsNullOrEmpty(query["page"]) && UInt32.TryParse(query["page"], out page))
126 start = (int)page * ASSETS_PER_PAGE;
127 }
128
129 html.AppendLine(HEADER);
130
131 html.AppendLine("<p>");
132 if (page > 0)
133 html.AppendFormat("<a href=\"{0}?page={1}\">&lt; Previous Page</a> | ", httpRequest.RawUrl, page - 1);
134 html.AppendFormat("<a href=\"{0}?page={1}\">Next Page &gt;</a>", httpRequest.RawUrl, page + 1);
135 html.AppendLine("</p>");
136
137 html.AppendLine(TABLE_HEADER);
138
139 m_server.StorageProvider.ForEach(
140 delegate(AssetMetadata data)
141 {
142 if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, data.FullID))
143 {
144 html.AppendLine(String.Format(
145 "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>",
146 data.Name, data.Description, data.ContentType, data.ID, data.Temporary,
147 BitConverter.ToString(data.SHA1).Replace("-", String.Empty)));
148 }
149 else
150 {
151 html.AppendLine(String.Format(
152 "<tr><td>[Protected Asset]</td><td>&nbsp;</td><td>&nbsp;</td><td>{0}</td><td>{1}</td><td>&nbsp;</td></tr>",
153 data.ID, data.Temporary));
154 }
155 }, start, ASSETS_PER_PAGE
156 );
157
158 html.AppendLine(TABLE_FOOTER);
159
160 html.AppendLine(FOOTER);
161
162 byte[] responseData = System.Text.Encoding.UTF8.GetBytes(html.ToString());
163
164 httpResponse.StatusCode = (int) HttpStatusCode.OK;
165 //httpResponse.Body.Write(responseData, 0, responseData.Length);
166 //httpResponse.Body.Flush();
167 return responseData;
168 }
169
170 #endregion IStreamedRequestHandler implementation
171 }
172 }
173}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs
deleted file mode 100644
index 8323450..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs
+++ /dev/null
@@ -1,211 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Net;
30using System.IO;
31using System.IO.Compression;
32using System.Xml;
33using System.Reflection;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Serialization;
37using OpenSim.Framework.Serialization.External;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using log4net;
41
42namespace OpenSim.Grid.AssetInventoryServer.Plugins
43{
44 public class InventoryArchivePlugin : IAssetInventoryServerPlugin
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private AssetInventoryServer m_server;
48
49 public InventoryArchivePlugin()
50 {
51 }
52
53 #region IPlugin implementation
54
55 public void Initialise(AssetInventoryServer server)
56 {
57 m_server = server;
58
59 m_server.HttpServer.AddStreamHandler(new GetInventoryArchive(server));
60
61 m_log.Info("[INVENTORYARCHIVE]: Inventory Archive loaded.");
62 }
63
64 /// <summary>
65 /// <para>Initialises asset interface</para>
66 /// </summary>
67 public void Initialise()
68 {
69 m_log.InfoFormat("[INVENTORYARCHIVE]: {0} cannot be default-initialized!", Name);
70 throw new PluginNotInitialisedException(Name);
71 }
72
73 public void Dispose()
74 {
75 }
76
77 public string Version
78 {
79 // TODO: this should be something meaningful and not hardcoded?
80 get { return "0.1"; }
81 }
82
83 public string Name
84 {
85 get { return "InventoryArchive"; }
86 }
87
88 #endregion IPlugin implementation
89
90 public class GetInventoryArchive : BaseStreamHandler
91 {
92 AssetInventoryServer m_server;
93
94 //public GetInventoryArchive(AssetInventoryServer server) : base("GET", @"^/inventoryarchive/")
95 public GetInventoryArchive(AssetInventoryServer server) : base("GET", "/inventoryarchive")
96 {
97 m_server = server;
98 }
99
100 public override string ContentType
101 {
102 get { return "application/x-compressed"; }
103 }
104
105 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
106 {
107 byte[] buffer = new byte[] {};
108 UUID ownerID;
109 // Split the URL up to get the asset ID out
110 string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/');
111
112 if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 && UUID.TryParse(rawUrl[2].Substring(0, 36), out ownerID))
113 {
114 Uri owner = Utils.GetOpenSimUri(ownerID);
115 InventoryCollection inventory;
116 BackendResponse storageResponse = m_server.InventoryProvider.TryFetchInventory(owner, out inventory);
117
118 if (storageResponse == BackendResponse.Success)
119 {
120 m_log.DebugFormat("[INVENTORYARCHIVE]: Archiving inventory for user UUID {0}", ownerID);
121 buffer = ArchiveInventoryCollection(inventory);
122 httpResponse.StatusCode = (int) HttpStatusCode.OK;
123 }
124 else
125 {
126 httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
127 }
128 }
129 else
130 {
131 m_log.Warn("[INVENTORYARCHIVE]: Unrecognized inventory archive request: " + httpRequest.Url.PathAndQuery);
132 }
133
134 return buffer;
135 }
136 }
137
138 private static byte[] ArchiveInventoryCollection(InventoryCollection inventory)
139 {
140 byte[] buffer = new byte[] {};
141
142 // Fill in each folder's Children dictionary.
143 InventoryFolderWithChildren rootFolder = BuildInventoryHierarchy(ref inventory);
144
145 // TODO: It's probably a bad idea to tar to memory for large
146 // inventories.
147 MemoryStream ms = new MemoryStream();
148 GZipStream gzs = new GZipStream(ms, CompressionMode.Compress, true);
149 TarArchiveWriter archive = new TarArchiveWriter(gzs);
150 WriteInventoryFolderToArchive(archive, rootFolder, ArchiveConstants.INVENTORY_PATH);
151
152 archive.Close();
153
154 ms.Seek(0, SeekOrigin.Begin);
155 buffer = ms.GetBuffer();
156 Array.Resize<byte>(ref buffer, (int) ms.Length);
157 ms.Close();
158 return buffer;
159 }
160
161 private static InventoryFolderWithChildren BuildInventoryHierarchy(ref InventoryCollection inventory)
162 {
163 m_log.DebugFormat("[INVENTORYARCHIVE]: Building inventory hierarchy");
164 InventoryFolderWithChildren rootFolder = null;
165
166 foreach (InventoryFolderWithChildren parentFolder in inventory.Folders.Values)
167 {
168 // Grab the root folder, it has no parents.
169 if (UUID.Zero == parentFolder.ParentID) rootFolder = parentFolder;
170
171 foreach (InventoryFolderWithChildren folder in inventory.Folders.Values)
172 if (parentFolder.ID == folder.ParentID)
173 parentFolder.Children.Add(folder.ID, folder);
174
175 foreach (InventoryItemBase item in inventory.Items.Values)
176 if (parentFolder.ID == item.Folder)
177 parentFolder.Children.Add(item.ID, item);
178 }
179
180 return rootFolder;
181 }
182
183 private static void WriteInventoryFolderToArchive(
184 TarArchiveWriter archive, InventoryFolderWithChildren folder, string path)
185 {
186 path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID);
187 archive.WriteDir(path);
188
189 foreach (InventoryNodeBase inventoryNode in folder.Children.Values)
190 {
191 if (inventoryNode is InventoryFolderWithChildren)
192 {
193 WriteInventoryFolderToArchive(archive, (InventoryFolderWithChildren) inventoryNode, path);
194 }
195 else if (inventoryNode is InventoryItemBase)
196 {
197 WriteInventoryItemToArchive(archive, (InventoryItemBase) inventoryNode, path);
198 }
199 }
200 }
201
202 private static void WriteInventoryItemToArchive(TarArchiveWriter archive, InventoryItemBase item, string path)
203 {
204 string filename = string.Format("{0}{1}_{2}.xml", path, item.Name, item.ID);
205 string serialization = UserInventoryItemSerializer.Serialize(item);
206 archive.WriteFile(filename, serialization);
207
208 //m_assetGatherer.GatherAssetUuids(item.AssetID, (AssetType) item.AssetType, assetUuids);
209 }
210 }
211}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs
deleted file mode 100644
index 8cde8f4..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using OpenMetaverse;
31using log4net;
32
33namespace OpenSim.Grid.AssetInventoryServer.Plugins
34{
35 public class NullMetricsPlugin : IMetricsProvider
36 {
37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 //private AssetInventoryServer m_server;
39
40 public NullMetricsPlugin()
41 {
42 }
43
44 #region IMetricsProvider implementation
45
46 public void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time)
47 {
48 m_log.DebugFormat("[{0}]: AssetMetadataFetch(): AssetID: {1}, Response: {2}", extension, assetID, response);
49 }
50
51 public void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time)
52 {
53 m_log.DebugFormat("[{0}]: AssetDataFetch(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID,
54 dataSize, response);
55 }
56
57 public void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time)
58 {
59 m_log.DebugFormat("[{0}]: AssetCreate(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID,
60 dataSize, response);
61 }
62
63 public void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time)
64 {
65 m_log.DebugFormat("[{0}]: InventoryFetch(): ObjID: {1}, Folder: {2}, OwnerID: {3}, Response: {4}", extension,
66 objID, folder, owner, response);
67 }
68
69 public void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time)
70 {
71 m_log.DebugFormat("[{0}]: InventoryFetchFolderContents(): FolderID: {1}, OwnerID: {2}, Response: {3}", extension,
72 folderID, owner, response);
73 }
74
75 public void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time)
76 {
77 m_log.DebugFormat("[{0}]: InventoryFetchFolderList(): OwnerID: {1}, Response: {2}", extension,
78 owner, response);
79 }
80
81 public void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time)
82 {
83 m_log.DebugFormat("[{0}]: InventoryFetchInventory(): OwnerID: {1}, Response: {2}", extension,
84 owner, response);
85 }
86
87 public void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time)
88 {
89 m_log.DebugFormat("[{0}]: InventoryFetchActiveGestures(): OwnerID: {1}, Response: {2}", extension,
90 owner, response);
91 }
92
93 public void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time)
94 {
95 m_log.DebugFormat("[{0}]: InventoryCreate(): OwnerID: {1}, Response: {2}", extension,
96 owner, response);
97 }
98
99 public void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time)
100 {
101 m_log.DebugFormat("[{0}]: InventoryCreateInventory(): Response: {1}", extension,
102 response);
103 }
104
105 public void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time)
106 {
107 m_log.DebugFormat("[{0}]: InventoryDelete(): OwnerID: {1}, Folder: {2}, Response: {3}", extension,
108 owner, folder, response);
109 }
110
111 public void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time)
112 {
113 m_log.DebugFormat("[{0}]: InventoryPurgeFolder(): OwnerID: {1}, FolderID: {2}, Response: {3}", extension,
114 owner, folderID, response);
115 }
116
117 #endregion IMetricsProvider implementation
118
119 #region IPlugin implementation
120
121 public void Initialise(AssetInventoryServer server)
122 {
123 //m_server = server;
124 }
125
126 /// <summary>
127 /// <para>Initialises metrics interface</para>
128 /// </summary>
129 public void Initialise()
130 {
131 m_log.Info("[NULLMETRICS]: Null metrics loaded.");
132 }
133
134 public void Dispose()
135 {
136 }
137
138 public string Version
139 {
140 // TODO: this should be something meaningful and not hardcoded?
141 get { return "0.1"; }
142 }
143
144 public string Name
145 {
146 get { return "NullMetrics"; }
147 }
148
149 #endregion IPlugin implementation
150 }
151}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs
deleted file mode 100644
index e4be55e..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetFrontendPlugin.cs
+++ /dev/null
@@ -1,198 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Net;
31using System.IO;
32using System.Text;
33using System.Xml;
34using System.Xml.Serialization;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer;
39using log4net;
40
41namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
42{
43 public class OpenSimAssetFrontendPlugin : IAssetInventoryServerPlugin
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private AssetInventoryServer m_server;
47
48 public OpenSimAssetFrontendPlugin()
49 {
50 }
51
52 #region IPlugin implementation
53
54 public void Initialise(AssetInventoryServer server)
55 {
56 m_server = server;
57
58 // Asset request
59 m_server.HttpServer.AddStreamHandler(new AssetRequestHandler(server));
60
61 // Asset creation
62 m_server.HttpServer.AddStreamHandler(new AssetPostHandler(server));
63
64 m_log.Info("[OPENSIMASSETFRONTEND]: OpenSim Asset Frontend loaded.");
65 }
66
67 /// <summary>
68 /// <para>Initialises asset interface</para>
69 /// </summary>
70 public void Initialise()
71 {
72 m_log.InfoFormat("[OPENSIMASSETFRONTEND]: {0} cannot be default-initialized!", Name);
73 throw new PluginNotInitialisedException(Name);
74 }
75
76 public void Dispose()
77 {
78 }
79
80 public string Version
81 {
82 // TODO: this should be something meaningful and not hardcoded?
83 get { return "0.1"; }
84 }
85
86 public string Name
87 {
88 get { return "OpenSimAssetFrontend"; }
89 }
90
91 #endregion IPlugin implementation
92
93 public class AssetRequestHandler : BaseStreamHandler
94 {
95 AssetInventoryServer m_server;
96
97 //public AssetRequestHandler(AssetInventoryServer server) : base("GET", "^/assets")
98 public AssetRequestHandler(AssetInventoryServer server) : base("GET", "/assets")
99 {
100 m_server = server;
101 }
102
103 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
104 {
105 byte[] buffer = new byte[] {};
106 UUID assetID;
107 // Split the URL up to get the asset ID out
108 string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/');
109
110 if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 && UUID.TryParse(rawUrl[2].Substring(0, 36), out assetID))
111 {
112 BackendResponse dataResponse;
113
114 AssetBase asset = new AssetBase();
115 if ((dataResponse = m_server.StorageProvider.TryFetchDataMetadata(assetID, out asset)) == BackendResponse.Success)
116 {
117 if (rawUrl.Length >= 4 && rawUrl[3] == "data")
118 {
119 httpResponse.StatusCode = (int)HttpStatusCode.OK;
120 httpResponse.ContentType = Utils.SLAssetTypeToContentType(asset.Type);
121 buffer=asset.Data;
122 }
123 else
124 {
125 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
126 MemoryStream ms = new MemoryStream();
127 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
128 xs.Serialize(xw, asset);
129 xw.Flush();
130
131 ms.Seek(0, SeekOrigin.Begin);
132 buffer = ms.GetBuffer();
133 Array.Resize<byte>(ref buffer, (int)ms.Length);
134 ms.Close();
135 httpResponse.StatusCode = (int)HttpStatusCode.OK;
136 }
137 }
138 else
139 {
140 m_log.WarnFormat("[OPENSIMASSETFRONTEND]: Failed to fetch asset data or metadata for {0}: {1}", assetID, dataResponse);
141 httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
142 }
143 }
144 else
145 {
146 m_log.Warn("[OPENSIMASSETFRONTEND]: Unrecognized OpenSim asset request: " + httpRequest.Url.PathAndQuery);
147 }
148
149 return buffer;
150 }
151 }
152
153 public class AssetPostHandler : BaseStreamHandler
154 {
155 AssetInventoryServer m_server;
156
157 //public AssetPostHandler(AssetInventoryServer server) : base("POST", "/^assets")
158 public AssetPostHandler(AssetInventoryServer server) : base("POST", "/assets")
159 {
160 m_server = server;
161 }
162
163 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
164 {
165 AssetBase asset = null;
166
167 try
168 {
169 asset = (AssetBase) new XmlSerializer(typeof (AssetBase)).Deserialize(httpRequest.InputStream);
170 }
171 catch (Exception ex)
172 {
173 m_log.Warn("[OPENSIMASSETFRONTEND]: Failed to parse POST data (expecting AssetBase): " + ex.Message);
174 httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
175 }
176
177 if (asset != null && asset.Data != null && asset.Data.Length > 0)
178 {
179 BackendResponse storageResponse = m_server.StorageProvider.TryCreateAsset(asset);
180
181 if (storageResponse == BackendResponse.Success)
182 httpResponse.StatusCode = (int) HttpStatusCode.Created;
183 else if (storageResponse == BackendResponse.NotFound)
184 httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
185 else
186 httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
187 }
188 else
189 {
190 m_log.Warn("[OPENSIMASSETFRONTEND]: AssetPostHandler called with no asset data");
191 httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
192 }
193
194 return new byte[] {};
195 }
196 }
197 }
198}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
deleted file mode 100644
index 0631ee7..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs
+++ /dev/null
@@ -1,189 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Data;
31using System.Collections.Generic;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Data;
35using Nini.Config;
36using log4net;
37
38namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
39{
40 public class OpenSimAssetStoragePlugin : IAssetStorageProvider
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 const string EXTENSION_NAME = "OpenSimAssetStorage"; // Used in metrics reporting
44
45 private AssetInventoryServer m_server;
46 private IAssetDataPlugin m_assetProvider;
47 private IConfig m_openSimConfig;
48
49 public OpenSimAssetStoragePlugin()
50 {
51 }
52
53 #region IAssetStorageProvider implementation
54
55 public BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata)
56 {
57 metadata = null;
58 BackendResponse ret;
59
60 AssetBase asset = m_assetProvider.FetchAsset(assetID);
61
62 if (asset == null) ret = BackendResponse.NotFound;
63 else
64 {
65 metadata = asset.Metadata;
66 ret = BackendResponse.Success;
67 }
68
69 m_server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now);
70 return ret;
71 }
72
73 public BackendResponse TryFetchData(UUID assetID, out byte[] assetData)
74 {
75 assetData = null;
76 BackendResponse ret;
77
78 AssetBase asset = m_assetProvider.FetchAsset(assetID);
79
80 if (asset == null) ret = BackendResponse.NotFound;
81 else
82 {
83 assetData = asset.Data;
84 ret = BackendResponse.Success;
85 }
86
87 m_server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now);
88 return ret;
89 }
90
91 public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset)
92 {
93 asset = m_assetProvider.FetchAsset(assetID);
94
95 if (asset == null) return BackendResponse.NotFound;
96
97 return BackendResponse.Success;
98 }
99
100 public BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID)
101 {
102 assetID = asset.FullID = UUID.Random();
103 return TryCreateAsset(asset);
104 }
105
106 public BackendResponse TryCreateAsset(AssetBase asset)
107 {
108 BackendResponse ret;
109
110 m_assetProvider.CreateAsset(asset);
111 ret = BackendResponse.Success;
112
113 m_server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now);
114 return ret;
115 }
116
117 public int ForEach(Action<AssetMetadata> action, int start, int count)
118 {
119 int rowCount = 0;
120
121 foreach (AssetMetadata metadata in m_assetProvider.FetchAssetMetadataSet(start, count))
122 {
123 // We set the ContentType here because Utils is only in
124 // AssetInventoryServer. This should be moved to the DB
125 // backends when the equivalent of SLAssetTypeToContentType is
126 // in OpenSim.Framework or similar.
127 metadata.ContentType = Utils.SLAssetTypeToContentType(metadata.Type);
128
129 action(metadata);
130 ++rowCount;
131 }
132
133 return rowCount;
134 }
135
136 #endregion IAssetStorageProvider implementation
137
138 #region IPlugin implementation
139
140 public void Initialise(AssetInventoryServer server)
141 {
142 m_server = server;
143 m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
144
145 try
146 {
147 m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(m_openSimConfig.GetString("asset_database_provider"),
148 m_openSimConfig.GetString("asset_database_connect"));
149 if (m_assetProvider == null)
150 {
151 m_log.Error("[OPENSIMASSETSTORAGE]: Failed to load a database plugin, server halting.");
152 Environment.Exit(-1);
153 }
154 else
155 m_log.InfoFormat("[OPENSIMASSETSTORAGE]: Loaded storage backend: {0}", Version);
156 }
157 catch (Exception e)
158 {
159 m_log.WarnFormat("[OPENSIMASSETSTORAGE]: Failure loading data plugin: {0}", e.ToString());
160 throw new PluginNotInitialisedException(Name);
161 }
162 }
163
164 /// <summary>
165 /// <para>Initialises asset interface</para>
166 /// </summary>
167 public void Initialise()
168 {
169 m_log.InfoFormat("[OPENSIMASSETSTORAGE]: {0} cannot be default-initialized!", Name);
170 throw new PluginNotInitialisedException(Name);
171 }
172
173 public void Dispose()
174 {
175 }
176
177 public string Version
178 {
179 get { return m_assetProvider.Version; }
180 }
181
182 public string Name
183 {
184 get { return "OpenSimAssetStorage"; }
185 }
186
187 #endregion IPlugin implementation
188 }
189}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs
deleted file mode 100644
index c83e911..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryFrontendPlugin.cs
+++ /dev/null
@@ -1,867 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Net;
30using System.Reflection;
31using System.Collections.Generic;
32using System.IO;
33using System.Xml;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer;
38using log4net;
39
40namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
41{
42 public class OpenSimInventoryFrontendPlugin : IAssetInventoryServerPlugin
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private AssetInventoryServer m_server;
46 private Utils.InventoryCollectionSerializer collectionSerializer = new Utils.InventoryCollectionSerializer();
47
48 public OpenSimInventoryFrontendPlugin()
49 {
50 }
51
52 #region IPlugin implementation
53
54 public void Initialise(AssetInventoryServer server)
55 {
56 m_server = server;
57
58 m_server.HttpServer.AddStreamHandler(new GetInventoryHandler(server, collectionSerializer));
59 m_server.HttpServer.AddStreamHandler(new CreateInventoryHandler(server));
60 m_server.HttpServer.AddStreamHandler(new NewFolderHandler(server));
61 m_server.HttpServer.AddStreamHandler(new UpdateFolderHandler(server));
62 m_server.HttpServer.AddStreamHandler(new MoveFolderHandler(server));
63 m_server.HttpServer.AddStreamHandler(new PurgeFolderHandler(server));
64 m_server.HttpServer.AddStreamHandler(new NewItemHandler(server));
65 m_server.HttpServer.AddStreamHandler(new DeleteItemHandler(server));
66 m_server.HttpServer.AddStreamHandler(new RootFoldersHandler(server));
67 m_server.HttpServer.AddStreamHandler(new ActiveGesturesHandler(server));
68
69 m_log.Info("[OPENSIMINVENTORYFRONTEND]: OpenSim Inventory Frontend loaded.");
70 }
71
72 /// <summary>
73 /// <para>Initialises asset interface</para>
74 /// </summary>
75 public void Initialise()
76 {
77 m_log.InfoFormat("[OPENSIMINVENTORYFRONTEND]: {0} cannot be default-initialized!", Name);
78 throw new PluginNotInitialisedException(Name);
79 }
80
81 public void Dispose()
82 {
83 }
84
85 public string Version
86 {
87 // TODO: this should be something meaningful and not hardcoded?
88 get { return "0.1"; }
89 }
90
91 public string Name
92 {
93 get { return "OpenSimInventoryFrontend"; }
94 }
95
96 #endregion IPlugin implementation
97
98 public class GetInventoryHandler : BaseStreamHandler
99 {
100 AssetInventoryServer m_server;
101 Utils.InventoryCollectionSerializer m_collectionSerializer;
102
103 //public GetInventoryHandler(AssetInventoryServer server, Utils.InventoryCollectionSerializer collectionSerializer) : base("POST", @"^/GetInventory/")
104 public GetInventoryHandler(AssetInventoryServer server, Utils.InventoryCollectionSerializer collectionSerializer) : base("POST", "/GetInventory")
105 {
106 m_server = server;
107 m_collectionSerializer = collectionSerializer;
108 }
109
110 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
111 {
112 byte[] buffer = new byte[] {};
113 UUID sessionID, agentID;
114 UUID ownerID = DeserializeUUID(httpRequest.InputStream, out agentID, out sessionID);
115
116 if (ownerID != UUID.Zero)
117 {
118 m_log.Warn("[OPENSIMINVENTORYFRONTEND]: GetInventory is not scalable on some inventory backends, avoid calling it wherever possible");
119
120 Uri owner = Utils.GetOpenSimUri(ownerID);
121 InventoryCollection inventory;
122 BackendResponse storageResponse = m_server.InventoryProvider.TryFetchInventory(owner, out inventory);
123
124 if (storageResponse == BackendResponse.Success)
125 {
126 //collectionSerializer.Serialize(httpResponse.Body, inventory);
127 //httpResponse.Body.Flush();
128 MemoryStream ms = new MemoryStream();
129 m_collectionSerializer.Serialize(ms, inventory);
130 ms.Seek(0, SeekOrigin.Begin);
131 buffer = ms.GetBuffer();
132 Array.Resize<byte>(ref buffer, (int) ms.Length);
133 ms.Close();
134 httpResponse.StatusCode = (int) HttpStatusCode.OK;
135 }
136 else if (storageResponse == BackendResponse.NotFound)
137 {
138 // Return an empty inventory set to mimic OpenSim.Grid.InventoryServer.exe
139 inventory = new InventoryCollection();
140 inventory.UserID = ownerID;
141 inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
142 inventory.Items = new Dictionary<UUID, InventoryItemBase>();
143 //collectionSerializer.Serialize(httpResponse.Body, inventory);
144 //httpResponse.Body.Flush();
145 MemoryStream ms = new MemoryStream();
146 m_collectionSerializer.Serialize(ms, inventory);
147 ms.Seek(0, SeekOrigin.Begin);
148 buffer = ms.GetBuffer();
149 Array.Resize<byte>(ref buffer, (int) ms.Length);
150 ms.Close();
151 httpResponse.StatusCode = (int) HttpStatusCode.OK;
152 }
153 else
154 {
155 httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
156 }
157 }
158 else
159 {
160 httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
161 }
162
163 return buffer;
164 }
165 }
166
167 public class CreateInventoryHandler : BaseStreamHandler
168 {
169 AssetInventoryServer m_server;
170
171 //public CreateInventoryHandler(AssetInventoryServer server) : base("POST", @"^/CreateInventory/")
172 public CreateInventoryHandler(AssetInventoryServer server) : base("POST", "/CreateInventory")
173 {
174 m_server = server;
175 }
176
177 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
178 {
179 UUID ownerID = DeserializeUUID(httpRequest.InputStream);
180
181 if (ownerID != UUID.Zero)
182 {
183 Uri owner = Utils.GetOpenSimUri(ownerID);
184 m_log.DebugFormat("[OPENSIMINVENTORYFRONTEND]: Created URI {0} for inventory creation", owner);
185
186 InventoryFolderWithChildren rootFolder = new InventoryFolderWithChildren("My Inventory", ownerID, UUID.Zero, (short)AssetType.Folder);
187 BackendResponse storageResponse = m_server.InventoryProvider.TryCreateInventory(owner, rootFolder);
188 if (storageResponse == BackendResponse.Success)
189 {
190 // TODO: The CreateFolder calls need to be executed in SimpleStorage.
191 //CreateFolder("Animations", ownerID, rootFolder.ID, AssetType.Animation);
192 //CreateFolder("Body Parts", ownerID, rootFolder.ID, AssetType.Bodypart);
193 //CreateFolder("Calling Cards", ownerID, rootFolder.ID, AssetType.CallingCard);
194 //CreateFolder("Clothing", ownerID, rootFolder.ID, AssetType.Clothing);
195 //CreateFolder("Gestures", ownerID, rootFolder.ID, AssetType.Gesture);
196 //CreateFolder("Landmarks", ownerID, rootFolder.ID, AssetType.Landmark);
197 //CreateFolder("Lost and Found", ownerID, rootFolder.ID, AssetType.LostAndFoundFolder);
198 //CreateFolder("Notecards", ownerID, rootFolder.ID, AssetType.Notecard);
199 //CreateFolder("Objects", ownerID, rootFolder.ID, AssetType.Object);
200 //CreateFolder("Photo Album", ownerID, rootFolder.ID, AssetType.SnapshotFolder);
201 //CreateFolder("Scripts", ownerID, rootFolder.ID, AssetType.LSLText);
202 //CreateFolder("Sounds", ownerID, rootFolder.ID, AssetType.Sound);
203 //CreateFolder("Textures", ownerID, rootFolder.ID, AssetType.Texture);
204 //CreateFolder("Trash", ownerID, rootFolder.ID, AssetType.TrashFolder);
205
206 return SerializeBool(true);
207 }
208 }
209
210 return SerializeBool(false);
211 }
212 }
213
214 public class NewFolderHandler : BaseStreamHandler
215 {
216 AssetInventoryServer m_server;
217
218 //public NewFolderHandler(AssetInventoryServer server) : base("POST", @"^/NewFolder/")
219 public NewFolderHandler(AssetInventoryServer server) : base("POST", "/NewFolder")
220 {
221 m_server = server;
222 }
223
224 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
225 {
226 UUID agentID, sessionID;
227 InventoryFolderWithChildren folder = DeserializeFolder(httpRequest.InputStream, out agentID, out sessionID);
228
229 if (folder != null)
230 {
231 Uri owner = Utils.GetOpenSimUri(folder.Owner);
232
233 // Some calls that are moving or updating a folder instead
234 // of creating a new one will pass in an InventoryFolder
235 // without the name set and type set to 0. If this is the
236 // case we need to look up the name first and preserver
237 // it's type.
238 if (String.IsNullOrEmpty(folder.Name))
239 {
240 InventoryFolderWithChildren oldFolder;
241 if (m_server.InventoryProvider.TryFetchFolder(owner, folder.ID, out oldFolder) == BackendResponse.Success)
242 {
243 folder.Name = oldFolder.Name;
244 folder.Type = oldFolder.Type;
245 }
246 }
247
248 BackendResponse storageResponse = m_server.InventoryProvider.TryCreateFolder(owner, folder);
249
250 if (storageResponse == BackendResponse.Success)
251 {
252 return SerializeBool(true);
253 }
254 }
255
256 return SerializeBool(false);
257 }
258 }
259
260 public class UpdateFolderHandler : BaseStreamHandler
261 {
262 AssetInventoryServer m_server;
263
264 //public UpdateFolderHandler(AssetInventoryServer server) : base("POST", @"^/UpdateFolder/")
265 public UpdateFolderHandler(AssetInventoryServer server) : base("POST", "/UpdateFolder")
266 {
267 m_server = server;
268 }
269
270 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
271 {
272 return new NewFolderHandler(m_server).Handle(path, request, httpRequest, httpResponse);
273 }
274 }
275
276 public class MoveFolderHandler : BaseStreamHandler
277 {
278 AssetInventoryServer m_server;
279
280 //public MoveFolderHandler(AssetInventoryServer server) : base("POST", @"^/MoveFolder/")
281 public MoveFolderHandler(AssetInventoryServer server) : base("POST", "/MoveFolder")
282 {
283 m_server = server;
284 }
285
286 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
287 {
288 return new NewFolderHandler(m_server).Handle(path, request, httpRequest, httpResponse);
289 }
290 }
291
292 public class PurgeFolderHandler : BaseStreamHandler
293 {
294 AssetInventoryServer m_server;
295
296 //public PurgeFolderHandler(AssetInventoryServer server) : base("POST", @"^/PurgeFolder/")
297 public PurgeFolderHandler(AssetInventoryServer server) : base("POST", "/PurgeFolder")
298 {
299 m_server = server;
300 }
301
302 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
303 {
304 UUID agentID, sessionID;
305 InventoryFolderWithChildren folder = DeserializeFolder(httpRequest.InputStream, out agentID, out sessionID);
306
307 if (folder != null)
308 {
309 Uri owner = Utils.GetOpenSimUri(folder.Owner);
310 BackendResponse storageResponse = m_server.InventoryProvider.TryPurgeFolder(owner, folder.ID);
311
312 if (storageResponse == BackendResponse.Success)
313 {
314 return SerializeBool(true);
315 }
316 }
317
318 return SerializeBool(false);
319 }
320 }
321
322 public class NewItemHandler : BaseStreamHandler
323 {
324 AssetInventoryServer m_server;
325
326 //public NewItemHandler(AssetInventoryServer server) : base("POST", @"^/NewItem/")
327 public NewItemHandler(AssetInventoryServer server) : base("POST", "/NewItem")
328 {
329 m_server = server;
330 }
331
332 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
333 {
334 UUID agentID, sessionID;
335 InventoryItemBase item = DeserializeItem(httpRequest.InputStream, out agentID, out sessionID);
336
337 if (item != null)
338 {
339 Uri owner = Utils.GetOpenSimUri(agentID);
340 BackendResponse storageResponse = m_server.InventoryProvider.TryCreateItem(owner, item);
341
342 if (storageResponse == BackendResponse.Success)
343 {
344 return SerializeBool(true);
345 }
346 }
347
348 return SerializeBool(false);
349 }
350 }
351
352 public class DeleteItemHandler : BaseStreamHandler
353 {
354 AssetInventoryServer m_server;
355
356 //public DeleteItemHandler(AssetInventoryServer server) : base("POST", @"^/DeleteItem/")
357 public DeleteItemHandler(AssetInventoryServer server) : base("POST", "/DeleteItem")
358 {
359 m_server = server;
360 }
361
362 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
363 {
364 UUID agentID, sessionID;
365 InventoryItemBase item = DeserializeItem(httpRequest.InputStream, out agentID, out sessionID);
366
367 if (item != null)
368 {
369 Uri owner = Utils.GetOpenSimUri(item.Owner);
370 BackendResponse storageResponse = m_server.InventoryProvider.TryDeleteItem(owner, item.ID);
371
372 if (storageResponse == BackendResponse.Success)
373 {
374 return SerializeBool(true);
375 }
376 }
377
378 return SerializeBool(false);
379 }
380 }
381
382 public class RootFoldersHandler : BaseStreamHandler
383 {
384 AssetInventoryServer m_server;
385
386 //public RootFoldersHandler(AssetInventoryServer server) : base("POST", @"^/RootFolders/")
387 public RootFoldersHandler(AssetInventoryServer server) : base("POST", "/RootFolders")
388 {
389 m_server = server;
390 }
391
392 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
393 {
394 byte[] buffer = new byte[] {};
395 UUID ownerID = DeserializeUUID(httpRequest.InputStream);
396
397 if (ownerID != UUID.Zero)
398 {
399 Uri owner = Utils.GetOpenSimUri(ownerID);
400 List<InventoryFolderWithChildren> skeleton;
401 BackendResponse storageResponse = m_server.InventoryProvider.TryFetchFolderList(owner, out skeleton);
402
403 if (storageResponse == BackendResponse.Success)
404 {
405 MemoryStream ms = new MemoryStream();
406 SerializeFolderList(ms, skeleton);
407 ms.Seek(0, SeekOrigin.Begin);
408 buffer = ms.GetBuffer();
409 Array.Resize<byte>(ref buffer, (int) ms.Length);
410 ms.Close();
411 httpResponse.StatusCode = (int) HttpStatusCode.OK;
412 }
413 else if (storageResponse == BackendResponse.NotFound)
414 {
415 // Return an empty set of inventory so the requester knows that
416 // an inventory needs to be created for this agent
417 MemoryStream ms = new MemoryStream();
418 SerializeFolderList(ms, new List<InventoryFolderWithChildren>(0));
419 ms.Seek(0, SeekOrigin.Begin);
420 buffer = ms.GetBuffer();
421 Array.Resize<byte>(ref buffer, (int) ms.Length);
422 ms.Close();
423 httpResponse.StatusCode = (int) HttpStatusCode.OK;
424 }
425 else
426 {
427 httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
428 }
429 }
430 else
431 {
432 httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
433 }
434
435 return buffer;
436 }
437 }
438
439 public class ActiveGesturesHandler : BaseStreamHandler
440 {
441 AssetInventoryServer m_server;
442
443 //public ActiveGesturesHandler(AssetInventoryServer server) : base("POST", @"^/ActiveGestures/")
444 public ActiveGesturesHandler(AssetInventoryServer server) : base("POST", "/ActiveGestures")
445 {
446 m_server = server;
447 }
448
449 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
450 {
451 byte[] buffer = new byte[] {};
452 UUID ownerID = DeserializeUUID(httpRequest.InputStream);
453
454 if (ownerID != UUID.Zero)
455 {
456 Uri owner = Utils.GetOpenSimUri(ownerID);
457 List<InventoryItemBase> gestures;
458 BackendResponse storageResponse = m_server.InventoryProvider.TryFetchActiveGestures(owner, out gestures);
459
460 if (storageResponse == BackendResponse.Success)
461 {
462 MemoryStream ms = new MemoryStream();
463 SerializeItemList(ms, gestures);
464 ms.Seek(0, SeekOrigin.Begin);
465 buffer = ms.GetBuffer();
466 Array.Resize<byte>(ref buffer, (int) ms.Length);
467 ms.Close();
468 httpResponse.StatusCode = (int) HttpStatusCode.OK;
469 }
470 else if (storageResponse == BackendResponse.NotFound)
471 {
472 // Return an empty set of gestures to match OpenSim.Grid.InventoryServer.exe behavior
473 MemoryStream ms = new MemoryStream();
474 SerializeItemList(ms, new List<InventoryItemBase>(0));
475 ms.Seek(0, SeekOrigin.Begin);
476 buffer = ms.GetBuffer();
477 Array.Resize<byte>(ref buffer, (int) ms.Length);
478 ms.Close();
479 httpResponse.StatusCode = (int) HttpStatusCode.OK;
480 }
481 else
482 {
483 httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
484 }
485 }
486 else
487 {
488 httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
489 }
490
491 return buffer;
492 }
493 }
494
495 //BackendResponse CreateFolder(string name, UUID ownerID, UUID parentID, AssetType assetType)
496 //{
497 // InventoryFolder folder = new InventoryFolder(name, ownerID, parentID, (short)assetType);
498 // Uri owner = Utils.GetOpenSimUri(ownerID);
499 // return m_server.InventoryProvider.TryCreateFolder(owner, folder);
500 //}
501
502 private static UUID DeserializeUUID(Stream stream)
503 {
504 UUID id = UUID.Zero;
505
506 try
507 {
508 using (XmlReader reader = XmlReader.Create(stream))
509 {
510 reader.MoveToContent();
511 UUID.TryParse(reader.ReadElementContentAsString("guid", String.Empty), out id);
512 }
513 }
514 catch (Exception ex)
515 {
516 m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse POST data (expecting guid): " + ex.Message);
517 }
518
519 return id;
520 }
521
522 private static UUID DeserializeUUID(Stream stream, out UUID agentID, out UUID sessionID)
523 {
524 UUID id;
525
526 try
527 {
528 using (XmlReader reader = XmlReader.Create(stream))
529 {
530 reader.MoveToContent();
531 reader.ReadStartElement("RestSessionObjectOfGuid");
532 UUID.TryParse(reader.ReadElementContentAsString("SessionID", String.Empty), out sessionID);
533 UUID.TryParse(reader.ReadElementContentAsString("AvatarID", String.Empty), out agentID);
534 UUID.TryParse(reader.ReadElementContentAsString("Body", String.Empty), out id);
535 reader.ReadEndElement();
536 }
537 }
538 catch (Exception ex)
539 {
540 m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse GetInventory POST data: " + ex.Message);
541 agentID = UUID.Zero;
542 sessionID = UUID.Zero;
543 return UUID.Zero;
544 }
545
546 return id;
547 }
548
549 private static InventoryFolderWithChildren DeserializeFolder(Stream stream, out UUID agentID, out UUID sessionID)
550 {
551 InventoryFolderWithChildren folder = new InventoryFolderWithChildren();
552
553 try
554 {
555 using (XmlReader reader = XmlReader.Create(stream))
556 {
557 reader.MoveToContent();
558 reader.ReadStartElement("RestSessionObjectOfInventoryFolderBase");
559 UUID.TryParse(reader.ReadElementContentAsString("SessionID", String.Empty), out sessionID);
560 UUID.TryParse(reader.ReadElementContentAsString("AvatarID", String.Empty), out agentID);
561 reader.ReadStartElement("Body");
562 if (reader.Name == "Name")
563 folder.Name = reader.ReadElementContentAsString("Name", String.Empty);
564 else
565 folder.Name = String.Empty;
566
567 UUID dummyUUID;
568 ReadUUID(reader, "ID", out dummyUUID);
569 folder.ID = dummyUUID;
570 ReadUUID(reader, "Owner", out dummyUUID);
571 folder.Owner = dummyUUID;
572 ReadUUID(reader, "ParentID", out dummyUUID);
573 folder.ParentID = dummyUUID;
574
575 short dummyType;
576 Int16.TryParse(reader.ReadElementContentAsString("Type", String.Empty), out dummyType);
577 folder.Type = dummyType;
578
579 ushort dummyVersion;
580 UInt16.TryParse(reader.ReadElementContentAsString("Version", String.Empty), out dummyVersion);
581 folder.Version = dummyVersion;
582
583 reader.ReadEndElement();
584 reader.ReadEndElement();
585 }
586 }
587 catch (Exception ex)
588 {
589 m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse POST data (expecting InventoryFolderBase): " + ex.Message);
590 agentID = UUID.Zero;
591 sessionID = UUID.Zero;
592 return null;
593 }
594
595 return folder;
596 }
597
598 private static InventoryItemBase DeserializeItem(Stream stream, out UUID agentID, out UUID sessionID)
599 {
600 InventoryItemBase item = new InventoryItemBase();
601
602 try
603 {
604 using (XmlReader reader = XmlReader.Create(stream))
605 {
606 reader.MoveToContent();
607 reader.ReadStartElement("RestSessionObjectOfInventoryItemBase");
608 UUID.TryParse(reader.ReadElementContentAsString("SessionID", String.Empty), out sessionID);
609 UUID.TryParse(reader.ReadElementContentAsString("AvatarID", String.Empty), out agentID);
610 reader.ReadStartElement("Body");
611
612 item.Name = reader.ReadElementContentAsString("Name", String.Empty);
613
614 UUID dummyUUID;
615 ReadUUID(reader, "ID", out dummyUUID);
616 item.ID = dummyUUID;
617
618 ReadUUID(reader, "Owner", out dummyUUID);
619 item.Owner = dummyUUID;
620
621 int dummyInt;
622 Int32.TryParse(reader.ReadElementContentAsString("InvType", String.Empty), out dummyInt);
623 item.InvType = dummyInt;
624
625 ReadUUID(reader, "Folder", out dummyUUID);
626 item.Folder = dummyUUID;
627
628 item.CreatorId = reader.ReadElementContentAsString("CreatorId", String.Empty);
629 item.Description = reader.ReadElementContentAsString("Description", String.Empty);
630
631 uint dummyUInt;
632 UInt32.TryParse(reader.ReadElementContentAsString("NextPermissions", String.Empty), out dummyUInt);
633 item.NextPermissions = dummyUInt;
634 UInt32.TryParse(reader.ReadElementContentAsString("CurrentPermissions", String.Empty), out dummyUInt);
635 item.CurrentPermissions = dummyUInt;
636 UInt32.TryParse(reader.ReadElementContentAsString("BasePermissions", String.Empty), out dummyUInt);
637 item.BasePermissions = dummyUInt;
638 UInt32.TryParse(reader.ReadElementContentAsString("EveryOnePermissions", String.Empty), out dummyUInt);
639 item.EveryOnePermissions = dummyUInt;
640 UInt32.TryParse(reader.ReadElementContentAsString("GroupPermissions", String.Empty), out dummyUInt);
641 item.GroupPermissions = dummyUInt;
642
643 Int32.TryParse(reader.ReadElementContentAsString("AssetType", String.Empty), out dummyInt);
644 item.AssetType = dummyInt;
645
646 ReadUUID(reader, "AssetID", out dummyUUID);
647 item.AssetID = dummyUUID;
648 ReadUUID(reader, "GroupID", out dummyUUID);
649 item.GroupID = dummyUUID;
650
651 bool dummyBool;
652 Boolean.TryParse(reader.ReadElementContentAsString("GroupOwned", String.Empty), out dummyBool);
653 item.GroupOwned = dummyBool;
654
655 Int32.TryParse(reader.ReadElementContentAsString("SalePrice", String.Empty), out dummyInt);
656 item.SalePrice = dummyInt;
657
658 byte dummyByte;
659 Byte.TryParse(reader.ReadElementContentAsString("SaleType", String.Empty), out dummyByte);
660 item.SaleType = dummyByte;
661
662 UInt32.TryParse(reader.ReadElementContentAsString("Flags", String.Empty), out dummyUInt);
663 item.Flags = dummyUInt;
664
665 Int32.TryParse(reader.ReadElementContentAsString("CreationDate", String.Empty), out dummyInt);
666 item.CreationDate = dummyInt;
667
668 reader.ReadEndElement();
669 reader.ReadEndElement();
670 }
671 }
672 catch (Exception ex)
673 {
674 m_log.Warn("[OPENSIMINVENTORYFRONTEND]: Failed to parse POST data (expecting InventoryItemBase): " + ex.Message);
675 agentID = UUID.Zero;
676 sessionID = UUID.Zero;
677 return null;
678 }
679
680 return item;
681 }
682
683 private static byte[] SerializeBool(bool value)
684 {
685 byte[] buffer;
686 MemoryStream ms = new MemoryStream();
687
688 using (XmlWriter writer = XmlWriter.Create(ms))
689 {
690 writer.WriteStartDocument();
691 writer.WriteStartElement("boolean");
692 writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
693 writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
694 writer.WriteString(value.ToString().ToLower());
695 writer.WriteEndElement();
696 writer.WriteEndDocument();
697 writer.Flush();
698 }
699
700 ms.Seek(0, SeekOrigin.Begin);
701 buffer = ms.GetBuffer();
702 Array.Resize<byte>(ref buffer, (int) ms.Length);
703 ms.Close();
704
705 return buffer;
706 }
707
708 private static void SerializeFolderList(Stream stream, List<InventoryFolderWithChildren> folders)
709 {
710 using (XmlWriter writer = XmlWriter.Create(stream))
711 {
712 writer.WriteStartDocument();
713 writer.WriteStartElement("ArrayOfInventoryFolderBase");
714 writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
715 writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
716
717 if (folders != null)
718 {
719 foreach (InventoryFolderWithChildren folder in folders)
720 {
721 writer.WriteStartElement("InventoryFolderBase");
722 writer.WriteElementString("Name", folder.Name);
723 WriteUUID(writer, "Owner", folder.Owner);
724 WriteUUID(writer, "ParentID", folder.ParentID);
725 WriteUUID(writer, "ID", folder.ID);
726 writer.WriteElementString("Type", XmlConvert.ToString(folder.Type));
727 writer.WriteElementString("Version", XmlConvert.ToString(folder.Version));
728 writer.WriteEndElement();
729 }
730 }
731
732 writer.WriteEndElement();
733 writer.WriteEndDocument();
734
735 writer.Flush();
736 }
737
738 stream.Flush();
739 }
740
741 private static void SerializeItemList(Stream stream, List<InventoryItemBase> items)
742 {
743 using (XmlWriter writer = XmlWriter.Create(stream))
744 {
745 writer.WriteStartDocument();
746 writer.WriteStartElement("ArrayOfInventoryItemBase");
747 writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
748 writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
749
750 if (items != null)
751 {
752 foreach (InventoryItemBase item in items)
753 {
754 writer.WriteStartElement("InventoryItemBase");
755 WriteUUID(writer, "ID", item.ID);
756 writer.WriteElementString("InvType", XmlConvert.ToString(item.InvType));
757 WriteUUID(writer, "Folder", item.Folder);
758 WriteUUID(writer, "Owner", item.Owner);
759 writer.WriteElementString("Creator", item.CreatorId);
760 writer.WriteElementString("Name", item.Name);
761 writer.WriteElementString("Description", item.Description);
762 writer.WriteElementString("NextPermissions", XmlConvert.ToString(item.NextPermissions));
763 writer.WriteElementString("CurrentPermissions", XmlConvert.ToString(item.CurrentPermissions));
764 writer.WriteElementString("BasePermissions", XmlConvert.ToString(item.BasePermissions));
765 writer.WriteElementString("EveryOnePermissions", XmlConvert.ToString(item.EveryOnePermissions));
766 writer.WriteElementString("GroupPermissions", XmlConvert.ToString(item.GroupPermissions));
767 writer.WriteElementString("AssetType", XmlConvert.ToString(item.AssetType));
768 WriteUUID(writer, "AssetID", item.AssetID);
769 WriteUUID(writer, "GroupID", item.GroupID);
770 writer.WriteElementString("GroupOwned", XmlConvert.ToString(item.GroupOwned));
771 writer.WriteElementString("SalePrice", XmlConvert.ToString(item.SalePrice));
772 writer.WriteElementString("SaleType", XmlConvert.ToString(item.SaleType));
773 writer.WriteElementString("Flags", XmlConvert.ToString(item.Flags));
774 writer.WriteElementString("CreationDate", XmlConvert.ToString(item.CreationDate));
775 writer.WriteEndElement();
776 }
777 }
778
779 writer.WriteEndElement();
780 writer.WriteEndDocument();
781
782 writer.Flush();
783 }
784
785 stream.Flush();
786 }
787
788 private static void WriteUUID(XmlWriter writer, string name, UUID id)
789 {
790 writer.WriteStartElement(name);
791 writer.WriteElementString("Guid", XmlConvert.ToString(id.Guid));
792 writer.WriteEndElement();
793 }
794
795 private static void ReadUUID(XmlReader reader, string name, out UUID id)
796 {
797 reader.ReadStartElement(name);
798 UUID.TryParse(reader.ReadElementContentAsString("Guid", String.Empty), out id);
799 reader.ReadEndElement();
800 }
801 }
802
803 #region OpenSim AssetType
804
805 /// <summary>
806 /// The different types of grid assets
807 /// </summary>
808 public enum AssetType : sbyte
809 {
810 /// <summary>Unknown asset type</summary>
811 Unknown = -1,
812 /// <summary>Texture asset, stores in JPEG2000 J2C stream format</summary>
813 Texture = 0,
814 /// <summary>Sound asset</summary>
815 Sound = 1,
816 /// <summary>Calling card for another avatar</summary>
817 CallingCard = 2,
818 /// <summary>Link to a location in world</summary>
819 Landmark = 3,
820 // <summary>Legacy script asset, you should never see one of these</summary>
821 //[Obsolete]
822 //Script = 4,
823 /// <summary>Collection of textures and parameters that can be
824 /// worn by an avatar</summary>
825 Clothing = 5,
826 /// <summary>Primitive that can contain textures, sounds,
827 /// scripts and more</summary>
828 Object = 6,
829 /// <summary>Notecard asset</summary>
830 Notecard = 7,
831 /// <summary>Holds a collection of inventory items</summary>
832 Folder = 8,
833 /// <summary>Root inventory folder</summary>
834 RootFolder = 9,
835 /// <summary>Linden scripting language script</summary>
836 LSLText = 10,
837 /// <summary>LSO bytecode for a script</summary>
838 LSLBytecode = 11,
839 /// <summary>Uncompressed TGA texture</summary>
840 TextureTGA = 12,
841 /// <summary>Collection of textures and shape parameters that can
842 /// be worn</summary>
843 Bodypart = 13,
844 /// <summary>Trash folder</summary>
845 TrashFolder = 14,
846 /// <summary>Snapshot folder</summary>
847 SnapshotFolder = 15,
848 /// <summary>Lost and found folder</summary>
849 LostAndFoundFolder = 16,
850 /// <summary>Uncompressed sound</summary>
851 SoundWAV = 17,
852 /// <summary>Uncompressed TGA non-square image, not to be used as a
853 /// texture</summary>
854 ImageTGA = 18,
855 /// <summary>Compressed JPEG non-square image, not to be used as a
856 /// texture</summary>
857 ImageJPEG = 19,
858 /// <summary>Animation</summary>
859 Animation = 20,
860 /// <summary>Sequence of animations, sounds, chat, and pauses</summary>
861 Gesture = 21,
862 /// <summary>Simstate file</summary>
863 Simstate = 22,
864 }
865
866 #endregion OpenSim AssetType
867}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
deleted file mode 100644
index 2239b87..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
+++ /dev/null
@@ -1,547 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Data;
35using Nini.Config;
36using log4net;
37
38namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
39{
40 public class OpenSimInventoryStoragePlugin : IInventoryStorageProvider
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting
44
45 private AssetInventoryServer m_server;
46 private IConfig m_openSimConfig;
47 private OpenSimInventoryService m_inventoryService;
48
49 public OpenSimInventoryStoragePlugin()
50 {
51 }
52
53 #region IInventoryStorageProvider implementation
54
55 public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
56 {
57 item = null;
58 //BackendResponse ret;
59
60 //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
61 //{
62 // IDataReader reader;
63
64 // try
65 // {
66 // dbConnection.Open();
67
68 // IDbCommand command = dbConnection.CreateCommand();
69 // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," +
70 // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," +
71 // "creationDate,groupID,groupOwned,flags,avatarID,parentFolderID,inventoryGroupPermissions FROM inventoryitems WHERE inventoryID='{0}'",
72 // itemID.ToString());
73 // reader = command.ExecuteReader();
74
75 // if (reader.Read())
76 // {
77 // item = new InventoryItemBase();
78 // item.ID = itemID;
79 // item.AssetID = UUID.Parse(reader.GetString(0));
80 // item.AssetType = reader.GetInt32(1);
81 // item.Name = reader.GetString(2);
82 // item.Description = reader.GetString(3);
83 // item.NextPermissions = (uint)reader.GetInt32(4);
84 // item.CurrentPermissions = (uint)reader.GetInt32(5);
85 // item.InvType = reader.GetInt32(6);
86 // item.Creator = UUID.Parse(reader.GetString(7));
87 // item.BasePermissions = (uint)reader.GetInt32(8);
88 // item.EveryOnePermissions = (uint)reader.GetInt32(9);
89 // item.SalePrice = reader.GetInt32(10);
90 // item.SaleType = reader.GetByte(11);
91 // item.CreationDate = reader.GetInt32(12);
92 // item.GroupID = UUID.Parse(reader.GetString(13));
93 // item.GroupOwned = reader.GetBoolean(14);
94 // item.Flags = (uint)reader.GetInt32(15);
95 // item.Owner = UUID.Parse(reader.GetString(16));
96 // item.Folder = UUID.Parse(reader.GetString(17));
97 // item.GroupPermissions = (uint)reader.GetInt32(18);
98
99 // ret = BackendResponse.Success;
100 // }
101 // else
102 // {
103 // ret = BackendResponse.NotFound;
104 // }
105 // }
106 // catch (MySqlException ex)
107 // {
108 // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
109 // ret = BackendResponse.Failure;
110 // }
111 //}
112
113 //m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
114 //return ret;
115 m_log.Warn("[OPENSIMINVENTORYSTORAGE]: Called TryFetchItem which is not implemented.");
116 return BackendResponse.Success;
117 }
118
119 public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder)
120 {
121 BackendResponse ret;
122
123 // TODO: implement some logic for "folder not found"
124 folder = m_inventoryService.GetInventoryFolder(folderID);
125 ret = BackendResponse.Success;
126
127 m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now);
128 return ret;
129 }
130
131 public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents)
132 {
133 contents = null;
134 //BackendResponse ret;
135
136 //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
137 //{
138 // IDataReader reader;
139
140 // try
141 // {
142 // dbConnection.Open();
143
144 // contents = new InventoryCollection();
145
146 // #region Folder retrieval
147
148 // IDbCommand command = dbConnection.CreateCommand();
149 // command.CommandText = String.Format("SELECT folderName,type,version,agentID,folderID FROM inventoryfolders WHERE parentFolderID='{0}'",
150 // folderID.ToString());
151 // reader = command.ExecuteReader();
152
153 // contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
154
155 // while (reader.Read())
156 // {
157 // InventoryFolderWithChildren folder = new InventoryFolderWithChildren();
158 // folder.ParentID = folderID;
159 // folder.Children = null; // This call doesn't do recursion
160 // folder.Name = reader.GetString(0);
161 // folder.Type = reader.GetInt16(1);
162 // folder.Version = (ushort)reader.GetInt16(2);
163 // folder.Owner = UUID.Parse(reader.GetString(3));
164 // folder.ID = UUID.Parse(reader.GetString(4));
165
166 // contents.Folders.Add(folder.ID, folder);
167 // contents.UserID = folder.Owner;
168 // }
169
170 // reader.Close();
171
172 // #endregion Folder retrieval
173
174 // #region Item retrieval
175
176 // command = dbConnection.CreateCommand();
177 // command.CommandText = String.Format("SELECT assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," +
178 // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," +
179 // "creationDate,groupID,groupOwned,flags,avatarID,inventoryID,inventoryGroupPermissions FROM inventoryitems WHERE parentFolderID='{0}'",
180 // folderID.ToString());
181 // reader = command.ExecuteReader();
182
183 // contents.Items = new Dictionary<UUID, InventoryItemBase>();
184
185 // while (reader.Read())
186 // {
187 // InventoryItemBase item = new InventoryItemBase();
188 // item.Folder = folderID;
189 // item.AssetID = UUID.Parse(reader.GetString(0));
190 // item.AssetType = reader.GetInt32(1);
191 // item.Name = reader.GetString(2);
192 // item.Description = reader.GetString(3);
193 // item.NextPermissions = (uint)reader.GetInt32(4);
194 // item.CurrentPermissions = (uint)reader.GetInt32(5);
195 // item.InvType = reader.GetInt32(6);
196 // item.Creator = UUID.Parse(reader.GetString(7));
197 // item.BasePermissions = (uint)reader.GetInt32(8);
198 // item.EveryOnePermissions = (uint)reader.GetInt32(9);
199 // item.SalePrice = reader.GetInt32(10);
200 // item.SaleType = reader.GetByte(11);
201 // item.CreationDate = reader.GetInt32(12);
202 // item.GroupID = UUID.Parse(reader.GetString(13));
203 // item.GroupOwned = reader.GetBoolean(14);
204 // item.Flags = (uint)reader.GetInt32(15);
205 // item.Owner = UUID.Parse(reader.GetString(16));
206 // item.ID = UUID.Parse(reader.GetString(17));
207 // item.GroupPermissions = (uint)reader.GetInt32(18);
208
209 // contents.Items.Add(item.ID, item);
210 // contents.UserID = item.Owner;
211 // }
212
213 // #endregion Item retrieval
214
215 // ret = BackendResponse.Success;
216 // }
217 // catch (MySqlException ex)
218 // {
219 // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
220 // ret = BackendResponse.Failure;
221 // }
222 //}
223
224 //m_server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
225 //return ret;
226 m_log.Warn("[OPENSIMINVENTORYSTORAGE]: Called TryFetchFolderContents which is not implemented.");
227 return BackendResponse.Success;
228 }
229
230 public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders)
231 {
232 folders = new List<InventoryFolderWithChildren>();
233 BackendResponse ret;
234 UUID ownerID;
235
236 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
237 {
238 List<InventoryFolderBase> baseFolders = m_inventoryService.GetInventorySkeleton(ownerID);
239 foreach (InventoryFolderBase baseFolder in baseFolders)
240 {
241 InventoryFolderWithChildren folder = new InventoryFolderWithChildren(baseFolder);
242 //folder.Children = null; // This call does not create a folder hierarchy
243 folders.Add(folder);
244 }
245
246 ret = BackendResponse.Success;
247 }
248 else
249 {
250 folders = null;
251 ret = BackendResponse.NotFound;
252 }
253
254 m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now);
255 return ret;
256 }
257
258 public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory)
259 {
260 inventory = null;
261 BackendResponse ret;
262 List<InventoryFolderWithChildren> folders;
263
264 ret = TryFetchFolderList(owner, out folders);
265
266 if (ret == BackendResponse.Success)
267 {
268 // Add the retrieved folders to the inventory collection
269 inventory = new InventoryCollection();
270 inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(folders.Count);
271 foreach (InventoryFolderWithChildren folder in folders)
272 inventory.Folders[folder.ID] = folder;
273
274 // Fetch inventory items
275 UUID ownerID;
276 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
277 {
278 inventory.UserID = ownerID;
279 inventory.Items = new Dictionary<UUID, InventoryItemBase>();
280
281 foreach (InventoryFolderWithChildren folder in folders)
282 {
283 foreach (InventoryItemBase item in m_inventoryService.RequestFolderItems(folder.ID))
284 {
285 inventory.Items.Add(item.ID, item);
286 }
287 }
288
289 ret = BackendResponse.Success;
290
291 }
292 else
293 {
294 ret = BackendResponse.NotFound;
295 }
296 }
297
298 m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now);
299 return ret;
300 }
301
302 public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures)
303 {
304 gestures = null;
305 BackendResponse ret;
306 UUID ownerID;
307
308 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
309 {
310 gestures = m_inventoryService.GetActiveGestures(ownerID);
311 ret = BackendResponse.Success;
312 }
313 else
314 {
315 ret = BackendResponse.NotFound;
316 }
317
318 m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now);
319 return ret;
320 }
321
322 public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item)
323 {
324 BackendResponse ret;
325
326 if (m_inventoryService.AddItem(item))
327 {
328 ret = BackendResponse.Success;
329 }
330 else
331 {
332 ret = BackendResponse.Failure;
333 }
334
335 m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now);
336 return ret;
337 }
338
339 public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder)
340 {
341 BackendResponse ret;
342
343 if (m_inventoryService.AddFolder(folder))
344 {
345 ret = BackendResponse.Success;
346 }
347 else
348 {
349 ret = BackendResponse.Failure;
350 }
351
352 m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now);
353 return ret;
354 }
355
356 public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
357 {
358 BackendResponse ret;
359 UUID ownerID;
360
361 if (Utils.TryGetOpenSimUUID(owner, out ownerID))
362 {
363 if (m_inventoryService.CreateNewUserInventory(ownerID))
364 {
365 ret = BackendResponse.Success;
366 }
367 else
368 {
369 ret = BackendResponse.Failure;
370 }
371 }
372 else
373 {
374 ret = BackendResponse.Failure;
375 }
376
377 return ret;
378 }
379
380 public BackendResponse TryDeleteItem(Uri owner, UUID itemID)
381 {
382 BackendResponse ret;
383
384 if (m_inventoryService.DeleteItem(m_inventoryService.GetInventoryItem(itemID)))
385 {
386 ret = BackendResponse.Success;
387 }
388 else
389 {
390 ret = BackendResponse.Failure;
391 }
392
393 m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
394 return ret;
395 }
396
397 public BackendResponse TryDeleteFolder(Uri owner, UUID folderID)
398 {
399 //BackendResponse ret;
400 //UUID ownerID;
401
402 //if (Utils.TryGetOpenSimUUID(owner, out ownerID))
403 //{
404 // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
405 // {
406 // try
407 // {
408 // dbConnection.Open();
409
410 // MySqlCommand command = new MySqlCommand(
411 // "DELETE FROM inventoryfolders WHERE folderID=?folderID AND agentID=?agentID", dbConnection);
412
413 // command.Parameters.AddWithValue("?folderID", folderID.ToString());
414 // command.Parameters.AddWithValue("?agentID", ownerID.ToString());
415
416 // int rowsAffected = command.ExecuteNonQuery();
417 // if (rowsAffected == 1)
418 // {
419 // ret = BackendResponse.Success;
420 // }
421 // else
422 // {
423 // m_log.ErrorFormat("[OPENSIMINVENTORYSTORAGE]: MySQL DELETE query affected {0} rows", rowsAffected);
424 // ret = BackendResponse.NotFound;
425 // }
426 // }
427 // catch (MySqlException ex)
428 // {
429 // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
430 // ret = BackendResponse.Failure;
431 // }
432 // }
433 //}
434 //else
435 //{
436 // ret = BackendResponse.NotFound;
437 //}
438
439 //m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now);
440 //return ret;
441 m_log.Warn("[OPENSIMINVENTORYSTORAGE]: Called TryDeleteFolder which is not implemented.");
442 return BackendResponse.Success;
443 }
444
445 public BackendResponse TryPurgeFolder(Uri owner, UUID folderID)
446 {
447 BackendResponse ret;
448
449 if (m_inventoryService.PurgeFolder(m_inventoryService.GetInventoryFolder(folderID)))
450 {
451 ret = BackendResponse.Success;
452 }
453 else
454 {
455 ret = BackendResponse.Failure;
456 }
457
458 m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
459 return ret;
460 }
461
462 public int ForEach(Action<AssetMetadata> action, int start, int count)
463 {
464 int rowCount = 0;
465
466 //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
467 //{
468 // MySqlDataReader reader;
469
470 // try
471 // {
472 // dbConnection.Open();
473
474 // MySqlCommand command = dbConnection.CreateCommand();
475 // command.CommandText = String.Format("SELECT name,description,assetType,temporary,data,id FROM assets LIMIT {0}, {1}",
476 // start, count);
477 // reader = command.ExecuteReader();
478 // }
479 // catch (MySqlException ex)
480 // {
481 // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
482 // return 0;
483 // }
484
485 // while (reader.Read())
486 // {
487 // Metadata metadata = new Metadata();
488 // metadata.CreationDate = OpenMetaverse.Utils.Epoch;
489 // metadata.Description = reader.GetString(1);
490 // metadata.ID = UUID.Parse(reader.GetString(5));
491 // metadata.Name = reader.GetString(0);
492 // metadata.SHA1 = OpenMetaverse.Utils.SHA1((byte[])reader.GetValue(4));
493 // metadata.Temporary = reader.GetBoolean(3);
494 // metadata.ContentType = Utils.SLAssetTypeToContentType(reader.GetInt32(2));
495
496 // action(metadata);
497 // ++rowCount;
498 // }
499
500 // reader.Close();
501 //}
502
503 return rowCount;
504 }
505
506 #endregion IInventoryStorageProvider implementation
507
508 #region IPlugin implementation
509
510 public void Initialise(AssetInventoryServer server)
511 {
512 m_server = server;
513 m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
514
515 m_inventoryService = new OpenSimInventoryService();
516 m_inventoryService.AddPlugin(m_openSimConfig.GetString("inventory_database_provider"),
517 m_openSimConfig.GetString("inventory_database_connect"));
518 }
519
520 public void Stop()
521 {
522 }
523
524 public void Initialise()
525 {
526 m_log.InfoFormat("[OPENSIMINVENTORYSTORAGE]: {0} cannot be default-initialized!", Name);
527 throw new PluginNotInitialisedException(Name);
528 }
529
530 public void Dispose()
531 {
532 }
533
534 public string Version
535 {
536 // TODO: this should be something meaningful and not hardcoded?
537 get { return "0.1"; }
538 }
539
540 public string Name
541 {
542 get { return "OpenSimInventoryStorage"; }
543 }
544
545 #endregion IPlugin implementation
546 }
547}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml
deleted file mode 100644
index 8cd7585..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml
+++ /dev/null
@@ -1,27 +0,0 @@
1<Addin id="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim" version="0.1">
2 <Runtime>
3 <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" />
4 <Import assembly="OpenSim.Data.dll" />
5 </Runtime>
6
7 <Dependencies>
8 <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" />
9 </Dependencies>
10
11 <ExtensionPoint path = "/OpenSim/AssetData">
12 <ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Data.IAssetDataPlugin" />
13 </ExtensionPoint>
14
15 <Extension path="/OpenSim/AssetInventoryServer/AssetStorageProvider">
16 <Plugin id="OpenSimAssetStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimAssetStoragePlugin" />
17 </Extension>
18 <Extension path="/OpenSim/AssetInventoryServer/InventoryStorageProvider">
19 <Plugin id="OpenSimInventoryStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimInventoryStoragePlugin" />
20 </Extension>
21 <Extension path="/OpenSim/AssetInventoryServer/Frontend">
22 <Plugin id="OpenSimAssetFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimAssetFrontendPlugin" />
23 </Extension>
24 <Extension path="/OpenSim/AssetInventoryServer/Frontend">
25 <Plugin id="OpenSimInventoryFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.OpenSimInventoryFrontendPlugin" />
26 </Extension>
27</Addin>
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs
deleted file mode 100644
index b5ad1a1..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/ReferenceFrontendPlugin.cs
+++ /dev/null
@@ -1,369 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31using System.Net;
32using OpenMetaverse;
33using OpenMetaverse.StructuredData;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Servers.HttpServer;
37using log4net;
38
39namespace OpenSim.Grid.AssetInventoryServer.Plugins
40{
41 public class ReferenceFrontendPlugin : IAssetInventoryServerPlugin
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 AssetInventoryServer m_server;
45
46 public ReferenceFrontendPlugin()
47 {
48 }
49
50 #region IPlugin implementation
51
52 public void Initialise(AssetInventoryServer server)
53 {
54 m_server = server;
55
56 // Asset metadata request
57 //m_server.HttpServer.AddStreamHandler(new MetadataRequestHandler(server));
58
59 // Asset data request
60 m_server.HttpServer.AddStreamHandler(new DataRequestHandler(server));
61
62 // Asset creation
63 //m_server.HttpServer.AddStreamHandler(new CreateRequestHandler(server));
64
65 m_log.Info("[REFERENCEFRONTEND]: Reference Frontend loaded.");
66 }
67
68 /// <summary>
69 /// <para>Initialises asset interface</para>
70 /// </summary>
71 public void Initialise()
72 {
73 m_log.InfoFormat("[REFERENCEFRONTEND]: {0} cannot be default-initialized!", Name);
74 throw new PluginNotInitialisedException(Name);
75 }
76
77 public void Dispose()
78 {
79 }
80
81 public string Version
82 {
83 // TODO: this should be something meaningful and not hardcoded?
84 get { return "0.1"; }
85 }
86
87 public string Name
88 {
89 get { return "ReferenceFrontend"; }
90 }
91
92 #endregion IPlugin implementation
93
94 //public class MetadataRequestHandler : IStreamedRequestHandler
95 //{
96 // AssetInventoryServer m_server;
97 // string m_contentType;
98 // string m_httpMethod;
99 // string m_path;
100
101 // public MetadataRequestHandler(AssetInventoryServer server)
102 // {
103 // m_server = server;
104 // m_contentType = null;
105 // m_httpMethod = "GET";
106 // m_path = @"^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/metadata";
107 // }
108
109 // #region IStreamedRequestHandler implementation
110
111 // public string ContentType
112 // {
113 // get { return m_contentType; }
114 // }
115
116 // public string HttpMethod
117 // {
118 // get { return m_httpMethod; }
119 // }
120
121 // public string Path
122 // {
123 // get { return m_path; }
124 // }
125
126 // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
127 // {
128 // byte[] serializedData = null;
129 // UUID assetID;
130 // // Split the URL up into an AssetID and a method
131 // string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/');
132
133 // if (rawUrl.Length >= 3 && UUID.TryParse(rawUrl[1], out assetID))
134 // {
135 // UUID authToken = Utils.GetAuthToken(httpRequest);
136
137 // if (m_server.AuthorizationProvider.IsMetadataAuthorized(authToken, assetID))
138 // {
139 // AssetMetadata metadata;
140 // BackendResponse storageResponse = m_server.StorageProvider.TryFetchMetadata(assetID, out metadata);
141
142 // if (storageResponse == BackendResponse.Success)
143 // {
144 // // If the asset data location wasn't specified in the metadata, specify it
145 // // manually here by pointing back to this asset server
146 // if (!metadata.Methods.ContainsKey("data"))
147 // {
148 // metadata.Methods["data"] = new Uri(String.Format("{0}://{1}/{2}/data",
149 // httpRequest.Url.Scheme, httpRequest.Url.Authority, assetID));
150 // }
151
152 // serializedData = metadata.SerializeToBytes();
153
154 // httpResponse.StatusCode = (int) HttpStatusCode.OK;
155 // httpResponse.ContentType = "application/json";
156 // httpResponse.ContentLength = serializedData.Length;
157 // httpResponse.Body.Write(serializedData, 0, serializedData.Length);
158 // }
159 // else if (storageResponse == BackendResponse.NotFound)
160 // {
161 // m_log.Warn("[REFERENCEFRONTEND]: Could not find metadata for asset " + assetID.ToString());
162 // httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
163 // }
164 // else
165 // {
166 // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
167 // }
168 // }
169 // else
170 // {
171 // httpResponse.StatusCode = (int) HttpStatusCode.Forbidden;
172 // }
173
174 // return serializedData;
175 // }
176
177 // httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
178 // return serializedData;
179 // }
180
181 // #endregion IStreamedRequestHandler implementation
182 //}
183
184 public class DataRequestHandler : IStreamedRequestHandler
185 {
186 AssetInventoryServer m_server;
187 string m_contentType;
188 string m_httpMethod;
189 string m_path;
190
191 public DataRequestHandler(AssetInventoryServer server)
192 {
193 m_server = server;
194 m_contentType = null;
195 m_httpMethod = "GET";
196 m_path = @"^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/data";
197 }
198
199 #region IStreamedRequestHandler implementation
200
201 public string ContentType
202 {
203 get { return m_contentType; }
204 }
205
206 public string HttpMethod
207 {
208 get { return m_httpMethod; }
209 }
210
211 public string Path
212 {
213 get { return m_path; }
214 }
215
216 public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
217 {
218 byte[] assetData = null;
219 UUID assetID;
220 // Split the URL up into an AssetID and a method
221 string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/');
222
223 if (rawUrl.Length >= 3 && UUID.TryParse(rawUrl[1], out assetID))
224 {
225 UUID authToken = Utils.GetAuthToken(httpRequest);
226
227 if (m_server.AuthorizationProvider.IsDataAuthorized(authToken, assetID))
228 {
229 BackendResponse storageResponse = m_server.StorageProvider.TryFetchData(assetID, out assetData);
230
231 if (storageResponse == BackendResponse.Success)
232 {
233 httpResponse.StatusCode = (int) HttpStatusCode.OK;
234 httpResponse.ContentType = "application/octet-stream";
235 httpResponse.AddHeader("Content-Disposition", "attachment; filename=" + assetID.ToString());
236 httpResponse.ContentLength = assetData.Length;
237 httpResponse.Body.Write(assetData, 0, assetData.Length);
238 }
239 else if (storageResponse == BackendResponse.NotFound)
240 {
241 httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
242 }
243 else
244 {
245 httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
246 }
247 }
248 else
249 {
250 httpResponse.StatusCode = (int) HttpStatusCode.Forbidden;
251 }
252
253 return assetData;
254 }
255
256 httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
257 return assetData;
258 }
259
260 #endregion IStreamedRequestHandler implementation
261 }
262
263 //public class CreateRequestHandler : IStreamedRequestHandler
264 //{
265 // AssetInventoryServer m_server;
266 // string m_contentType;
267 // string m_httpMethod;
268 // string m_path;
269
270 // public CreateRequestHandler(AssetInventoryServer server)
271 // {
272 // m_server = server;
273 // m_contentType = null;
274 // m_httpMethod = "POST";
275 // m_path = "^/createasset";
276 // }
277
278 // #region IStreamedRequestHandler implementation
279
280 // public string ContentType
281 // {
282 // get { return m_contentType; }
283 // }
284
285 // public string HttpMethod
286 // {
287 // get { return m_httpMethod; }
288 // }
289
290 // public string Path
291 // {
292 // get { return m_path; }
293 // }
294
295 // public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
296 // {
297 // byte[] responseData = null;
298 // UUID authToken = Utils.GetAuthToken(httpRequest);
299
300 // if (m_server.AuthorizationProvider.IsCreateAuthorized(authToken))
301 // {
302 // try
303 // {
304 // OSD osdata = OSDParser.DeserializeJson(new StreamReader(httpRequest.InputStream).ReadToEnd());
305
306 // if (osdata.Type == OSDType.Map)
307 // {
308 // OSDMap map = (OSDMap)osdata;
309 // Metadata metadata = new Metadata();
310 // metadata.Deserialize(map);
311
312 // byte[] assetData = map["data"].AsBinary();
313
314 // if (assetData != null && assetData.Length > 0)
315 // {
316 // BackendResponse storageResponse;
317
318 // if (metadata.ID != UUID.Zero)
319 // storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData);
320 // else
321 // storageResponse = m_server.StorageProvider.TryCreateAsset(metadata, assetData, out metadata.ID);
322
323 // if (storageResponse == BackendResponse.Success)
324 // {
325 // httpResponse.StatusCode = (int) HttpStatusCode.Created;
326 // OSDMap responseMap = new OSDMap(1);
327 // responseMap["id"] = OSD.FromUUID(metadata.ID);
328 // LitJson.JsonData jsonData = OSDParser.SerializeJson(responseMap);
329 // responseData = System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson());
330 // httpResponse.Body.Write(responseData, 0, responseData.Length);
331 // httpResponse.Body.Flush();
332 // }
333 // else if (storageResponse == BackendResponse.NotFound)
334 // {
335 // httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
336 // }
337 // else
338 // {
339 // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
340 // }
341 // }
342 // else
343 // {
344 // httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
345 // }
346 // }
347 // else
348 // {
349 // httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
350 // }
351 // }
352 // catch (Exception ex)
353 // {
354 // httpResponse.StatusCode = (int) HttpStatusCode.InternalServerError;
355 // httpResponse.StatusDescription = ex.Message;
356 // }
357 // }
358 // else
359 // {
360 // httpResponse.StatusCode = (int) HttpStatusCode.Forbidden;
361 // }
362
363 // return responseData;
364 // }
365
366 // #endregion IStreamedRequestHandler implementation
367 //}
368 }
369}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml
deleted file mode 100644
index 42a279d..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml
+++ /dev/null
@@ -1,28 +0,0 @@
1<Addin id="OpenSim.Grid.AssetInventoryServer.Plugins" version="0.1">
2 <Runtime>
3 <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.dll" />
4 </Runtime>
5
6 <Dependencies>
7 <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" />
8 </Dependencies>
9
10 <Extension path="/OpenSim/AssetInventoryServer/MetricsProvider">
11 <Plugin id="NullMetrics" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.NullMetricsPlugin" />
12 </Extension>
13 <Extension path="/OpenSim/AssetInventoryServer/Frontend">
14 <Plugin id="BrowseFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.BrowseFrontendPlugin" />
15 </Extension>
16 <Extension path="/OpenSim/AssetInventoryServer/Frontend">
17 <Plugin id="ReferenceFrontend" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.ReferenceFrontendPlugin" />
18 </Extension>
19 <Extension path="/OpenSim/AssetInventoryServer/AuthenticationProvider">
20 <Plugin id="NullAuthentication" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.NullAuthenticationPlugin" />
21 </Extension>
22 <Extension path="/OpenSim/AssetInventoryServer/AuthorizationProvider">
23 <Plugin id="AuthorizeAll" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.AuthorizeAllPlugin" />
24 </Extension>
25 <Extension path="/OpenSim/AssetInventoryServer/Frontend">
26 <Plugin id="InventoryArchive" provider="OpenSim.Grid.AssetInventoryServer.Plugins.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.InventoryArchivePlugin" />
27 </Extension>
28</Addin>
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml
deleted file mode 100644
index cb6959e..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml
+++ /dev/null
@@ -1,16 +0,0 @@
1<Addin id="OpenSim.Grid.AssetInventoryServer.Plugins.Simple" version="0.1">
2 <Runtime>
3 <Import assembly="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" />
4 </Runtime>
5
6 <Dependencies>
7 <Addin id="OpenSim.Grid.AssetInventoryServer" version="0.1" />
8 </Dependencies>
9
10 <Extension path="/OpenSim/AssetInventoryServer/AssetStorageProvider">
11 <Plugin id="SimpleAssetStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.SimpleAssetStoragePlugin" />
12 </Extension>
13 <Extension path="/OpenSim/AssetInventoryServer/InventoryStorageProvider">
14 <Plugin id="SimpleInventoryStorage" provider="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll" type="OpenSim.Grid.AssetInventoryServer.Plugins.Simple.SimpleInventoryStoragePlugin" />
15 </Extension>
16</Addin>
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs
deleted file mode 100644
index 4ec2d96..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleAssetStoragePlugin.cs
+++ /dev/null
@@ -1,290 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections.Generic;
31using System.IO;
32using OpenMetaverse;
33using OpenSim.Framework;
34using log4net;
35
36namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
37{
38 public class SimpleAssetStoragePlugin : IAssetStorageProvider
39 {
40 const string EXTENSION_NAME = "SimpleAssetStorage"; // Used in metrics reporting
41 const string DEFAULT_DATA_DIR = "SimpleAssets";
42 const string TEMP_DATA_DIR = "SimpleAssetsTemp";
43
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 AssetInventoryServer server;
46 Dictionary<UUID, AssetMetadata> metadataStorage;
47 Dictionary<UUID, string> filenames;
48
49 public SimpleAssetStoragePlugin()
50 {
51 }
52
53 #region Required Interfaces
54
55 public BackendResponse TryFetchMetadata(UUID assetID, out AssetMetadata metadata)
56 {
57 metadata = null;
58 BackendResponse ret;
59
60 if (metadataStorage.TryGetValue(assetID, out metadata))
61 ret = BackendResponse.Success;
62 else
63 ret = BackendResponse.NotFound;
64
65 server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now);
66 return ret;
67 }
68
69 public BackendResponse TryFetchData(UUID assetID, out byte[] assetData)
70 {
71 assetData = null;
72 string filename;
73 BackendResponse ret;
74
75 if (filenames.TryGetValue(assetID, out filename))
76 {
77 try
78 {
79 assetData = File.ReadAllBytes(filename);
80 ret = BackendResponse.Success;
81 }
82 catch (Exception ex)
83 {
84 m_log.ErrorFormat("[SIMPLEASSETSTORAGE]: Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message);
85 ret = BackendResponse.Failure;
86 }
87 }
88 else
89 {
90 ret = BackendResponse.NotFound;
91 }
92
93 server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now);
94 return ret;
95 }
96
97 public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset)
98 {
99 asset = new AssetBase();
100 AssetMetadata metadata = asset.Metadata;
101
102 string filename;
103 BackendResponse ret;
104
105 if (metadataStorage.TryGetValue(assetID, out metadata) &&
106 filenames.TryGetValue(assetID, out filename))
107 {
108 try
109 {
110 asset.Data = File.ReadAllBytes(filename);
111 ret = BackendResponse.Success;
112 }
113 catch (Exception ex)
114 {
115 m_log.ErrorFormat("[SIMPLEASSETSTORAGE]: Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message);
116 ret = BackendResponse.Failure;
117 }
118
119 asset.Type = (sbyte) Utils.ContentTypeToSLAssetType(metadata.ContentType);
120 asset.Local = false;
121 }
122 else
123 {
124 asset = null;
125 ret = BackendResponse.NotFound;
126 }
127
128 server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now);
129 server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (asset != null && asset.Data != null ? asset.Data.Length : 0), DateTime.Now);
130 return ret;
131 }
132
133 public BackendResponse TryCreateAsset(AssetBase asset, out UUID assetID)
134 {
135 assetID = asset.FullID = UUID.Random();
136 return TryCreateAsset(asset);
137 }
138
139 public BackendResponse TryCreateAsset(AssetBase asset)
140 {
141 BackendResponse ret;
142 AssetMetadata metadata = asset.Metadata;
143
144 string path;
145 string filename = String.Format("{0}.{1}", asset.FullID, Utils.ContentTypeToExtension(metadata.ContentType));
146
147 if (asset.Temporary)
148 path = Path.Combine(TEMP_DATA_DIR, filename);
149 else
150 path = Path.Combine(DEFAULT_DATA_DIR, filename);
151
152 try
153 {
154 File.WriteAllBytes(path, asset.Data);
155 lock (filenames) filenames[asset.FullID] = path;
156
157 // Set the creation date to right now
158 metadata.CreationDate = DateTime.Now;
159
160 lock (metadataStorage)
161 metadataStorage[asset.FullID] = metadata;
162
163 ret = BackendResponse.Success;
164 }
165 catch (Exception ex)
166 {
167 m_log.ErrorFormat("[SIMPLEASSETSTORAGE]: Failed writing data for asset {0} to {1}: {2}", asset.FullID, filename, ex.Message);
168 ret = BackendResponse.Failure;
169 }
170
171 server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now);
172 return ret;
173 }
174
175 public int ForEach(Action<AssetMetadata> action, int start, int count)
176 {
177 int rowCount = 0;
178
179 //lock (metadataStorage)
180 //{
181 // foreach (Metadata metadata in metadataStorage.Values)
182 // {
183 // action(metadata);
184 // ++rowCount;
185 // }
186 //}
187
188 return rowCount;
189 }
190
191 #endregion Required Interfaces
192
193 #region IPlugin implementation
194
195 public void Initialise(AssetInventoryServer server)
196 {
197 this.server = server;
198
199 metadataStorage = new Dictionary<UUID, AssetMetadata>();
200 filenames = new Dictionary<UUID, string>();
201
202 LoadFiles(DEFAULT_DATA_DIR, false);
203 LoadFiles(TEMP_DATA_DIR, true);
204
205 m_log.InfoFormat("[SIMPLEASSETSTORAGE]: Initialized the store index with metadata for {0} assets",
206 metadataStorage.Count);
207 }
208
209 /// <summary>
210 /// <para>Initialises asset interface</para>
211 /// </summary>
212 public void Initialise()
213 {
214 m_log.InfoFormat("[SIMPLEASSETSTORAGE]: {0} cannot be default-initialized!", Name);
215 throw new PluginNotInitialisedException(Name);
216 }
217
218 public void Dispose()
219 {
220 WipeTemporary();
221 }
222
223 public string Version
224 {
225 // TODO: this should be something meaningful and not hardcoded?
226 get { return "0.1"; }
227 }
228
229 public string Name
230 {
231 get { return "SimpleAssetStorage"; }
232 }
233
234 #endregion IPlugin implementation
235
236 public void WipeTemporary()
237 {
238 if (Directory.Exists(TEMP_DATA_DIR))
239 {
240 try { Directory.Delete(TEMP_DATA_DIR); }
241 catch (Exception ex) { m_log.Error("[SIMPLEASSETSTORAGE]: " + ex.Message); }
242 }
243 }
244
245 void LoadFiles(string folder, bool temporary)
246 {
247 // Try to create the directory if it doesn't already exist
248 if (!Directory.Exists(folder))
249 {
250 try { Directory.CreateDirectory(folder); }
251 catch (Exception ex)
252 {
253 m_log.Warn("[SIMPLEASSETSTORAGE]: " + ex.Message);
254 return;
255 }
256 }
257
258 lock (metadataStorage)
259 {
260 try
261 {
262 string[] assets = Directory.GetFiles(folder);
263
264 for (int i = 0; i < assets.Length; i++)
265 {
266 string filename = assets[i];
267 byte[] data = File.ReadAllBytes(filename);
268
269 AssetMetadata metadata = new AssetMetadata();
270 metadata.CreationDate = File.GetCreationTime(filename);
271 metadata.Description = String.Empty;
272 metadata.FullID = SimpleUtils.ParseUUIDFromFilename(filename);
273 metadata.Name = SimpleUtils.ParseNameFromFilename(filename);
274 metadata.SHA1 = OpenMetaverse.Utils.SHA1(data);
275 metadata.Temporary = false;
276 metadata.ContentType = Utils.ExtensionToContentType(Path.GetExtension(filename).TrimStart('.'));
277
278 // Store the loaded data
279 metadataStorage[metadata.FullID] = metadata;
280 filenames[metadata.FullID] = filename;
281 }
282 }
283 catch (Exception ex)
284 {
285 m_log.Warn("[SIMPLEASSETSTORAGE]: " + ex.Message);
286 }
287 }
288 }
289 }
290}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs
deleted file mode 100644
index 4010818..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs
+++ /dev/null
@@ -1,625 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections.Generic;
31using System.IO;
32using System.Text;
33using OpenMetaverse;
34using OpenSim.Framework;
35using log4net;
36
37namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
38{
39 public class SimpleInventoryStoragePlugin : IInventoryStorageProvider
40 {
41 const string EXTENSION_NAME = "SimpleInventoryStorage"; // Used for metrics reporting
42 const string DEFAULT_INVENTORY_DIR = "SimpleInventory";
43
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 AssetInventoryServer server;
46 Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>();
47 Dictionary<Uri, List<InventoryItemBase>> activeGestures = new Dictionary<Uri, List<InventoryItemBase>>();
48 Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer();
49 Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer();
50
51 public SimpleInventoryStoragePlugin()
52 {
53 }
54
55 #region Required Interfaces
56
57 public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
58 {
59 item = null;
60 BackendResponse ret;
61
62 InventoryCollection collection;
63 if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item))
64 ret = BackendResponse.Success;
65 else
66 ret = BackendResponse.NotFound;
67
68 server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
69 return ret;
70 }
71
72 public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder)
73 {
74 folder = null;
75 BackendResponse ret;
76
77 InventoryCollection collection;
78 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
79 ret = BackendResponse.Success;
80 else
81 ret = BackendResponse.NotFound;
82
83 server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now);
84 return ret;
85 }
86
87 public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents)
88 {
89 contents = null;
90 BackendResponse ret;
91
92 InventoryCollection collection;
93 InventoryFolderWithChildren folder;
94
95 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
96 {
97 contents = new InventoryCollection();
98 contents.UserID = collection.UserID;
99 contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
100 contents.Items = new Dictionary<UUID, InventoryItemBase>();
101
102 foreach (InventoryNodeBase invBase in folder.Children.Values)
103 {
104 if (invBase is InventoryItemBase)
105 {
106 InventoryItemBase invItem = invBase as InventoryItemBase;
107 contents.Items.Add(invItem.ID, invItem);
108 }
109 else
110 {
111 InventoryFolderWithChildren invFolder = invBase as InventoryFolderWithChildren;
112 contents.Folders.Add(invFolder.ID, invFolder);
113 }
114 }
115
116 ret = BackendResponse.Success;
117 }
118 else
119 {
120 ret = BackendResponse.NotFound;
121 }
122
123 server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
124 return ret;
125 }
126
127 public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders)
128 {
129 folders = null;
130 BackendResponse ret;
131
132 InventoryCollection collection;
133 if (inventories.TryGetValue(owner, out collection))
134 {
135 folders = new List<InventoryFolderWithChildren>(collection.Folders.Values);
136 return BackendResponse.Success;
137 }
138 else
139 {
140 ret = BackendResponse.NotFound;
141 }
142
143 server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now);
144 return ret;
145 }
146
147 public BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory)
148 {
149 inventory = null;
150 BackendResponse ret;
151
152 if (inventories.TryGetValue(owner, out inventory))
153 ret = BackendResponse.Success;
154 else
155 ret = BackendResponse.NotFound;
156
157 server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now);
158 return ret;
159 }
160
161 public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures)
162 {
163 gestures = null;
164 BackendResponse ret;
165
166 if (activeGestures.TryGetValue(owner, out gestures))
167 ret = BackendResponse.Success;
168 else
169 ret = BackendResponse.NotFound;
170
171 server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now);
172 return ret;
173 }
174
175 public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item)
176 {
177 BackendResponse ret;
178
179 InventoryCollection collection;
180 if (inventories.TryGetValue(owner, out collection))
181 {
182 // Delete this item first if it already exists
183 InventoryItemBase oldItem;
184 if (collection.Items.TryGetValue(item.ID, out oldItem))
185 TryDeleteItem(owner, item.ID);
186
187 try
188 {
189 // Create the file
190 SaveItem(item);
191
192 // Add the item to the collection
193 lock (collection) collection.Items[item.ID] = item;
194
195 // Add the item to its parent folder
196 InventoryFolderWithChildren parent;
197 if (collection.Folders.TryGetValue(item.Folder, out parent))
198 lock (parent.Children) parent.Children.Add(item.ID, item);
199
200 // Add active gestures to our list
201 if (item.InvType == (int)InventoryType.Gesture && item.Flags == 1)
202 {
203 lock (activeGestures)
204 activeGestures[owner].Add(item);
205 }
206
207 ret = BackendResponse.Success;
208 }
209 catch (Exception ex)
210 {
211 m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message);
212 ret = BackendResponse.Failure;
213 }
214 }
215 else
216 {
217 return BackendResponse.NotFound;
218 }
219
220 server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now);
221 return ret;
222 }
223
224 public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder)
225 {
226 BackendResponse ret;
227
228 InventoryCollection collection;
229 if (inventories.TryGetValue(owner, out collection))
230 {
231 // Delete this folder first if it already exists
232 InventoryFolderWithChildren oldFolder;
233 if (collection.Folders.TryGetValue(folder.ID, out oldFolder))
234 TryDeleteFolder(owner, folder.ID);
235
236 try
237 {
238 // Create the file
239 SaveFolder(folder);
240
241 // Add the folder to the collection
242 lock (collection) collection.Folders[folder.ID] = folder;
243
244 // Add the folder to its parent folder
245 InventoryFolderWithChildren parent;
246 if (collection.Folders.TryGetValue(folder.ParentID, out parent))
247 lock (parent.Children) parent.Children.Add(folder.ID, folder);
248
249 ret = BackendResponse.Success;
250 }
251 catch (Exception ex)
252 {
253 m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message);
254 ret = BackendResponse.Failure;
255 }
256 }
257 else
258 {
259 ret = BackendResponse.NotFound;
260 }
261
262 server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now);
263 return ret;
264 }
265
266 public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
267 {
268 BackendResponse ret;
269
270 lock (inventories)
271 {
272 if (!inventories.ContainsKey(owner))
273 {
274 InventoryCollection collection = new InventoryCollection();
275 collection.UserID = rootFolder.Owner;
276 collection.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
277 collection.Folders.Add(rootFolder.ID, rootFolder);
278 collection.Items = new Dictionary<UUID, InventoryItemBase>();
279
280 inventories.Add(owner, collection);
281
282 ret = BackendResponse.Success;
283 }
284 else
285 {
286 ret = BackendResponse.Failure;
287 }
288 }
289
290 if (ret == BackendResponse.Success)
291 {
292 string path = Path.Combine(DEFAULT_INVENTORY_DIR, rootFolder.Owner.ToString());
293 try
294 {
295 // Create the directory for this agent
296 Directory.CreateDirectory(path);
297
298 // Create an index.txt containing the UUID and URI for this agent
299 string[] index = new string[] { rootFolder.Owner.ToString(), owner.ToString() };
300 File.WriteAllLines(Path.Combine(path, "index.txt"), index);
301
302 // Create the root folder file
303 SaveFolder(rootFolder);
304 }
305 catch (Exception ex)
306 {
307 m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message);
308 ret = BackendResponse.Failure;
309 }
310 }
311
312 server.MetricsProvider.LogInventoryCreateInventory(EXTENSION_NAME, ret, DateTime.Now);
313 return ret;
314 }
315
316 public BackendResponse TryDeleteItem(Uri owner, UUID itemID)
317 {
318 BackendResponse ret;
319
320 InventoryCollection collection;
321 InventoryItemBase item;
322 if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item))
323 {
324 // Remove the item from its parent folder
325 InventoryFolderWithChildren parent;
326 if (collection.Folders.TryGetValue(item.Folder, out parent))
327 lock (parent.Children) parent.Children.Remove(itemID);
328
329 // Remove the item from the collection
330 lock (collection) collection.Items.Remove(itemID);
331
332 // Remove from the active gestures list if applicable
333 if (item.InvType == (int)InventoryType.Gesture)
334 {
335 lock (activeGestures)
336 {
337 for (int i = 0; i < activeGestures[owner].Count; i++)
338 {
339 if (activeGestures[owner][i].ID == itemID)
340 {
341 activeGestures[owner].RemoveAt(i);
342 break;
343 }
344 }
345 }
346 }
347
348 // Delete the file. We don't know exactly what the file name is,
349 // so search for it
350 string path = PathFromURI(owner);
351 string[] matches = Directory.GetFiles(path, String.Format("*{0}.item", itemID), SearchOption.TopDirectoryOnly);
352 foreach (string match in matches)
353 {
354 try { File.Delete(match); }
355 catch (Exception ex) { m_log.ErrorFormat("[SIMPLEINVENTORYSTORAGE]: Failed to delete file {0}: {1}", match, ex.Message); }
356 }
357
358 ret = BackendResponse.Success;
359 }
360 else
361 {
362 ret = BackendResponse.NotFound;
363 }
364
365 server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
366 return ret;
367 }
368
369 public BackendResponse TryDeleteFolder(Uri owner, UUID folderID)
370 {
371 BackendResponse ret;
372
373 InventoryCollection collection;
374 InventoryFolderWithChildren folder;
375 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
376 {
377 // Remove the folder from its parent folder
378 InventoryFolderWithChildren parent;
379 if (collection.Folders.TryGetValue(folder.ParentID, out parent))
380 lock (parent.Children) parent.Children.Remove(folderID);
381
382 // Remove the folder from the collection
383 lock (collection) collection.Items.Remove(folderID);
384
385 // Delete the folder file. We don't know exactly what the file name is,
386 // so search for it
387 string path = PathFromURI(owner);
388 string[] matches = Directory.GetFiles(path, String.Format("*{0}.folder", folderID), SearchOption.TopDirectoryOnly);
389 foreach (string match in matches)
390 {
391 try { File.Delete(match); }
392 catch (Exception ex) { m_log.ErrorFormat("[SIMPLEINVENTORYSTORAGE]: Failed to delete folder file {0}: {1}", match, ex.Message); }
393 }
394
395 ret = BackendResponse.Success;
396 }
397 else
398 {
399 ret = BackendResponse.NotFound;
400 }
401
402 server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now);
403 return ret;
404 }
405
406 public BackendResponse TryPurgeFolder(Uri owner, UUID folderID)
407 {
408 BackendResponse ret;
409
410 InventoryCollection collection;
411 InventoryFolderWithChildren folder;
412 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
413 {
414 // Delete all of the folder children
415 foreach (InventoryNodeBase obj in new List<InventoryNodeBase>(folder.Children.Values))
416 {
417 if (obj is InventoryItemBase)
418 {
419 TryDeleteItem(owner, (obj as InventoryItemBase).ID);
420 }
421 else
422 {
423 InventoryFolderWithChildren childFolder = obj as InventoryFolderWithChildren;
424 TryPurgeFolder(owner, childFolder.ID);
425 TryDeleteFolder(owner, childFolder.ID);
426 }
427 }
428
429 ret = BackendResponse.Success;
430 }
431 else
432 {
433 ret = BackendResponse.NotFound;
434 }
435
436 server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
437 return ret;
438 }
439
440 #endregion Required Interfaces
441
442 void SaveItem(InventoryItemBase item)
443 {
444 string filename = String.Format("{0}-{1}.item", SanitizeFilename(item.Name), item.ID);
445
446 string path = Path.Combine(DEFAULT_INVENTORY_DIR, item.Owner.ToString());
447 path = Path.Combine(path, filename);
448
449 using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
450 {
451 itemSerializer.Serialize(stream, item);
452 stream.Flush();
453 }
454 }
455
456 void SaveFolder(InventoryFolderWithChildren folder)
457 {
458 string filename = String.Format("{0}-{1}.folder", SanitizeFilename(folder.Name), folder.ID);
459
460 string path = Path.Combine(DEFAULT_INVENTORY_DIR, folder.Owner.ToString());
461 path = Path.Combine(path, filename);
462
463 using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
464 {
465 folderSerializer.Serialize(stream, folder);
466 stream.Flush();
467 }
468 }
469
470 string SanitizeFilename(string filename)
471 {
472 string output = filename;
473
474 if (output.Length > 64)
475 output = output.Substring(0, 64);
476
477 foreach (char i in Path.GetInvalidFileNameChars())
478 output = output.Replace(i, '_');
479
480 return output;
481 }
482
483 static string PathFromURI(Uri uri)
484 {
485 byte[] hash = OpenMetaverse.Utils.SHA1(Encoding.UTF8.GetBytes(uri.ToString()));
486 StringBuilder digest = new StringBuilder(40);
487
488 // Convert the hash to a hex string
489 foreach (byte b in hash)
490 digest.AppendFormat(OpenMetaverse.Utils.EnUsCulture, "{0:x2}", b);
491
492 return Path.Combine(DEFAULT_INVENTORY_DIR, digest.ToString());
493 }
494
495 void LoadFiles(string folder)
496 {
497 // Try to create the directory if it doesn't already exist
498 if (!Directory.Exists(folder))
499 {
500 try { Directory.CreateDirectory(folder); }
501 catch (Exception ex)
502 {
503 m_log.Warn("[SIMPLEINVENTORYSTORAGE]: " + ex.Message);
504 return;
505 }
506 }
507
508 try
509 {
510 string[] agentFolders = Directory.GetDirectories(DEFAULT_INVENTORY_DIR);
511
512 for (int i = 0; i < agentFolders.Length; i++)
513 {
514 string foldername = agentFolders[i];
515 string indexPath = Path.Combine(foldername, "index.txt");
516 UUID ownerID = UUID.Zero;
517 Uri owner = null;
518
519 try
520 {
521 string[] index = File.ReadAllLines(indexPath);
522 ownerID = UUID.Parse(index[0]);
523 owner = new Uri(index[1]);
524 }
525 catch (Exception ex)
526 {
527 m_log.WarnFormat("[SIMPLEINVENTORYSTORAGE]: Failed loading the index file {0}: {1}", indexPath, ex.Message);
528 }
529
530 if (ownerID != UUID.Zero && owner != null)
531 {
532 // Initialize the active gestures list for this agent
533 activeGestures.Add(owner, new List<InventoryItemBase>());
534
535 InventoryCollection collection = new InventoryCollection();
536 collection.UserID = ownerID;
537
538 // Load all of the folders for this agent
539 string[] folders = Directory.GetFiles(foldername, "*.folder", SearchOption.TopDirectoryOnly);
540 collection.Folders = new Dictionary<UUID,InventoryFolderWithChildren>(folders.Length);
541
542 for (int j = 0; j < folders.Length; j++)
543 {
544 InventoryFolderWithChildren invFolder = (InventoryFolderWithChildren)folderSerializer.Deserialize(
545 new FileStream(folders[j], FileMode.Open, FileAccess.Read));
546 collection.Folders[invFolder.ID] = invFolder;
547 }
548
549 // Iterate over the folders collection, adding children to their parents
550 foreach (InventoryFolderWithChildren invFolder in collection.Folders.Values)
551 {
552 InventoryFolderWithChildren parent;
553 if (collection.Folders.TryGetValue(invFolder.ParentID, out parent))
554 parent.Children[invFolder.ID] = invFolder;
555 }
556
557 // Load all of the items for this agent
558 string[] files = Directory.GetFiles(foldername, "*.item", SearchOption.TopDirectoryOnly);
559 collection.Items = new Dictionary<UUID, InventoryItemBase>(files.Length);
560
561 for (int j = 0; j < files.Length; j++)
562 {
563 InventoryItemBase invItem = (InventoryItemBase)itemSerializer.Deserialize(
564 new FileStream(files[j], FileMode.Open, FileAccess.Read));
565 collection.Items[invItem.ID] = invItem;
566
567 // Add items to their parent folders
568 InventoryFolderWithChildren parent;
569 if (collection.Folders.TryGetValue(invItem.Folder, out parent))
570 parent.Children[invItem.ID] = invItem;
571
572 // Add active gestures to our list
573 if (invItem.InvType == (int)InventoryType.Gesture && invItem.Flags != 0)
574 activeGestures[owner].Add(invItem);
575 }
576
577 inventories.Add(owner, collection);
578 }
579 }
580 }
581 catch (Exception ex)
582 {
583 m_log.ErrorFormat("[SIMPLEINVENTORYSTORAGE]: Failed loading inventory from {0}: {1}", folder, ex.Message);
584 }
585 }
586
587 #region IPlugin implementation
588
589 public void Initialise(AssetInventoryServer server)
590 {
591 this.server = server;
592
593 LoadFiles(DEFAULT_INVENTORY_DIR);
594
595 m_log.InfoFormat("[SIMPLEINVENTORYSTORAGE]: Initialized the inventory index with data for {0} avatars",
596 inventories.Count);
597 }
598
599 /// <summary>
600 /// <para>Initialises asset interface</para>
601 /// </summary>
602 public void Initialise()
603 {
604 m_log.InfoFormat("[SIMPLEINVENTORYSTORAGE]: {0} cannot be default-initialized!", Name);
605 throw new PluginNotInitialisedException(Name);
606 }
607
608 public void Dispose()
609 {
610 }
611
612 public string Version
613 {
614 // TODO: this should be something meaningful and not hardcoded?
615 get { return "0.1"; }
616 }
617
618 public string Name
619 {
620 get { return "SimpleInventoryStorage"; }
621 }
622
623 #endregion IPlugin implementation
624 }
625}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs
deleted file mode 100644
index 0d5c53a..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleUtils.cs
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using OpenMetaverse;
31
32namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
33{
34 public static class SimpleUtils
35 {
36 public static string ParseNameFromFilename(string filename)
37 {
38 filename = Path.GetFileName(filename);
39
40 int dot = filename.LastIndexOf('.');
41 int firstDash = filename.IndexOf('-');
42
43 if (dot - 37 > 0 && firstDash > 0)
44 return filename.Substring(0, firstDash);
45 else
46 return String.Empty;
47 }
48
49 public static UUID ParseUUIDFromFilename(string filename)
50 {
51 int dot = filename.LastIndexOf('.');
52
53 if (dot > 35)
54 {
55 // Grab the last 36 characters of the filename
56 string uuidString = filename.Substring(dot - 36, 36);
57 UUID uuid;
58 UUID.TryParse(uuidString, out uuid);
59 return uuid;
60 }
61 else
62 {
63 UUID uuid;
64 if (UUID.TryParse(Path.GetFileName(filename), out uuid))
65 return uuid;
66 else
67 return UUID.Zero;
68 }
69 }
70 }
71}
diff --git a/OpenSim/Grid/AssetInventoryServer/Utils.cs b/OpenSim/Grid/AssetInventoryServer/Utils.cs
deleted file mode 100644
index 9bbc0bc..0000000
--- a/OpenSim/Grid/AssetInventoryServer/Utils.cs
+++ /dev/null
@@ -1,1031 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Globalization;
30using System.Xml;
31using System.Xml.Serialization;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Servers;
35using OpenSim.Framework.Servers.HttpServer;
36
37namespace OpenSim.Grid.AssetInventoryServer
38{
39 public static class Utils
40 {
41 public static UUID GetAuthToken(OSHttpRequest request)
42 {
43 UUID authToken = UUID.Zero;
44
45 string[] authHeader = request.Headers.GetValues("Authorization");
46 if (authHeader != null && authHeader.Length == 1)
47 {
48 // Example header:
49 // Authorization: OpenGrid 65fda0b5-4446-42f5-b828-aaf644293646
50 string[] authHeaderParts = authHeader[0].Split(' ');
51 if (authHeaderParts.Length == 2 && authHeaderParts[0] == "OpenGrid")
52 UUID.TryParse(authHeaderParts[1], out authToken);
53 }
54
55 //if (authToken == UUID.Zero && request.Cookies != null)
56 //{
57 // // Check for an authToken cookie to make logins browser-compatible
58 // RequestCookie authCookie = request.Cookies["authToken"];
59 // if (authCookie != null)
60 // UUID.TryParse(authCookie.Value, out authToken);
61 //}
62
63 return authToken;
64 }
65
66 public static Uri GetOpenSimUri(UUID avatarID)
67 {
68 return new Uri("http://opensim/" + avatarID.ToString());
69 }
70
71 public static bool TryGetOpenSimUUID(Uri avatarUri, out UUID avatarID)
72 {
73 string[] parts = avatarUri.Segments;
74 return UUID.TryParse(parts[parts.Length - 1], out avatarID);
75 }
76
77 #region SL / file extension / content-type conversions
78
79 public static string SLAssetTypeToContentType(int assetType)
80 {
81 switch (assetType)
82 {
83 case 0:
84 return "image/jp2";
85 case 1:
86 return "application/ogg";
87 case 2:
88 return "application/x-metaverse-callingcard";
89 case 3:
90 return "application/x-metaverse-landmark";
91 case 5:
92 return "application/x-metaverse-clothing";
93 case 6:
94 return "application/x-metaverse-primitive";
95 case 7:
96 return "application/x-metaverse-notecard";
97 case 8:
98 return "application/x-metaverse-folder";
99 case 10:
100 return "application/x-metaverse-lsl";
101 case 11:
102 return "application/x-metaverse-lso";
103 case 12:
104 return "image/tga";
105 case 13:
106 return "application/x-metaverse-bodypart";
107 case 17:
108 return "audio/x-wav";
109 case 19:
110 return "image/jpeg";
111 case 20:
112 return "application/x-metaverse-animation";
113 case 21:
114 return "application/x-metaverse-gesture";
115 case 22:
116 return "application/x-metaverse-simstate";
117 default:
118 return "application/octet-stream";
119 }
120 }
121
122 public static int ContentTypeToSLAssetType(string contentType)
123 {
124 switch (contentType)
125 {
126 case "image/jp2":
127 return 0;
128 case "application/ogg":
129 return 1;
130 case "application/x-metaverse-callingcard":
131 return 2;
132 case "application/x-metaverse-landmark":
133 return 3;
134 case "application/x-metaverse-clothing":
135 return 5;
136 case "application/x-metaverse-primitive":
137 return 6;
138 case "application/x-metaverse-notecard":
139 return 7;
140 case "application/x-metaverse-lsl":
141 return 10;
142 case "application/x-metaverse-lso":
143 return 11;
144 case "image/tga":
145 return 12;
146 case "application/x-metaverse-bodypart":
147 return 13;
148 case "audio/x-wav":
149 return 17;
150 case "image/jpeg":
151 return 19;
152 case "application/x-metaverse-animation":
153 return 20;
154 case "application/x-metaverse-gesture":
155 return 21;
156 case "application/x-metaverse-simstate":
157 return 22;
158 default:
159 return -1;
160 }
161 }
162
163 public static string ContentTypeToExtension(string contentType)
164 {
165 switch (contentType)
166 {
167 case "image/jp2":
168 return "texture";
169 case "application/ogg":
170 return "ogg";
171 case "application/x-metaverse-callingcard":
172 return "callingcard";
173 case "application/x-metaverse-landmark":
174 return "landmark";
175 case "application/x-metaverse-clothing":
176 return "clothing";
177 case "application/x-metaverse-primitive":
178 return "primitive";
179 case "application/x-metaverse-notecard":
180 return "notecard";
181 case "application/x-metaverse-lsl":
182 return "lsl";
183 case "application/x-metaverse-lso":
184 return "lso";
185 case "image/tga":
186 return "tga";
187 case "application/x-metaverse-bodypart":
188 return "bodypart";
189 case "audio/x-wav":
190 return "wav";
191 case "image/jpeg":
192 return "jpg";
193 case "application/x-metaverse-animation":
194 return "animation";
195 case "application/x-metaverse-gesture":
196 return "gesture";
197 case "application/x-metaverse-simstate":
198 return "simstate";
199 default:
200 return "bin";
201 }
202 }
203
204 public static string ExtensionToContentType(string extension)
205 {
206 switch (extension)
207 {
208 case "texture":
209 case "jp2":
210 case "j2c":
211 return "image/jp2";
212 case "sound":
213 case "ogg":
214 return "application/ogg";
215 case "callingcard":
216 return "application/x-metaverse-callingcard";
217 case "landmark":
218 return "application/x-metaverse-landmark";
219 case "clothing":
220 return "application/x-metaverse-clothing";
221 case "primitive":
222 return "application/x-metaverse-primitive";
223 case "notecard":
224 return "application/x-metaverse-notecard";
225 case "lsl":
226 return "application/x-metaverse-lsl";
227 case "lso":
228 return "application/x-metaverse-lso";
229 case "tga":
230 return "image/tga";
231 case "bodypart":
232 return "application/x-metaverse-bodypart";
233 case "wav":
234 return "audio/x-wav";
235 case "jpg":
236 case "jpeg":
237 return "image/jpeg";
238 case "animation":
239 return "application/x-metaverse-animation";
240 case "gesture":
241 return "application/x-metaverse-gesture";
242 case "simstate":
243 return "application/x-metaverse-simstate";
244 case "txt":
245 return "text/plain";
246 case "xml":
247 return "application/xml";
248 default:
249 return "application/octet-stream";
250 }
251 }
252
253 #endregion SL / file extension / content-type conversions
254
255 #region XML Serialization
256
257 public class GeneratedReader : XmlSerializationReader
258 {
259 public object ReadRoot_InventoryFolderBase()
260 {
261 Reader.MoveToContent();
262 if (Reader.LocalName != "InventoryFolderBase" || Reader.NamespaceURI != "")
263 throw CreateUnknownNodeException();
264 return ReadObject_InventoryFolder(true, true);
265 }
266
267 public object ReadRoot_InventoryItemBase()
268 {
269 Reader.MoveToContent();
270 if (Reader.LocalName != "InventoryItemBase" || Reader.NamespaceURI != "")
271 throw CreateUnknownNodeException();
272 return ReadObject_InventoryItem(true, true);
273 }
274
275 public object ReadRoot_InventoryCollection()
276 {
277 Reader.MoveToContent();
278 if (Reader.LocalName != "InventoryCollection" || Reader.NamespaceURI != "")
279 throw CreateUnknownNodeException();
280 return ReadObject_InventoryCollection(true, true);
281 }
282
283 public InventoryFolderWithChildren ReadObject_InventoryFolder(bool isNullable, bool checkType)
284 {
285 InventoryFolderWithChildren ob = null;
286 if (isNullable && ReadNull()) return null;
287
288 if (checkType)
289 {
290 System.Xml.XmlQualifiedName t = GetXsiType();
291 if (t == null)
292 { }
293 else if (t.Name != "InventoryFolderBase" || t.Namespace != "")
294 throw CreateUnknownTypeException(t);
295 }
296
297 ob = (InventoryFolderWithChildren)Activator.CreateInstance(typeof(InventoryFolderWithChildren), true);
298
299 Reader.MoveToElement();
300
301 while (Reader.MoveToNextAttribute())
302 {
303 if (IsXmlnsAttribute(Reader.Name))
304 {
305 }
306 else
307 {
308 UnknownNode(ob);
309 }
310 }
311
312 Reader.MoveToElement();
313 Reader.MoveToElement();
314 if (Reader.IsEmptyElement)
315 {
316 Reader.Skip();
317 return ob;
318 }
319
320 Reader.ReadStartElement();
321 Reader.MoveToContent();
322
323 bool b0 = false, b1 = false, b2 = false, b3 = false, b4 = false, b5 = false;
324
325 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
326 {
327 if (Reader.NodeType == System.Xml.XmlNodeType.Element)
328 {
329 if (Reader.LocalName == "Owner" && Reader.NamespaceURI == "" && !b1)
330 {
331 b1 = true;
332 ob.@Owner = ReadObject_UUID(false, true);
333 }
334 else if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b5)
335 {
336 b5 = true;
337 string s6 = Reader.ReadElementString();
338 ob.@Version = UInt16.Parse(s6, CultureInfo.InvariantCulture);
339 }
340 else if (Reader.LocalName == "ID" && Reader.NamespaceURI == "" && !b3)
341 {
342 b3 = true;
343 ob.@ID = ReadObject_UUID(false, true);
344 }
345 else if (Reader.LocalName == "Type" && Reader.NamespaceURI == "" && !b4)
346 {
347 b4 = true;
348 string s7 = Reader.ReadElementString();
349 ob.@Type = Int16.Parse(s7, CultureInfo.InvariantCulture);
350 }
351 else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b0)
352 {
353 b0 = true;
354 string s8 = Reader.ReadElementString();
355 ob.@Name = s8;
356 }
357 else if (Reader.LocalName == "ParentID" && Reader.NamespaceURI == "" && !b2)
358 {
359 b2 = true;
360 ob.@ParentID = ReadObject_UUID(false, true);
361 }
362 else
363 {
364 UnknownNode(ob);
365 }
366 }
367 else
368 UnknownNode(ob);
369
370 Reader.MoveToContent();
371 }
372
373 ReadEndElement();
374
375 return ob;
376 }
377
378 public InventoryItemBase ReadObject_InventoryItem(bool isNullable, bool checkType)
379 {
380 InventoryItemBase ob = null;
381 if (isNullable && ReadNull()) return null;
382
383 if (checkType)
384 {
385 System.Xml.XmlQualifiedName t = GetXsiType();
386 if (t == null)
387 { }
388 else if (t.Name != "InventoryItemBase" || t.Namespace != "")
389 throw CreateUnknownTypeException(t);
390 }
391
392 ob = (InventoryItemBase)Activator.CreateInstance(typeof(InventoryItemBase), true);
393
394 Reader.MoveToElement();
395
396 while (Reader.MoveToNextAttribute())
397 {
398 if (IsXmlnsAttribute(Reader.Name))
399 {
400 }
401 else
402 {
403 UnknownNode(ob);
404 }
405 }
406
407 Reader.MoveToElement();
408 Reader.MoveToElement();
409 if (Reader.IsEmptyElement)
410 {
411 Reader.Skip();
412 return ob;
413 }
414
415 Reader.ReadStartElement();
416 Reader.MoveToContent();
417
418 bool b9 = false, b10 = false, b11 = false, b12 = false, b13 = false, b14 = false, b15 = false, b16 = false, b17 = false, b18 = false, b19 = false, b20 = false, b21 = false, b22 = false, b23 = false, b24 = false, b25 = false, b26 = false, b27 = false, b28 = false;
419
420 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
421 {
422 if (Reader.NodeType == System.Xml.XmlNodeType.Element)
423 {
424 if (Reader.LocalName == "GroupPermissions" && Reader.NamespaceURI == "" && !b20)
425 {
426 b20 = true;
427 string s29 = Reader.ReadElementString();
428 ob.@GroupPermissions = UInt32.Parse(s29, CultureInfo.InvariantCulture);
429 }
430 else if (Reader.LocalName == "AssetType" && Reader.NamespaceURI == "" && !b21)
431 {
432 b21 = true;
433 string s30 = Reader.ReadElementString();
434 ob.@AssetType = Int32.Parse(s30, CultureInfo.InvariantCulture);
435 }
436 else if (Reader.LocalName == "SalePrice" && Reader.NamespaceURI == "" && !b25)
437 {
438 b25 = true;
439 string s31 = Reader.ReadElementString();
440 ob.@SalePrice = Int32.Parse(s31, CultureInfo.InvariantCulture);
441 }
442 else if (Reader.LocalName == "AssetID" && Reader.NamespaceURI == "" && !b22)
443 {
444 b22 = true;
445 ob.@AssetID = ReadObject_UUID(false, true);
446 }
447 else if (Reader.LocalName == "Folder" && Reader.NamespaceURI == "" && !b11)
448 {
449 b11 = true;
450 ob.@Folder = ReadObject_UUID(false, true);
451 }
452 else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b14)
453 {
454 b14 = true;
455 string s32 = Reader.ReadElementString();
456 ob.@Name = s32;
457 }
458 else if (Reader.LocalName == "NextPermissions" && Reader.NamespaceURI == "" && !b16)
459 {
460 b16 = true;
461 string s33 = Reader.ReadElementString();
462 ob.@NextPermissions = UInt32.Parse(s33, CultureInfo.InvariantCulture);
463 }
464 else if (Reader.LocalName == "BasePermissions" && Reader.NamespaceURI == "" && !b18)
465 {
466 b18 = true;
467 string s34 = Reader.ReadElementString();
468 ob.@BasePermissions = UInt32.Parse(s34, CultureInfo.InvariantCulture);
469 }
470 else if (Reader.LocalName == "ID" && Reader.NamespaceURI == "" && !b9)
471 {
472 b9 = true;
473 ob.@ID = ReadObject_UUID(false, true);
474 }
475 else if (Reader.LocalName == "Flags" && Reader.NamespaceURI == "" && !b27)
476 {
477 b27 = true;
478 string s35 = Reader.ReadElementString();
479 ob.@Flags = UInt32.Parse(s35, CultureInfo.InvariantCulture);
480 }
481 else if (Reader.LocalName == "GroupOwned" && Reader.NamespaceURI == "" && !b24)
482 {
483 b24 = true;
484 string s36 = Reader.ReadElementString();
485 ob.@GroupOwned = XmlConvert.ToBoolean(s36);
486 }
487 else if (Reader.LocalName == "InvType" && Reader.NamespaceURI == "" && !b10)
488 {
489 b10 = true;
490 string s37 = Reader.ReadElementString();
491 ob.@InvType = Int32.Parse(s37, CultureInfo.InvariantCulture);
492 }
493 else if (Reader.LocalName == "GroupID" && Reader.NamespaceURI == "" && !b23)
494 {
495 b23 = true;
496 ob.@GroupID = ReadObject_UUID(false, true);
497 }
498 else if (Reader.LocalName == "Description" && Reader.NamespaceURI == "" && !b15)
499 {
500 b15 = true;
501 string s38 = Reader.ReadElementString();
502 ob.@Description = s38;
503 }
504 else if (Reader.LocalName == "CreationDate" && Reader.NamespaceURI == "" && !b28)
505 {
506 b28 = true;
507 string s39 = Reader.ReadElementString();
508 ob.@CreationDate = Int32.Parse(s39, CultureInfo.InvariantCulture);
509 }
510 else if (Reader.LocalName == "EveryOnePermissions" && Reader.NamespaceURI == "" && !b19)
511 {
512 b19 = true;
513 string s40 = Reader.ReadElementString();
514 ob.@EveryOnePermissions = UInt32.Parse(s40, CultureInfo.InvariantCulture);
515 }
516 else if (Reader.LocalName == "Creator" && Reader.NamespaceURI == "" && !b13)
517 {
518 b13 = true;
519 ob.@CreatorId = Reader.ReadElementString();
520 }
521 else if (Reader.LocalName == "Owner" && Reader.NamespaceURI == "" && !b12)
522 {
523 b12 = true;
524 ob.@Owner = ReadObject_UUID(false, true);
525 }
526 else if (Reader.LocalName == "SaleType" && Reader.NamespaceURI == "" && !b26)
527 {
528 b26 = true;
529 string s41 = Reader.ReadElementString();
530 ob.@SaleType = byte.Parse(s41, CultureInfo.InvariantCulture);
531 }
532 else if (Reader.LocalName == "CurrentPermissions" && Reader.NamespaceURI == "" && !b17)
533 {
534 b17 = true;
535 string s42 = Reader.ReadElementString();
536 ob.@CurrentPermissions = UInt32.Parse(s42, CultureInfo.InvariantCulture);
537 }
538 else
539 {
540 UnknownNode(ob);
541 }
542 }
543 else
544 UnknownNode(ob);
545
546 Reader.MoveToContent();
547 }
548
549 ReadEndElement();
550
551 return ob;
552 }
553
554 public InventoryCollection ReadObject_InventoryCollection(bool isNullable, bool checkType)
555 {
556 InventoryCollection ob = null;
557 if (isNullable && ReadNull()) return null;
558
559 if (checkType)
560 {
561 System.Xml.XmlQualifiedName t = GetXsiType();
562 if (t == null)
563 { }
564 else if (t.Name != "InventoryCollection" || t.Namespace != "")
565 throw CreateUnknownTypeException(t);
566 }
567
568 ob = (InventoryCollection)Activator.CreateInstance(typeof(InventoryCollection), true);
569
570 Reader.MoveToElement();
571
572 while (Reader.MoveToNextAttribute())
573 {
574 if (IsXmlnsAttribute(Reader.Name))
575 {
576 }
577 else
578 {
579 UnknownNode(ob);
580 }
581 }
582
583 Reader.MoveToElement();
584 Reader.MoveToElement();
585 if (Reader.IsEmptyElement)
586 {
587 Reader.Skip();
588 if (ob.@Folders == null)
589 {
590 ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>();
591 }
592 if (ob.@Items == null)
593 {
594 ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>();
595 }
596 return ob;
597 }
598
599 Reader.ReadStartElement();
600 Reader.MoveToContent();
601
602 bool b43 = false, b44 = false, b45 = false;
603
604 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
605 {
606 if (Reader.NodeType == System.Xml.XmlNodeType.Element)
607 {
608 if (Reader.LocalName == "UserID" && Reader.NamespaceURI == "" && !b45)
609 {
610 b45 = true;
611 ob.@UserID = ReadObject_UUID(false, true);
612 }
613 else if (Reader.LocalName == "Items" && Reader.NamespaceURI == "" && !b44)
614 {
615 System.Collections.Generic.Dictionary<UUID, InventoryItemBase> o46 = ob.@Items;
616 if (((object)o46) == null)
617 {
618 o46 = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>();
619 ob.@Items = o46;
620 }
621 if (Reader.IsEmptyElement)
622 {
623 Reader.Skip();
624 }
625 else
626 {
627 int n47 = 0;
628 Reader.ReadStartElement();
629 Reader.MoveToContent();
630
631 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
632 {
633 if (Reader.NodeType == System.Xml.XmlNodeType.Element)
634 {
635 if (Reader.LocalName == "InventoryItemBase" && Reader.NamespaceURI == "")
636 {
637 if (((object)o46) == null)
638 throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryItemBase>");
639 InventoryItemBase item = ReadObject_InventoryItem(true, true);
640 o46.Add(item.ID, item);
641 n47++;
642 }
643 else UnknownNode(null);
644 }
645 else UnknownNode(null);
646
647 Reader.MoveToContent();
648 }
649 ReadEndElement();
650 }
651 b44 = true;
652 }
653 else if (Reader.LocalName == "Folders" && Reader.NamespaceURI == "" && !b43)
654 {
655 System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren> o48 = ob.@Folders;
656 if (((object)o48) == null)
657 {
658 o48 = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>();
659 ob.@Folders = o48;
660 }
661 if (Reader.IsEmptyElement)
662 {
663 Reader.Skip();
664 }
665 else
666 {
667 int n49 = 0;
668 Reader.ReadStartElement();
669 Reader.MoveToContent();
670
671 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
672 {
673 if (Reader.NodeType == System.Xml.XmlNodeType.Element)
674 {
675 if (Reader.LocalName == "InventoryFolderBase" && Reader.NamespaceURI == "")
676 {
677 if (((object)o48) == null)
678 throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryFolderBase>");
679 InventoryFolderWithChildren folder = ReadObject_InventoryFolder(true, true);
680 o48.Add(folder.ID, folder);
681 n49++;
682 }
683 else UnknownNode(null);
684 }
685 else UnknownNode(null);
686
687 Reader.MoveToContent();
688 }
689 ReadEndElement();
690 }
691 b43 = true;
692 }
693 else
694 {
695 UnknownNode(ob);
696 }
697 }
698 else
699 UnknownNode(ob);
700
701 Reader.MoveToContent();
702 }
703 if (ob.@Folders == null)
704 {
705 ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>();
706 }
707 if (ob.@Items == null)
708 {
709 ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>();
710 }
711
712 ReadEndElement();
713
714 return ob;
715 }
716
717 public OpenMetaverse.UUID ReadObject_UUID(bool isNullable, bool checkType)
718 {
719 OpenMetaverse.UUID ob = (OpenMetaverse.UUID)Activator.CreateInstance(typeof(OpenMetaverse.UUID), true);
720 System.Xml.XmlQualifiedName t = GetXsiType();
721 if (t == null)
722 { }
723 else if (t.Name != "UUID" || t.Namespace != "")
724 throw CreateUnknownTypeException(t);
725
726 Reader.MoveToElement();
727
728 while (Reader.MoveToNextAttribute())
729 {
730 if (IsXmlnsAttribute(Reader.Name))
731 {
732 }
733 else
734 {
735 UnknownNode(ob);
736 }
737 }
738
739 Reader.MoveToElement();
740 Reader.MoveToElement();
741 if (Reader.IsEmptyElement)
742 {
743 Reader.Skip();
744 return ob;
745 }
746
747 Reader.ReadStartElement();
748 Reader.MoveToContent();
749
750 bool b52 = false;
751
752 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
753 {
754 if (Reader.NodeType == System.Xml.XmlNodeType.Element)
755 {
756 if (Reader.LocalName == "Guid" && Reader.NamespaceURI == "" && !b52)
757 {
758 b52 = true;
759 string s53 = Reader.ReadElementString();
760 ob.@Guid = XmlConvert.ToGuid(s53);
761 }
762 else
763 {
764 UnknownNode(ob);
765 }
766 }
767 else
768 UnknownNode(ob);
769
770 Reader.MoveToContent();
771 }
772
773 ReadEndElement();
774
775 return ob;
776 }
777
778 protected override void InitCallbacks()
779 {
780 }
781
782 protected override void InitIDs()
783 {
784 }
785 }
786
787 public class GeneratedWriter : XmlSerializationWriter
788 {
789 const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
790 //static readonly System.Reflection.MethodInfo toBinHexStringMethod = typeof(XmlConvert).GetMethod("ToBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type[] { typeof(byte[]) }, null);
791 //static string ToBinHexString(byte[] input)
792 //{
793 // return input == null ? null : (string)toBinHexStringMethod.Invoke(null, new object[] { input });
794 //}
795 public void WriteRoot_InventoryFolder(object o)
796 {
797 WriteStartDocument();
798 InventoryFolderWithChildren ob = (InventoryFolderWithChildren)o;
799 TopLevelElement();
800 WriteObject_InventoryFolder(ob, "InventoryFolderBase", "", true, false, true);
801 }
802
803 public void WriteRoot_InventoryItem(object o)
804 {
805 WriteStartDocument();
806 InventoryItemBase ob = (InventoryItemBase)o;
807 TopLevelElement();
808 WriteObject_InventoryItem(ob, "InventoryItemBase", "", true, false, true);
809 }
810
811 public void WriteRoot_InventoryCollection(object o)
812 {
813 WriteStartDocument();
814 InventoryCollection ob = (InventoryCollection)o;
815 TopLevelElement();
816 WriteObject_InventoryCollection(ob, "InventoryCollection", "", true, false, true);
817 }
818
819 void WriteObject_InventoryFolder(InventoryFolderWithChildren ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
820 {
821 if (((object)ob) == null)
822 {
823 if (isNullable)
824 WriteNullTagLiteral(element, namesp);
825 return;
826 }
827
828 System.Type type = ob.GetType();
829 if (type == typeof(InventoryFolderWithChildren))
830 { }
831 else
832 {
833 throw CreateUnknownTypeException(ob);
834 }
835
836 if (writeWrappingElem)
837 {
838 WriteStartElement(element, namesp, ob);
839 }
840
841 if (needType) WriteXsiType("InventoryFolderBase", "");
842
843 WriteElementString("Name", "", ob.@Name);
844 WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true);
845 WriteObject_UUID(ob.@ParentID, "ParentID", "", false, false, true);
846 WriteObject_UUID(ob.@ID, "ID", "", false, false, true);
847 WriteElementString("Type", "", ob.@Type.ToString(CultureInfo.InvariantCulture));
848 WriteElementString("Version", "", ob.@Version.ToString(CultureInfo.InvariantCulture));
849 if (writeWrappingElem) WriteEndElement(ob);
850 }
851
852 void WriteObject_InventoryItem(InventoryItemBase ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
853 {
854 if (((object)ob) == null)
855 {
856 if (isNullable)
857 WriteNullTagLiteral(element, namesp);
858 return;
859 }
860
861 System.Type type = ob.GetType();
862 if (type == typeof(InventoryItemBase))
863 { }
864 else
865 {
866 throw CreateUnknownTypeException(ob);
867 }
868
869 if (writeWrappingElem)
870 {
871 WriteStartElement(element, namesp, ob);
872 }
873
874 if (needType) WriteXsiType("InventoryItemBase", "");
875
876 WriteObject_UUID(ob.@ID, "ID", "", false, false, true);
877 WriteElementString("InvType", "", ob.@InvType.ToString(CultureInfo.InvariantCulture));
878 WriteObject_UUID(ob.@Folder, "Folder", "", false, false, true);
879 WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true);
880 WriteElementString("Creator", "", ob.@CreatorId);
881 WriteElementString("Name", "", ob.@Name);
882 WriteElementString("Description", "", ob.@Description);
883 WriteElementString("NextPermissions", "", ob.@NextPermissions.ToString(CultureInfo.InvariantCulture));
884 WriteElementString("CurrentPermissions", "", ob.@CurrentPermissions.ToString(CultureInfo.InvariantCulture));
885 WriteElementString("BasePermissions", "", ob.@BasePermissions.ToString(CultureInfo.InvariantCulture));
886 WriteElementString("EveryOnePermissions", "", ob.@EveryOnePermissions.ToString(CultureInfo.InvariantCulture));
887 WriteElementString("GroupPermissions", "", ob.@GroupPermissions.ToString(CultureInfo.InvariantCulture));
888 WriteElementString("AssetType", "", ob.@AssetType.ToString(CultureInfo.InvariantCulture));
889 WriteObject_UUID(ob.@AssetID, "AssetID", "", false, false, true);
890 WriteObject_UUID(ob.@GroupID, "GroupID", "", false, false, true);
891 WriteElementString("GroupOwned", "", (ob.@GroupOwned ? "true" : "false"));
892 WriteElementString("SalePrice", "", ob.@SalePrice.ToString(CultureInfo.InvariantCulture));
893 WriteElementString("SaleType", "", ob.@SaleType.ToString(CultureInfo.InvariantCulture));
894 WriteElementString("Flags", "", ob.@Flags.ToString(CultureInfo.InvariantCulture));
895 WriteElementString("CreationDate", "", ob.@CreationDate.ToString(CultureInfo.InvariantCulture));
896 if (writeWrappingElem) WriteEndElement(ob);
897 }
898
899 void WriteObject_InventoryCollection(InventoryCollection ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
900 {
901 if (((object)ob) == null)
902 {
903 if (isNullable)
904 WriteNullTagLiteral(element, namesp);
905 return;
906 }
907
908 System.Type type = ob.GetType();
909 if (type == typeof(InventoryCollection))
910 { }
911 else
912 {
913 throw CreateUnknownTypeException(ob);
914 }
915
916 if (writeWrappingElem)
917 {
918 WriteStartElement(element, namesp, ob);
919 }
920
921 if (needType) WriteXsiType("InventoryCollection", "");
922
923 if (ob.@Folders != null)
924 {
925 WriteStartElement("Folders", "", ob.@Folders);
926 foreach (InventoryFolderWithChildren folder in ob.Folders.Values)
927 {
928 WriteObject_InventoryFolder(folder, "InventoryFolderBase", "", true, false, true);
929 }
930 WriteEndElement(ob.@Folders);
931 }
932 if (ob.@Items != null)
933 {
934 WriteStartElement("Items", "", ob.@Items);
935 foreach (InventoryItemBase item in ob.Items.Values)
936 {
937 WriteObject_InventoryItem(item, "InventoryItemBase", "", true, false, true);
938 }
939 WriteEndElement(ob.@Items);
940 }
941 WriteObject_UUID(ob.@UserID, "UserID", "", false, false, true);
942 if (writeWrappingElem) WriteEndElement(ob);
943 }
944
945 void WriteObject_UUID(OpenMetaverse.UUID ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
946 {
947 System.Type type = ob.GetType();
948 if (type == typeof(OpenMetaverse.UUID))
949 { }
950 else
951 {
952 throw CreateUnknownTypeException(ob);
953 }
954
955 if (writeWrappingElem)
956 {
957 WriteStartElement(element, namesp, ob);
958 }
959
960 if (needType) WriteXsiType("UUID", "");
961
962 WriteElementString("Guid", "", XmlConvert.ToString(ob.@Guid));
963 if (writeWrappingElem) WriteEndElement(ob);
964 }
965
966 protected override void InitCallbacks()
967 {
968 }
969
970 }
971
972 public class BaseXmlSerializer : System.Xml.Serialization.XmlSerializer
973 {
974 protected override System.Xml.Serialization.XmlSerializationReader CreateReader()
975 {
976 return new GeneratedReader();
977 }
978
979 protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter()
980 {
981 return new GeneratedWriter();
982 }
983
984 public override bool CanDeserialize(System.Xml.XmlReader xmlReader)
985 {
986 return true;
987 }
988 }
989
990 public sealed class InventoryFolderSerializer : BaseXmlSerializer
991 {
992 protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer)
993 {
994 ((GeneratedWriter)writer).WriteRoot_InventoryFolder(obj);
995 }
996
997 protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader)
998 {
999 return ((GeneratedReader)reader).ReadRoot_InventoryFolderBase();
1000 }
1001 }
1002
1003 public sealed class InventoryItemSerializer : BaseXmlSerializer
1004 {
1005 protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer)
1006 {
1007 ((GeneratedWriter)writer).WriteRoot_InventoryItem(obj);
1008 }
1009
1010 protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader)
1011 {
1012 return ((GeneratedReader)reader).ReadRoot_InventoryItemBase();
1013 }
1014 }
1015
1016 public sealed class InventoryCollectionSerializer : BaseXmlSerializer
1017 {
1018 protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer)
1019 {
1020 ((GeneratedWriter)writer).WriteRoot_InventoryCollection(obj);
1021 }
1022
1023 protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader)
1024 {
1025 return ((GeneratedReader)reader).ReadRoot_InventoryCollection();
1026 }
1027 }
1028
1029 #endregion XML Serialization
1030 }
1031}
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index f25e847..ac8f888 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -140,7 +140,7 @@ namespace OpenSim.Grid.AssetServer
140 140
141 protected void StoreAsset(AssetBase asset) 141 protected void StoreAsset(AssetBase asset)
142 { 142 {
143 m_assetProvider.CreateAsset(asset); 143 m_assetProvider.StoreAsset(asset);
144 } 144 }
145 } 145 }
146} 146}
diff --git a/OpenSim/Grid/GridServer.Modules/GridDBService.cs b/OpenSim/Grid/GridServer.Modules/GridDBService.cs
index caa2c10..fd5a09a 100644
--- a/OpenSim/Grid/GridServer.Modules/GridDBService.cs
+++ b/OpenSim/Grid/GridServer.Modules/GridDBService.cs
@@ -206,11 +206,11 @@ namespace OpenSim.Grid.GridServer.Modules
206 { 206 {
207 if (existingSim == null) 207 if (existingSim == null)
208 { 208 {
209 insertResponse = plugin.AddProfile(sim); 209 insertResponse = plugin.StoreProfile(sim);
210 } 210 }
211 else 211 else
212 { 212 {
213 insertResponse = plugin.UpdateProfile(sim); 213 insertResponse = plugin.StoreProfile(sim);
214 } 214 }
215 } 215 }
216 catch (Exception e) 216 catch (Exception e)
@@ -259,7 +259,7 @@ namespace OpenSim.Grid.GridServer.Modules
259 if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || 259 if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
260 (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) 260 (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey))
261 { 261 {
262 plugin.AddProfile(theSim); 262 plugin.StoreProfile(theSim);
263 m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); 263 m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
264 logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5, 264 logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5,
265 "Region successfully updated and connected to grid."); 265 "Region successfully updated and connected to grid.");
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index c41a728..d63ac2e 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -31,6 +31,7 @@ using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Timers; 32using System.Timers;
33using log4net; 33using log4net;
34using Nini.Config;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
@@ -46,6 +47,9 @@ namespace OpenSim.Grid.GridServer
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 48
48 protected GridConfig m_config; 49 protected GridConfig m_config;
50 public string m_consoleType = "local";
51 public IConfigSource m_configSource = null;
52 public string m_configFile = "GridServer_Config.xml";
49 53
50 public GridConfig Config 54 public GridConfig Config
51 { 55 {
@@ -71,16 +75,36 @@ namespace OpenSim.Grid.GridServer
71 75
72 public GridServerBase() 76 public GridServerBase()
73 { 77 {
74 m_console = new LocalConsole("Grid");
75 MainConsole.Instance = m_console;
76 } 78 }
77 79
78 protected override void StartupSpecific() 80 protected override void StartupSpecific()
79 { 81 {
80 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); 82 switch (m_consoleType)
83 {
84 case "rest":
85 m_console = new RemoteConsole("Grid");
86 break;
87 case "basic":
88 m_console = new CommandConsole("Grid");
89 break;
90 default:
91 m_console = new LocalConsole("Grid");
92 break;
93 }
94 MainConsole.Instance = m_console;
95 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), m_configFile)));
81 96
82 m_log.Info("[GRID]: Starting HTTP process"); 97 m_log.Info("[GRID]: Starting HTTP process");
83 m_httpServer = new BaseHttpServer(m_config.HttpPort); 98 m_httpServer = new BaseHttpServer(m_config.HttpPort);
99 if (m_console is RemoteConsole)
100 {
101 RemoteConsole c = (RemoteConsole)m_console;
102 c.SetServer(m_httpServer);
103 IConfig netConfig = m_configSource.AddConfig("Network");
104 netConfig.Set("ConsoleUser", m_config.ConsoleUser);
105 netConfig.Set("ConsolePass", m_config.ConsolePass);
106 c.ReadConfig(m_configSource);
107 }
84 108
85 LoadPlugins(); 109 LoadPlugins();
86 110
diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Grid/GridServer/Program.cs
index 9618b85..741a01b 100644
--- a/OpenSim/Grid/GridServer/Program.cs
+++ b/OpenSim/Grid/GridServer/Program.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using log4net.Config; 28using log4net.Config;
29using Nini.Config;
29 30
30namespace OpenSim.Grid.GridServer 31namespace OpenSim.Grid.GridServer
31{ 32{
@@ -33,10 +34,23 @@ namespace OpenSim.Grid.GridServer
33 { 34 {
34 public static void Main(string[] args) 35 public static void Main(string[] args)
35 { 36 {
37 ArgvConfigSource argvSource = new ArgvConfigSource(args);
38 argvSource.AddSwitch("Startup", "console", "c");
39 argvSource.AddSwitch("Startup", "xmlfile", "x");
40
36 XmlConfigurator.Configure(); 41 XmlConfigurator.Configure();
37 42
38 GridServerBase app = new GridServerBase(); 43 GridServerBase app = new GridServerBase();
39 44
45 IConfig startupConfig = argvSource.Configs["Startup"];
46 if (startupConfig != null)
47 {
48 app.m_consoleType = startupConfig.GetString("console", "local");
49 app.m_configFile = startupConfig.GetString("xmlfile", "GridServer_Config.xml");
50 }
51
52 app.m_configSource = argvSource;
53
40// if (args.Length > 0 && args[0] == "-setuponly") 54// if (args.Length > 0 && args[0] == "-setuponly")
41// { 55// {
42// app.Config(); 56// app.Config();
diff --git a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs b/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs
index d56e48a..dadf34a 100644
--- a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs
+++ b/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs
@@ -28,7 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31namespace OpenSim.Framework.Communications.Cache 31namespace OpenSim.Grid.InventoryServer
32{ 32{
33 public class AuthedSessionCache 33 public class AuthedSessionCache
34 { 34 {
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs
index 309c415..f8b4949 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs
@@ -30,8 +30,10 @@ using System.Reflection;
30using log4net; 30using log4net;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Data; 32using OpenSim.Data;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
33 35
34namespace OpenSim.Framework.Communications 36namespace OpenSim.Grid.InventoryServer
35{ 37{
36 /// <summary> 38 /// <summary>
37 /// Abstract base class used by local and grid implementations of an inventory service. 39 /// Abstract base class used by local and grid implementations of an inventory service.
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs
index dcefeea..f2631a7 100644
--- a/OpenSim/Grid/MessagingServer/Main.cs
+++ b/OpenSim/Grid/MessagingServer/Main.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using Nini.Config;
33using log4net.Config; 34using log4net.Config;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
@@ -56,8 +57,25 @@ namespace OpenSim.Grid.MessagingServer
56 57
57 // private UUID m_lastCreatedUser = UUID.Random(); 58 // private UUID m_lastCreatedUser = UUID.Random();
58 59
60 protected static string m_consoleType = "local";
61 protected static IConfigSource m_config = null;
62 protected static string m_configFile = "MessagingServer_Config.xml";
63
59 public static void Main(string[] args) 64 public static void Main(string[] args)
60 { 65 {
66 ArgvConfigSource argvSource = new ArgvConfigSource(args);
67 argvSource.AddSwitch("Startup", "console", "c");
68 argvSource.AddSwitch("Startup", "xmlfile", "x");
69
70 IConfig startupConfig = argvSource.Configs["Startup"];
71 if (startupConfig != null)
72 {
73 m_consoleType = startupConfig.GetString("console", "local");
74 m_configFile = startupConfig.GetString("xmlfile", "MessagingServer_Config.xml");
75 }
76
77 m_config = argvSource;
78
61 XmlConfigurator.Configure(); 79 XmlConfigurator.Configure();
62 80
63 m_log.Info("[SERVER]: Launching MessagingServer..."); 81 m_log.Info("[SERVER]: Launching MessagingServer...");
@@ -70,7 +88,18 @@ namespace OpenSim.Grid.MessagingServer
70 88
71 public OpenMessage_Main() 89 public OpenMessage_Main()
72 { 90 {
73 m_console = new LocalConsole("Messaging"); 91 switch (m_consoleType)
92 {
93 case "rest":
94 m_console = new RemoteConsole("Messaging");
95 break;
96 case "basic":
97 m_console = new CommandConsole("Messaging");
98 break;
99 default:
100 m_console = new LocalConsole("Messaging");
101 break;
102 }
74 MainConsole.Instance = m_console; 103 MainConsole.Instance = m_console;
75 } 104 }
76 105
@@ -88,20 +117,33 @@ namespace OpenSim.Grid.MessagingServer
88 { 117 {
89 if (m_userServerModule.registerWithUserServer()) 118 if (m_userServerModule.registerWithUserServer())
90 { 119 {
91 m_log.Info("[SERVER]: Starting HTTP process"); 120 if (m_httpServer == null)
92 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 121 {
93 122 m_log.Info("[SERVER]: Starting HTTP process");
94 m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); 123 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
95 m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); 124
96 m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); 125 if (m_console is RemoteConsole)
97 m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); 126 {
98 m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); 127 RemoteConsole c = (RemoteConsole)m_console;
99 m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); 128 c.SetServer(m_httpServer);
100 129 IConfig netConfig = m_config.AddConfig("Network");
101 m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup); 130 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
102 m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); 131 netConfig.Set("ConsolePass", Cfg.ConsolePass);
103 132 c.ReadConfig(m_config);
104 m_httpServer.Start(); 133 }
134
135 m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn);
136 m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff);
137 m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk);
138 m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown);
139 m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation);
140 m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving);
141
142 m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup);
143 m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown);
144
145 m_httpServer.Start();
146 }
105 m_log.Info("[SERVER]: Userserver registration was successful"); 147 m_log.Info("[SERVER]: Userserver registration was successful");
106 } 148 }
107 else 149 else
@@ -114,18 +156,18 @@ namespace OpenSim.Grid.MessagingServer
114 private void deregisterFromUserServer() 156 private void deregisterFromUserServer()
115 { 157 {
116 m_userServerModule.deregisterWithUserServer(); 158 m_userServerModule.deregisterWithUserServer();
117 if (m_httpServer != null) 159// if (m_httpServer != null)
118 { 160// {
119 // try a completely fresh registration, with fresh handlers, too 161 // try a completely fresh registration, with fresh handlers, too
120 m_httpServer.Stop(); 162// m_httpServer.Stop();
121 m_httpServer = null; 163// m_httpServer = null;
122 } 164// }
123 m_console.Output("[SERVER]: Deregistered from userserver."); 165 m_console.Output("[SERVER]: Deregistered from userserver.");
124 } 166 }
125 167
126 protected override void StartupSpecific() 168 protected override void StartupSpecific()
127 { 169 {
128 Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); 170 Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), m_configFile)));
129 171
130 m_userDataBaseService = new UserDataBaseService(); 172 m_userDataBaseService = new UserDataBaseService();
131 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); 173 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 86c2abb..baf0fd3 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -43,6 +43,7 @@ using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1; 43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework; 44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules; 45using OpenSim.Grid.UserServer.Modules;
46using Nini.Config;
46 47
47namespace OpenSim.Grid.UserServer 48namespace OpenSim.Grid.UserServer
48{ 49{
@@ -73,8 +74,25 @@ namespace OpenSim.Grid.UserServer
73 74
74 protected AvatarCreationModule m_appearanceModule; 75 protected AvatarCreationModule m_appearanceModule;
75 76
77 protected static string m_consoleType = "local";
78 protected static IConfigSource m_config = null;
79 protected static string m_configFile = "UserServer_Config.xml";
80
76 public static void Main(string[] args) 81 public static void Main(string[] args)
77 { 82 {
83 ArgvConfigSource argvSource = new ArgvConfigSource(args);
84 argvSource.AddSwitch("Startup", "console", "c");
85 argvSource.AddSwitch("Startup", "xmlfile", "x");
86
87 IConfig startupConfig = argvSource.Configs["Startup"];
88 if (startupConfig != null)
89 {
90 m_consoleType = startupConfig.GetString("console", "local");
91 m_configFile = startupConfig.GetString("xmlfile", "UserServer_Config.xml");
92 }
93
94 m_config = argvSource;
95
78 XmlConfigurator.Configure(); 96 XmlConfigurator.Configure();
79 97
80 m_log.Info("Launching UserServer..."); 98 m_log.Info("Launching UserServer...");
@@ -87,7 +105,18 @@ namespace OpenSim.Grid.UserServer
87 105
88 public OpenUser_Main() 106 public OpenUser_Main()
89 { 107 {
90 m_console = new LocalConsole("User"); 108 switch (m_consoleType)
109 {
110 case "rest":
111 m_console = new RemoteConsole("User");
112 break;
113 case "basic":
114 m_console = new CommandConsole("User");
115 break;
116 default:
117 m_console = new LocalConsole("User");
118 break;
119 }
91 MainConsole.Instance = m_console; 120 MainConsole.Instance = m_console;
92 } 121 }
93 122
@@ -125,10 +154,20 @@ namespace OpenSim.Grid.UserServer
125 154
126 protected virtual IInterServiceInventoryServices StartupCoreComponents() 155 protected virtual IInterServiceInventoryServices StartupCoreComponents()
127 { 156 {
128 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); 157 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), m_configFile)));
129 158
130 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 159 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
131 160
161 if (m_console is RemoteConsole)
162 {
163 RemoteConsole c = (RemoteConsole)m_console;
164 c.SetServer(m_httpServer);
165 IConfig netConfig = m_config.AddConfig("Network");
166 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
167 netConfig.Set("ConsolePass", Cfg.ConsolePass);
168 c.ReadConfig(m_config);
169 }
170
132 RegisterInterface<CommandConsole>(m_console); 171 RegisterInterface<CommandConsole>(m_console);
133 RegisterInterface<UserConfig>(Cfg); 172 RegisterInterface<UserConfig>(Cfg);
134 173
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 06bea3d..dd01780 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -2177,7 +2177,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2177 bulkUpdate.AgentData.AgentID = AgentId; 2177 bulkUpdate.AgentData.AgentID = AgentId;
2178 bulkUpdate.AgentData.TransactionID = transactionId; 2178 bulkUpdate.AgentData.TransactionID = transactionId;
2179 bulkUpdate.FolderData = folderDataBlocks.ToArray(); 2179 bulkUpdate.FolderData = folderDataBlocks.ToArray();
2180 2180 List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
2181 bulkUpdate.ItemData = foo.ToArray();
2182
2181 //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate); 2183 //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
2182 OutPacket(bulkUpdate, ThrottleOutPacketType.Asset); 2184 OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
2183 } 2185 }
@@ -6633,9 +6635,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6633 } 6635 }
6634 else // Agent 6636 else // Agent
6635 { 6637 {
6636 //InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(itemID);
6637 IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>(); 6638 IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
6638 InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(itemID)); 6639 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId);
6640 assetRequestItem = invService.GetItem(assetRequestItem);
6639 if (assetRequestItem == null) 6641 if (assetRequestItem == null)
6640 { 6642 {
6641 assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 6643 assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
@@ -7027,14 +7029,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7027 if (OnMoveInventoryItem != null) 7029 if (OnMoveInventoryItem != null)
7028 { 7030 {
7029 handlerMoveInventoryItem = null; 7031 handlerMoveInventoryItem = null;
7032 InventoryItemBase itm = null;
7033 List<InventoryItemBase> items = new List<InventoryItemBase>();
7030 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) 7034 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
7031 { 7035 {
7032 handlerMoveInventoryItem = OnMoveInventoryItem; 7036 itm = new InventoryItemBase(datablock.ItemID, AgentId);
7033 if (handlerMoveInventoryItem != null) 7037 itm.Folder = datablock.FolderID;
7034 { 7038 itm.Name = Util.FieldToString(datablock.NewName);
7035 handlerMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, 7039 // weird, comes out as empty string
7036 Util.FieldToString(datablock.NewName)); 7040 //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
7037 } 7041 items.Add(itm);
7042 }
7043 handlerMoveInventoryItem = OnMoveInventoryItem;
7044 if (handlerMoveInventoryItem != null)
7045 {
7046 handlerMoveInventoryItem(this, items);
7038 } 7047 }
7039 } 7048 }
7040 break; 7049 break;
@@ -7053,14 +7062,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7053 if (OnRemoveInventoryItem != null) 7062 if (OnRemoveInventoryItem != null)
7054 { 7063 {
7055 handlerRemoveInventoryItem = null; 7064 handlerRemoveInventoryItem = null;
7065 List<UUID> uuids = new List<UUID>();
7056 foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) 7066 foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
7057 { 7067 {
7058 handlerRemoveInventoryItem = OnRemoveInventoryItem; 7068 uuids.Add(datablock.ItemID);
7059 if (handlerRemoveInventoryItem != null) 7069 }
7060 { 7070 handlerRemoveInventoryItem = OnRemoveInventoryItem;
7061 handlerRemoveInventoryItem(this, datablock.ItemID); 7071 if (handlerRemoveInventoryItem != null)
7062 } 7072 {
7073 handlerRemoveInventoryItem(this, uuids);
7063 } 7074 }
7075
7064 } 7076 }
7065 break; 7077 break;
7066 case PacketType.RemoveInventoryFolder: 7078 case PacketType.RemoveInventoryFolder:
@@ -7078,14 +7090,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7078 if (OnRemoveInventoryFolder != null) 7090 if (OnRemoveInventoryFolder != null)
7079 { 7091 {
7080 handlerRemoveInventoryFolder = null; 7092 handlerRemoveInventoryFolder = null;
7093 List<UUID> uuids = new List<UUID>();
7081 foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) 7094 foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
7082 { 7095 {
7083 handlerRemoveInventoryFolder = OnRemoveInventoryFolder; 7096 uuids.Add(datablock.FolderID);
7084 7097 }
7085 if (handlerRemoveInventoryFolder != null) 7098 handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
7086 { 7099 if (handlerRemoveInventoryFolder != null)
7087 handlerRemoveInventoryFolder(this, datablock.FolderID); 7100 {
7088 } 7101 handlerRemoveInventoryFolder(this, uuids);
7089 } 7102 }
7090 } 7103 }
7091 break; 7104 break;
@@ -7102,27 +7115,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7102 if (OnRemoveInventoryFolder != null) 7115 if (OnRemoveInventoryFolder != null)
7103 { 7116 {
7104 handlerRemoveInventoryFolder = null; 7117 handlerRemoveInventoryFolder = null;
7118 List<UUID> uuids = new List<UUID>();
7105 foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) 7119 foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
7106 { 7120 {
7107 handlerRemoveInventoryFolder = OnRemoveInventoryFolder; 7121 uuids.Add(datablock.FolderID);
7108 7122 }
7109 if (handlerRemoveInventoryFolder != null) 7123 handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
7110 { 7124 if (handlerRemoveInventoryFolder != null)
7111 handlerRemoveInventoryFolder(this, datablock.FolderID); 7125 {
7112 } 7126 handlerRemoveInventoryFolder(this, uuids);
7113 } 7127 }
7114 } 7128 }
7115 7129
7116 if (OnRemoveInventoryItem != null) 7130 if (OnRemoveInventoryItem != null)
7117 { 7131 {
7118 handlerRemoveInventoryItem = null; 7132 handlerRemoveInventoryItem = null;
7133 List<UUID> uuids = new List<UUID>();
7119 foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) 7134 foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
7120 { 7135 {
7121 handlerRemoveInventoryItem = OnRemoveInventoryItem; 7136 uuids.Add(datablock.ItemID);
7122 if (handlerRemoveInventoryItem != null) 7137 }
7123 { 7138 handlerRemoveInventoryItem = OnRemoveInventoryItem;
7124 handlerRemoveInventoryItem(this, datablock.ItemID); 7139 if (handlerRemoveInventoryItem != null)
7125 } 7140 {
7141 handlerRemoveInventoryItem(this, uuids);
7126 } 7142 }
7127 } 7143 }
7128 break; 7144 break;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
index bf0b06d..798c1e7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
@@ -128,28 +128,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP
128 // Store the throttle multiplier for posterity. 128 // Store the throttle multiplier for posterity.
129 throttleMultiplier = userSettings.ClientThrottleMultipler; 129 throttleMultiplier = userSettings.ClientThrottleMultipler;
130 130
131
132 int throttleMaxBPS = 1500000;
133 if (userSettings.TotalThrottleSettings != null)
134 throttleMaxBPS = userSettings.TotalThrottleSettings.Max;
135
131 // Set up the throttle classes (min, max, current) in bits per second 136 // Set up the throttle classes (min, max, current) in bits per second
132 ResendThrottle = new LLPacketThrottle(5000, 100000, 16000, userSettings.ClientThrottleMultipler); 137 ResendThrottle = new LLPacketThrottle(5000, throttleMaxBPS / 15, 16000, userSettings.ClientThrottleMultipler);
133 LandThrottle = new LLPacketThrottle(1000, 100000, 2000, userSettings.ClientThrottleMultipler); 138 LandThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 15, 2000, userSettings.ClientThrottleMultipler);
134 WindThrottle = new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler); 139 WindThrottle = new LLPacketThrottle(0, throttleMaxBPS / 15, 0, userSettings.ClientThrottleMultipler);
135 CloudThrottle = new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler); 140 CloudThrottle = new LLPacketThrottle(0, throttleMaxBPS / 15, 0, userSettings.ClientThrottleMultipler);
136 TaskThrottle = new LLPacketThrottle(1000, 800000, 3000, userSettings.ClientThrottleMultipler); 141 TaskThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 3000, userSettings.ClientThrottleMultipler);
137 AssetThrottle = new LLPacketThrottle(1000, 800000, 1000, userSettings.ClientThrottleMultipler); 142 AssetThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 1000, userSettings.ClientThrottleMultipler);
138 TextureThrottle = new LLPacketThrottle(1000, 800000, 4000, userSettings.ClientThrottleMultipler); 143 TextureThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 4000, userSettings.ClientThrottleMultipler);
139 144
140 // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second. 145
146 // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second.
147
148
141 ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings; 149 ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings;
142 if (null == totalThrottleSettings) 150 if (null == totalThrottleSettings)
143 { 151 {
144 totalThrottleSettings = new ThrottleSettings(0, 1500000, 28000); 152 totalThrottleSettings = new ThrottleSettings(0, throttleMaxBPS, 28000);
145 } 153 }
146 154
147 TotalThrottle 155 TotalThrottle
148 = new LLPacketThrottle( 156 = new LLPacketThrottle(
149 totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current, 157 totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current,
150 userSettings.ClientThrottleMultipler); 158 userSettings.ClientThrottleMultipler);
151 159
152 throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor)); 160 throttleTimer = new Timer((int)(throttletimems / throttleTimeDivisor));
153 throttleTimer.Elapsed += ThrottleTimerElapsed; 161 throttleTimer.Elapsed += ThrottleTimerElapsed;
154 throttleTimer.Start(); 162 throttleTimer.Start();
155 163
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 5184e35..9ee8df5 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -152,11 +152,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
152 ClientStackUserSettings userSettings = new ClientStackUserSettings(); 152 ClientStackUserSettings userSettings = new ClientStackUserSettings();
153 153
154 IConfig config = configSource.Configs["ClientStack.LindenUDP"]; 154 IConfig config = configSource.Configs["ClientStack.LindenUDP"];
155 155
156 if (config != null) 156 if (config != null)
157 { 157 {
158 if (config.Contains("client_throttle_max_bps"))
159 {
160 int maxBPS = config.GetInt("client_throttle_max_bps", 1500000);
161 userSettings.TotalThrottleSettings = new ThrottleSettings(0, maxBPS,
162 maxBPS > 28000 ? maxBPS : 28000);
163 }
164
158 if (config.Contains("client_throttle_multiplier")) 165 if (config.Contains("client_throttle_multiplier"))
159 userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier"); 166 userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier");
160 if (config.Contains("client_socket_rcvbuf_size")) 167 if (config.Contains("client_socket_rcvbuf_size"))
161 m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size"); 168 m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size");
162 } 169 }
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 582beee..35c59aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -130,7 +130,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
130 } 130 }
131 else 131 else
132 { 132 {
133 InventoryItemBase baseItem = invService.GetItem(new InventoryItemBase(appearance.Wearables[i].ItemID)); 133 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
134 baseItem = invService.GetItem(baseItem);
134 135
135 if (baseItem != null) 136 if (baseItem != null)
136 { 137 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
index a68db1b..ff12361 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
@@ -65,7 +65,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures
65 { 65 {
66 IInventoryService invService = m_scene.InventoryService; 66 IInventoryService invService = m_scene.InventoryService;
67 67
68 InventoryItemBase item = invService.GetItem(new InventoryItemBase(gestureId)); 68 InventoryItemBase item = new InventoryItemBase(gestureId, client.AgentId);
69 item = invService.GetItem(item);
69 if (item != null) 70 if (item != null)
70 { 71 {
71 item.Flags = 1; 72 item.Flags = 1;
@@ -80,7 +81,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures
80 { 81 {
81 IInventoryService invService = m_scene.InventoryService; 82 IInventoryService invService = m_scene.InventoryService;
82 83
83 InventoryItemBase item = invService.GetItem(new InventoryItemBase(gestureId)); 84 InventoryItemBase item = new InventoryItemBase(gestureId, client.AgentId);
85 item = invService.GetItem(item);
84 if (item != null) 86 if (item != null)
85 { 87 {
86 item.Flags = 0; 88 item.Flags = 0;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 5e7cf4b..4495303 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -56,7 +56,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
56 if (cnf != null && cnf.GetString( 56 if (cnf != null && cnf.GetString(
57 "MessageTransferModule", "MessageTransferModule") != 57 "MessageTransferModule", "MessageTransferModule") !=
58 "MessageTransferModule") 58 "MessageTransferModule")
59 {
60 m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration");
59 return; 61 return;
62 }
60 63
61 cnf = config.Configs["Startup"]; 64 cnf = config.Configs["Startup"];
62 if (cnf != null) 65 if (cnf != null)
@@ -72,6 +75,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
72 "grid_instant_message", processXMLRPCGridInstantMessage); 75 "grid_instant_message", processXMLRPCGridInstantMessage);
73 } 76 }
74 77
78 m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active");
75 scene.RegisterModuleInterface<IMessageTransferModule>(this); 79 scene.RegisterModuleInterface<IMessageTransferModule>(this);
76 m_Scenes.Add(scene); 80 m_Scenes.Add(scene);
77 } 81 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 5315c11..75976e2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -67,13 +67,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
67 67
68 if (!m_Scenelist.Contains(scene)) 68 if (!m_Scenelist.Contains(scene))
69 { 69 {
70 if (m_Scenelist.Count == 0)
71 {
72 m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
73 if (m_TransferModule == null)
74 m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only");
75 }
76
77 m_Scenelist.Add(scene); 70 m_Scenelist.Add(scene);
78 71
79 scene.RegisterModuleInterface<IInventoryTransferModule>(this); 72 scene.RegisterModuleInterface<IInventoryTransferModule>(this);
@@ -86,6 +79,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
86 79
87 public void PostInitialise() 80 public void PostInitialise()
88 { 81 {
82 if (m_Scenelist.Count > 0)
83 {
84 m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>();
85 if (m_TransferModule == null)
86 m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only");
87 }
89 } 88 }
90 89
91 public void Close() 90 public void Close()
@@ -257,8 +256,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
257 invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); 256 invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);
258 257
259 UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip 258 UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
260 259
261 InventoryItemBase item = invService.GetItem(new InventoryItemBase(inventoryEntityID)); 260 InventoryItemBase item = new InventoryItemBase(inventoryEntityID, client.AgentId);
261 item = invService.GetItem(item);
262 InventoryFolderBase folder = null; 262 InventoryFolderBase folder = null;
263 263
264 if (item != null && trashFolder != null) 264 if (item != null && trashFolder != null)
@@ -266,12 +266,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
266 item.Folder = trashFolder.ID; 266 item.Folder = trashFolder.ID;
267 267
268 // Diva comment: can't we just update this item??? 268 // Diva comment: can't we just update this item???
269 invService.DeleteItem(item); 269 List<UUID> uuids = new List<UUID>();
270 uuids.Add(item.ID);
271 invService.DeleteItems(item.Owner, uuids);
270 scene.AddInventoryItem(client, item); 272 scene.AddInventoryItem(client, item);
271 } 273 }
272 else 274 else
273 { 275 {
274 folder = invService.GetFolder(new InventoryFolderBase(inventoryEntityID)); 276 folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
277 folder = invService.GetFolder(folder);
275 278
276 if (folder != null & trashFolder != null) 279 if (folder != null & trashFolder != null)
277 { 280 {
@@ -451,10 +454,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
451 else 454 else
452 { 455 {
453 UUID itemID = new UUID(msg.binaryBucket, 1); 456 UUID itemID = new UUID(msg.binaryBucket, 1);
454 InventoryItemBase item = new InventoryItemBase(); 457 InventoryItemBase item = new InventoryItemBase(itemID, user.ControllingClient.AgentId);
455
456 item.ID = itemID;
457 item.Owner = user.ControllingClient.AgentId;
458 458
459 // Fetch from service 459 // Fetch from service
460 // 460 //
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs b/OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs
index 0effa9f..cd2fe4f 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs
+++ b/OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs
@@ -26,31 +26,15 @@
26 */ 26 */
27 27
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Framework; 29using OpenSim.Region.Framework.Scenes;
30using OpenSim.Framework.Communications;
31using OpenSim.Data;
32 30
33namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim 31namespace OpenSim.Region.CoreModules.Avatar.NPC
34{ 32{
35 public class OpenSimInventoryService : InventoryServiceBase 33 public interface INPCModule
36 { 34 {
37 public InventoryFolderWithChildren GetInventoryFolder(UUID folderID) 35 UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom);
38 { 36 void Autopilot(UUID agentID, Scene scene, Vector3 pos);
39 InventoryFolderBase baseFolder = null; 37 void Say(UUID agentID, Scene scene, string text);
40 InventoryFolderWithChildren folder = null; 38 void DeleteNPC(UUID agentID, Scene scene);
41
42 foreach (IInventoryDataPlugin plugin in m_plugins)
43 {
44 baseFolder = plugin.getInventoryFolder(folderID);
45 }
46
47 if (null != baseFolder)
48 {
49 folder = new InventoryFolderWithChildren(baseFolder);
50 folder.Children = null; // This call only returns data for the folder itself, no children data
51 }
52
53 return folder;
54 }
55 } 39 }
56} 40} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 2640f08..e577fbe 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -443,7 +443,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
443 endPoint.X = (int) x; 443 endPoint.X = (int) x;
444 endPoint.Y = (int) y; 444 endPoint.Y = (int) y;
445 Image image = ImageHttpRequest(nextLine); 445 Image image = ImageHttpRequest(nextLine);
446 graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); 446 if (image != null)
447 {
448 graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
449 }
450 else
451 {
452 graph.DrawString("URL couldn't be resolved or is", new Font("Arial",6), myBrush, startPoint);
453 graph.DrawString("not an image. Please check URL.", new Font("Arial", 6), myBrush, new Point(startPoint.X, 12 + startPoint.Y));
454 graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
455 }
447 startPoint.X += endPoint.X; 456 startPoint.X += endPoint.X;
448 startPoint.Y += endPoint.Y; 457 startPoint.Y += endPoint.Y;
449 } 458 }
@@ -469,13 +478,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
469 startPoint.X += endPoint.X; 478 startPoint.X += endPoint.X;
470 startPoint.Y += endPoint.Y; 479 startPoint.Y += endPoint.Y;
471 } 480 }
481 else if (nextLine.StartsWith("FillPolygon"))
482 {
483 PointF[] points = null;
484 GetParams(partsDelimiter, ref nextLine, 11, ref points);
485 graph.FillPolygon(myBrush, points);
486 }
472 else if (nextLine.StartsWith("Ellipse")) 487 else if (nextLine.StartsWith("Ellipse"))
473 { 488 {
474 float x = 0; 489 float x = 0;
475 float y = 0; 490 float y = 0;
476 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); 491 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
477 endPoint.X = (int) x; 492 endPoint.X = (int)x;
478 endPoint.Y = (int) y; 493 endPoint.Y = (int)y;
479 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); 494 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
480 startPoint.X += endPoint.X; 495 startPoint.X += endPoint.X;
481 startPoint.Y += endPoint.Y; 496 startPoint.Y += endPoint.Y;
@@ -492,30 +507,31 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
492 nextLine = nextLine.Remove(0, 8); 507 nextLine = nextLine.Remove(0, 8);
493 nextLine = nextLine.Trim(); 508 nextLine = nextLine.Trim();
494 509
495 string [] fprops = nextLine.Split(partsDelimiter); 510 string[] fprops = nextLine.Split(partsDelimiter);
496 foreach (string prop in fprops) { 511 foreach (string prop in fprops)
497 512 {
513
498 switch (prop) 514 switch (prop)
499 { 515 {
500 case "B": 516 case "B":
501 if (!(myFont.Bold)) 517 if (!(myFont.Bold))
502 myFont = new Font(myFont, myFont.Style | FontStyle.Bold); 518 myFont = new Font(myFont, myFont.Style | FontStyle.Bold);
503 break; 519 break;
504 case "I": 520 case "I":
505 if (!(myFont.Italic)) 521 if (!(myFont.Italic))
506 myFont = new Font(myFont, myFont.Style | FontStyle.Italic); 522 myFont = new Font(myFont, myFont.Style | FontStyle.Italic);
507 break; 523 break;
508 case "U": 524 case "U":
509 if (!(myFont.Underline)) 525 if (!(myFont.Underline))
510 myFont = new Font(myFont, myFont.Style | FontStyle.Underline); 526 myFont = new Font(myFont, myFont.Style | FontStyle.Underline);
511 break; 527 break;
512 case "S": 528 case "S":
513 if (!(myFont.Strikeout)) 529 if (!(myFont.Strikeout))
514 myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout); 530 myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
515 break; 531 break;
516 case "R": 532 case "R":
517 myFont = new Font(myFont, FontStyle.Regular); 533 myFont = new Font(myFont, FontStyle.Regular);
518 break; 534 break;
519 } 535 }
520 } 536 }
521 } 537 }
@@ -532,6 +548,57 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
532 float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); 548 float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
533 drawPen.Width = size; 549 drawPen.Width = size;
534 } 550 }
551 else if (nextLine.StartsWith("PenCap"))
552 {
553 bool start = true, end = true;
554 nextLine = nextLine.Remove(0, 6);
555 nextLine = nextLine.Trim();
556 string[] cap = nextLine.Split(partsDelimiter);
557 if (cap[0].ToLower() == "start")
558 end = false;
559 else if (cap[0].ToLower() == "end")
560 start = false;
561 else if (cap[0].ToLower() != "both")
562 return;
563 string type = cap[1].ToLower();
564
565 if (end)
566 {
567 switch (type)
568 {
569 case "arrow":
570 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
571 break;
572 case "round":
573 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
574 break;
575 case "diamond":
576 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
577 break;
578 case "flat":
579 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat;
580 break;
581 }
582 }
583 if (start)
584 {
585 switch (type)
586 {
587 case "arrow":
588 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
589 break;
590 case "round":
591 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
592 break;
593 case "diamond":
594 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
595 break;
596 case "flat":
597 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat;
598 break;
599 }
600 }
601 }
535 else if (nextLine.StartsWith("PenColour")) 602 else if (nextLine.StartsWith("PenColour"))
536 { 603 {
537 nextLine = nextLine.Remove(0, 9); 604 nextLine = nextLine.Remove(0, 9);
@@ -542,7 +609,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
542 if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex)) 609 if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
543 { 610 {
544 newColour = Color.FromArgb(hex); 611 newColour = Color.FromArgb(hex);
545 } 612 }
546 else 613 else
547 { 614 {
548 // this doesn't fail, it just returns black if nothing is found 615 // this doesn't fail, it just returns black if nothing is found
@@ -582,18 +649,40 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
582 } 649 }
583 } 650 }
584 651
652 private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref PointF[] points)
653 {
654 line = line.Remove(0, startLength);
655 string[] parts = line.Split(partsDelimiter);
656 if (parts.Length > 1 && parts.Length % 2 == 0)
657 {
658 points = new PointF[parts.Length / 2];
659 for (int i = 0; i < parts.Length; i = i + 2)
660 {
661 string xVal = parts[i].Trim();
662 string yVal = parts[i+1].Trim();
663 float x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture);
664 float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture);
665 PointF point = new PointF(x, y);
666 points[i / 2] = point;
667 }
668 }
669 }
670
585 private Bitmap ImageHttpRequest(string url) 671 private Bitmap ImageHttpRequest(string url)
586 { 672 {
673 try
674 {
587 WebRequest request = HttpWebRequest.Create(url); 675 WebRequest request = HttpWebRequest.Create(url);
588//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 676//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
589//Ckrinke Stream str = null; 677//Ckrinke Stream str = null;
590 HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); 678 HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
591 if (response.StatusCode == HttpStatusCode.OK) 679 if (response.StatusCode == HttpStatusCode.OK)
592 { 680 {
593 Bitmap image = new Bitmap(response.GetResponseStream()); 681 Bitmap image = new Bitmap(response.GetResponseStream());
594 return image; 682 return image;
683 }
595 } 684 }
596 685 catch { }
597 return null; 686 return null;
598 } 687 }
599 } 688 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
index ef5ffe1..bd32f3b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
@@ -139,6 +139,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
139 public abstract bool MoveFolder(InventoryFolderBase folder); 139 public abstract bool MoveFolder(InventoryFolderBase folder);
140 140
141 /// <summary> 141 /// <summary>
142 /// Delete a list of inventory folders (from trash)
143 /// </summary>
144 public abstract bool DeleteFolders(UUID ownerID, List<UUID> folderIDs);
145
146 /// <summary>
142 /// Purge an inventory folder of all its items and subfolders. 147 /// Purge an inventory folder of all its items and subfolders.
143 /// </summary> 148 /// </summary>
144 /// <param name="folder"></param> 149 /// <param name="folder"></param>
@@ -181,12 +186,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
181 /// <returns>true if the item was successfully updated</returns> 186 /// <returns>true if the item was successfully updated</returns>
182 public abstract bool UpdateItem(InventoryItemBase item); 187 public abstract bool UpdateItem(InventoryItemBase item);
183 188
189 public abstract bool MoveItems(UUID ownerID, List<InventoryItemBase> items);
190
184 /// <summary> 191 /// <summary>
185 /// Delete an item from the user's inventory 192 /// Delete an item from the user's inventory
186 /// </summary> 193 /// </summary>
187 /// <param name="item"></param> 194 /// <param name="item"></param>
188 /// <returns>true if the item was successfully deleted</returns> 195 /// <returns>true if the item was successfully deleted</returns>
189 public abstract bool DeleteItem(InventoryItemBase item); 196 public abstract bool DeleteItems(UUID ownerID, List<UUID> itemIDs);
190 197
191 public abstract InventoryItemBase GetItem(InventoryItemBase item); 198 public abstract InventoryItemBase GetItem(InventoryItemBase item);
192 199
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index dd451ef..1c66254 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -290,7 +290,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
290 290
291 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 291 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
292 { 292 {
293 return new List<InventoryItemBase>(); 293 if (IsLocalGridUser(userID))
294 return m_GridService.GetFolderItems(userID, folderID);
295 else
296 {
297 UUID sessionID = GetSessionID(userID);
298 string uri = GetUserInventoryURI(userID) + "/" + userID;
299 return m_HGService.GetFolderItems(uri, folderID, sessionID);
300 }
294 } 301 }
295 302
296 public override bool AddFolder(InventoryFolderBase folder) 303 public override bool AddFolder(InventoryFolderBase folder)
@@ -323,6 +330,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
323 } 330 }
324 } 331 }
325 332
333 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
334 {
335 if (folderIDs == null)
336 return false;
337 if (folderIDs.Count == 0)
338 return false;
339
340 if (IsLocalGridUser(ownerID))
341 return m_GridService.DeleteFolders(ownerID, folderIDs);
342 else
343 {
344 UUID sessionID = GetSessionID(ownerID);
345 string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString();
346 return m_HGService.DeleteFolders(uri, folderIDs, sessionID);
347 }
348 }
349
326 public override bool MoveFolder(InventoryFolderBase folder) 350 public override bool MoveFolder(InventoryFolderBase folder)
327 { 351 {
328 if (folder == null) 352 if (folder == null)
@@ -386,18 +410,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
386 } 410 }
387 } 411 }
388 412
389 public override bool DeleteItem(InventoryItemBase item) 413 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
390 { 414 {
391 if (item == null) 415 if (items == null)
392 return false; 416 return false;
417 if (items.Count == 0)
418 return true;
393 419
394 if (IsLocalGridUser(item.Owner)) 420 if (IsLocalGridUser(ownerID))
395 return m_GridService.DeleteItem(item); 421 return m_GridService.MoveItems(ownerID, items);
396 else 422 else
397 { 423 {
398 UUID sessionID = GetSessionID(item.Owner); 424 UUID sessionID = GetSessionID(ownerID);
399 string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); 425 string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString();
400 return m_HGService.DeleteItem(uri, item, sessionID); 426 return m_HGService.MoveItems(uri, items, sessionID);
427 }
428 }
429
430 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
431 {
432 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
433
434 if (itemIDs == null)
435 return false;
436 if (itemIDs.Count == 0)
437 return true;
438
439 if (IsLocalGridUser(ownerID))
440 return m_GridService.DeleteItems(ownerID, itemIDs);
441 else
442 {
443 UUID sessionID = GetSessionID(ownerID);
444 string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString();
445 return m_HGService.DeleteItems(uri, itemIDs, sessionID);
401 } 446 }
402 } 447 }
403 448
@@ -483,12 +528,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
483 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 528 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI);
484 string uri = m_LocalGridInventoryURI.TrimEnd('/'); 529 string uri = m_LocalGridInventoryURI.TrimEnd('/');
485 530
486 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, comparing {0} to {1}.", userInventoryServerURI, uri);
487
488 if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) 531 if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
489 { 532 {
490 return true; 533 return true;
491 } 534 }
535 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user {0} is foreign({1} - {2})", userID, userInventoryServerURI, uri);
492 return false; 536 return false;
493 } 537 }
494 538
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index 2fbc5fe..66d11dd 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
191 191
192 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID) 192 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
193 { 193 {
194 InventoryFolderBase root = GetRootFolder(userID); 194 InventoryFolderBase root = m_InventoryService.GetRootFolder(userID);
195 if (root != null) 195 if (root != null)
196 { 196 {
197 InventoryCollection content = GetFolderContent(userID, root.ID); 197 InventoryCollection content = GetFolderContent(userID, root.ID);
@@ -202,13 +202,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
202 { 202 {
203 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) 203 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
204 { 204 {
205 m_log.InfoFormat("[INVENTORY CONNECTOR]: folder type {0} ", folder.Type); 205 //m_log.InfoFormat("[INVENTORY CONNECTOR]: folder type {0} ", folder.Type);
206 folders[(AssetType)folder.Type] = folder; 206 folders[(AssetType)folder.Type] = folder;
207 } 207 }
208 } 208 }
209 // Put the root folder there, as type Folder 209 // Put the root folder there, as type Folder
210 folders[AssetType.Folder] = root; 210 folders[AssetType.Folder] = root;
211 m_log.InfoFormat("[INVENTORY CONNECTOR]: root folder is type {0} ", root.Type); 211 //m_log.InfoFormat("[INVENTORY CONNECTOR]: root folder is type {0} ", root.Type);
212 212
213 return folders; 213 return folders;
214 } 214 }
@@ -258,6 +258,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
258 return m_InventoryService.MoveFolder(folder); 258 return m_InventoryService.MoveFolder(folder);
259 } 259 }
260 260
261 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
262 {
263 return m_InventoryService.DeleteFolders(ownerID, folderIDs);
264 }
265
261 /// <summary> 266 /// <summary>
262 /// Purge an inventory folder of all its items and subfolders. 267 /// Purge an inventory folder of all its items and subfolders.
263 /// </summary> 268 /// </summary>
@@ -289,14 +294,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
289 return m_InventoryService.UpdateItem(item); 294 return m_InventoryService.UpdateItem(item);
290 } 295 }
291 296
297
298 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
299 {
300 return m_InventoryService.MoveItems(ownerID, items);
301 }
302
292 /// <summary> 303 /// <summary>
293 /// Delete an item from the user's inventory 304 /// Delete an item from the user's inventory
294 /// </summary> 305 /// </summary>
295 /// <param name="item"></param> 306 /// <param name="item"></param>
296 /// <returns>true if the item was successfully deleted</returns> 307 /// <returns>true if the item was successfully deleted</returns>
297 public override bool DeleteItem(InventoryItemBase item) 308 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
298 { 309 {
299 return m_InventoryService.DeleteItem(item); 310 return m_InventoryService.DeleteItems(ownerID, itemIDs);
300 } 311 }
301 312
302 public override InventoryItemBase GetItem(InventoryItemBase item) 313 public override InventoryItemBase GetItem(InventoryItemBase item)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
index bef716b..0d32c77 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
@@ -212,7 +212,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
212 212
213 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 213 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
214 { 214 {
215 return new List<InventoryItemBase>(); 215 UUID sessionID = GetSessionID(userID);
216 return m_RemoteConnector.GetFolderItems(userID.ToString(), folderID, sessionID);
216 } 217 }
217 218
218 public override bool AddFolder(InventoryFolderBase folder) 219 public override bool AddFolder(InventoryFolderBase folder)
@@ -242,6 +243,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
242 return m_RemoteConnector.MoveFolder(folder.Owner.ToString(), folder, sessionID); 243 return m_RemoteConnector.MoveFolder(folder.Owner.ToString(), folder, sessionID);
243 } 244 }
244 245
246 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
247 {
248 if (folderIDs == null)
249 return false;
250 if (folderIDs.Count == 0)
251 return false;
252
253 UUID sessionID = GetSessionID(ownerID);
254 return m_RemoteConnector.DeleteFolders(ownerID.ToString(), folderIDs, sessionID);
255 }
256
257
245 public override bool PurgeFolder(InventoryFolderBase folder) 258 public override bool PurgeFolder(InventoryFolderBase folder)
246 { 259 {
247 if (folder == null) 260 if (folder == null)
@@ -272,13 +285,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
272 return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID); 285 return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID);
273 } 286 }
274 287
275 public override bool DeleteItem(InventoryItemBase item) 288 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
276 { 289 {
277 if (item == null) 290 if (items == null)
278 return false; 291 return false;
279 292
280 UUID sessionID = GetSessionID(item.Owner); 293 UUID sessionID = GetSessionID(ownerID);
281 return m_RemoteConnector.DeleteItem(item.Owner.ToString(), item, sessionID); 294 return m_RemoteConnector.MoveItems(ownerID.ToString(), items, sessionID);
295 }
296
297
298 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
299 {
300 if (itemIDs == null)
301 return false;
302 if (itemIDs.Count == 0)
303 return true;
304
305 UUID sessionID = GetSessionID(ownerID);
306 return m_RemoteConnector.DeleteItems(ownerID.ToString(), itemIDs, sessionID);
282 } 307 }
283 308
284 public override InventoryItemBase GetItem(InventoryItemBase item) 309 public override InventoryItemBase GetItem(InventoryItemBase item)
@@ -320,14 +345,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
320 345
321 private UUID GetSessionID(UUID userID) 346 private UUID GetSessionID(UUID userID)
322 { 347 {
323 if (m_Scene == null) 348 //if (m_Scene == null)
324 { 349 //{
325 m_log.Debug("[INVENTORY CONNECTOR]: OOPS! scene is null"); 350 // m_log.Debug("[INVENTORY CONNECTOR]: OOPS! scene is null");
326 } 351 //}
327 352
328 if (m_UserProfileService == null) 353 if (m_UserProfileService == null)
329 { 354 {
330 m_log.Debug("[INVENTORY CONNECTOR]: OOPS! UserProfileCacheService is null"); 355 //m_log.Debug("[INVENTORY CONNECTOR]: OOPS! UserProfileCacheService is null");
331 return UUID.Zero; 356 return UUID.Zero;
332 } 357 }
333 358
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 9c71b41..f360577 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -966,7 +966,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
966 if (objectID == UUID.Zero) // User inventory 966 if (objectID == UUID.Zero) // User inventory
967 { 967 {
968 IInventoryService invService = m_scene.InventoryService; 968 IInventoryService invService = m_scene.InventoryService;
969 InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(notecard)); 969 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
970 assetRequestItem = invService.GetItem(assetRequestItem);
970 if (assetRequestItem == null) // Library item 971 if (assetRequestItem == null) // Library item
971 { 972 {
972 assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); 973 assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);
@@ -1385,7 +1386,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1385 if (objectID == UUID.Zero) // User inventory 1386 if (objectID == UUID.Zero) // User inventory
1386 { 1387 {
1387 IInventoryService invService = m_scene.InventoryService; 1388 IInventoryService invService = m_scene.InventoryService;
1388 InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(script)); 1389 InventoryItemBase assetRequestItem = new InventoryItemBase(script, user);
1390 assetRequestItem = invService.GetItem(assetRequestItem);
1389 if (assetRequestItem == null) // Library item 1391 if (assetRequestItem == null) // Library item
1390 { 1392 {
1391 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); 1393 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script);
@@ -1479,7 +1481,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1479 if (objectID == UUID.Zero) // User inventory 1481 if (objectID == UUID.Zero) // User inventory
1480 { 1482 {
1481 IInventoryService invService = m_scene.InventoryService; 1483 IInventoryService invService = m_scene.InventoryService;
1482 InventoryItemBase assetRequestItem = invService.GetItem(new InventoryItemBase(notecard)); 1484 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
1485 assetRequestItem = invService.GetItem(assetRequestItem);
1483 if (assetRequestItem == null) // Library item 1486 if (assetRequestItem == null) // Library item
1484 { 1487 {
1485 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); 1488 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 46777e1..3301536 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -140,7 +140,8 @@ namespace OpenSim.Region.Framework.Scenes
140 /// <returns></returns> 140 /// <returns></returns>
141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) 141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
142 { 142 {
143 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 143 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
144 item = InventoryService.GetItem(item);
144 145
145 if (item != null) 146 if (item != null)
146 { 147 {
@@ -178,8 +179,8 @@ namespace OpenSim.Region.Framework.Scenes
178 else 179 else
179 { 180 {
180 m_log.ErrorFormat( 181 m_log.ErrorFormat(
181 "[AGENT INVENTORY]: Could not resolve user {0} for caps inventory update", 182 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
182 remoteClient.AgentId); 183 itemID);
183 } 184 }
184 185
185 return UUID.Zero; 186 return UUID.Zero;
@@ -315,7 +316,8 @@ namespace OpenSim.Region.Framework.Scenes
315 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, 316 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
316 UUID itemID, InventoryItemBase itemUpd) 317 UUID itemID, InventoryItemBase itemUpd)
317 { 318 {
318 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 319 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
320 item = InventoryService.GetItem(item);
319 321
320 if (item != null) 322 if (item != null)
321 { 323 {
@@ -408,7 +410,8 @@ namespace OpenSim.Region.Framework.Scenes
408 { 410 {
409 Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); 411 Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
410 412
411 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemId)); 413 InventoryItemBase item = new InventoryItemBase(itemId, senderId);
414 item = InventoryService.GetItem(item);
412 415
413 if ((item != null) && (item.Owner == senderId)) 416 if ((item != null) && (item.Owner == senderId))
414 { 417 {
@@ -474,7 +477,11 @@ namespace OpenSim.Region.Framework.Scenes
474 if (!Permissions.BypassPermissions()) 477 if (!Permissions.BypassPermissions())
475 { 478 {
476 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 479 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
477 InventoryService.DeleteItem(new InventoryItemBase(itemId)); 480 {
481 List<UUID> items = new List<UUID>();
482 items.Add(itemId);
483 InventoryService.DeleteItems(senderId, items);
484 }
478 } 485 }
479 486
480 return itemCopy; 487 return itemCopy;
@@ -558,7 +565,8 @@ namespace OpenSim.Region.Framework.Scenes
558 565
559 if (item == null) 566 if (item == null)
560 { 567 {
561 item = InventoryService.GetItem(new InventoryItemBase(oldItemID)); 568 item = new InventoryItemBase(oldItemID, remoteClient.AgentId);
569 item = InventoryService.GetItem(item);
562 570
563 if (item == null) 571 if (item == null)
564 { 572 {
@@ -630,33 +638,13 @@ namespace OpenSim.Region.Framework.Scenes
630 /// <param name="itemID"></param> 638 /// <param name="itemID"></param>
631 /// <param name="length"></param> 639 /// <param name="length"></param>
632 /// <param name="newName"></param> 640 /// <param name="newName"></param>
633 public void MoveInventoryItem(IClientAPI remoteClient, UUID folderID, UUID itemID, int length, 641 public void MoveInventoryItem(IClientAPI remoteClient, List<InventoryItemBase> items)
634 string newName)
635 { 642 {
636 m_log.DebugFormat( 643 m_log.DebugFormat(
637 "[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId); 644 "[AGENT INVENTORY]: Moving {0} items for user {1}", items.Count, remoteClient.AgentId);
638
639 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID));
640
641 if (item != null)
642 {
643 if (newName != String.Empty)
644 {
645 item.Name = newName;
646 }
647 item.Folder = folderID;
648
649 // Diva comment: can't we just update?
650 InventoryService.DeleteItem(item);
651
652 AddInventoryItem(remoteClient, item);
653 }
654 else
655 {
656 m_log.Warn("[AGENT INVENTORY]: Failed to find item " + itemID.ToString());
657 645
658 return; 646 if (!InventoryService.MoveItems(remoteClient.AgentId, items))
659 } 647 m_log.Warn("[AGENT INVENTORY]: Failed to move items for user " + remoteClient.AgentId);
660 } 648 }
661 649
662 /// <summary> 650 /// <summary>
@@ -794,29 +782,22 @@ namespace OpenSim.Region.Framework.Scenes
794 /// </summary> 782 /// </summary>
795 /// <param name="remoteClient"></param> 783 /// <param name="remoteClient"></param>
796 /// <param name="itemID"></param> 784 /// <param name="itemID"></param>
797 private void RemoveInventoryItem(IClientAPI remoteClient, UUID itemID) 785 private void RemoveInventoryItem(IClientAPI remoteClient, List<UUID> itemIDs)
798 { 786 {
799 InventoryService.DeleteItem(new InventoryItemBase(itemID)); 787 //m_log.Debug("[SCENE INVENTORY]: user " + remoteClient.AgentId);
788 InventoryService.DeleteItems(remoteClient.AgentId, itemIDs);
800 } 789 }
801 790
802 /// <summary> 791 /// <summary>
803 /// Removes an inventory folder. Although there is a packet in the Linden protocol for this, it may be 792 /// Removes an inventory folder. This packet is sent when the user
804 /// legacy and not currently used (purge folder is used to remove folders from trash instead). 793 /// right-clicks a folder that's already in trash and chooses "purge"
805 /// </summary> 794 /// </summary>
806 /// <param name="remoteClient"></param> 795 /// <param name="remoteClient"></param>
807 /// <param name="folderID"></param> 796 /// <param name="folderID"></param>
808 private void RemoveInventoryFolder(IClientAPI remoteClient, UUID folderID) 797 private void RemoveInventoryFolder(IClientAPI remoteClient, List<UUID> folderIDs)
809 { 798 {
810 // Unclear is this handler is ever called by the Linden client, but it might 799 m_log.DebugFormat("[SCENE INVENTORY]: RemoveInventoryFolders count {0}", folderIDs.Count);
811 800 InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs);
812 InventoryFolderBase folder = new InventoryFolderBase(folderID);
813 folder.Owner = remoteClient.AgentId;
814 InventoryFolderBase trash = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder);
815 if (trash != null)
816 {
817 folder.ParentID = trash.ID;
818 InventoryService.MoveFolder(folder);
819 }
820 } 801 }
821 802
822 private SceneObjectGroup GetGroupByPrim(uint localID) 803 private SceneObjectGroup GetGroupByPrim(uint localID)
@@ -1224,7 +1205,8 @@ namespace OpenSim.Region.Framework.Scenes
1224 UUID copyID = UUID.Random(); 1205 UUID copyID = UUID.Random();
1225 if (itemID != UUID.Zero) 1206 if (itemID != UUID.Zero)
1226 { 1207 {
1227 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 1208 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1209 item = InventoryService.GetItem(item);
1228 1210
1229 // Try library 1211 // Try library
1230 if (null == item) 1212 if (null == item)
@@ -1242,7 +1224,11 @@ namespace OpenSim.Region.Framework.Scenes
1242 if (!Permissions.BypassPermissions()) 1224 if (!Permissions.BypassPermissions())
1243 { 1225 {
1244 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1226 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1245 RemoveInventoryItem(remoteClient, itemID); 1227 {
1228 List<UUID> uuids = new List<UUID>();
1229 uuids.Add(itemID);
1230 RemoveInventoryItem(remoteClient, uuids);
1231 }
1246 } 1232 }
1247 } 1233 }
1248 else 1234 else
@@ -1287,7 +1273,8 @@ namespace OpenSim.Region.Framework.Scenes
1287 1273
1288 if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory 1274 if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory
1289 { 1275 {
1290 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 1276 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1277 item = InventoryService.GetItem(item);
1291 1278
1292 // Try library 1279 // Try library
1293 // XXX clumsy, possibly should be one call 1280 // XXX clumsy, possibly should be one call
@@ -1672,7 +1659,7 @@ namespace OpenSim.Region.Framework.Scenes
1672 1659
1673 if (DeRezAction.SaveToExistingUserInventoryItem == action) 1660 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1674 { 1661 {
1675 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID); 1662 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1676 item = InventoryService.GetItem(item); 1663 item = InventoryService.GetItem(item);
1677 1664
1678 //item = userInfo.RootFolder.FindItem( 1665 //item = userInfo.RootFolder.FindItem(
@@ -1834,7 +1821,8 @@ namespace OpenSim.Region.Framework.Scenes
1834 1821
1835 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 1822 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1836 1823
1837 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 1824 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1825 item = InventoryService.GetItem(item);
1838 1826
1839 if (item != null) 1827 if (item != null)
1840 { 1828 {
@@ -1984,7 +1972,8 @@ namespace OpenSim.Region.Framework.Scenes
1984 BypassRayCast, bRayEndIsIntersection,true,scale, false); 1972 BypassRayCast, bRayEndIsIntersection,true,scale, false);
1985 1973
1986 // Rez object 1974 // Rez object
1987 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 1975 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1976 item = InventoryService.GetItem(item);
1988 1977
1989 if (item != null) 1978 if (item != null)
1990 { 1979 {
@@ -2135,7 +2124,11 @@ namespace OpenSim.Region.Framework.Scenes
2135 // copy ones will be lost, so avoid it 2124 // copy ones will be lost, so avoid it
2136 // 2125 //
2137 if (!attachment) 2126 if (!attachment)
2138 InventoryService.DeleteItem(item); 2127 {
2128 List<UUID> uuids = new List<UUID>();
2129 uuids.Add(item.ID);
2130 InventoryService.DeleteItems(item.Owner, uuids);
2131 }
2139 } 2132 }
2140 } 2133 }
2141 2134
@@ -2309,7 +2302,8 @@ namespace OpenSim.Region.Framework.Scenes
2309 ScenePresence presence; 2302 ScenePresence presence;
2310 if (TryGetAvatar(remoteClient.AgentId, out presence)) 2303 if (TryGetAvatar(remoteClient.AgentId, out presence))
2311 { 2304 {
2312 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID, remoteClient.AgentId)); 2305 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2306 item = InventoryService.GetItem(item);
2313 2307
2314 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 2308 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2315 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); 2309 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
@@ -2360,7 +2354,8 @@ namespace OpenSim.Region.Framework.Scenes
2360 if (TryGetAvatar(remoteClient.AgentId, out presence)) 2354 if (TryGetAvatar(remoteClient.AgentId, out presence))
2361 { 2355 {
2362 // XXYY!! 2356 // XXYY!!
2363 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 2357 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2358 item = InventoryService.GetItem(item);
2364 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 2359 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2365 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); 2360 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
2366 if (ava != null) 2361 if (ava != null)
@@ -2393,7 +2388,9 @@ namespace OpenSim.Region.Framework.Scenes
2393 } 2388 }
2394 part.ParentGroup.DetachToGround(); 2389 part.ParentGroup.DetachToGround();
2395 2390
2396 InventoryService.DeleteItem(new InventoryItemBase(inventoryID)); 2391 List<UUID> uuids = new List<UUID>();
2392 uuids.Add(inventoryID);
2393 InventoryService.DeleteItems(remoteClient.AgentId, uuids);
2397 remoteClient.SendRemoveInventoryItem(inventoryID); 2394 remoteClient.SendRemoveInventoryItem(inventoryID);
2398 } 2395 }
2399 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); 2396 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 2bf4ea8..d3e414f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -25,6 +25,7 @@
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 System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Threading; 30using System.Threading;
30using OpenMetaverse; 31using OpenMetaverse;
@@ -404,7 +405,8 @@ namespace OpenSim.Region.Framework.Scenes
404 return; 405 return;
405 } 406 }
406 407
407 InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); 408 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
409 item = InventoryService.GetItem(item);
408 410
409 if (item != null) 411 if (item != null)
410 { 412 {
@@ -439,9 +441,24 @@ namespace OpenSim.Region.Framework.Scenes
439 return; 441 return;
440 } 442 }
441 443
444 // We're going to send the reply async, because there may be
445 // an enormous quantity of packets -- basically the entire inventory!
446 // We don't want to block the client thread while all that is happening.
447 SendInventoryDelegate d = SendInventoryAsync;
448 d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d);
449 }
450
451 delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder);
452
453 void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
454 {
442 SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); 455 SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems);
443 } 456 }
444 457
458 void SendInventoryComplete(IAsyncResult iar)
459 {
460 }
461
445 /// <summary> 462 /// <summary>
446 /// Handle the caps inventory descendents fetch. 463 /// Handle the caps inventory descendents fetch.
447 /// 464 ///
@@ -517,27 +534,25 @@ namespace OpenSim.Region.Framework.Scenes
517// m_log.DebugFormat( 534// m_log.DebugFormat(
518// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); 535// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);
519 536
520 CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 537 InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
521 538 folder = InventoryService.GetFolder(folder);
522 if (null == userProfile) 539 if (folder != null)
523 {
524 m_log.ErrorFormat(
525 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
526 remoteClient.Name, remoteClient.AgentId);
527 return;
528 }
529
530 if (!userProfile.UpdateFolder(name, folderID, type, parentID))
531 { 540 {
532 m_log.ErrorFormat( 541 folder.Name = name;
533 "[AGENT INVENTORY]: Failed to update folder for user {0} {1}", 542 folder.Type = (short)type;
534 remoteClient.Name, remoteClient.AgentId); 543 folder.ParentID = parentID;
544 if (!InventoryService.UpdateFolder(folder))
545 {
546 m_log.ErrorFormat(
547 "[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
548 remoteClient.Name, remoteClient.AgentId);
549 }
535 } 550 }
536 } 551 }
537 552
538 public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID) 553 public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
539 { 554 {
540 InventoryFolderBase folder = new InventoryFolderBase(folderID); 555 InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
541 folder = InventoryService.GetFolder(folder); 556 folder = InventoryService.GetFolder(folder);
542 if (folder != null) 557 if (folder != null)
543 { 558 {
@@ -559,15 +574,34 @@ namespace OpenSim.Region.Framework.Scenes
559 /// <param name="remoteClient"></param> 574 /// <param name="remoteClient"></param>
560 /// <param name="folderID"></param> 575 /// <param name="folderID"></param>
561 576
577 delegate void PurgeFolderDelegate(UUID userID, UUID folder);
578
562 public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) 579 public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
563 { 580 {
564 InventoryFolderBase folder = new InventoryFolderBase(folderID); 581 PurgeFolderDelegate d = PurgeFolderAsync;
582 try
583 {
584 d.BeginInvoke(remoteClient.AgentId, folderID, PurgeFolderCompleted, d);
585 }
586 catch (Exception e)
587 {
588 m_log.WarnFormat("[AGENT INVENTORY]: Exception on purge folder for user {0}: {1}", remoteClient.AgentId, e.Message);
589 }
590 }
591
592
593 private void PurgeFolderAsync(UUID userID, UUID folderID)
594 {
595 InventoryFolderBase folder = new InventoryFolderBase(folderID, userID);
565 596
566 if (InventoryService.PurgeFolder(folder)) 597 if (InventoryService.PurgeFolder(folder))
567 m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID); 598 m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID);
568 else 599 else
569 m_log.WarnFormat("[AGENT INVENTORY]: could not purge folder {0}", folderID); 600 m_log.WarnFormat("[AGENT INVENTORY]: could not purge folder {0}", folderID);
570 } 601 }
571 602
603 private void PurgeFolderCompleted(IAsyncResult iar)
604 {
605 }
572 } 606 }
573} 607}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d1f7a4b..6118a70 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2044,9 +2044,14 @@ namespace OpenSim.Region.Framework.Scenes
2044 { 2044 {
2045 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2045 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2046 2046
2047 m_log.DebugFormat( 2047 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2048 "[SCENE]: Adding new {0} agent for {1} in {2}", 2048 /*
2049 ((aCircuit.child == true) ? "child" : "root"), client.Name, RegionInfo.RegionName); 2049 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}",
2050 ((aCircuit.child == true) ? "child" : "root"), client.Name,
2051 RegionInfo.RegionName);
2052
2053 m_log.Debug(logMsg);
2054 */
2050 2055
2051 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2056 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
2052 2057
@@ -2055,7 +2060,7 @@ namespace OpenSim.Region.Framework.Scenes
2055 // HERE!!! Do the initial attachments right here 2060 // HERE!!! Do the initial attachments right here
2056 // first agent upon login is a root agent by design. 2061 // first agent upon login is a root agent by design.
2057 // All other AddNewClient calls find aCircuit.child to be true 2062 // All other AddNewClient calls find aCircuit.child to be true
2058 if (aCircuit.child == false) 2063 if (aCircuit == null || aCircuit.child == false)
2059 { 2064 {
2060 sp.IsChildAgent = false; 2065 sp.IsChildAgent = false;
2061 sp.RezAttachments(); 2066 sp.RezAttachments();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index ce6f3d6..3ee6007 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -225,7 +225,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests
225 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); 225 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered");
226 } 226 }
227 227
228 [Test] 228 // I'm commenting this test because it does not represent
229 // crossings. The Thread.Sleep's in here are not meaningful mocks,
230 // and they sometimes fail in panda.
231 // We need to talk in order to develop a test
232 // that really tests region crossings. There are 3 async components,
233 // but things are synchronous among them. So there should be
234 // 3 threads in here.
235 //[Test]
229 public void T021_TestCrossToNewRegion() 236 public void T021_TestCrossToNewRegion()
230 { 237 {
231 TestHelper.InMethod(); 238 TestHelper.InMethod();
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
index b61959f..3c5e8c9 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
@@ -213,7 +213,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
213 m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword); 213 m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword);
214 string[] excludes = config.GetString("exclude_list", "").Trim().Split(new Char[] { ',' }); 214 string[] excludes = config.GetString("exclude_list", "").Trim().Split(new Char[] { ',' });
215 cs.ExcludeList = new List<string>(excludes.Length); 215 cs.ExcludeList = new List<string>(excludes.Length);
216 foreach(string name in excludes) 216 foreach (string name in excludes)
217 { 217 {
218 cs.ExcludeList.Add(name.Trim().ToLower()); 218 cs.ExcludeList.Add(name.Trim().ToLower());
219 } 219 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 8c9717c..b3bfe07 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -25,26 +25,158 @@
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 System.Collections.Generic;
29using System.Threading;
28using OpenMetaverse; 30using OpenMetaverse;
29using Nini.Config; 31using Nini.Config;
30using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
31using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.CoreModules.Avatar.NPC;
35using OpenSim.Framework;
36using Timer=System.Timers.Timer;
32 37
33namespace OpenSim.Region.OptionalModules.World.NPC 38namespace OpenSim.Region.OptionalModules.World.NPC
34{ 39{
35 public class NPCModule : IRegionModule 40 public class NPCModule : IRegionModule, INPCModule
36 { 41 {
37 // private const bool m_enabled = false; 42 // private const bool m_enabled = false;
38 43
44 private Mutex m_createMutex = new Mutex(false);
45
46 private Timer m_timer = new Timer(500);
47
48 private Dictionary<UUID,NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
49
50 private Dictionary<UUID,AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>();
51
52 // Timer vars.
53 private bool p_inUse = false;
54 private readonly object p_lock = new object();
55 // Private Temporary Variables.
56 private string p_firstname;
57 private string p_lastname;
58 private Vector3 p_position;
59 private Scene p_scene;
60 private UUID p_cloneAppearanceFrom;
61 private UUID p_returnUuid;
62
63 private AvatarAppearance GetAppearance(UUID target, Scene scene)
64 {
65 if (m_appearanceCache.ContainsKey(target))
66 return m_appearanceCache[target];
67
68 AvatarAppearance x = scene.CommsManager.AvatarService.GetUserAppearance(target);
69
70 m_appearanceCache.Add(target, x);
71
72 return x;
73 }
74
75 public UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom)
76 {
77 // Block.
78 m_createMutex.WaitOne();
79
80 // Copy Temp Variables for Timer to pick up.
81 lock (p_lock)
82 {
83 p_firstname = firstname;
84 p_lastname = lastname;
85 p_position = position;
86 p_scene = scene;
87 p_cloneAppearanceFrom = cloneAppearanceFrom;
88 p_inUse = true;
89 p_returnUuid = UUID.Zero;
90 }
91
92 while (p_returnUuid == UUID.Zero)
93 {
94 Thread.Sleep(250);
95 }
96
97 m_createMutex.ReleaseMutex();
98
99 return p_returnUuid;
100 }
101
102 public void Autopilot(UUID agentID, Scene scene, Vector3 pos)
103 {
104 lock (m_avatars)
105 {
106 if (m_avatars.ContainsKey(agentID))
107 {
108 ScenePresence sp;
109 scene.TryGetAvatar(agentID, out sp);
110 sp.DoAutoPilot(0, pos, m_avatars[agentID]);
111 }
112 }
113 }
114
115 public void Say(UUID agentID, Scene scene, string text)
116 {
117 lock (m_avatars)
118 {
119 if (m_avatars.ContainsKey(agentID))
120 {
121 m_avatars[agentID].Say(text);
122 }
123 }
124 }
125
126 public void DeleteNPC(UUID agentID, Scene scene)
127 {
128 lock (m_avatars)
129 {
130 if (m_avatars.ContainsKey(agentID))
131 {
132 scene.RemoveClient(agentID);
133 m_avatars.Remove(agentID);
134 }
135 }
136 }
137
138
39 public void Initialise(Scene scene, IConfigSource source) 139 public void Initialise(Scene scene, IConfigSource source)
40 { 140 {
41 // if (m_enabled) 141 scene.RegisterModuleInterface<INPCModule>(this);
42 // { 142
43 // NPCAvatar testAvatar = new NPCAvatar("Jack", "NPC", new Vector3(128, 128, 40), scene); 143 m_timer.Elapsed += m_timer_Elapsed;
44 // NPCAvatar testAvatar2 = new NPCAvatar("Jill", "NPC", new Vector3(136, 128, 40), scene); 144 m_timer.Start();
45 // scene.AddNewClient(testAvatar); 145 }
46 // scene.AddNewClient(testAvatar2); 146
47 // } 147 void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
148 {
149 lock (p_lock)
150 {
151 if (p_inUse)
152 {
153 p_inUse = false;
154
155 NPCAvatar npcAvatar = new NPCAvatar(p_firstname, p_lastname, p_position, p_scene);
156 npcAvatar.CircuitCode = (uint) Util.RandomClass.Next(0, int.MaxValue);
157
158 p_scene.ClientManager.Add(npcAvatar.CircuitCode, npcAvatar);
159 p_scene.AddNewClient(npcAvatar);
160
161 ScenePresence sp;
162 if (p_scene.TryGetAvatar(npcAvatar.AgentId, out sp))
163 {
164 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);
165
166 List<byte> wearbyte = new List<byte>();
167 for (int i = 0; i < x.VisualParams.Length; i++)
168 {
169 wearbyte.Add(x.VisualParams[i]);
170 }
171
172 sp.SetAppearance(x.Texture.GetBytes(), wearbyte);
173 }
174
175 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
176
177 p_returnUuid = npcAvatar.AgentId;
178 }
179 }
48 } 180 }
49 181
50 public void PostInitialise() 182 public void PostInitialise()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2dbbf70..16dd834 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1978,6 +1978,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1978 return new LSL_Rotation(q.X, q.Y, q.Z, q.W); 1978 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
1979 } 1979 }
1980 1980
1981 private LSL_Rotation GetPartRot(SceneObjectPart part)
1982 {
1983 Quaternion q;
1984 if (part.LinkNum == 0 || part.LinkNum == 1) // unlinked or root prim
1985 {
1986 if (part.ParentGroup.RootPart.AttachmentPoint != 0)
1987 {
1988 ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar);
1989 if (avatar != null)
1990 {
1991 if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0)
1992 q = avatar.CameraRotation; // Mouselook
1993 else
1994 q = avatar.Rotation; // Currently infrequently updated so may be inaccurate
1995 }
1996 else
1997 q = part.ParentGroup.GroupRotation; // Likely never get here but just in case
1998 }
1999 else
2000 q = part.ParentGroup.GroupRotation; // just the group rotation
2001 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
2002 }
2003 q = part.GetWorldRotation();
2004 return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
2005 }
2006
1981 public LSL_Rotation llGetLocalRot() 2007 public LSL_Rotation llGetLocalRot()
1982 { 2008 {
1983 m_host.AddScriptLPS(1); 2009 m_host.AddScriptLPS(1);
@@ -7299,7 +7325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7299 break; 7325 break;
7300 7326
7301 case (int)ScriptBaseClass.PRIM_ROTATION: 7327 case (int)ScriptBaseClass.PRIM_ROTATION:
7302 res.Add(llGetRot()); 7328 res.Add(GetPartRot(part));
7303 break; 7329 break;
7304 7330
7305 case (int)ScriptBaseClass.PRIM_TYPE: 7331 case (int)ScriptBaseClass.PRIM_TYPE:
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 6e3a3ab..b1c357c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -31,12 +31,14 @@ using System.Collections.Generic;
31using System.Runtime.Remoting.Lifetime; 31using System.Runtime.Remoting.Lifetime;
32using System.Text; 32using System.Text;
33using System.Net; 33using System.Net;
34using System.Threading;
34using OpenMetaverse; 35using OpenMetaverse;
35using Nini.Config; 36using Nini.Config;
36using OpenSim; 37using OpenSim;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
41using OpenSim.Region.CoreModules.Avatar.NPC;
40using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Scenes.Hypergrid; 44using OpenSim.Region.Framework.Scenes.Hypergrid;
@@ -831,6 +833,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
831 return drawList; 833 return drawList;
832 } 834 }
833 835
836 public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
837 {
838 CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon");
839
840 m_host.AddScriptLPS(1);
841
842 if (x.Length != y.Length || x.Length < 3)
843 {
844 return "";
845 }
846 drawList += "FillPolygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
847 for (int i = 1; i < x.Length; i++)
848 {
849 drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
850 }
851 drawList += "; ";
852 return drawList;
853 }
854
834 public string osSetFontSize(string drawList, int fontSize) 855 public string osSetFontSize(string drawList, int fontSize)
835 { 856 {
836 CheckThreatLevel(ThreatLevel.None, "osSetFontSize"); 857 CheckThreatLevel(ThreatLevel.None, "osSetFontSize");
@@ -858,6 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
858 return drawList; 879 return drawList;
859 } 880 }
860 881
882 public string osSetPenCap(string drawList, string direction, string type)
883 {
884 CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
885
886 m_host.AddScriptLPS(1);
887 drawList += "PenCap " + direction + "," + type + "; ";
888 return drawList;
889 }
890
861 public string osDrawImage(string drawList, int width, int height, string imageUrl) 891 public string osDrawImage(string drawList, int width, int height, string imageUrl)
862 { 892 {
863 CheckThreatLevel(ThreatLevel.None, "osDrawImage"); 893 CheckThreatLevel(ThreatLevel.None, "osDrawImage");
@@ -1762,5 +1792,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1762 return retVal; 1792 return retVal;
1763 } 1793 }
1764 1794
1795 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
1796 {
1797 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
1798 //QueueUserWorkItem
1799
1800 INPCModule module = World.RequestModuleInterface<INPCModule>();
1801 if (module != null)
1802 {
1803 UUID x = module.CreateNPC(firstname,
1804 lastname,
1805 new Vector3((float) position.x, (float) position.y, (float) position.z),
1806 World,
1807 new UUID(cloneFrom));
1808
1809 return new LSL_Key(x.ToString());
1810 }
1811 return new LSL_Key(UUID.Zero.ToString());
1812 }
1813
1814 public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
1815 {
1816 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
1817
1818 INPCModule module = World.RequestModuleInterface<INPCModule>();
1819 if (module != null)
1820 {
1821 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
1822 module.Autopilot(new UUID(npc.m_string), World, pos);
1823 }
1824 }
1825
1826 public void osNpcSay(LSL_Key npc, string message)
1827 {
1828 CheckThreatLevel(ThreatLevel.High, "osNpcSay");
1829
1830 INPCModule module = World.RequestModuleInterface<INPCModule>();
1831 if (module != null)
1832 {
1833 module.Say(new UUID(npc.m_string), World, message);
1834 }
1835 }
1836
1837 public void osNpcRemove(LSL_Key npc)
1838 {
1839 CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
1840
1841 INPCModule module = World.RequestModuleInterface<INPCModule>();
1842 if (module != null)
1843 {
1844 module.DeleteNPC(new UUID(npc.m_string), World);
1845 }
1846 }
1765 } 1847 }
1766} 1848}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 0be29f2..2365bee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -97,9 +97,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
97 string osDrawEllipse(string drawList, int width, int height); 97 string osDrawEllipse(string drawList, int width, int height);
98 string osDrawRectangle(string drawList, int width, int height); 98 string osDrawRectangle(string drawList, int width, int height);
99 string osDrawFilledRectangle(string drawList, int width, int height); 99 string osDrawFilledRectangle(string drawList, int width, int height);
100 string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y);
100 string osSetFontSize(string drawList, int fontSize); 101 string osSetFontSize(string drawList, int fontSize);
101 string osSetPenSize(string drawList, int penSize); 102 string osSetPenSize(string drawList, int penSize);
102 string osSetPenColour(string drawList, string colour); 103 string osSetPenColour(string drawList, string colour);
104 string osSetPenCap(string drawList, string direction, string type);
103 string osDrawImage(string drawList, int width, int height, string imageUrl); 105 string osDrawImage(string drawList, int width, int height, string imageUrl);
104 vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); 106 vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize);
105 void osSetStateEvents(int events); 107 void osSetStateEvents(int events);
@@ -149,5 +151,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
149 151
150 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); 152 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
151 153
154
155 key osNpcCreate(string user, string name, vector position, key cloneFrom);
156 void osNpcMoveTo(key npc, vector position);
157 void osNpcSay(key npc, string message);
158 void osNpcRemove(key npc);
159
152 } 160 }
153} 161}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index abdba05..f877acb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -267,6 +267,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
267 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height); 267 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
268 } 268 }
269 269
270 public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
271 {
272 return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y);
273 }
274
270 public string osSetFontSize(string drawList, int fontSize) 275 public string osSetFontSize(string drawList, int fontSize)
271 { 276 {
272 return m_OSSL_Functions.osSetFontSize(drawList, fontSize); 277 return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
@@ -277,6 +282,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
277 return m_OSSL_Functions.osSetPenSize(drawList, penSize); 282 return m_OSSL_Functions.osSetPenSize(drawList, penSize);
278 } 283 }
279 284
285 public string osSetPenCap(string drawList, string direction, string type)
286 {
287 return m_OSSL_Functions.osSetPenCap(drawList, direction, type);
288 }
289
280 public string osSetPenColour(string drawList, string colour) 290 public string osSetPenColour(string drawList, string colour)
281 { 291 {
282 return m_OSSL_Functions.osSetPenColour(drawList, colour); 292 return m_OSSL_Functions.osSetPenColour(drawList, colour);
@@ -393,6 +403,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
393 return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); 403 return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules);
394 } 404 }
395 405
406 public key osNpcCreate(string user, string name, vector position, key cloneFrom)
407 {
408 return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom);
409 }
410
411 public void osNpcMoveTo(key npc, vector position)
412 {
413 m_OSSL_Functions.osNpcMoveTo(npc, position);
414 }
415
416 public void osNpcSay(key npc, string message)
417 {
418 m_OSSL_Functions.osNpcSay(npc, message);
419 }
420
421 public void osNpcRemove(key npc)
422 {
423 m_OSSL_Functions.osNpcRemove(npc);
424 }
396 425
397 public OSSLPrim Prim; 426 public OSSLPrim Prim;
398 427
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index bdacf8b..2842f6b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -439,6 +439,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
439 439
440 set {m_data = value; } 440 set {m_data = value; }
441 } 441 }
442 // Function to obtain LSL type from an index. This is needed
443 // because LSL lists allow for multiple types, and safely
444 // iterating in them requires a type check.
445 public Type GetLSLListItemType(int itemIndex)
446 {
447 return m_data[itemIndex].GetType();
448 }
442 449
443 // Member functions to obtain item as specific types. 450 // Member functions to obtain item as specific types.
444 // For cases where implicit conversions would apply if items 451 // For cases where implicit conversions would apply if items
@@ -465,6 +472,10 @@ namespace OpenSim.Region.ScriptEngine.Shared
465 { 472 {
466 return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); 473 return new LSL_Types.LSLFloat((Double)m_data[itemIndex]);
467 } 474 }
475 else if (m_data[itemIndex] is LSL_Types.LSLString)
476 {
477 return new LSL_Types.LSLFloat(m_data[itemIndex].ToString());
478 }
468 else 479 else
469 { 480 {
470 return (LSL_Types.LSLFloat)m_data[itemIndex]; 481 return (LSL_Types.LSLFloat)m_data[itemIndex];
@@ -481,20 +492,32 @@ namespace OpenSim.Region.ScriptEngine.Shared
481 { 492 {
482 return new LSL_Types.LSLString((string)m_data[itemIndex]); 493 return new LSL_Types.LSLString((string)m_data[itemIndex]);
483 } 494 }
495 else if (m_data[itemIndex] is LSL_Types.LSLFloat)
496 {
497 return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]);
498 }
499 else if (m_data[itemIndex] is LSL_Types.LSLInteger)
500 {
501 return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]);
502 }
484 else 503 else
485 { 504 {
486 return (LSL_Types.LSLString)m_data[itemIndex]; 505 return (LSL_Types.LSLString)m_data[itemIndex];
487 } 506 }
488 } 507 }
489 508
490 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) 509 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
491 { 510 {
492 if (m_data[itemIndex] is LSL_Types.LSLInteger) 511 if (m_data[itemIndex] is LSL_Types.LSLInteger)
493 return (LSL_Types.LSLInteger)m_data[itemIndex]; 512 return (LSL_Types.LSLInteger)m_data[itemIndex];
494 else if (m_data[itemIndex] is Int32) 513 if (m_data[itemIndex] is LSL_Types.LSLFloat)
495 return new LSLInteger((int)m_data[itemIndex]); 514 return new LSLInteger((int)m_data[itemIndex]);
496 else 515 else if (m_data[itemIndex] is Int32)
497 throw new InvalidCastException(); 516 return new LSLInteger((int)m_data[itemIndex]);
517 else if (m_data[itemIndex] is LSL_Types.LSLString)
518 return new LSLInteger((string)m_data[itemIndex]);
519 else
520 throw new InvalidCastException();
498 } 521 }
499 522
500 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 523 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
@@ -1331,6 +1354,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
1331 m_string=s; 1354 m_string=s;
1332 } 1355 }
1333 1356
1357 public LSLString(LSLInteger i)
1358 {
1359 string s = String.Format("{0}", i);
1360 m_string = s;
1361 }
1362
1334 #endregion 1363 #endregion
1335 1364
1336 #region Operators 1365 #region Operators
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 619c2d1..1d9eb0d 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -65,6 +65,10 @@ namespace OpenSim.Server.Base
65 // 65 //
66 private bool m_Running = true; 66 private bool m_Running = true;
67 67
68 // PID file
69 //
70 private string m_pidFile = String.Empty;
71
68 // Handle all the automagical stuff 72 // Handle all the automagical stuff
69 // 73 //
70 public ServicesServerBase(string prompt, string[] args) 74 public ServicesServerBase(string prompt, string[] args)
@@ -211,6 +215,11 @@ namespace OpenSim.Server.Base
211 } 215 }
212 } 216 }
213 217
218 if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty)
219 {
220 CreatePIDFile(startupConfig.GetString("PIDFile"));
221 }
222
214 // Register the quit command 223 // Register the quit command
215 // 224 //
216 MainConsole.Instance.Commands.AddCommand("base", false, "quit", 225 MainConsole.Instance.Commands.AddCommand("base", false, "quit",
@@ -230,6 +239,8 @@ namespace OpenSim.Server.Base
230 MainConsole.Instance.Prompt(); 239 MainConsole.Instance.Prompt();
231 } 240 }
232 241
242 if (m_pidFile != String.Empty)
243 File.Delete(m_pidFile);
233 return 0; 244 return 0;
234 } 245 }
235 246
@@ -246,5 +257,22 @@ namespace OpenSim.Server.Base
246 protected virtual void Initialise() 257 protected virtual void Initialise()
247 { 258 {
248 } 259 }
260
261 protected void CreatePIDFile(string path)
262 {
263 try
264 {
265 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
266 FileStream fs = File.Create(path);
267 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
268 Byte[] buf = enc.GetBytes(pidstring);
269 fs.Write(buf, 0, buf.Length);
270 fs.Close();
271 m_pidFile = path;
272 }
273 catch (Exception)
274 {
275 }
276 }
249 } 277 }
250} 278}
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
index 30b3cae..998b322 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
@@ -105,8 +105,12 @@ namespace OpenSim.Server.Handlers.Inventory
105 "POST", "/PurgeFolder/", m_InventoryService.PurgeFolder, CheckAuthSession)); 105 "POST", "/PurgeFolder/", m_InventoryService.PurgeFolder, CheckAuthSession));
106 106
107 m_httpServer.AddStreamHandler( 107 m_httpServer.AddStreamHandler(
108 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 108 new RestDeserialiseSecureHandler<List<Guid>, bool>(
109 "POST", "/DeleteItem/", m_InventoryService.DeleteItem, CheckAuthSession)); 109 "POST", "/DeleteFolders/", DeleteFolders, CheckAuthSession));
110
111 m_httpServer.AddStreamHandler(
112 new RestDeserialiseSecureHandler<List<Guid>, bool>(
113 "POST", "/DeleteItem/", DeleteItems, CheckAuthSession));
110 114
111 m_httpServer.AddStreamHandler( 115 m_httpServer.AddStreamHandler(
112 new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 116 new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
@@ -125,8 +129,8 @@ namespace OpenSim.Server.Handlers.Inventory
125 "POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession)); 129 "POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession));
126 130
127 m_httpServer.AddStreamHandler( 131 m_httpServer.AddStreamHandler(
128 new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>( 132 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
129 "POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckTrustSource)); 133 "POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckAuthSession));
130 134
131 m_httpServer.AddStreamHandler( 135 m_httpServer.AddStreamHandler(
132 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 136 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
@@ -137,9 +141,16 @@ namespace OpenSim.Server.Handlers.Inventory
137 "POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource)); 141 "POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource));
138 142
139 m_httpServer.AddStreamHandler( 143 m_httpServer.AddStreamHandler(
140 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>( 144 new RestDeserialiseSecureHandler<Guid, List<InventoryItemBase>>(
141 "POST", "/GetItems/", GetFolderItems, CheckTrustSource)); 145 "POST", "/GetItems/", GetFolderItems, CheckAuthSession));
142 146
147 m_httpServer.AddStreamHandler(
148 new RestDeserialiseSecureHandler<List<InventoryItemBase>, bool>(
149 "POST", "/MoveItems/", MoveItems, CheckAuthSession));
150
151 m_httpServer.AddStreamHandler(new InventoryServerMoveItemsHandler(m_InventoryService));
152
153
143 // for persistent active gestures 154 // for persistent active gestures
144 m_httpServer.AddStreamHandler( 155 m_httpServer.AddStreamHandler(
145 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> 156 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
@@ -247,6 +258,33 @@ namespace OpenSim.Server.Handlers.Inventory
247 return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID); 258 return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID);
248 } 259 }
249 260
261 public bool DeleteFolders(List<Guid> items)
262 {
263 List<UUID> uuids = new List<UUID>();
264 foreach (Guid g in items)
265 uuids.Add(new UUID(g));
266 // oops we lost the user info here. Bad bad handlers
267 return m_InventoryService.DeleteFolders(UUID.Zero, uuids);
268 }
269
270 public bool DeleteItems(List<Guid> items)
271 {
272 List<UUID> uuids = new List<UUID>();
273 foreach (Guid g in items)
274 uuids.Add(new UUID(g));
275 // oops we lost the user info here. Bad bad handlers
276 return m_InventoryService.DeleteItems(UUID.Zero, uuids);
277 }
278
279 public bool MoveItems(List<InventoryItemBase> items)
280 {
281 // oops we lost the user info here. Bad bad handlers
282 // let's peek at one item
283 UUID ownerID = UUID.Zero;
284 if (items.Count > 0)
285 ownerID = items[0].Owner;
286 return m_InventoryService.MoveItems(ownerID, items);
287 }
250 #endregion 288 #endregion
251 289
252 /// <summary> 290 /// <summary>
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
index 026b3c8..850bf14 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
@@ -1,4 +1,4 @@
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 *
@@ -25,71 +25,57 @@
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 Nini.Config;
29using log4net;
28using System; 30using System;
31using System.Collections.Generic;
29using System.Reflection; 32using System.Reflection;
30using OpenMetaverse; 33using System.IO;
34using System.Net;
35using System.Text;
36using System.Text.RegularExpressions;
37using System.Xml;
38using System.Xml.Serialization;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
31using OpenSim.Framework; 41using OpenSim.Framework;
32using log4net; 42using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse;
33 44
34namespace OpenSim.Grid.AssetInventoryServer.Plugins 45namespace OpenSim.Server.Handlers.Inventory
35{ 46{
36 public class NullAuthenticationPlugin : IAuthenticationProvider 47 public class InventoryServerMoveItemsHandler : BaseStreamHandler
37 { 48 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39 //private AssetInventoryServer m_server;
40
41 public NullAuthenticationPlugin()
42 {
43 }
44
45 #region IPlugin implementation
46
47 public void Initialise(AssetInventoryServer server)
48 {
49 //m_server = server;
50
51 m_log.Info("[NULLAUTHENTICATION]: Null Authentication loaded.");
52 }
53 50
54 /// <summary> 51 private IInventoryService m_InventoryService;
55 /// <para>Initialises asset interface</para>
56 /// </summary>
57 public void Initialise()
58 {
59 m_log.InfoFormat("[NULLAUTHENTICATION]: {0} cannot be default-initialized!", Name);
60 throw new PluginNotInitialisedException(Name);
61 }
62
63 public void Dispose()
64 {
65 }
66 52
67 public string Version 53 public InventoryServerMoveItemsHandler(IInventoryService service) :
54 base("PUT", "/inventory")
68 { 55 {
69 // TODO: this should be something meaningful and not hardcoded? 56 m_InventoryService = service;
70 get { return "0.1"; }
71 } 57 }
72 58
73 public string Name 59 public override byte[] Handle(string path, Stream request,
60 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
74 { 61 {
75 get { return "NullAuthentication"; } 62 XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>));
76 } 63 List<InventoryItemBase> items = (List<InventoryItemBase>)xs.Deserialize(request);
77 64
78 #endregion IPlugin implementation 65 bool result = false;
66 string[] p = SplitParams(path);
79 67
80 public void AddIdentifier(UUID authToken, Uri identifier) 68 if (p.Length > 0)
81 { 69 {
82 } 70 UUID ownerID = UUID.Zero;
83 71 UUID.TryParse(p[0], out ownerID);
84 public bool RemoveIdentifier(UUID authToken) 72 result = m_InventoryService.MoveItems(ownerID, items);
85 { 73 }
86 return true; 74 else
87 } 75 m_log.WarnFormat("[MOVEITEMS HANDLER]: ownerID not provided in request. Unable to serve.");
88 76
89 public bool TryGetIdentifier(UUID authToken, out Uri identifier) 77 xs = new XmlSerializer(typeof(bool));
90 { 78 return ServerUtils.SerializeResult(xs, result);
91 identifier = null;
92 return true;
93 } 79 }
94 } 80 }
95} 81}
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index fe663eb..88a905c 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Services.AssetService
83 if (!UUID.TryParse(id, out assetID)) 83 if (!UUID.TryParse(id, out assetID))
84 return null; 84 return null;
85 85
86 return m_Database.FetchAsset(assetID); 86 return m_Database.GetAsset(assetID);
87 } 87 }
88 88
89 public AssetMetadata GetMetadata(string id) 89 public AssetMetadata GetMetadata(string id)
@@ -93,7 +93,7 @@ namespace OpenSim.Services.AssetService
93 if (!UUID.TryParse(id, out assetID)) 93 if (!UUID.TryParse(id, out assetID))
94 return null; 94 return null;
95 95
96 AssetBase asset = m_Database.FetchAsset(assetID); 96 AssetBase asset = m_Database.GetAsset(assetID);
97 return asset.Metadata; 97 return asset.Metadata;
98 } 98 }
99 99
@@ -104,7 +104,7 @@ namespace OpenSim.Services.AssetService
104 if (!UUID.TryParse(id, out assetID)) 104 if (!UUID.TryParse(id, out assetID))
105 return null; 105 return null;
106 106
107 AssetBase asset = m_Database.FetchAsset(assetID); 107 AssetBase asset = m_Database.GetAsset(assetID);
108 return asset.Data; 108 return asset.Data;
109 } 109 }
110 110
@@ -117,7 +117,7 @@ namespace OpenSim.Services.AssetService
117 if (!UUID.TryParse(id, out assetID)) 117 if (!UUID.TryParse(id, out assetID))
118 return false; 118 return false;
119 119
120 AssetBase asset = m_Database.FetchAsset(assetID); 120 AssetBase asset = m_Database.GetAsset(assetID);
121 121
122 //m_log.DebugFormat("[AssetService]: Got asset {0}", asset); 122 //m_log.DebugFormat("[AssetService]: Got asset {0}", asset);
123 123
@@ -129,7 +129,7 @@ namespace OpenSim.Services.AssetService
129 public string Store(AssetBase asset) 129 public string Store(AssetBase asset)
130 { 130 {
131 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); 131 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
132 m_Database.CreateAsset(asset); 132 m_Database.StoreAsset(asset);
133 133
134 return asset.ID; 134 return asset.ID;
135 } 135 }
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
index 94b4ad9..1004fb9 100644
--- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
@@ -201,6 +201,19 @@ namespace OpenSim.Services.Connectors.Inventory
201 return false; 201 return false;
202 } 202 }
203 203
204 public bool DeleteFolders(string id, List<UUID> folders, UUID sessionID)
205 {
206 string url = string.Empty;
207 string userID = string.Empty;
208
209 if (StringToUrlAndUserID(id, out url, out userID))
210 {
211 ISessionAuthInventoryService connector = GetConnector(url);
212 return connector.DeleteFolders(userID, folders, sessionID);
213 }
214 return false;
215 }
216
204 public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID) 217 public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID)
205 { 218 {
206 string url = string.Empty; 219 string url = string.Empty;
@@ -214,6 +227,19 @@ namespace OpenSim.Services.Connectors.Inventory
214 return false; 227 return false;
215 } 228 }
216 229
230 public List<InventoryItemBase> GetFolderItems(string id, UUID folderID, UUID sessionID)
231 {
232 string url = string.Empty;
233 string userID = string.Empty;
234
235 if (StringToUrlAndUserID(id, out url, out userID))
236 {
237 ISessionAuthInventoryService connector = GetConnector(url);
238 return connector.GetFolderItems(userID, folderID, sessionID);
239 }
240 return new List<InventoryItemBase>();
241 }
242
217 public bool AddItem(string id, InventoryItemBase item, UUID sessionID) 243 public bool AddItem(string id, InventoryItemBase item, UUID sessionID)
218 { 244 {
219 string url = string.Empty; 245 string url = string.Empty;
@@ -240,7 +266,7 @@ namespace OpenSim.Services.Connectors.Inventory
240 return false; 266 return false;
241 } 267 }
242 268
243 public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) 269 public bool MoveItems(string id, List<InventoryItemBase> items, UUID sessionID)
244 { 270 {
245 string url = string.Empty; 271 string url = string.Empty;
246 string userID = string.Empty; 272 string userID = string.Empty;
@@ -248,7 +274,20 @@ namespace OpenSim.Services.Connectors.Inventory
248 if (StringToUrlAndUserID(id, out url, out userID)) 274 if (StringToUrlAndUserID(id, out url, out userID))
249 { 275 {
250 ISessionAuthInventoryService connector = GetConnector(url); 276 ISessionAuthInventoryService connector = GetConnector(url);
251 return connector.UpdateItem(userID, item, sessionID); 277 return connector.MoveItems(userID, items, sessionID);
278 }
279 return false;
280 }
281
282 public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID)
283 {
284 string url = string.Empty;
285 string userID = string.Empty;
286
287 if (StringToUrlAndUserID(id, out url, out userID))
288 {
289 ISessionAuthInventoryService connector = GetConnector(url);
290 return connector.DeleteItems(userID, itemIDs, sessionID);
252 } 291 }
253 return false; 292 return false;
254 } 293 }
diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
index f50bcf5..da8c7e2 100644
--- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
+++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
@@ -89,6 +89,11 @@ namespace OpenSim.Services.Connectors
89 bool MoveFolder(string userID, InventoryFolderBase folder, UUID session_id); 89 bool MoveFolder(string userID, InventoryFolderBase folder, UUID session_id);
90 90
91 /// <summary> 91 /// <summary>
92 /// Delete a list of inventory folders (from trash)
93 /// </summary>
94 bool DeleteFolders(string userID, List<UUID> folders, UUID session_id);
95
96 /// <summary>
92 /// Purge an inventory folder of all its items and subfolders. 97 /// Purge an inventory folder of all its items and subfolders.
93 /// </summary> 98 /// </summary>
94 /// <param name="folder"></param> 99 /// <param name="folder"></param>
@@ -96,6 +101,13 @@ namespace OpenSim.Services.Connectors
96 bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id); 101 bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id);
97 102
98 /// <summary> 103 /// <summary>
104 /// Get items from a folder.
105 /// </summary>
106 /// <param name="folder"></param>
107 /// <returns>true if the folder was successfully purged</returns>
108 List<InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID session_id);
109
110 /// <summary>
99 /// Add a new item to the user's inventory 111 /// Add a new item to the user's inventory
100 /// </summary> 112 /// </summary>
101 /// <param name="item"></param> 113 /// <param name="item"></param>
@@ -109,12 +121,14 @@ namespace OpenSim.Services.Connectors
109 /// <returns>true if the item was successfully updated</returns> 121 /// <returns>true if the item was successfully updated</returns>
110 bool UpdateItem(string userID, InventoryItemBase item, UUID session_id); 122 bool UpdateItem(string userID, InventoryItemBase item, UUID session_id);
111 123
124 bool MoveItems(string userID, List<InventoryItemBase> items, UUID session_id);
125
112 /// <summary> 126 /// <summary>
113 /// Delete an item from the user's inventory 127 /// Delete an item from the user's inventory
114 /// </summary> 128 /// </summary>
115 /// <param name="item"></param> 129 /// <param name="item"></param>
116 /// <returns>true if the item was successfully deleted</returns> 130 /// <returns>true if the item was successfully deleted</returns>
117 bool DeleteItem(string userID, InventoryItemBase item, UUID session_id); 131 bool DeleteItems(string userID, List<UUID> itemIDs, UUID session_id);
118 132
119 InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id); 133 InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id);
120 134
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
index 5d94eac..a2261ba 100644
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
@@ -178,30 +178,36 @@ namespace OpenSim.Services.Connectors
178 catch (Exception e) 178 catch (Exception e)
179 { 179 {
180 // Maybe we're talking to an old inventory server. Try this other thing. 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.", 181 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1} (old sever?). Trying GetInventory.",
182 e.Source, e.Message); 182 e.Source, e.Message);
183 183
184 try 184 try
185 { 185 {
186 folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( 186 InventoryCollection inventory = SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
187 "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); 187 "POST", m_ServerURI + "/GetInventory/", new Guid(userID), sessionID.ToString(), userID.ToString());
188 folders = inventory.Folders;
188 } 189 }
189 catch (Exception ex) 190 catch (Exception ex)
190 { 191 {
191 m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.", 192 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetInventory operation also failed, {0} {1}. Giving up.",
192 e.Source, ex.Message); 193 e.Source, ex.Message);
193 } 194 }
194 195
195 if ((folders != null) && (folders.Count > 0)) 196 if ((folders != null) && (folders.Count > 0))
196 { 197 {
197 dFolders[AssetType.Folder] = folders[0]; // Root folder is the first one 198 m_log.DebugFormat("[INVENTORY CONNECTOR]: Received entire inventory ({0} folders) for user {1}",
198 folders.RemoveAt(0); 199 folders.Count, userID);
199 foreach (InventoryFolderBase f in folders) 200 foreach (InventoryFolderBase f in folders)
200 { 201 {
201 if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown)) 202 if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown))
202 dFolders[(AssetType)f.Type] = f; 203 dFolders[(AssetType)f.Type] = f;
203 } 204 }
204 205
206 UUID rootFolderID = dFolders[AssetType.Animation].ParentID;
207 InventoryFolderBase rootFolder = new InventoryFolderBase(rootFolderID, new UUID(userID));
208 rootFolder = QueryFolder(userID, rootFolder, sessionID);
209 dFolders[AssetType.Folder] = rootFolder;
210 m_log.DebugFormat("[INVENTORY CONNECTOR]: {0} system folders for user {1}", dFolders.Count, userID);
205 return dFolders; 211 return dFolders;
206 } 212 }
207 } 213 }
@@ -223,51 +229,56 @@ namespace OpenSim.Services.Connectors
223 return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject( 229 return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
224 "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString()); 230 "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString());
225 } 231 }
232 catch (TimeoutException e)
233 {
234 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation to {0} timed out {0} {1}.", m_ServerURI,
235 e.Source, e.Message);
236 }
226 catch (Exception e) 237 catch (Exception e)
227 { 238 {
228 // Maybe we're talking to an old inventory server. Try this other thing. 239 // 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.", 240 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1} (old server?). Trying GetInventory.",
230 e.Source, e.Message); 241 e.Source, e.Message);
231 242
243 InventoryCollection inventory;
232 List<InventoryFolderBase> folders = null; 244 List<InventoryFolderBase> folders = null;
233 try 245 try
234 { 246 {
235 folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( 247 inventory = SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
236 "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); 248 "POST", m_ServerURI + "/GetInventory/", new Guid(userID), sessionID.ToString(), userID.ToString());
249 if (inventory != null)
250 folders = inventory.Folders;
237 } 251 }
238 catch (Exception ex) 252 catch (Exception ex)
239 { 253 {
240 m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.", 254 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetInventory operation also failed, {0} {1}. Giving up.",
241 e.Source, ex.Message); 255 e.Source, ex.Message);
256 return new InventoryCollection();
242 } 257 }
243 258
244 if ((folders != null) && (folders.Count > 0)) 259 if ((folders != null) && (folders.Count > 0))
245 { 260 {
246 folders = folders.FindAll(delegate (InventoryFolderBase f) { return f.ParentID == folderID ; }); 261 m_log.DebugFormat("[INVENTORY CONNECTOR]: Received entire inventory ({0} folders) for user {1}",
247 262 folders.Count, userID);
248 try
249 {
250 List<InventoryItemBase> items = SynchronousRestSessionObjectPoster<Guid, List<InventoryItemBase>>.BeginPostObject(
251 "POST", m_ServerURI + "/GetItems/", folderID.Guid, sessionID.ToString(), userID.ToString());
252 263
253 if (items != null) 264 folders = folders.FindAll(delegate(InventoryFolderBase f) { return f.ParentID == folderID; });
254 { 265 List<InventoryItemBase> items = inventory.Items;
255 InventoryCollection result = new InventoryCollection(); 266 if (items != null)
256 result.Folders = folders;
257 result.Items = items;
258 result.UserID = new UUID(userID);
259 return result;
260 }
261 }
262 catch (Exception ex)
263 { 267 {
264 m_log.ErrorFormat("[INVENTORY CONNECTOR]: QueryFolder and GetItems operation failed, {0} {1}. Give up.", 268 items = items.FindAll(delegate(InventoryItemBase i) { return i.Folder == folderID; });
265 e.Source, ex.Message);
266 } 269 }
270
271 inventory.Items = items;
272 inventory.Folders = folders;
273 return inventory;
267 } 274 }
268 } 275 }
269 276
270 return null; 277 InventoryCollection nullCollection = new InventoryCollection();
278 nullCollection.Folders = new List<InventoryFolderBase>();
279 nullCollection.Items = new List<InventoryItemBase>();
280 nullCollection.UserID = new UUID(userID);
281 return nullCollection;
271 } 282 }
272 283
273 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID) 284 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID)
@@ -302,6 +313,25 @@ namespace OpenSim.Services.Connectors
302 return false; 313 return false;
303 } 314 }
304 315
316 public bool DeleteFolders(string userID, List<UUID> folderIDs, UUID sessionID)
317 {
318 try
319 {
320 List<Guid> guids = new List<Guid>();
321 foreach (UUID u in folderIDs)
322 guids.Add(u.Guid);
323 return SynchronousRestSessionObjectPoster<List<Guid>, bool>.BeginPostObject(
324 "POST", m_ServerURI + "/DeleteFolders/", guids, sessionID.ToString(), userID);
325 }
326 catch (Exception e)
327 {
328 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Delete inventory folders operation failed, {0} {1}",
329 e.Source, e.Message);
330 }
331
332 return false;
333 }
334
305 public bool MoveFolder(string userID, InventoryFolderBase folder, UUID sessionID) 335 public bool MoveFolder(string userID, InventoryFolderBase folder, UUID sessionID)
306 { 336 {
307 try 337 try
@@ -334,6 +364,23 @@ namespace OpenSim.Services.Connectors
334 return false; 364 return false;
335 } 365 }
336 366
367 public List<InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID sessionID)
368 {
369 try
370 {
371 InventoryFolderBase folder = new InventoryFolderBase(folderID, new UUID(userID));
372 return SynchronousRestSessionObjectPoster<InventoryFolderBase, List<InventoryItemBase>>.BeginPostObject(
373 "POST", m_ServerURI + "/GetItems/", folder, sessionID.ToString(), userID);
374 }
375 catch (Exception e)
376 {
377 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed, {0} {1}",
378 e.Source, e.Message);
379 }
380
381 return null;
382 }
383
337 public bool AddItem(string userID, InventoryItemBase item, UUID sessionID) 384 public bool AddItem(string userID, InventoryItemBase item, UUID sessionID)
338 { 385 {
339 try 386 try
@@ -366,12 +413,72 @@ namespace OpenSim.Services.Connectors
366 return false; 413 return false;
367 } 414 }
368 415
369 public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID) 416 /**
417 * MoveItems Async group
418 */
419
420 delegate void MoveItemsDelegate(string userID, List<InventoryItemBase> items, UUID sessionID);
421
422 private void MoveItemsAsync(string userID, List<InventoryItemBase> items, UUID sessionID)
370 { 423 {
424 if (items == null)
425 {
426 m_log.WarnFormat("[INVENTORY CONNECTOR]: request to move items got a null list.");
427 return;
428 }
429
371 try 430 try
372 { 431 {
373 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject( 432 //SynchronousRestSessionObjectPoster<List<InventoryItemBase>, bool>.BeginPostObject(
374 "POST", m_ServerURI + "/DeleteItem/", item, sessionID.ToString(), item.Owner.ToString()); 433 // "POST", m_ServerURI + "/MoveItems/", items, sessionID.ToString(), userID.ToString());
434
435 //// Success
436 //return;
437 string uri = m_ServerURI + "/inventory/" + userID;
438 if (SynchronousRestObjectRequester.
439 MakeRequest<List<InventoryItemBase>, bool>("PUT", uri, items))
440 m_log.DebugFormat("[INVENTORY CONNECTOR]: move {0} items poster succeeded {1}", items.Count, uri);
441 else
442 m_log.DebugFormat("[INVENTORY CONNECTOR]: move {0} items poster failed {1}", items.Count, uri); ;
443
444 return;
445
446 }
447 catch (Exception e)
448 {
449 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory items operation failed, {0} {1} (old server?). Trying slow way.",
450 e.Source, e.Message);
451 }
452
453 foreach (InventoryItemBase item in items)
454 {
455 InventoryItemBase itm = this.QueryItem(userID, item, sessionID);
456 itm.Name = item.Name;
457 itm.Folder = item.Folder;
458 this.UpdateItem(userID, itm, sessionID);
459 }
460 }
461
462 private void MoveItemsCompleted(IAsyncResult iar)
463 {
464 }
465
466 public bool MoveItems(string userID, List<InventoryItemBase> items, UUID sessionID)
467 {
468 MoveItemsDelegate d = MoveItemsAsync;
469 d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d);
470 return true;
471 }
472
473 public bool DeleteItems(string userID, List<UUID> items, UUID sessionID)
474 {
475 try
476 {
477 List<Guid> guids = new List<Guid>();
478 foreach (UUID u in items)
479 guids.Add(u.Guid);
480 return SynchronousRestSessionObjectPoster<List<Guid>, bool>.BeginPostObject(
481 "POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID);
375 } 482 }
376 catch (Exception e) 483 catch (Exception e)
377 { 484 {
@@ -398,12 +505,12 @@ namespace OpenSim.Services.Connectors
398 return null; 505 return null;
399 } 506 }
400 507
401 public InventoryFolderBase QueryFolder(string userID, InventoryFolderBase item, UUID sessionID) 508 public InventoryFolderBase QueryFolder(string userID, InventoryFolderBase folder, UUID sessionID)
402 { 509 {
403 try 510 try
404 { 511 {
405 return SynchronousRestSessionObjectPoster<InventoryFolderBase, InventoryFolderBase>.BeginPostObject( 512 return SynchronousRestSessionObjectPoster<InventoryFolderBase, InventoryFolderBase>.BeginPostObject(
406 "POST", m_ServerURI + "/QueryFolder/", item, sessionID.ToString(), item.Owner.ToString()); 513 "POST", m_ServerURI + "/QueryFolder/", folder, sessionID.ToString(), userID);
407 } 514 }
408 catch (Exception e) 515 catch (Exception e)
409 { 516 {
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
index 5cbd307..a7aa138 100644
--- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
@@ -136,6 +136,12 @@ namespace OpenSim.Services.Connectors
136 return false; 136 return false;
137 } 137 }
138 138
139 public bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
140 {
141 return false;
142 }
143
144
139 public bool PurgeFolder(InventoryFolderBase folder) 145 public bool PurgeFolder(InventoryFolderBase folder)
140 { 146 {
141 return false; 147 return false;
@@ -151,7 +157,12 @@ namespace OpenSim.Services.Connectors
151 return false; 157 return false;
152 } 158 }
153 159
154 public bool DeleteItem(InventoryItemBase item) 160 public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
161 {
162 return false;
163 }
164
165 public bool DeleteItems(UUID owner, List<UUID> itemIDs)
155 { 166 {
156 return false; 167 return false;
157 } 168 }
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs
index a89a238..c775090 100644
--- a/OpenSim/Services/Interfaces/IInventoryService.cs
+++ b/OpenSim/Services/Interfaces/IInventoryService.cs
@@ -122,6 +122,14 @@ namespace OpenSim.Services.Interfaces
122 bool MoveFolder(InventoryFolderBase folder); 122 bool MoveFolder(InventoryFolderBase folder);
123 123
124 /// <summary> 124 /// <summary>
125 /// Delete an item from the user's inventory
126 /// </summary>
127 /// <param name="item"></param>
128 /// <returns>true if the item was successfully deleted</returns>
129 //bool DeleteItem(InventoryItemBase item);
130 bool DeleteFolders(UUID userID, List<UUID> folderIDs);
131
132 /// <summary>
125 /// Purge an inventory folder of all its items and subfolders. 133 /// Purge an inventory folder of all its items and subfolders.
126 /// </summary> 134 /// </summary>
127 /// <param name="folder"></param> 135 /// <param name="folder"></param>
@@ -142,12 +150,15 @@ namespace OpenSim.Services.Interfaces
142 /// <returns>true if the item was successfully updated</returns> 150 /// <returns>true if the item was successfully updated</returns>
143 bool UpdateItem(InventoryItemBase item); 151 bool UpdateItem(InventoryItemBase item);
144 152
153 bool MoveItems(UUID ownerID, List<InventoryItemBase> items);
154
145 /// <summary> 155 /// <summary>
146 /// Delete an item from the user's inventory 156 /// Delete an item from the user's inventory
147 /// </summary> 157 /// </summary>
148 /// <param name="item"></param> 158 /// <param name="item"></param>
149 /// <returns>true if the item was successfully deleted</returns> 159 /// <returns>true if the item was successfully deleted</returns>
150 bool DeleteItem(InventoryItemBase item); 160 //bool DeleteItem(InventoryItemBase item);
161 bool DeleteItems(UUID userID, List<UUID> itemIDs);
151 162
152 /// <summary> 163 /// <summary>
153 /// Get an item, given by its UUID 164 /// Get an item, given by its UUID
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs
index 65c2d96..19b1fd8 100644
--- a/OpenSim/Services/InventoryService/InventoryService.cs
+++ b/OpenSim/Services/InventoryService/InventoryService.cs
@@ -235,8 +235,6 @@ namespace OpenSim.Services.InventoryService
235 235
236 public InventoryCollection GetFolderContent(UUID userID, UUID folderID) 236 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
237 { 237 {
238 m_log.Info("[INVENTORY SERVICE]: Processing request for folder " + folderID);
239
240 // Uncomment me to simulate a slow responding inventory server 238 // Uncomment me to simulate a slow responding inventory server
241 //Thread.Sleep(16000); 239 //Thread.Sleep(16000);
242 240
@@ -249,7 +247,7 @@ namespace OpenSim.Services.InventoryService
249 invCollection.Folders = folders; 247 invCollection.Folders = folders;
250 invCollection.Items = items; 248 invCollection.Items = items;
251 249
252 m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders", items.Count, folders.Count); 250 m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders in folder {2}", items.Count, folders.Count, folderID);
253 251
254 return invCollection; 252 return invCollection;
255 } 253 }
@@ -386,13 +384,33 @@ namespace OpenSim.Services.InventoryService
386 return true; 384 return true;
387 } 385 }
388 386
387 public virtual bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
388 {
389 m_log.InfoFormat(
390 "[INVENTORY SERVICE]: Moving {0} items from user {1}", items.Count, ownerID);
391
392 InventoryItemBase itm = null;
393 foreach (InventoryItemBase item in items)
394 {
395 itm = GetInventoryItem(item.ID);
396 itm.Folder = item.Folder;
397 if ((item.Name != null) && !item.Name.Equals(string.Empty))
398 itm.Name = item.Name;
399 m_Database.updateInventoryItem(itm);
400 }
401
402 return true;
403 }
404
389 // See IInventoryServices 405 // See IInventoryServices
390 public virtual bool DeleteItem(InventoryItemBase item) 406 public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs)
391 { 407 {
392 m_log.InfoFormat( 408 m_log.InfoFormat(
393 "[INVENTORY SERVICE]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); 409 "[INVENTORY SERVICE]: Deleting {0} items from user {1}", itemIDs.Count, owner);
394 410
395 m_Database.deleteInventoryItem(item.ID); 411 // uhh.....
412 foreach (UUID uuid in itemIDs)
413 m_Database.deleteInventoryItem(uuid);
396 414
397 // FIXME: Should return false on failure 415 // FIXME: Should return false on failure
398 return true; 416 return true;
@@ -400,22 +418,34 @@ namespace OpenSim.Services.InventoryService
400 418
401 public virtual InventoryItemBase GetItem(InventoryItemBase item) 419 public virtual InventoryItemBase GetItem(InventoryItemBase item)
402 { 420 {
403 InventoryItemBase result = m_Database.queryInventoryItem(item.ID); 421 InventoryItemBase result = m_Database.getInventoryItem(item.ID);
404 if (result != null) 422 if (result != null)
405 return result; 423 return result;
406 424 m_log.DebugFormat("[INVENTORY SERVICE]: GetItem failed to find item {0}", item.ID);
407 return null; 425 return null;
408 } 426 }
409 427
410 public virtual InventoryFolderBase GetFolder(InventoryFolderBase item) 428 public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder)
411 { 429 {
412 InventoryFolderBase result = m_Database.queryInventoryFolder(item.ID); 430 InventoryFolderBase result = m_Database.getInventoryFolder(folder.ID);
413 if (result != null) 431 if (result != null)
414 return result; 432 return result;
415 433
434 m_log.DebugFormat("[INVENTORY SERVICE]: GetFolder failed to find folder {0}", folder.ID);
416 return null; 435 return null;
417 } 436 }
418 437
438 public virtual bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
439 {
440 foreach (UUID id in folderIDs)
441 {
442 InventoryFolderBase folder = new InventoryFolderBase(id, ownerID);
443 PurgeFolder(folder);
444 m_Database.deleteInventoryFolder(id);
445 }
446 return true;
447 }
448
419 /// <summary> 449 /// <summary>
420 /// Purge a folder of all items items and subfolders. 450 /// Purge a folder of all items items and subfolders.
421 /// 451 ///
@@ -439,10 +469,12 @@ namespace OpenSim.Services.InventoryService
439 469
440 List<InventoryItemBase> items = GetFolderItems(folder.Owner, folder.ID); 470 List<InventoryItemBase> items = GetFolderItems(folder.Owner, folder.ID);
441 471
472 List<UUID> uuids = new List<UUID>();
442 foreach (InventoryItemBase item in items) 473 foreach (InventoryItemBase item in items)
443 { 474 {
444 DeleteItem(item); 475 uuids.Add(item.ID);
445 } 476 }
477 DeleteItems(folder.Owner, uuids);
446 478
447 // FIXME: Should return false on failure 479 // FIXME: Should return false on failure
448 return true; 480 return true;
diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
index 8ab72dc..3981fe9 100644
--- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs
@@ -25,6 +25,7 @@
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 System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenSim.Framework; 31using OpenSim.Framework;
@@ -46,6 +47,18 @@ namespace OpenSim.Tests.Common.Mock
46 public void Initialise(string connect) {} 47 public void Initialise(string connect) {}
47 public void Dispose() {} 48 public void Dispose() {}
48 49
50 private readonly List<AssetBase> assets = new List<AssetBase>();
51
52 public AssetBase GetAsset(UUID uuid)
53 {
54 return assets.Find(x=>x.FullID == uuid);
55 }
56
57 public void StoreAsset(AssetBase asset)
58 {
59 assets.Add(asset);
60 }
61
49 public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); } 62 public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); }
50 } 63 }
51} \ No newline at end of file 64} \ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
index ba9cbe9..5a0ee7c 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
@@ -128,6 +128,11 @@ namespace OpenSim.Tests.Common.Mock
128 return false; 128 return false;
129 } 129 }
130 130
131 public bool DeleteFolders(UUID ownerID, List<UUID> ids)
132 {
133 return false;
134 }
135
131 public bool PurgeFolder(InventoryFolderBase folder) 136 public bool PurgeFolder(InventoryFolderBase folder)
132 { 137 {
133 return false; 138 return false;
@@ -143,7 +148,12 @@ namespace OpenSim.Tests.Common.Mock
143 return false; 148 return false;
144 } 149 }
145 150
146 public bool DeleteItem(InventoryItemBase item) 151 public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
152 {
153 return false;
154 }
155
156 public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
147 { 157 {
148 return false; 158 return false;
149 } 159 }