28 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Framework.Serialization.External;
36 using OpenSim.Server.Base;
37 using OpenSim.Services.Interfaces;
38 using OpenSim.Services.FSAssetService;
40 namespace OpenSim.Services.HypergridService
49 private static readonly ILog m_log =
51 MethodBase.GetCurrentMethod().DeclaringType);
53 private string m_HomeURL;
60 public HGFSAssetService(IConfigSource config,
string configName) : base(config,
"AssetService")
62 m_log.Debug(
"[HGAsset Service]: Starting in FSAsset mode");
63 IConfig assetConfig = config.Configs[configName];
64 if (assetConfig == null)
65 throw new Exception(
"No HGAssetService configuration");
67 string userAccountsDll = assetConfig.GetString(
"UserAccountsService", string.Empty);
68 if (userAccountsDll ==
string.Empty)
69 throw new Exception(
"Please specify UserAccountsService in HGAssetService configuration");
71 Object[] args =
new Object[] { config };
73 if (m_UserAccountService == null)
74 throw new Exception(String.Format(
"Unable to create UserAccountService from {0}", userAccountsDll));
76 m_HomeURL = Util.GetConfigVarFromSections<
string>(config,
"HomeURI",
77 new string[] {
"Startup",
"Hypergrid", configName }, string.Empty);
78 if (m_HomeURL ==
string.Empty)
79 throw new Exception(
"[HGAssetService] No HomeURI specified");
81 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
87 #region IAssetService overrides
95 if (!m_AssetPerms.AllowedExport(asset.
Type))
99 asset.
Data = AdjustIdentifiers(asset.
Data);
113 AdjustIdentifiers(meta);
125 if (!m_AssetPerms.AllowedExport(asset.
Type))
130 if (asset.
Type == (
int)AssetType.Object && asset.Data != null)
132 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
133 asset.Data = Utils.StringToBytes(xml);
143 if (!m_AssetPerms.AllowedImport(asset.
Type))
148 if (asset.
Type == (
int)AssetType.Object && asset.Data != null)
150 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
151 asset.Data = Utils.StringToBytes(xml);
154 return base.Store(asset);
167 if (meta == null || m_Cache == null)
170 UserAccount creator = m_Cache.GetUser(meta.CreatorID);
172 meta.CreatorID = meta.CreatorID +
";" + m_HomeURL +
"/" + creator.FirstName +
" " + creator.LastName;
178 string xml = Utils.BytesToString(data);
182 xml = ExternalRepresentationUtils.SanitizeXml(xml);
184 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml,
"HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
override byte[] GetData(string id)
Get an asset's data, ignoring the metadata.
override AssetBase Get(string id)
Get an asset synchronously.
override AssetMetadata GetMetadata(string id)
Get an asset's metadata
HGFSAssetService(IConfigSource config, string configName)
sbyte Type
(sbyte) AssetType enum
Hypergrid asset service. It serves the IAssetService interface, but implements it in ways that are ap...
Asset class. All Assets are reference by this class or a class derived from this class ...
override bool Delete(string id)
Delete an asset
byte[] AdjustIdentifiers(byte[] data)
void AdjustIdentifiers(AssetMetadata meta)
override string Store(AssetBase asset)
Creates a new asset