29 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
36 using OpenSim.Services.Interfaces;
43 private static readonly ILog m_log =
45 MethodBase.GetCurrentMethod().DeclaringType);
50 : this(config,
"AssetService")
54 public AssetService(IConfigSource config,
string configName) : base(config, configName)
56 if (m_RootInstance == null)
58 m_RootInstance =
this;
60 if (m_AssetLoader != null)
62 IConfig assetConfig = config.Configs[m_ConfigName];
63 if (assetConfig == null)
64 throw new Exception(
"No " + m_ConfigName +
" configuration");
66 string loaderArgs = assetConfig.GetString(
"AssetLoaderArgs",
69 bool assetLoaderEnabled = assetConfig.GetBoolean(
"AssetLoaderEnabled",
true);
71 if (assetLoaderEnabled)
73 m_log.DebugFormat(
"[ASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
75 m_AssetLoader.ForEachDefaultXmlAsset(
82 if (existingAsset == null || Util.SHA1Hash(existingAsset.
Data) != Util.SHA1Hash(a.Data))
90 m_log.Debug(
"[ASSET SERVICE]: Local asset service enabled");
101 if (!UUID.TryParse(
id, out assetID))
103 m_log.WarnFormat(
"[ASSET SERVICE]: Could not parse requested asset id {0}", id);
109 return m_Database.GetAsset(assetID);
113 m_log.ErrorFormat(
"[ASSET SERVICE]: Exception getting asset {0} {1}", assetID, e);
130 return asset.Metadata;
151 handler(
id, sender, Get(
id));
160 UUID[] uuid = Array.ConvertAll(ids,
id => UUID.Parse(id));
161 return m_Database.AssetsExist(uuid);
165 m_log.Error(
"[ASSET SERVICE]: Exception getting assets ", e);
166 return new bool[ids.Length];
172 bool exists = m_Database.AssetsExist(
new[] { asset.FullID })[0];
177 if (!m_Database.StoreAsset(asset))
179 return UUID.Zero.ToString();
201 if (!UUID.TryParse(
id, out assetID))
204 return m_Database.Delete(id);
virtual byte[] GetData(string id)
Get an asset's data, ignoring the metadata.
AssetService(IConfigSource config)
virtual bool[] AssetsExist(string[] ids)
Check if assets exist in the database.
AssetService(IConfigSource config, string configName)
virtual AssetBase Get(string id)
Get an asset synchronously.
virtual AssetBase GetCached(string id)
Synchronously fetches an asset from the local cache only.
virtual bool Delete(string id)
Delete an asset
virtual string Store(AssetBase asset)
Creates a new asset
Asset class. All Assets are reference by this class or a class derived from this class ...
bool UpdateContent(string id, byte[] data)
Update an asset's content
Interactive OpenSim region server
virtual bool Get(string id, Object sender, AssetRetrieved handler)
Get an asset synchronously or asynchronously (depending on whether it is locally cached) and fire a c...
delegate void AssetRetrieved(string id, Object sender, AssetBase asset)
virtual AssetMetadata GetMetadata(string id)
Get an asset's metadata
string ID
Asset MetaData ID (transferring from UUID to string ID)
static AssetService m_RootInstance