From 0c03a48fb2060eda4d288e2d2ca4e650ce000b4b Mon Sep 17 00:00:00 2001
From: Mike Mazur
Date: Wed, 4 Feb 2009 00:01:36 +0000
Subject: - add OpenSim.Framework.AssetMetadata class. AssetBase is now
composed of it - trim trailing whitespace
---
.../Framework/Communications/Cache/AssetCache.cs | 84 +++++++++++-----------
.../Communications/Cache/CryptoGridAssetClient.cs | 46 ++++++------
.../Communications/Cache/FileAssetClient.cs | 4 +-
.../Communications/Cache/GridAssetClient.cs | 2 +-
4 files changed, 68 insertions(+), 68 deletions(-)
(limited to 'OpenSim/Framework/Communications/Cache')
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 653597b..2b2467c 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Manages local cache of assets and their sending to viewers.
///
- ///
+ ///
/// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either
/// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and
/// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and
@@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache
private Dictionary RequestLists;
///
- /// The 'server' from which assets can be requested and to which assets are persisted.
+ /// The 'server' from which assets can be requested and to which assets are persisted.
///
private readonly IAssetServer m_assetServer;
@@ -211,7 +211,7 @@ namespace OpenSim.Framework.Communications.Cache
else
{
// m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId);
-
+
NewAssetRequest req = new NewAssetRequest(callback);
AssetRequestsList requestList;
@@ -228,10 +228,10 @@ namespace OpenSim.Framework.Communications.Cache
// m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId);
requestList = new AssetRequestsList();
requestList.TimeRequested = DateTime.Now;
- requestList.Requests.Add(req);
-
- RequestLists.Add(assetId, requestList);
-
+ requestList.Requests.Add(req);
+
+ RequestLists.Add(assetId, requestList);
+
m_assetServer.RequestAsset(assetId, isTexture);
}
}
@@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Cache
/// the allowed number of polls. This isn't a very good way of doing things since a single thread
/// is processing inbound packets, so if the asset server is slow, we could block this for up to
/// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset()
- ///
+ ///
///
///
/// null if the asset could not be retrieved
@@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications.Cache
{
return asset;
}
-
+
m_assetServer.RequestAsset(assetID, isTexture);
do
@@ -275,7 +275,7 @@ namespace OpenSim.Framework.Communications.Cache
{
return asset;
}
- }
+ }
while (--maxPolls > 0);
m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached",
@@ -290,17 +290,17 @@ namespace OpenSim.Framework.Communications.Cache
///
public void AddAsset(AssetBase asset)
{
- if (!m_memcache.Contains(asset.FullID))
+ if (!m_memcache.Contains(asset.Metadata.FullID))
{
- m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access");
+ m_log.Info("[CACHE] Caching " + asset.Metadata.FullID + " for 24 hours from last access");
// Use 24 hour rolling asset cache.
- m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24));
+ m_memcache.AddOrUpdate(asset.Metadata.FullID, asset, TimeSpan.FromHours(24));
- // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the
+ // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the
// information is stored locally. It could disappear, in which case we could send the
- // ImageNotInDatabase packet to tell the client this.
+ // ImageNotInDatabase packet to tell the client this.
//
- // However, this doesn't quite appear to work with local textures that are part of an avatar's
+ // However, this doesn't quite appear to work with local textures that are part of an avatar's
// appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake
// and reupload by the client, if those assets aren't pushed to the asset server anyway, then
// on crossing onto another region server, other avatars can no longer get the required textures.
@@ -314,7 +314,7 @@ namespace OpenSim.Framework.Communications.Cache
// But for now, we're going to take the easy way out and store local assets globally.
//
// TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView.
- if (!asset.Temporary || asset.Local)
+ if (!asset.Metadata.Temporary || asset.Metadata.Local)
{
m_assetServer.StoreAsset(asset);
}
@@ -345,25 +345,25 @@ namespace OpenSim.Framework.Communications.Cache
{
AssetInfo assetInf = new AssetInfo(asset);
- if (!m_memcache.Contains(assetInf.FullID))
+ if (!m_memcache.Contains(assetInf.Metadata.FullID))
{
- m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24));
+ m_memcache.AddOrUpdate(assetInf.Metadata.FullID, assetInf, TimeSpan.FromHours(24));
if (StatsManager.SimExtraStats != null)
{
StatsManager.SimExtraStats.AddAsset(assetInf);
}
- if (RequestedAssets.ContainsKey(assetInf.FullID))
+ if (RequestedAssets.ContainsKey(assetInf.Metadata.FullID))
{
- AssetRequest req = RequestedAssets[assetInf.FullID];
+ AssetRequest req = RequestedAssets[assetInf.Metadata.FullID];
req.AssetInf = assetInf;
req.NumPackets = CalculateNumPackets(assetInf.Data);
- RequestedAssets.Remove(assetInf.FullID);
+ RequestedAssets.Remove(assetInf.Metadata.FullID);
// If it's a direct request for a script, drop it
// because it's a hacked client
- if (req.AssetRequestSource != 2 || assetInf.Type != 10)
+ if (req.AssetRequestSource != 2 || assetInf.Metadata.Type != 10)
AssetRequests.Add(req);
}
}
@@ -373,8 +373,8 @@ namespace OpenSim.Framework.Communications.Cache
lock (RequestLists)
{
- if (RequestLists.TryGetValue(asset.FullID, out reqList))
- RequestLists.Remove(asset.FullID);
+ if (RequestLists.TryGetValue(asset.Metadata.FullID, out reqList))
+ RequestLists.Remove(asset.Metadata.FullID);
}
if (reqList != null)
@@ -385,8 +385,8 @@ namespace OpenSim.Framework.Communications.Cache
foreach (NewAssetRequest req in reqList.Requests)
{
// Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked
- // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID);
- req.Callback(asset.FullID, asset);
+ // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.Metadata.FullID);
+ req.Callback(asset.Metadata.FullID, asset);
}
}
}
@@ -398,12 +398,12 @@ namespace OpenSim.Framework.Communications.Cache
// Remember the fact that this asset could not be found to prevent delays from repeated requests
m_memcache.Add(assetID, null, TimeSpan.FromHours(24));
-
+
// Notify requesters for this asset
AssetRequestsList reqList;
lock (RequestLists)
{
- if (RequestLists.TryGetValue(assetID, out reqList))
+ if (RequestLists.TryGetValue(assetID, out reqList))
RequestLists.Remove(assetID);
}
@@ -411,7 +411,7 @@ namespace OpenSim.Framework.Communications.Cache
{
if (StatsManager.SimExtraStats != null)
StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested);
-
+
foreach (NewAssetRequest req in reqList.Requests)
{
req.Callback(assetID, null);
@@ -461,7 +461,7 @@ namespace OpenSim.Framework.Communications.Cache
source = 3;
//Console.WriteLine("asset request " + requestID);
}
-
+
//check to see if asset is in local cache, if not we need to request it from asset server.
//Console.WriteLine("asset request " + requestID);
if (!m_memcache.Contains(requestID))
@@ -494,7 +494,7 @@ namespace OpenSim.Framework.Communications.Cache
}
// Scripts cannot be retrieved by direct request
- if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10)
+ if (transferRequest.TransferInfo.SourceType == 2 && asset.Metadata.Type == 10)
return;
// The asset is knosn to exist and is in our cache, so add it to the AssetRequests list
@@ -520,7 +520,7 @@ namespace OpenSim.Framework.Communications.Cache
//no requests waiting
return;
}
-
+
// if less than 5, do all of them
int num = Math.Min(5, AssetRequests.Count);
@@ -580,10 +580,10 @@ namespace OpenSim.Framework.Communications.Cache
public AssetInfo(AssetBase aBase)
{
Data = aBase.Data;
- FullID = aBase.FullID;
- Type = aBase.Type;
- Name = aBase.Name;
- Description = aBase.Description;
+ Metadata.FullID = aBase.Metadata.FullID;
+ Metadata.Type = aBase.Metadata.Type;
+ Metadata.Name = aBase.Metadata.Name;
+ Metadata.Description = aBase.Metadata.Description;
}
}
@@ -592,10 +592,10 @@ namespace OpenSim.Framework.Communications.Cache
public TextureImage(AssetBase aBase)
{
Data = aBase.Data;
- FullID = aBase.FullID;
- Type = aBase.Type;
- Name = aBase.Name;
- Description = aBase.Description;
+ Metadata.FullID = aBase.Metadata.FullID;
+ Metadata.Type = aBase.Metadata.Type;
+ Metadata.Name = aBase.Metadata.Name;
+ Metadata.Description = aBase.Metadata.Description;
}
}
@@ -608,7 +608,7 @@ namespace OpenSim.Framework.Communications.Cache
/// A list of requests for assets
///
public List Requests = new List();
-
+
///
/// Record the time that this request was first made.
///
diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
index 3ed9172..1b3e70d 100644
--- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
@@ -86,11 +86,11 @@ namespace OpenSim.Framework.Communications.Cache
#region Rjindael
///
- /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and
+ /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and
/// decrypt data. As long as encryption and decryption routines use the same
/// parameters to generate the keys, the keys are guaranteed to be the same.
/// The class uses static functions with duplicate code to make it easier to
- /// demonstrate encryption and decryption logic. In a real-life application,
+ /// demonstrate encryption and decryption logic. In a real-life application,
/// this may not be the most efficient way of handling encryption, so - as
/// soon as you feel comfortable with it - you may want to redesign this class.
///
@@ -123,11 +123,11 @@ namespace OpenSim.Framework.Communications.Cache
///
///
/// Initialization vector (or IV). This value is required to encrypt the
- /// first block of plaintext data. For RijndaelManaged class IV must be
+ /// first block of plaintext data. For RijndaelManaged class IV must be
/// exactly 16 ASCII characters long.
///
///
- /// Size of encryption key in bits. Allowed values are: 128, 192, and 256.
+ /// Size of encryption key in bits. Allowed values are: 128, 192, and 256.
/// Longer keys are more secure than shorter keys.
///
///
@@ -143,7 +143,7 @@ namespace OpenSim.Framework.Communications.Cache
{
// Convert strings into byte arrays.
// Let us assume that strings only contain ASCII codes.
- // If strings include Unicode characters, use Unicode, UTF7, or UTF8
+ // If strings include Unicode characters, use Unicode, UTF7, or UTF8
// encoding.
byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
@@ -153,8 +153,8 @@ namespace OpenSim.Framework.Communications.Cache
byte[] plainTextBytes = plainText;
// First, we must create a password, from which the key will be derived.
- // This password will be generated from the specified passphrase and
- // salt value. The password will be created using the specified hash
+ // This password will be generated from the specified passphrase and
+ // salt value. The password will be created using the specified hash
// algorithm. Password creation can be done in several iterations.
PasswordDeriveBytes password = new PasswordDeriveBytes(
passPhrase,
@@ -173,8 +173,8 @@ namespace OpenSim.Framework.Communications.Cache
// (CBC). Use default options for other symmetric key parameters.
symmetricKey.Mode = CipherMode.CBC;
- // Generate encryptor from the existing key bytes and initialization
- // vector. Key size will be defined based on the number of the key
+ // Generate encryptor from the existing key bytes and initialization
+ // vector. Key size will be defined based on the number of the key
// bytes.
ICryptoTransform encryptor = symmetricKey.CreateEncryptor(
keyBytes,
@@ -265,8 +265,8 @@ namespace OpenSim.Framework.Communications.Cache
// Convert our ciphertext into a byte array.
byte[] cipherTextBytes = cipherText;
- // First, we must create a password, from which the key will be
- // derived. This password will be generated from the specified
+ // First, we must create a password, from which the key will be
+ // derived. This password will be generated from the specified
// passphrase and salt value. The password will be created using
// the specified hash algorithm. Password creation can be done in
// several iterations.
@@ -286,8 +286,8 @@ namespace OpenSim.Framework.Communications.Cache
// (CBC). Use default options for other symmetric key parameters.
symmetricKey.Mode = CipherMode.CBC;
- // Generate decryptor from the existing key bytes and initialization
- // vector. Key size will be defined based on the number of the key
+ // Generate decryptor from the existing key bytes and initialization
+ // vector. Key size will be defined based on the number of the key
// bytes.
ICryptoTransform decryptor = symmetricKey.CreateDecryptor(
keyBytes,
@@ -320,7 +320,7 @@ namespace OpenSim.Framework.Communications.Cache
for (i = 0; i < decryptedByteCount; i++)
plainText[i] = plainTextBytes[i];
- // Return decrypted string.
+ // Return decrypted string.
return plainText;
}
}
@@ -403,17 +403,17 @@ namespace OpenSim.Framework.Communications.Cache
string salt = Convert.ToBase64String(rand);
x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize);
- x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}",
- "OPENSIM_AES_AF1",
- file.AlsoKnownAs,
- salt,
- x.Description);
+ x.Metadata.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}",
+ "OPENSIM_AES_AF1",
+ file.AlsoKnownAs,
+ salt,
+ x.Metadata.Description);
}
private bool DecryptAssetBase(AssetBase x)
{
// Check it's encrypted first.
- if (!x.Description.Contains("ENCASS"))
+ if (!x.Metadata.Description.Contains("ENCASS"))
return true;
// ENCASS:ALG:AKA:SALT:Description
@@ -421,7 +421,7 @@ namespace OpenSim.Framework.Communications.Cache
string[] splitchars = new string[1];
splitchars[0] = "#:~:#";
- string[] meta = x.Description.Split(splitchars, StringSplitOptions.None);
+ string[] meta = x.Metadata.Description.Split(splitchars, StringSplitOptions.None);
if (meta.Length < 5)
{
m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt");
@@ -432,7 +432,7 @@ namespace OpenSim.Framework.Communications.Cache
if (m_keyfiles.ContainsKey(meta[2]))
{
RjinKeyfile deckey = m_keyfiles[meta[2]];
- x.Description = meta[4];
+ x.Metadata.Description = meta[4];
switch (meta[1])
{
case "OPENSIM_AES_AF1":
@@ -506,7 +506,7 @@ namespace OpenSim.Framework.Communications.Cache
{
string assetUrl = _assetServerUrl + "/assets/";
- m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID);
+ m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID);
RestObjectPoster.BeginPostObject(assetUrl, asset);
}
diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
index 5f15c3e..8b8172e 100644
--- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache
}
public override void StoreAsset(AssetBase asset)
{
- byte[] idBytes = asset.FullID.Guid.ToByteArray();
+ byte[] idBytes = asset.Metadata.FullID.Guid.ToByteArray();
string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0]
+ Path.DirectorySeparatorChar + idBytes[1];
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Communications.Cache
if (!Directory.Exists(cdir))
Directory.CreateDirectory(cdir);
- FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create);
+ FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.Metadata.FullID + ".xml", FileMode.Create);
m_xs.Serialize(x, asset);
x.Flush();
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index e27c4f4..1cc9833 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache
// rc.Request(s);
//m_log.InfoFormat("[ASSET]: Stored {0}", rc);
- m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID);
+ m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID);
RestObjectPoster.BeginPostObject(assetUrl, asset);
}
--
cgit v1.1