28 using System.Collections.Generic;
30 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Framework.Serialization.External;
39 using OpenSim.Server.Base;
40 using OpenSim.Services.Interfaces;
41 using OpenSim.Services.AssetService;
43 namespace OpenSim.Services.HypergridService
52 private static readonly ILog m_log =
54 MethodBase.GetCurrentMethod().DeclaringType);
56 private string m_HomeURL;
63 public HGAssetService(IConfigSource config,
string configName) : base(config, configName)
65 m_log.Debug(
"[HGAsset Service]: Starting");
66 IConfig assetConfig = config.Configs[configName];
67 if (assetConfig == null)
68 throw new Exception(
"No HGAssetService configuration");
70 string userAccountsDll = assetConfig.GetString(
"UserAccountsService", string.Empty);
71 if (userAccountsDll ==
string.Empty)
72 throw new Exception(
"Please specify UserAccountsService in HGAssetService configuration");
74 Object[] args =
new Object[] { config };
76 if (m_UserAccountService == null)
77 throw new Exception(String.Format(
"Unable to create UserAccountService from {0}", userAccountsDll));
79 m_HomeURL = Util.GetConfigVarFromSections<
string>(config,
"HomeURI",
80 new string[] {
"Startup",
"Hypergrid", configName }, string.Empty);
81 if (m_HomeURL ==
string.Empty)
82 throw new Exception(
"[HGAssetService] No HomeURI specified");
84 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
91 #region IAssetService overrides
99 if (!m_AssetPerms.AllowedExport(asset.
Type))
103 asset.
Data = AdjustIdentifiers(asset.
Data);
117 AdjustIdentifiers(meta);
129 if (!m_AssetPerms.AllowedExport(asset.
Type))
134 if (asset.
Type == (
int)AssetType.Object && asset.Data != null)
136 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
137 asset.Data = Utils.StringToBytes(xml);
147 if (!m_AssetPerms.AllowedImport(asset.
Type))
152 if (asset.
Type == (
int)AssetType.Object && asset.Data != null)
154 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
155 asset.Data = Utils.StringToBytes(xml);
158 return base.Store(asset);
171 if (meta == null || m_Cache == null)
174 UserAccount creator = m_Cache.GetUser(meta.CreatorID);
176 meta.CreatorID = meta.CreatorID +
";" + m_HomeURL +
"/" + creator.FirstName +
" " + creator.LastName;
182 string xml = Utils.BytesToString(data);
186 xml = ExternalRepresentationUtils.SanitizeXml(xml);
188 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 string Store(AssetBase asset)
Creates a new asset
sbyte Type
(sbyte) AssetType enum
HGAssetService(IConfigSource config, string configName)
byte[] AdjustIdentifiers(byte[] data)
Asset class. All Assets are reference by this class or a class derived from this class ...
Hypergrid asset service. It serves the IAssetService interface, but implements it in ways that are ap...
Interactive OpenSim region server
override bool Delete(string id)
Delete an asset
override AssetBase Get(string id)
Get an asset synchronously.
void AdjustIdentifiers(AssetMetadata meta)
override AssetMetadata GetMetadata(string id)
Get an asset's metadata