aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService/XAssetService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/AssetService/XAssetService.cs')
-rw-r--r--OpenSim/Services/AssetService/XAssetService.cs51
1 files changed, 39 insertions, 12 deletions
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs
index a1d10ed..7dd48c9 100644
--- a/OpenSim/Services/AssetService/XAssetService.cs
+++ b/OpenSim/Services/AssetService/XAssetService.cs
@@ -39,8 +39,7 @@ using OpenMetaverse;
39namespace OpenSim.Services.AssetService 39namespace OpenSim.Services.AssetService
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// This will be developed into a de-duplicating asset service. 42 /// A de-duplicating asset service.
43 /// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it.
44 /// </summary> 43 /// </summary>
45 public class XAssetService : XAssetServiceBase, IAssetService 44 public class XAssetService : XAssetServiceBase, IAssetService
46 { 45 {
@@ -48,7 +47,9 @@ namespace OpenSim.Services.AssetService
48 47
49 protected static XAssetService m_RootInstance; 48 protected static XAssetService m_RootInstance;
50 49
51 public XAssetService(IConfigSource config) : base(config) 50 public XAssetService(IConfigSource config) : this(config, "AssetService") {}
51
52 public XAssetService(IConfigSource config, string configName) : base(config, configName)
52 { 53 {
53 if (m_RootInstance == null) 54 if (m_RootInstance == null)
54 { 55 {
@@ -56,22 +57,21 @@ namespace OpenSim.Services.AssetService
56 57
57 if (m_AssetLoader != null) 58 if (m_AssetLoader != null)
58 { 59 {
59 IConfig assetConfig = config.Configs["AssetService"]; 60 IConfig assetConfig = config.Configs[configName];
60 if (assetConfig == null) 61 if (assetConfig == null)
61 throw new Exception("No AssetService configuration"); 62 throw new Exception("No AssetService configuration");
62 63
63 string loaderArgs = assetConfig.GetString("AssetLoaderArgs", 64 string loaderArgs = assetConfig.GetString("AssetLoaderArgs", String.Empty);
64 String.Empty);
65 65
66 bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); 66 bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
67 67
68 if (assetLoaderEnabled) 68 if (assetLoaderEnabled && !HasChainedAssetService)
69 { 69 {
70 m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs); 70 m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
71 71
72 m_AssetLoader.ForEachDefaultXmlAsset( 72 m_AssetLoader.ForEachDefaultXmlAsset(
73 loaderArgs, 73 loaderArgs,
74 delegate(AssetBase a) 74 a =>
75 { 75 {
76 AssetBase existingAsset = Get(a.ID); 76 AssetBase existingAsset = Get(a.ID);
77// AssetMetadata existingMetadata = GetMetadata(a.ID); 77// AssetMetadata existingMetadata = GetMetadata(a.ID);
@@ -103,7 +103,14 @@ namespace OpenSim.Services.AssetService
103 103
104 try 104 try
105 { 105 {
106 return m_Database.GetAsset(assetID); 106 AssetBase asset = m_Database.GetAsset(assetID);
107
108 if (asset != null)
109 return asset;
110 else if (HasChainedAssetService)
111 return m_ChainedAssetService.Get(id);
112 else
113 return null;
107 } 114 }
108 catch (Exception e) 115 catch (Exception e)
109 { 116 {
@@ -128,9 +135,17 @@ namespace OpenSim.Services.AssetService
128 135
129 AssetBase asset = m_Database.GetAsset(assetID); 136 AssetBase asset = m_Database.GetAsset(assetID);
130 if (asset != null) 137 if (asset != null)
138 {
131 return asset.Metadata; 139 return asset.Metadata;
132 140 }
133 return null; 141 else if (HasChainedAssetService)
142 {
143 return m_ChainedAssetService.GetMetadata(id);
144 }
145 else
146 {
147 return null;
148 }
134 } 149 }
135 150
136 public virtual byte[] GetData(string id) 151 public virtual byte[] GetData(string id)
@@ -143,7 +158,13 @@ namespace OpenSim.Services.AssetService
143 return null; 158 return null;
144 159
145 AssetBase asset = m_Database.GetAsset(assetID); 160 AssetBase asset = m_Database.GetAsset(assetID);
146 return asset.Data; 161
162 if (asset != null)
163 return asset.Data;
164 else if (HasChainedAssetService)
165 return m_ChainedAssetService.GetData(id);
166 else
167 return null;
147 } 168 }
148 169
149 public virtual bool Get(string id, Object sender, AssetRetrieved handler) 170 public virtual bool Get(string id, Object sender, AssetRetrieved handler)
@@ -157,6 +178,9 @@ namespace OpenSim.Services.AssetService
157 178
158 AssetBase asset = m_Database.GetAsset(assetID); 179 AssetBase asset = m_Database.GetAsset(assetID);
159 180
181 if (asset == null && HasChainedAssetService)
182 asset = m_ChainedAssetService.Get(id);
183
160 //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); 184 //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
161 185
162 handler(id, sender, asset); 186 handler(id, sender, asset);
@@ -194,6 +218,9 @@ namespace OpenSim.Services.AssetService
194 if (!UUID.TryParse(id, out assetID)) 218 if (!UUID.TryParse(id, out assetID))
195 return false; 219 return false;
196 220
221 // Don't bother deleting from a chained asset service. This isn't a big deal since deleting happens
222 // very rarely.
223
197 return m_Database.Delete(id); 224 return m_Database.Delete(id);
198 } 225 }
199 } 226 }