mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
- remove the Metadata property from AssetBase and return all previous
properties as before - prefix private variables with m_ in AssetBase.cs - related to Mantis #3122, as mentioned in https://lists.berlios.de/pipermail/opensim-dev/2009-February/005088.html - all services will likely need to be upgraded after this commit
This commit is contained in:
@@ -33,128 +33,166 @@ namespace OpenSim.Framework
|
||||
[Serializable]
|
||||
public class AssetBase
|
||||
{
|
||||
private byte[] _data;
|
||||
private AssetMetadata _metadata;
|
||||
private byte[] m_data;
|
||||
private AssetMetadata m_metadata;
|
||||
|
||||
public AssetBase()
|
||||
{
|
||||
Metadata = new AssetMetadata();
|
||||
m_metadata = new AssetMetadata();
|
||||
}
|
||||
|
||||
public AssetBase(UUID assetId, string name)
|
||||
{
|
||||
Metadata = new AssetMetadata();
|
||||
Metadata.FullID = assetId;
|
||||
Metadata.Name = name;
|
||||
m_metadata = new AssetMetadata();
|
||||
m_metadata.FullID = assetId;
|
||||
m_metadata.Name = name;
|
||||
}
|
||||
|
||||
public virtual byte[] Data
|
||||
{
|
||||
get { return _data; }
|
||||
set { _data = value; }
|
||||
get { return m_data; }
|
||||
set { m_data = value; }
|
||||
}
|
||||
|
||||
public virtual AssetMetadata Metadata
|
||||
{
|
||||
get { return _metadata; }
|
||||
set { _metadata = value; }
|
||||
}
|
||||
|
||||
// We expose FullID here because the NHibernate mappers require a
|
||||
// property on the AssetBase class for its primary key (see
|
||||
// OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml).
|
||||
public UUID FullID
|
||||
{
|
||||
get { return Metadata.FullID; }
|
||||
set { Metadata.FullID = value; }
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AssetMetadata
|
||||
{
|
||||
private UUID _fullid;
|
||||
private string _name = String.Empty;
|
||||
private string _description = String.Empty;
|
||||
private DateTime _creation_date;
|
||||
private sbyte _type;
|
||||
private string _content_type;
|
||||
private byte[] _sha1;
|
||||
private bool _local = false;
|
||||
private bool _temporary = false;
|
||||
//private Dictionary<string, Uri> _methods = new Dictionary<string, Uri>();
|
||||
//private OSDMap _extra_data;
|
||||
|
||||
public UUID FullID
|
||||
{
|
||||
get { return _fullid; }
|
||||
set { _fullid = value; }
|
||||
get { return m_metadata.FullID; }
|
||||
set { m_metadata.FullID = value; }
|
||||
}
|
||||
|
||||
public string ID
|
||||
{
|
||||
get { return _fullid.ToString(); }
|
||||
set { _fullid = new UUID(value); }
|
||||
get { return m_metadata.ID; }
|
||||
set { m_metadata.ID = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
get { return m_metadata.Name; }
|
||||
set { m_metadata.Name = value; }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set { _description = value; }
|
||||
}
|
||||
|
||||
public DateTime CreationDate
|
||||
{
|
||||
get { return _creation_date; }
|
||||
set { _creation_date = value; }
|
||||
get { return m_metadata.Description; }
|
||||
set { m_metadata.Description = value; }
|
||||
}
|
||||
|
||||
public sbyte Type
|
||||
{
|
||||
get { return _type; }
|
||||
set { _type = value; }
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
get { return _content_type; }
|
||||
set { _content_type = value; }
|
||||
}
|
||||
|
||||
public byte[] SHA1
|
||||
{
|
||||
get { return _sha1; }
|
||||
set { _sha1 = value; }
|
||||
get { return m_metadata.Type; }
|
||||
set { m_metadata.Type = value; }
|
||||
}
|
||||
|
||||
public bool Local
|
||||
{
|
||||
get { return _local; }
|
||||
set { _local = value; }
|
||||
get { return m_metadata.Local; }
|
||||
set { m_metadata.Local = value; }
|
||||
}
|
||||
|
||||
public bool Temporary
|
||||
{
|
||||
get { return _temporary; }
|
||||
set { _temporary = value; }
|
||||
get { return m_metadata.Temporary; }
|
||||
set { m_metadata.Temporary = value; }
|
||||
}
|
||||
|
||||
// We have methods here because properties are serialized, and we don't
|
||||
// want that.
|
||||
public virtual AssetMetadata getMetadata()
|
||||
{
|
||||
return m_metadata;
|
||||
}
|
||||
|
||||
public virtual void setMetadata(AssetMetadata metadata)
|
||||
{
|
||||
m_metadata = metadata;
|
||||
}
|
||||
}
|
||||
|
||||
public class AssetMetadata
|
||||
{
|
||||
private UUID m_fullid;
|
||||
private string m_name = String.Empty;
|
||||
private string m_description = String.Empty;
|
||||
private DateTime m_creation_date;
|
||||
private sbyte m_type;
|
||||
private string m_content_type;
|
||||
private byte[] m_sha1;
|
||||
private bool m_local = false;
|
||||
private bool m_temporary = false;
|
||||
//private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>();
|
||||
//private OSDMap m_extra_data;
|
||||
|
||||
public UUID FullID
|
||||
{
|
||||
get { return m_fullid; }
|
||||
set { m_fullid = value; }
|
||||
}
|
||||
|
||||
public string ID
|
||||
{
|
||||
get { return m_fullid.ToString(); }
|
||||
set { m_fullid = new UUID(value); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return m_name; }
|
||||
set { m_name = value; }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return m_description; }
|
||||
set { m_description = value; }
|
||||
}
|
||||
|
||||
public DateTime CreationDate
|
||||
{
|
||||
get { return m_creation_date; }
|
||||
set { m_creation_date = value; }
|
||||
}
|
||||
|
||||
public sbyte Type
|
||||
{
|
||||
get { return m_type; }
|
||||
set { m_type = value; }
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
get { return m_content_type; }
|
||||
set { m_content_type = value; }
|
||||
}
|
||||
|
||||
public byte[] SHA1
|
||||
{
|
||||
get { return m_sha1; }
|
||||
set { m_sha1 = value; }
|
||||
}
|
||||
|
||||
public bool Local
|
||||
{
|
||||
get { return m_local; }
|
||||
set { m_local = value; }
|
||||
}
|
||||
|
||||
public bool Temporary
|
||||
{
|
||||
get { return m_temporary; }
|
||||
set { m_temporary = value; }
|
||||
}
|
||||
|
||||
//public Dictionary<string, Uri> Methods
|
||||
//{
|
||||
// get { return _methods; }
|
||||
// set { _methods = value; }
|
||||
// get { return m_methods; }
|
||||
// set { m_methods = value; }
|
||||
//}
|
||||
|
||||
//public OSDMap ExtraData
|
||||
//{
|
||||
// get { return _extra_data; }
|
||||
// set { _extra_data = value; }
|
||||
// get { return m_extra_data; }
|
||||
// set { m_extra_data = value; }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ namespace OpenSim.Framework
|
||||
public AssetLandmark(AssetBase a)
|
||||
{
|
||||
Data = a.Data;
|
||||
Metadata.FullID = a.Metadata.FullID;
|
||||
Metadata.Type = a.Metadata.Type;
|
||||
Metadata.Name = a.Metadata.Name;
|
||||
Metadata.Description = a.Metadata.Description;
|
||||
FullID = a.FullID;
|
||||
Type = a.Type;
|
||||
Name = a.Name;
|
||||
Description = a.Description;
|
||||
InternData();
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
|
||||
|
||||
AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false);
|
||||
|
||||
newAsset.Metadata.Type = type;
|
||||
newAsset.Type = type;
|
||||
assets.Add(newAsset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,11 +341,11 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
/// <param name="asset"></param>
|
||||
public void AddAsset(AssetBase asset)
|
||||
{
|
||||
if (!m_memcache.Contains(asset.Metadata.FullID))
|
||||
if (!m_memcache.Contains(asset.FullID))
|
||||
{
|
||||
m_log.Info("[CACHE] Caching " + asset.Metadata.FullID + " for 24 hours from last access");
|
||||
m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access");
|
||||
// Use 24 hour rolling asset cache.
|
||||
m_memcache.AddOrUpdate(asset.Metadata.FullID, asset, TimeSpan.FromHours(24));
|
||||
m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24));
|
||||
|
||||
// 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
|
||||
@@ -365,7 +365,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.Metadata.Temporary || asset.Metadata.Local)
|
||||
if (!asset.Temporary || asset.Local)
|
||||
{
|
||||
m_assetServer.StoreAsset(asset);
|
||||
}
|
||||
@@ -396,25 +396,25 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
{
|
||||
|
||||
AssetInfo assetInf = new AssetInfo(asset);
|
||||
if (!m_memcache.Contains(assetInf.Metadata.FullID))
|
||||
if (!m_memcache.Contains(assetInf.FullID))
|
||||
{
|
||||
m_memcache.AddOrUpdate(assetInf.Metadata.FullID, assetInf, TimeSpan.FromHours(24));
|
||||
m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24));
|
||||
|
||||
if (StatsManager.SimExtraStats != null)
|
||||
{
|
||||
StatsManager.SimExtraStats.AddAsset(assetInf);
|
||||
}
|
||||
|
||||
if (RequestedAssets.ContainsKey(assetInf.Metadata.FullID))
|
||||
if (RequestedAssets.ContainsKey(assetInf.FullID))
|
||||
{
|
||||
AssetRequest req = RequestedAssets[assetInf.Metadata.FullID];
|
||||
AssetRequest req = RequestedAssets[assetInf.FullID];
|
||||
req.AssetInf = assetInf;
|
||||
req.NumPackets = CalculateNumPackets(assetInf.Data);
|
||||
|
||||
RequestedAssets.Remove(assetInf.Metadata.FullID);
|
||||
RequestedAssets.Remove(assetInf.FullID);
|
||||
// If it's a direct request for a script, drop it
|
||||
// because it's a hacked client
|
||||
if (req.AssetRequestSource != 2 || assetInf.Metadata.Type != 10)
|
||||
if (req.AssetRequestSource != 2 || assetInf.Type != 10)
|
||||
AssetRequests.Add(req);
|
||||
}
|
||||
}
|
||||
@@ -424,8 +424,8 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
|
||||
lock (RequestLists)
|
||||
{
|
||||
if (RequestLists.TryGetValue(asset.Metadata.FullID, out reqList))
|
||||
RequestLists.Remove(asset.Metadata.FullID);
|
||||
if (RequestLists.TryGetValue(asset.FullID, out reqList))
|
||||
RequestLists.Remove(asset.FullID);
|
||||
}
|
||||
|
||||
if (reqList != null)
|
||||
@@ -436,8 +436,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.Metadata.FullID);
|
||||
req.Callback(asset.Metadata.FullID, asset);
|
||||
// m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID);
|
||||
req.Callback(asset.FullID, asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,7 +545,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
}
|
||||
|
||||
// Scripts cannot be retrieved by direct request
|
||||
if (transferRequest.TransferInfo.SourceType == 2 && asset.Metadata.Type == 10)
|
||||
if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10)
|
||||
return;
|
||||
|
||||
// The asset is knosn to exist and is in our cache, so add it to the AssetRequests list
|
||||
@@ -631,10 +631,10 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
public AssetInfo(AssetBase aBase)
|
||||
{
|
||||
Data = aBase.Data;
|
||||
Metadata.FullID = aBase.Metadata.FullID;
|
||||
Metadata.Type = aBase.Metadata.Type;
|
||||
Metadata.Name = aBase.Metadata.Name;
|
||||
Metadata.Description = aBase.Metadata.Description;
|
||||
FullID = aBase.FullID;
|
||||
Type = aBase.Type;
|
||||
Name = aBase.Name;
|
||||
Description = aBase.Description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,10 +643,10 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
public TextureImage(AssetBase aBase)
|
||||
{
|
||||
Data = aBase.Data;
|
||||
Metadata.FullID = aBase.Metadata.FullID;
|
||||
Metadata.Type = aBase.Metadata.Type;
|
||||
Metadata.Name = aBase.Metadata.Name;
|
||||
Metadata.Description = aBase.Metadata.Description;
|
||||
FullID = aBase.FullID;
|
||||
Type = aBase.Type;
|
||||
Name = aBase.Name;
|
||||
Description = aBase.Description;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -441,17 +441,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.Metadata.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}",
|
||||
"OPENSIM_AES_AF1",
|
||||
file.AlsoKnownAs,
|
||||
salt,
|
||||
x.Metadata.Description);
|
||||
x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}",
|
||||
"OPENSIM_AES_AF1",
|
||||
file.AlsoKnownAs,
|
||||
salt,
|
||||
x.Description);
|
||||
}
|
||||
|
||||
private bool DecryptAssetBase(AssetBase x)
|
||||
{
|
||||
// Check it's encrypted first.
|
||||
if (!x.Metadata.Description.Contains("ENCASS"))
|
||||
if (!x.Description.Contains("ENCASS"))
|
||||
return true;
|
||||
|
||||
// ENCASS:ALG:AKA:SALT:Description
|
||||
@@ -459,7 +459,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
string[] splitchars = new string[1];
|
||||
splitchars[0] = "#:~:#";
|
||||
|
||||
string[] meta = x.Metadata.Description.Split(splitchars, StringSplitOptions.None);
|
||||
string[] meta = x.Description.Split(splitchars, StringSplitOptions.None);
|
||||
if (meta.Length < 5)
|
||||
{
|
||||
m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt");
|
||||
@@ -470,7 +470,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
if (m_keyfiles.ContainsKey(meta[2]))
|
||||
{
|
||||
RjinKeyfile deckey = m_keyfiles[meta[2]];
|
||||
x.Metadata.Description = meta[4];
|
||||
x.Description = meta[4];
|
||||
switch (meta[1])
|
||||
{
|
||||
case "OPENSIM_AES_AF1":
|
||||
@@ -544,7 +544,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
{
|
||||
string assetUrl = _assetServerUrl + "/assets/";
|
||||
|
||||
m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID);
|
||||
m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID);
|
||||
|
||||
RestObjectPoster.BeginPostObject<AssetBase>(assetUrl, asset);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
|
||||
public override void StoreAsset(AssetBase asset)
|
||||
{
|
||||
byte[] idBytes = asset.Metadata.FullID.Guid.ToByteArray();
|
||||
byte[] idBytes = asset.FullID.Guid.ToByteArray();
|
||||
|
||||
string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0]
|
||||
+ Path.DirectorySeparatorChar + idBytes[1];
|
||||
@@ -90,7 +90,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||
if (!Directory.Exists(cdir))
|
||||
Directory.CreateDirectory(cdir);
|
||||
|
||||
FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.Metadata.FullID + ".xml", FileMode.Create);
|
||||
FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create);
|
||||
m_xs.Serialize(x, asset);
|
||||
|
||||
x.Flush();
|
||||
|
||||
@@ -126,7 +126,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.Metadata.FullID);
|
||||
m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID);
|
||||
|
||||
RestObjectPoster.BeginPostObject<AssetBase>(assetUrl, asset);
|
||||
}
|
||||
|
||||
@@ -740,9 +740,9 @@ namespace OpenSim.Framework.Communications.Capabilities
|
||||
|
||||
AssetBase asset;
|
||||
asset = new AssetBase();
|
||||
asset.Metadata.FullID = assetID;
|
||||
asset.Metadata.Type = assType;
|
||||
asset.Metadata.Name = assetName;
|
||||
asset.FullID = assetID;
|
||||
asset.Type = assType;
|
||||
asset.Name = assetName;
|
||||
asset.Data = data;
|
||||
m_assetCache.AddAsset(asset);
|
||||
|
||||
@@ -750,7 +750,7 @@ namespace OpenSim.Framework.Communications.Capabilities
|
||||
item.Owner = m_agentID;
|
||||
item.Creator = m_agentID;
|
||||
item.ID = inventoryItem;
|
||||
item.AssetID = asset.Metadata.FullID;
|
||||
item.AssetID = asset.FullID;
|
||||
item.Description = assetDescription;
|
||||
item.Name = assetName;
|
||||
item.AssetType = assType;
|
||||
|
||||
Reference in New Issue
Block a user