refactor: Reuse Get() method in AssetService to eliminate some copy/paste in other Get methods

0.7.4-extended
Justin Clark-Casey (justincc) 2013-03-15 22:42:34 +00:00
parent 2e9c57f644
commit 95cdaf81a3
1 changed files with 5 additions and 23 deletions

View File

@ -123,29 +123,20 @@ namespace OpenSim.Services.AssetService
public virtual AssetMetadata GetMetadata(string id) public virtual AssetMetadata GetMetadata(string id)
{ {
// m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id); // m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) AssetBase asset = Get(id);
return null;
AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null) if (asset != null)
return asset.Metadata; return asset.Metadata;
else
return null; return null;
} }
public virtual byte[] GetData(string id) public virtual byte[] GetData(string id)
{ {
// m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id); // m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) AssetBase asset = Get(id);
return null;
AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null) if (asset != null)
return asset.Data; return asset.Data;
@ -156,17 +147,8 @@ namespace OpenSim.Services.AssetService
public virtual bool Get(string id, Object sender, AssetRetrieved handler) public virtual bool Get(string id, Object sender, AssetRetrieved handler)
{ {
//m_log.DebugFormat("[AssetService]: Get asset async {0}", id); //m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) handler(id, sender, Get(id));
return false;
AssetBase asset = m_Database.GetAsset(assetID);
//m_log.DebugFormat("[AssetService]: Got asset {0}", asset);
handler(id, sender, asset);
return true; return true;
} }