aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AssetBase.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-11-05 13:10:58 -0800
committerJohn Hurliman2009-11-05 13:10:58 -0800
commitafef1ac191d32e9c1514c294b17e404b1d4ae217 (patch)
treec390ef81c9c30922c2e95e32844832919884fd9c /OpenSim/Framework/AssetBase.cs
parentApplying #4332, optional packet statistics logging (diff)
downloadopensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.zip
opensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.tar.gz
opensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.tar.bz2
opensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.tar.xz
Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AssetBase.cs42
1 files changed, 35 insertions, 7 deletions
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 9679ff2..eed9703 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Xml.Serialization; 29using System.Xml.Serialization;
30using System.Reflection;
31using log4net;
30using OpenMetaverse; 32using OpenMetaverse;
31 33
32namespace OpenSim.Framework 34namespace OpenSim.Framework
@@ -37,6 +39,8 @@ namespace OpenSim.Framework
37 [Serializable] 39 [Serializable]
38 public class AssetBase 40 public class AssetBase
39 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
40 /// <summary> 44 /// <summary>
41 /// Data of the Asset 45 /// Data of the Asset
42 /// </summary> 46 /// </summary>
@@ -47,16 +51,34 @@ namespace OpenSim.Framework
47 /// </summary> 51 /// </summary>
48 private AssetMetadata m_metadata; 52 private AssetMetadata m_metadata;
49 53
50 public AssetBase() 54 public AssetBase(UUID assetID, string name, sbyte assetType)
51 { 55 {
56 if (assetType == (sbyte)AssetType.Unknown)
57 {
58 System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true);
59 m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}",
60 name, assetID, trace.ToString());
61 }
62
52 m_metadata = new AssetMetadata(); 63 m_metadata = new AssetMetadata();
64 m_metadata.FullID = assetID;
65 m_metadata.Name = name;
66 m_metadata.Type = assetType;
53 } 67 }
54 68
55 public AssetBase(UUID assetId, string name) 69 public AssetBase(string assetID, string name, sbyte assetType)
56 { 70 {
71 if (assetType == (sbyte)AssetType.Unknown)
72 {
73 System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true);
74 m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}",
75 name, assetID, trace.ToString());
76 }
77
57 m_metadata = new AssetMetadata(); 78 m_metadata = new AssetMetadata();
58 m_metadata.FullID = assetId; 79 m_metadata.ID = assetID;
59 m_metadata.Name = name; 80 m_metadata.Name = name;
81 m_metadata.Type = assetType;
60 } 82 }
61 83
62 public bool ContainsReferences 84 public bool ContainsReferences
@@ -193,11 +215,11 @@ namespace OpenSim.Framework
193 private string m_name = String.Empty; 215 private string m_name = String.Empty;
194 private string m_description = String.Empty; 216 private string m_description = String.Empty;
195 private DateTime m_creation_date; 217 private DateTime m_creation_date;
196 private sbyte m_type; 218 private sbyte m_type = (sbyte)AssetType.Unknown;
197 private string m_content_type; 219 private string m_content_type;
198 private byte[] m_sha1; 220 private byte[] m_sha1;
199 private bool m_local = false; 221 private bool m_local;
200 private bool m_temporary = false; 222 private bool m_temporary;
201 //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>(); 223 //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>();
202 //private OSDMap m_extra_data; 224 //private OSDMap m_extra_data;
203 225
@@ -211,7 +233,13 @@ namespace OpenSim.Framework
211 { 233 {
212 //get { return m_fullid.ToString(); } 234 //get { return m_fullid.ToString(); }
213 //set { m_fullid = new UUID(value); } 235 //set { m_fullid = new UUID(value); }
214 get { return m_id; } 236 get
237 {
238 if (String.IsNullOrEmpty(m_id))
239 m_id = m_fullid.ToString();
240
241 return m_id;
242 }
215 set 243 set
216 { 244 {
217 UUID uuid = UUID.Zero; 245 UUID uuid = UUID.Zero;